|
From: <txm...@us...> - 2014-05-22 15:51:29
|
Revision: 12544
http://sourceforge.net/p/xoops/svn/12544
Author: txmodxoops
Date: 2014-05-22 15:51:24 +0000 (Thu, 22 May 2014)
Log Message:
-----------
Fix many bugs
Work in progress
Modified Paths:
--------------
XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/admin/building.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/blocks_templates.php
XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/class/files/class_files.php
XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/class/files/file.php
XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/class/files/sql_files.php
XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/class/files/structure.php
XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/class/files/user_pages.php
XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/class/files/user_templates.php
XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/class/files/user_xoopsversion.php
XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/templates/admin/building.tpl
Added Paths:
-----------
XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/class/files/formelements.php
Removed Paths:
-------------
XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/admin/includes.php
XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/class/files/form_elements.php
Modified: XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/admin/building.php
===================================================================
--- XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/admin/building.php 2014-05-21 22:01:47 UTC (rev 12543)
+++ XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/admin/building.php 2014-05-22 15:51:24 UTC (rev 12544)
@@ -21,13 +21,13 @@
include 'header.php';
$op = TDMCreateRequest::getString('op', 'default');
$mid = TDMCreateRequest::getInt('mod_id');
-$moduleObj = $tdmcreate->getHandler('repository')->get( $mid );
+$repObj = $tdmcreate->getHandler('repository')->get( $mid );
//
$tid = TDMCreateRequest::getInt('table_id');
$table = $tdmcreate->getHandler('tables')->get( $tid );
//
-$mod_id = $moduleObj->getVar('mod_id');
-$mod_name = $moduleObj->getVar('mod_name');
+$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));
@@ -58,7 +58,7 @@
$handler->getPath( TDMC_PATH );
$handler->getUploadPath( TDMC_UPLOAD_PATH );
// Creation of the structure of folders and files
- $base_architecture = $handler->createBaseFoldersFiles( $moduleObj );
+ $base_architecture = $handler->createBaseFoldersFiles( $repObj );
if($base_architecture !== false) {
$GLOBALS['xoopsTpl']->assign('base_architecture', true);
} else {
@@ -66,19 +66,17 @@
}
// Get files
$builds = array();
- $files = $handler->createBuildingFiles( $moduleObj, $table, $tables, $fields );
+ $files = $handler->createBuildingFiles( $repObj, $table, $tables, $fields );
foreach($files as $file) {
if($file) {
- $builds['created'] = $file;
- } else {
- $builds['notcreated'] = $file;
- }
+ $builds['list'] = $file;
+ }
$GLOBALS['xoopsTpl']->append('builds', $builds);
}
// Directory to saved all files
$GLOBALS['xoopsTpl']->assign('building_directory', sprintf(_AM_TDMCREATE_BUILDING_DIRECTORY, str_replace(' ', '', strtolower($mod_name))));
// Copy this module in root modules
- if ( $moduleObj->getVar('mod_inroot_copy') == 1 ) {
+ if ( $repObj->getVar('mod_inroot_copy') == 1 ) {
TDMCreate_copyr($from_dir, $to_dir);
}
break;
Deleted: XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/admin/includes.php
===================================================================
--- XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/admin/includes.php 2014-05-21 22:01:47 UTC (rev 12543)
+++ XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/admin/includes.php 2014-05-22 15:51:24 UTC (rev 12544)
@@ -1,65 +0,0 @@
-<?php
-/*
- 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.
- */
-/**
- * tdmcreate module
- *
- * @copyright The XOOPS Project http://sourceforge.net/projects/xoops/
- * @license GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html)
- * @package tdmcreate
- * @since 2.5.0
- * @author Txmod Xoops http://www.txmodxoops.org
- * @version $Id: includes.php 11084 2013-02-23 15:44:20Z timgno $
- */
-include '../../../include/cp_header.php';
-include_once("../include/functions.php");
-
-$modPath = XOOPS_ROOT_PATH.'/modules/TDMCreate';
-$cPath = $modPath.'/const';
-
-include_once $cPath.'/const_structure.php';
-include_once $cPath.'/const_xoopsversion.php';
-include_once $cPath.'/const_changelog.php';
-include_once $cPath.'/const_include_search.php';
-include_once $cPath.'/const_include_comments.php';
-include_once $cPath.'/const_include_notifications.php';
-include_once $cPath.'/const_include_common.php';
-include_once $cPath.'/const_include_functions.php';
-include_once $cPath.'/const_include_install.php';
-include_once $cPath.'/const_waiting.php';
-include_once $cPath.'/const_css_style.php';
-include_once $cPath.'/const_sql.php';
-include_once $cPath.'/const_blocks.php';
-include_once $cPath.'/const_blocks_templates.php';
-include_once $cPath.'/const_class.php';
-include_once $cPath.'/const_class_helper.php';
-include_once $cPath.'/const_class_request.php';
-include_once $cPath.'/const_class_module.php';
-include_once $cPath.'/const_admin_header.php';
-include_once $cPath.'/const_admin_footer.php';
-include_once $cPath.'/const_admin_menu.php';
-include_once $cPath.'/const_admin_index.php';
-include_once $cPath.'/const_admin_pages.php';
-include_once $cPath.'/const_admin_about.php';
-include_once $cPath.'/const_admin_permissions.php';
-include_once $cPath.'/const_admin_language.php';
-include_once $cPath.'/const_modinfo_language.php';
-include_once $cPath.'/const_help_language.php';
-include_once $cPath.'/const_blocks_language.php';
-include_once $cPath.'/const_main_language.php';
-include_once $cPath.'/const_user_header.php';
-include_once $cPath.'/const_user_index.php';
-include_once $cPath.'/const_user_pages.php';
-include_once $cPath.'/const_templates_header.php';
-include_once $cPath.'/const_templates_index.php';
-include_once $cPath.'/const_templates_pages.php';
-include_once $cPath.'/const_templates_footer.php';
-include_once $cPath.'/const_templates_admin_about.php';
-include_once $cPath.'/const_templates_admin_help.php';
\ No newline at end of file
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-21 22:01:47 UTC (rev 12543)
+++ XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/class/files/admin_pages.php 2014-05-22 15:51:24 UTC (rev 12544)
@@ -35,18 +35,23 @@
*/
private $tables = null;
/*
+ * @var string
+ */
+ private $fields = null;
+ /*
* @public function constructor
* @param string $module
* @param mixed $table
* @param string $filename
*/
- public function __construct($module, $table, $tables, $filename) {
+ public function __construct($module, $table, $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;
}
/*
* @static function &getInstance
@@ -54,11 +59,11 @@
* @param mixed $table
* @param string $filename
*/
- public static function &getInstance($module, $table, $tables, $filename)
+ public static function &getInstance($module, $table, $tables, $fields, $filename)
{
static $instance = false;
if (!$instance) {
- $instance = new self($module, $table, $tables, $filename);
+ $instance = new self($module, $table, $tables, $fields, $filename);
}
return $instance;
}
@@ -87,7 +92,7 @@
* @param string $table_name
* @param string $language
*/
- public function getAdminPagesList($table_name, $language) {
+ public function getAdminPagesList($table_name, $language, $fpif, $fpmf) {
$stu_table_name = strtoupper($table_name);
$ret = <<<EOT
case 'list':
@@ -141,7 +146,7 @@
* @param string $table_name
* @param string $language
*/
- public function getAdminPagesSave($table_name, $language) {
+ public function getAdminPagesSave($table_name, $language, $fpif, $fpmf) {
$stu_table_name = strtoupper($table_name);
$ret = <<<EOT
case 'save':
@@ -195,7 +200,7 @@
* @param string $table_name
* @param string $language
*/
- public function getAdminPagesEdit($table_name, $language) {
+ public function getAdminPagesEdit($table_name, $language, $fpif) {
$stu_table_name = strtoupper($table_name);
$ret = <<<EOT
case 'edit':
@@ -215,7 +220,7 @@
* @param string $table_name
* @param string $language
*/
- public function getAdminPagesDelete($table_name, $language) {
+ public function getAdminPagesDelete($table_name, $language, $fpif, $fpmf) {
$ret = <<<EOT
case 'delete':
@@ -253,8 +258,18 @@
* @public function render
* @param null
*/
- public function render() {
- $module = $this->getModule();
+ public function render()
+ {
+ 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');
+ }
+ }
+ $module = $this->getModule();
$module_name = $module->getVar('mod_name');
$table_name = $this->table->getVar('table_name');
$filename = $this->getFileName();
@@ -262,9 +277,10 @@
$content = $this->getHeaderFilesComments($module, $filename);
$content .= $this->getAdminPagesHeader($module_name, $table_name);
$content .= $this->getAdminPagesNew($table_name, $language);
- $content .= $this->getAdminPagesSave($table_name, $language);
- $content .= $this->getAdminPagesEdit($table_name, $language);
- $content .= $this->getAdminPagesDelete($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->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-21 22:01:47 UTC (rev 12543)
+++ XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/class/files/admin_permissions.php 2014-05-22 15:51:24 UTC (rev 12544)
@@ -31,16 +31,21 @@
*/
private $table = null;
/*
+ * @var string
+ */
+ private $fields = null;
+ /*
* @public function constructor
* @param string $module
* @param string $filename
*/
- public function __construct($module, $table, $filename) {
+ public function __construct($module, $table, $fields, $filename) {
$this->tdmcfile = TDMCreateFile::getInstance();
$this->setModule($module);
//$this->setTable($table);
$this->setFileName($filename);
$this->table = $table;
+ $this->fields = $fields;
}
/*
* @static function &getInstance
@@ -48,11 +53,11 @@
* @param mixed $table
* @param string $filename
*/
- public static function &getInstance($module, $table, $filename)
+ public static function &getInstance($module, $table, $fields, $filename)
{
static $instance = false;
if (!$instance) {
- $instance = new self($module, $table, $filename);
+ $instance = new self($module, $table, $fields, $filename);
}
return $instance;
}
@@ -60,15 +65,18 @@
* @public function render
* @param null
*/
- public function render() {
- $module = $this->getModule();
- //$table = $this->getTable();
- $filename = $this->getFileName();
- $module_name = $module->getVar('mod_name');
- $table_name = $this->table->getVar('table_name');
- $language = $this->getLanguage($module_name, 'AM');
- $content = $this->getHeaderFilesComments($module, $filename);
- $content .= <<<EOT
+ 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
\ninclude_once 'header.php';
include_once XOOPS_ROOT_PATH.'/class/xoopsform/grouppermform.php';
if( !empty(\$_POST['submit']) )
@@ -154,6 +162,22 @@
unset(\$permform);
include_once 'footer.php';
EOT;
+ return $ret;
+ }
+
+ /*
+ * @public function render
+ * @param null
+ */
+ public function render() {
+ $module = $this->getModule();
+ $filename = $this->getFileName();
+ $module_name = $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);
+ //
$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-21 22:01:47 UTC (rev 12543)
+++ XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/class/files/architecture.php 2014-05-22 15:51:24 UTC (rev 12544)
@@ -178,7 +178,7 @@
$adminMenu = AdminMenu::getInstance($module, $table, $tables, 'menu.php');
$ret[] = $adminMenu->render();
// Admin Permissions File
- $adminPermissions = AdminPermissions::getInstance($module, $table, 'permissions.php');
+ $adminPermissions = AdminPermissions::getInstance($module, $table, $fields, 'permissions.php');
$ret[] = $adminPermissions->render();
// Admin Styles File
$cssStyles = CssStyles::getInstance($module, 'style.css');
@@ -191,31 +191,34 @@
$ret[] = $includeFunctions->render();
// Admin Install File
$includeInstall = IncludeInstall::getInstance($module, $table, $tables, $fields, 'install.php');
- $ret[] = $includeInstall->render();
+ $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, $table_name.'.php');
+ $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, $table_name.'.php');
+ $blocksFiles = BlocksFiles::getInstance($module, $table, $fields, $table_name.'.php');
$ret[] = $blocksFiles->render();
// Blocks Templates File
- $blocksTemplates = BlocksTemplates::getInstance($module, $table, $tables, $table_name.'.tpl');
+ $blocksTemplates = BlocksTemplates::getInstance($module, $table, $fields, $table_name.'.tpl');
$ret[] = $blocksTemplates->render();
// Class Files
- $classFiles = ClassFiles::getInstance($module, $table, $tables, $table_name.'.php');
+ $classFiles = ClassFiles::getInstance($module, $table, $tables, $fields, $table_name.'.php');
$ret[] = $classFiles->render();
// User Pages File
- $userPages = UserPages::getInstance($module, $table, $table_name.'.php');
+ $userPages = UserPages::getInstance($module, $table, $fields, $table_name.'.php');
$ret[] = $userPages->render();
// User Templates File
- $userTemplates = UserTemplates::getInstance($module, $table, $table_name.'.tpl');
+ $userTemplates = UserTemplates::getInstance($module, $table, $fields, $table_name.'.tpl');
$ret[] = $userTemplates->render();
}
// Language Admin 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-21 22:01:47 UTC (rev 12543)
+++ XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/class/files/blocks_files.php 2014-05-22 15:51:24 UTC (rev 12544)
@@ -31,17 +31,22 @@
*/
private $table = null;
/*
+ * @var string
+ */
+ private $fields = null;
+ /*
* @public function constructor
* @param string $module
* @param mixed $table
* @param string $filename
*/
- public function __construct($module, $table, $filename) {
+ public function __construct($module, $table, $fields, $filename) {
$this->tdmcfile = TDMCreateFile::getInstance();
$this->setModule($module);
//$this->setTable($table);
$this->setFileName($filename);
$this->table = $table;
+ $this->fields = $fields;
}
/*
* @static function &getInstance
@@ -49,11 +54,11 @@
* @param mixed $table
* @param string $filename
*/
- public static function &getInstance($module, $table, $filename)
+ public static function &getInstance($module, $table, $fields, $filename)
{
static $instance = false;
if (!$instance) {
- $instance = new self($module, $table, $filename);
+ $instance = new self($module, $table, $fields, $filename);
}
return $instance;
}
@@ -61,7 +66,7 @@
* @public function getBlocksShow
* @param null
*/
- public function getBlocksShow($module) {
+ public function getBlocksShow($module, $fpif, $fpmf) {
$mod_name = $module->getVar('mod_name');
$mod_name_lowercase = strtolower($mod_name);
$table_name = $this->table->getVar('table_name');
@@ -91,28 +96,7 @@
}
EOT;
}
- //fields
- $fields = explode('|', $table_fields);
- $nb_fields = count($fields);
- //print_r($fields_total);
- //parameters
- $parameters_total = explode('|', $table_parameters);
-
- for ($i = 0; $i < $nb_fields; $i++)
- {
- $field = explode(':', $fields[$i]);
- if( $i == 0 ) {
- $fpif = $field[0]; // fpif = fields parameters id field
- $fpbf = '0'; // fpdf = fields parameters display form
- } else {
- $param = explode(':', $parameters_total[$i-1]);
- $fpbf[$i] = $param[3]; // fpdf = fields parameters display form
- if ( $param[4] == 1 ) {
- $fpmf = $field[0]; // fpmf = fields parameters main field
- }
- }
- }
-
+
$ret .= <<<EOT
\n\tif (\$type_block)
{
@@ -126,36 +110,34 @@
foreach (array_keys(\${$table_name}_arr) as \$i)
{
EOT;
+ foreach(array_keys($this->fields) as $f)
+ {
+ if( $this->fields[$f]->getVar('field_block') == 1 ) {
+ $ret .= <<<EOT
+\n\t\t\${$table_fieldname}['{$fpmf}'] = \${$table_name}_arr[\$i]->getVar('{$fpmf}');\n
+EOT;
+ }
+ }
+ $ret .= <<<EOT
+ }
+ return \${$table_fieldname};
+}
+EOT;
return $ret;
}
/*
* @public function getBlocksEdit
* @param null
*/
- public function getBlocksEdit($module) {
+ public function getBlocksEdit($module, $fpif, $fpmf, $language) {
$mod_name = $module->getVar('mod_name');
$mod_name_lowercase = strtolower($mod_name);
$table_name = $this->table->getVar('table_name');
$table_fieldname = $this->table->getVar('table_fieldname');
-
- for ($i = 0; $i < $nb_fields; $i++)
- {
- $structure_fields = explode(':', $fields[$i]);
- if( $fpbf[$i] == 1 ) {
- $ret .= <<<EOT
-\n\t\t\${$table_fieldname}['{$structure_fields[0]}'] = \${$table_name}_arr[\$i]->getVar('{$structure_fields[0]}');
-EOT;
- }
- }
- $ret .= <<<EOT
- \n\t}
- return \${$table_fieldname};
-}
-
+ $ret = <<<EOT
function b_{$mod_name_lowercase}_{$table_name}_edit(\$options)
{
EOT;
-
if ( $this->table->getVar('table_category') == 1 ) {
$ret .=<<<EOT
\ninclude_once XOOPS_ROOT_PATH.'/modules/{$mod_name}/class/category.php';
@@ -199,15 +181,26 @@
* @public function render
* @param null
*/
- public function render() {
+ public function render()
+ {
+ 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');
+ }
+ }
$module = $this->getModule();
$module_name = $module->getVar('mod_name');
$table = $this->getTable();
$filename = $this->getFileName();
$language = $this->getLanguage($module_name, 'MB');
$content = $this->getHeaderFilesComments($module, $filename);
- $content .= $this->getBlocksShow($module);
- $content .= $this->getBlocksEdit($module);
+ $content .= $this->getBlocksShow($module, $fpif, $fpmf);
+ $content .= $this->getBlocksEdit($module, $fpif, $fpmf, $language);
+ //
$this->tdmcfile->create($module_name, 'blocks', $filename, $content, _AM_TDMCREATE_FILE_CREATED, _AM_TDMCREATE_FILE_NOTCREATED);
return $this->tdmcfile->renderFile();
}
Modified: XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/class/files/blocks_templates.php
===================================================================
--- XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/class/files/blocks_templates.php 2014-05-21 22:01:47 UTC (rev 12543)
+++ XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/class/files/blocks_templates.php 2014-05-22 15:51:24 UTC (rev 12544)
@@ -35,18 +35,22 @@
*/
private $tables = null;
/*
+ * @var string
+ */
+ private $fields = null;
+ /*
* @public function constructor
* @param string $module
* @param mixed $table
* @param string $filename
*/
- public function __construct($module, $table, $tables, $filename) {
+ public function __construct($module, $table, $fields, $filename) {
$this->tdmcfile = TDMCreateFile::getInstance();
$this->setModule($module);
//$this->setTable($table);
$this->setFileName($filename);
$this->table = $table;
- $this->tables = $tables;
+ $this->fields = $fields;
}
/*
* @static function &getInstance
@@ -54,11 +58,11 @@
* @param mixed $table
* @param string $filename
*/
- public static function &getInstance($module, $table, $tables, $filename)
+ public static function &getInstance($module, $table, $fields, $filename)
{
static $instance = false;
if (!$instance) {
- $instance = new self($module, $table, $tables, $filename);
+ $instance = new self($module, $table, $fields, $filename);
}
return $instance;
}
@@ -68,8 +72,8 @@
*/
public function render() {
$module = $this->getModule();
- $table_nbfields = $this->table->getVar('table_nbfields');
- $fields = $this->getFields();
+ $table_fieldname = $this->table->getVar('table_fieldname');
+ //$fields = $this->getFields();
$filename = $this->getFileName();
$module_name = $module->getVar('mod_name');
$language = $this->getLanguage($module_name, 'MB');
@@ -78,9 +82,9 @@
<table class="outer">
<tr class="head">
EOT;
- for ($i = 0; $i < $table_nbfields; $i++)
- {
- $lng_field_name = $language.strtoupper($fields[$i]->getVar('field_name'));
+ foreach(array_keys($this->fields) as $f)
+ {
+ $lng_field_name = $language.strtoupper($this->fields[$f]->getVar('field_name'));
$content .= <<<EOT
\n\t\t<th><{\$smarty.const.{$lng_field_name}}></th>
EOT;
@@ -91,9 +95,9 @@
<tr class = "<{cycle values = 'even,odd'}>">
<td>
EOT;
- for ($i = 0; $i < $table_nbfields; $i++)
+ foreach(array_keys($this->fields) as $f)
{
- $table_field_name = $table_fieldname.'.'.strip_tags($fields[$i]->getVar('field_name'));
+ $table_field_name = $table_fieldname.'.'.strip_tags($this->fields[$f]->getVar('field_name'));
$content .= <<<EOT
\n\t\t\t<{\${$table_field_name}}>
EOT;
Modified: XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/class/files/class_files.php
===================================================================
--- XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/class/files/class_files.php 2014-05-21 22:01:47 UTC (rev 12543)
+++ XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/class/files/class_files.php 2014-05-22 15:51:24 UTC (rev 12544)
@@ -19,8 +19,8 @@
* @version $Id: class_files.php 12258 2014-01-02 09:33:29Z timgno $
*/
defined('XOOPS_ROOT_PATH') or die('Restricted access');
-
-class ClassFiles extends TDMCreateFile
+require_once 'formelements.php';
+class ClassFiles extends TDMCreateFormElements
{
/*
* @var string
@@ -29,24 +29,34 @@
/*
* @var string
*/
+ private $formelements = null;
+ /*
+ * @var string
+ */
private $table = null;
/*
* @var string
*/
private $tables = null;
/*
+ * @var string
+ */
+ private $fields = null;
+ /*
* @public function constructor
* @param string $module
* @param mixed $table
* @param string $filename
*/
- public function __construct($module, $table, $tables, $filename) {
+ public function __construct($module, $table, $tables, $fields, $filename) {
$this->tdmcfile = TDMCreateFile::getInstance();
+ $this->formelements = TDMCreateFormElements::getInstance();
$this->setModule($module);
//$this->setTable($table);
$this->setFileName($filename);
$this->table = $table;
$this->tables = $tables;
+ $this->fields = $fields;
}
/*
* @static function &getInstance
@@ -54,11 +64,11 @@
* @param mixed $table
* @param string $filename
*/
- public static function &getInstance($module, $table, $tables, $filename)
+ public static function &getInstance($module, $table, $tables, $fields, $filename)
{
static $instance = false;
if (!$instance) {
- $instance = new self($module, $table, $tables, $filename);
+ $instance = new self($module, $table, $tables, $fields, $filename);
}
return $instance;
}
@@ -78,13 +88,12 @@
* @param array $table_nbfields
* @param array $fields
*/
- public function getInitVars($table_nbfields, $fields) {
+ public function getInitVars($table_nbfields) {
$ret = '';
// Creation of the initVar functions list
- for ($i = 0; $i < $table_nbfields; $i++) {
- $field_name = $fields[$i]->getVar('field_name');
- $field_type = $fields[$i]->getVar('field_type');
- switch($field_type) {
+ for ($i = 0; $i < $this->table->getVar('table_nbfields'); $i++) {
+ $field_name = $this->fields[$i]->getVar('field_name');
+ switch($this->fields[$i]->getVar('field_type')) {
case 'int':
case 'tinyint':
case 'mediumint':
@@ -279,23 +288,25 @@
$module = $this->getModule();
$table_nbfields = $this->table->getVar('table_nbfields');
$table_name = $this->table->getVar('table_name');
- $fields = $this->getFields();
+ //$fields = $this->getFields();
$filename = $this->getFileName();
$module_name = $module->getVar('mod_name');
- $initvar = $this->getInitVars($table_nbfields, $fields);
-
- for ($i = 0; $i < $table_nbfields; $i++) {
- $field_name = $fields[$i]->getVar('field_name');
- if($i == 0) {
+ $initvar = $this->getInitVars($table_nbfields);
+ $fpif = ''; $fpmf = '';
+ $initvar_functions = array();
+ foreach(array_keys($this->fields) as $f)
+ {
+ $field_name = $this->fields[$f]->getVar('field_name');
+ if($f == 0) {
$fpif = $field_name;
}
- if($fields[$i]->getVar('field_main') == 1) {
+ if($this->fields[$f]->getVar('field_main') == 1) {
$fpmf = $field_name;
- }
+ }
}
+ $this->formelements->initForm($module, $this->table, $this->fields);
+ $elements_form = $this->formelements->renderElement();
- $elements_form = '/* ------------- Here function elements form ---------------------- */';
-
$content = $this->getHeaderFilesComments($module, $filename);
$content .= $this->getHeadClass($module_name, $table_name, $initvar);
$content .= $this->getHeadFunctionForm($module_name, $elements_form);
Modified: XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/class/files/file.php
===================================================================
--- XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/class/files/file.php 2014-05-21 22:01:47 UTC (rev 12543)
+++ XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/class/files/file.php 2014-05-22 15:51:24 UTC (rev 12544)
@@ -307,8 +307,11 @@
$str = strrpos($path, '/');
if($str !== false){
return substr($path, $str + 1, strlen($path));
- }
- }
+ } else {
+ return substr($path, $str, strlen($path));
+ }
+ }
+ //return 'root module';
}
/*
@@ -439,20 +442,20 @@
// Integration of the content in the file
if (!$this->xoopsfile->write($this->getContent(), $mode, true)) {
$ret .= sprintf($notcreated, $filename, $folder_name);
- //$GLOBALS['xoopsTpl']->assign('notcreated', sprintf($notcreated, $filename, $folder_name));
+ $GLOBALS['xoopsTpl']->assign('created', false);
exit();
}
// Created
$ret .= sprintf($created, $filename, $folder_name);
- //$GLOBALS['xoopsTpl']->assign('created', sprintf($created, $filename, $folder_name));
+ $GLOBALS['xoopsTpl']->assign('created', true);
$this->xoopsfile->close();
} else {
$ret .= sprintf($notcreated, $filename, $folder_name);
- //$GLOBALS['xoopsTpl']->assign('notcreated', sprintf($notcreated, $filename, $folder_name));
+ $GLOBALS['xoopsTpl']->assign('created', false);
}
} else {
$ret .= sprintf($notcreated, $filename, $folder_name);
- //$GLOBALS['xoopsTpl']->assign('notcreated', sprintf($notcreated, $filename, $folder_name));
+ $GLOBALS['xoopsTpl']->assign('created', false);
}
}
return $ret;
Deleted: XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/class/files/form_elements.php
===================================================================
--- XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/class/files/form_elements.php 2014-05-21 22:01:47 UTC (rev 12543)
+++ XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/class/files/form_elements.php 2014-05-22 15:51:24 UTC (rev 12544)
@@ -1,315 +0,0 @@
-<?php
-/*
- 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.
- */
-/**
- * tdmcreate module
- *
- * @copyright The XOOPS Project http://sourceforge.net/projects/xoops/
- * @license GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html)
- * @package tdmcreate
- * @since 2.5.0
- * @author Txmod Xoops http://www.txmodxoops.org
- * @version $Id: form_elements.php 12258 2014-01-02 09:33:29Z timgno $
- */
-defined('XOOPS_ROOT_PATH') or die('Restricted access');
-
-class FormElements
-{
- /*
- * @public function constructor
- * @param string $module
- * @param array $table
- * @param string $fields
- */
- public function __construct($module, $table, $fields) {
- $this->setModule($module);
- $this->setTable($table);
- $this->setFields($fields);
- }
- /**
- * @param string $method
- * @param array $args
- */
- public function __call($method, $args)
- {
- $arg = isset($args[0]) ? $args[0] : null;
- return $this->getVar($method, $arg);
- }
- /*
- * @static function &getInstance
- * @param null
- */
- public static function &getInstance()
- {
- static $instance = false;
- if (!$instance) {
- $instance = new self();
- }
- return $instance;
- }
- /*
- * @public function getXoopsFormText
- * @param string $language
- * @param string $field_name
- * @param string $required
- */
- public function getXoopsFormText($language, $field_name, $required = 'false') {
- $ret = <<<EOT
- \$form->addElement(new XoopsFormText({$language}, '{$field_name}', 50, 255, \$this->getVar('{$field_name}')), {$required});
-EOT;
- return $ret;
- }
- /*
- * @public function getXoopsFormText
- * @param string $language
- * @param string $field_name
- * @param string $required
- */
- public function getXoopsFormTextArea($language, $field_name, $required = 'false') {
- $ret = <<<EOT
- \$form->addElement(new XoopsFormTextArea({$language}, '{$field_name}', \$this->getVar('{$field_name}'), 4, 47), {$required});
-EOT;
- return $ret;
- }
- /*
- * @public function getXoopsFormDhtmlTextArea
- * @param string $language
- * @param string $module_name
- * @param string $field_name
- * @param string $required
- */
- public function getXoopsFormDhtmlTextArea($language, $module_name, $field_name, $required = 'false') {
- $ret = <<<EOT
- \$editor_configs = array();
- \$editor_configs['name'] = '{$field_name}';
- \$editor_configs['value'] = \$this->getVar('{$field_name}', 'e');
- \$editor_configs['rows'] = 5;
- \$editor_configs['cols'] = 40;
- \$editor_configs['width'] = '100%';
- \$editor_configs['height'] = '400px';
- \$editor_configs['editor'] = xoops_getModuleOption('{$module_name}_editor', '{$module_name}');
- \$form->addElement( new XoopsFormEditor({$language}, '{$field_name}', \$editor_configs), {$required} );
-EOT;
- return $ret;
- }
- /*
- * @public function getXoopsFormCheckBox
- * @param string $language
- * @param string $field_name
- * @param string $required
- */
- public function getXoopsFormCheckBox($language, $field_name, $required = 'false') {
- $ret = <<<EOT
- \${$field_name} = \$this->isNew() ? 0 : \$this->getVar('{$field_name}');
- \$check_{$field_name} = new XoopsFormCheckBox({$language}, '{$field_name}', \${$field_name});
- \$check_{$field_name}->addOption(1, " ");
- \$form->addElement(\$check_{$field_name}, {$required});
-EOT;
- return $ret;
- }
- /*
- * @public function getXoopsFormHidden
- * @param string $field_name
- */
- public function getXoopsFormHidden($field_name) {
- $ret = <<<EOT
- \$form->addElement(new XoopsFormHidden('{$field_name}', \$this->getVar('{$field_name}')));
-EOT;
- return $ret;
- }
- /*
- * @public function getXoopsFormUploadFile
- * @param string $language
- * @param string $field_name
- * @param string $required
- */
- public function getXoopsFormUploadFile($language, $field_name, $required = 'false') {
- $ret = <<<EOT
- \$form->addElement(new XoopsFormUploadFile({$language}, '{$field_name}', \$xoopsModuleConfig['maxsize']), {$required});
-EOT;
- return $ret;
- }
- /*
- * @public function getXoopsFormUploadImage
- * @param string $language
- * @param string $field_name
- * @param string $required
- */
- public function getXoopsFormUploadImage($language, $field_name, $required = 'false') {
- $ret = <<<EOT
- \$form->addElement(new XoopsFormUploadImage({$language}, '{$field_name}', \$xoopsModuleConfig['maxsize']), {$required});
-EOT;
- return $ret;
- }
- /*
- * @public function getXoopsFormColorPicker
- * @param string $language
- * @param string $field_name
- * @param string $required
- */
- public function getXoopsFormColorPicker($language, $field_name, $required = 'false') {
- $ret = <<<EOT
- \$form->addElement(new XoopsFormColorPicker({$language}, '{$field_name}', \$xoopsModuleConfig['maxsize']), {$required});
-EOT;
- return $ret;
- }
- /*
- * @public function getXoopsFormSelectUser
- * @param string $language
- * @param string $field_name
- * @param string $required
- */
- public function getXoopsFormSelectUser($language, $field_name, $required = 'false') {
- $ret = <<<EOT
- \$form->addElement(new XoopsFormSelectUser({$language}, '{$field_name}', false, \$this->getVar('{$field_name}'), 1, false), {$required});
-EOT;
- return $ret;
- }
- /*
- * @public function getXoopsFormRadioYN
- * @param string $language
- * @param string $field_name
- * @param string $required
- */
- public function getXoopsFormRadioYN($language, $field_name, $required = 'false') {
- $ret = <<<EOT
- ${$field_name} = \$this->isNew() ? 0 : \$this->getVar('{$field_name}');
- \$form->addElement(new XoopsFormRadioYN({$language}, '{$field_name}', ${$field_name}), {$required});
-EOT;
- return $ret;
- }
- /*
- * @public function getXoopsFormTextDateSelect
- * @param string $language
- * @param string $field_name
- * @param string $required
- */
- public function getXoopsFormTextDateSelect($language, $field_name, $required = 'false') {
- $ret = <<<EOT
- \$form->addElement(new XoopsFormTextDateSelect({$language}, '{$field_name}', '', \$this->getVar('{$field_name}')), {$required});
-EOT;
- return $ret;
- }
- /*
- * @public function getXoopsFormTable
- * @param string $language
- * @param string $module_name
- * @param string $table_name
- * @param string $field_name
- * @param string $required
- */
- public function getXoopsFormTable($language, $module_name, $table_name, $field_name, $required = 'false') {
- $ret = <<<XFT
- \${$table_name}Handler =& xoops_getModuleHandler('{$table_name}', '{$module_name}');
- \${$field_name}_select = new XoopsFormSelect({$language}, '{$field_name}', \$this->getVar('{$field_name}'));
- \${$field_name}_select->addOptionArray(${$field_name}Handler->getList());
- \$form->addElement(${$field_name}_select, {$required});
-XFT;
- return $ret;
- }
- /*
- * @public function getXoopsFormTopic
- * @param string $language
- * @param string $module_name
- * @param string $table_name
- * @param string $field_name
- * @param string $required
- */
- public function getXoopsFormTopic($language, $module_name, $table_name, $fields, $required = 'false') {
- //
- //
- // ========================== Da elaborare per field parent e field name ============================
- //
- //
- if($fields->getVar('field_id') == 1) {
- $field_id = $fields->getVar('field_name');
- }
- if($fields->getVar('field_main') == 1) {
- $field_name = $fields->getVar('field_name');
- }
- if($fields->getVar('field_parent') == 1) {
- $field_pid = $fields->getVar('field_name');
- }
- $ret = <<<XFT
- include_once(XOOPS_ROOT_PATH . '/class/tree.php');
- \${$table_name}Handler = xoops_getModuleHandler('{$table_name}', '\${$module_name}' );
- \$criteria = new CriteriaCompo();
- \${$table_name} = \${$table_name}Handler->getObjects( \$criteria );
- if(\${$table_name}) {
- \${$table_name}_tree = new XoopsObjectTree( \${$table_name}, '{$field_id}', '{$field_pid}' );
- \${$field_pid} = \${$table_name}_tree->makeSelBox( '{$field_pid}', '{$field_name}','--', \$this->getVar('{$field_pid}', 'e' ), true );
- \$form->addElement( new XoopsFormLabel ( {$language}, \${$field_pid} ) );
- }
-XFT;
- // ========================== Da elaborare per field parent e field name ============================
- return $ret;
- }
- /*
- * @public function render
- * @param null
- */
- public function renderElement() {
- $module = $this->getModule();
- $module_name = $module->getVar('module_name');
- $table = $this->getTable();
- $table_name = $table->getVar('table_name');
- $fields = $this->getFields();
- $field_name = $fields->getVar('field_name');
- $filename = $this->getFileName();
- $language = $this->getLanguage('AM', '_');
- $language = $language . strtoupper($table_name) . '_' . strtoupper($field_name);
- $required = ( $fields->getVar('field_required') == 1 ) ? 'true' : 'false';
- $ret = '';
- switch($fields->getVar('field_element'))
- {
- case 1:
- $ret .= $this->getXoopsFormText($language, $field_name, $required);
- break;
- case 2:
- $ret .= $this->getXoopsFormTextArea($language, $field_name, $required);
- break;
- case 3:
- $ret .= $this->getXoopsFormDhtmlTextArea($language, $module_name, $field_name, $required);
- break;
- case 4:
- $ret .= $this->getXoopsFormCheckBox($language, $field_name, $required);
- break;
- case 5:
- $ret .= $this->getXoopsFormHidden($field_name);
- break;
- case 6:
- $ret .= $this->getXoopsFormUploadFile($language, $field_name, $required);
- break;
- case 7:
- $ret .= $this->getXoopsFormUploadImage($language, $field_name, $required);
- break;
- case 8:
- $ret .= $this->getXoopsFormColorPicker($language, $field_name, $required);
- break;
- case 9:
- $ret .= $this->getXoopsFormSelectUser($language, $field_name, $required);
- break;
- case 10:
- $ret .= $this->getXoopsFormRadioYN($language, $field_name, $required);
- break;
- case 11:
- $ret .= $this->getXoopsFormTextDateSelect($language, $field_name, $required);
- break;
- default:
- if($table->getVar('table_category') == 0) {
- $ret .= $this->getXoopsFormTable($language, $module_name, $table_name, $field_name, $required);
- } else {
- $ret .= $this->getXoopsFormTopic($language, $module_name, $table_name, $fields, $required);
- }
- break;
- }
- return $ret;
- }
-}
\ No newline at end of file
Added: XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/class/files/formelements.php
===================================================================
--- XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/class/files/formelements.php (rev 0)
+++ XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/class/files/formelements.php 2014-05-22 15:51:24 UTC (rev 12544)
@@ -0,0 +1,339 @@
+<?php
+/*
+ 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.
+ */
+/**
+ * tdmcreate module
+ *
+ * @copyright The XOOPS Project http://sourceforge.net/projects/xoops/
+ * @license GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html)
+ * @package tdmcreate
+ * @since 2.5.0
+ * @author Txmod Xoops http://www.txmodxoops.org
+ * @version $Id: form_elements.php 12258 2014-01-02 09:33:29Z timgno $
+ */
+defined('XOOPS_ROOT_PATH') or die('Restricted access');
+
+class TDMCreateFormElements extends TDMCreateFile
+{
+ /*
+ * @var string
+ */
+ private $module = null;
+ /*
+ * @var string
+ */
+ private $table = null;
+ /*
+ * @var string
+ */
+ private $fields = null;
+ /*
+ * @public function constructor
+ * @param null
+ */
+ public function __construct() {
+ parent::__construct();
+ }
+ /**
+ * @param string $method
+ * @param array $args
+ */
+ public function __call($method, $args)
+ {
+ $arg = isset($args[0]) ? $args[0] : null;
+ return $this->getVar($method, $arg);
+ }
+ /*
+ * @static function &getInstance
+ * @param null
+ */
+ public static function &getInstance()
+ {
+ static $instance = false;
+ if (!$instance) {
+ $instance = new self();
+ }
+ return $instance;
+ }
+ /*
+ * @public function initForm
+ * @param string $module
+ * @param array $table
+ * @param string $fields
+ */
+ public function initForm($module, $table, $fields) {
+ $this->module = $module;
+ $this->table = $table;
+ $this->fields = $fields;
+ }
+ /*
+ * @public function getXoopsFormText
+ * @param string $language
+ * @param string $field_name
+ * @param string $required
+ */
+ public function getXoopsFormText($language, $field_name, $required = 'false') {
+ $ret = <<<EOT
+ \$form->addElement(new XoopsFormText({$language}, '{$field_name}', 50, 255, \$this->getVar('{$field_name}')), {$required});
+EOT;
+ return $ret;
+ }
+ /*
+ * @public function getXoopsFormText
+ * @param string $language
+ * @param string $field_name
+ * @param string $required
+ */
+ public function getXoopsFormTextArea($language, $field_name, $required = 'false') {
+ $ret = <<<EOT
+ \$form->addElement(new XoopsFormTextArea({$language}, '{$field_name}', \$this->getVar('{$field_name}'), 4, 47), {$required});
+EOT;
+ return $ret;
+ }
+ /*
+ * @public function getXoopsFormDhtmlTextArea
+ * @param string $language
+ * @param string $module_name
+ * @param string $field_name
+ * @param string $required
+ */
+ public function getXoopsFormDhtmlTextArea($language, $module_name, $field_name, $required = 'false') {
+ $ret = <<<EOT
+ \$editor_configs = array();
+ \$editor_configs['name'] = '{$field_name}';
+ \$editor_configs['value'] = \$this->getVar('{$field_name}', 'e');
+ \$editor_configs['rows'] = 5;
+ \$editor_configs['cols'] = 40;
+ \$editor_configs['width'] = '100%';
+ \$editor_configs['height'] = '400px';
+ \$editor_configs['editor'] = xoops_getModuleOption('{$module_name}_editor', '{$module_name}');
+ \$form->addElement( new XoopsFormEditor({$language}, '{$field_name}', \$editor_configs), {$required} );
+EOT;
+ return $ret;
+ }
+ /*
+ * @public function getXoopsFormCheckBox
+ * @param string $language
+ * @param string $field_name
+ * @param string $required
+ */
+ public function getXoopsFormCheckBox($language, $field_name, $required = 'false') {
+ $ret = <<<EOT
+ \${$field_name} = \$this->isNew() ? 0 : \$this->getVar('{$field_name}');
+ \$check_{$field_name} = new XoopsFormCheckBox({$language}, '{$field_name}', \${$field_name});
+ \$check_{$field_name}->addOption(1, " ");
+ \$form->addElement(\$check_{$field_name}, {$required});
+EOT;
+ return $ret;
+ }
+ /*
+ * @public function getXoopsFormHidden
+ * @param string $field_name
+ */
+ public function getXoopsFormHidden($field_name) {
+ $ret = <<<EOT
+ \$form->addElement(new XoopsFormHidden('{$field_name}', \$this->getVar('{$field_name}')));
+EOT;
+ return $ret;
+ }
+ /*
+ * @public function getXoopsFormUploadFile
+ * @param string $language
+ * @param string $field_name
+ * @param string $required
+ */
+ public function getXoopsFormUploadFile($language, $field_name, $required = 'false') {
+ $ret = <<<EOT
+ \$form->addElement(new XoopsFormUploadFile({$language}, '{$field_name}', \$xoopsModuleConfig['maxsize']), {$required});
+EOT;
+ return $ret;
+ }
+ /*
+ * @public function getXoopsFormUploadImage
+ * @param string $language
+ * @param string $field_name
+ * @param string $required
+ */
+ public function getXoopsFormUploadImage($language, $field_name, $required = 'false') {
+ $ret = <<<EOT
+ \$form->addElement(new XoopsFormUploadImage({$language}, '{$field_name}', \$xoopsModuleConfig['maxsize']), {$required});
+EOT;
+ return $ret;
+ }
+ /*
+ * @public function getXoopsFormColorPicker
+ * @param string $language
+ * @param string $field_name
+ * @param string $required
+ */
+ public function getXoopsFormColorPicker($language, $field_name, $required = 'false') {
+ $ret = <<<EOT
+ \$form->addElement(new XoopsFormColorPicker({$language}, '{$field_name}', \$xoopsModuleConfig['maxsize']), {$required});
+EOT;
+ return $ret;
+ }
+ /*
+ * @public function getXoopsFormSelectUser
+ * @param string $language
+ * @param string $field_name
+ * @param string $required
+ */
+ public function getXoopsFormSelectUser($language, $field_name, $required = 'false') {
+ $ret = <<<EOT
+ \$form->addElement(new XoopsFormSelectUser({$language}, '{$field_name}', false, \$this->getVar('{$field_name}'), 1, false), {$required});
+EOT;
+ return $ret;
+ }
+ /*
+ * @public function getXoopsFormRadioYN
+ * @param string $language
+ * @param string $field_name
+ * @param string $required
+ */
+ public function getXoopsFormRadioYN($language, $field_name, $required = 'false') {
+ $ret = <<<EOT
+ ${$field_name} = \$this->isNew() ? 0 : \$this->getVar('{$field_name}');
+ \$form->addElement(new XoopsFormRadioYN({$language}, '{$field_name}', ${$field_name}), {$required});
+EOT;
+ return $ret;
+ }
+ /*
+ * @public function getXoopsFormTextDateSelect
+ * @param string $language
+ * @param string $field_name
+ * @param string $required
+ */
+ public function getXoopsFormTextDateSelect($language, $field_name, $required = 'false') {
+ $ret = <<<EOT
+ \$form->addElement(new XoopsFormTextDateSelect({$language}, '{$field_name}', '', \$this->getVar('{$field_name}')), {$required});
+EOT;
+ return $ret;
+ }
+ /*
+ * @public function getXoopsFormTable
+ * @param string $language
+ * @param string $module_name
+ * @param string $table_name
+ * @param string $required
+ */
+ public function getXoopsFormTable($language, $module_name, $table_name, $required = 'false')
+ {
+ $field_name = '';
+ foreach(array_keys($this->fields) as $f)
+ {
+ if(($this->fields[$f]->getVar('field_parent') == 1)) {
+ $field_name = $this->fields[$f]->getVar('field_name');
+ }
+ }
+ $ret = <<<XFT
+ \${$table_name}Handler =& xoops_getModuleHandler('{$table_name}', '{$module_name}');
+ \${$field_name}_select = new XoopsFormSelect({$language}, '{$field_name}', \$this->getVar('{$field_name}'));
+ \${$field_name}_select->addOptionArray(\${$field_name}Handler->getList());
+ \$form->addElement(\${$field_name}_select, {$required});
+XFT;
+ return $ret;
+ }
+ /*
+ * @public function getXoopsFormTopic
+ * @param string $language
+ * @param string $module_name
+ * @param string $table_name
+ * @param string $required
+ */
+ public function getXoopsFormTopic($language, $module_name, $table_name, $required = 'false')
+ {
+ foreach(array_keys($this->fields) as $f)
+ {
+ $field_name = $this->fields[$f]->getVar('field_name');
+ if($this->fields[$f]->getVar('field_id') == 1) {
+ $field_id = $this->fields[$f]->getVar('field_name');
+ }
+ if($this->fields[$f]->getVar('field_parent') == 1) {
+ $field_pid = $this->fields[$f]->getVar('field_name');
+ }
+ if($this->fields[$f]->getVar('field_main') == 1) {
+ $field_main = $this->fields[$f]->getVar('field_name');
+ }
+ }
+ $ret = <<<XFT
+ include_once(XOOPS_ROOT_PATH . '/class/tree.php');
+ \${$table_name}Handler = xoops_getModuleHandler('{$table_name}', '\${$module_name}' );
+ \$criteria = new CriteriaCompo();
+ \${$table_name} = \${$table_name}Handler->getObjects( \$criteria );
+ if(\${$table_name}) {
+ \${$table_name}_tree = new XoopsObjectTree( \${$table_name}, '{$field_id}', '{$field_pid}' );
+ \${$field_pid} = \${$table_name}_tree->makeSelBox( '{$field_pid}', '{$field_main}','--', \$this->getVar('{$field_pid}', 'e' ), true );
+ \$form->addElement( new XoopsFormLabel ( {$language}, \${$field_pid} ), {$required} );
+ }
+XFT;
+ return $ret;
+ }
+ /*
+ * @public function render
+ * @param null
+ */
+ public function renderElement() {
+ $module_name = $this->module->getVar('mod_name');
+ $table_name = $this->table->getVar('table_name');
+ $language = $this->getLanguage($module_name, 'AM');
+ $ret = '';
+ foreach(array_keys($this->fields) as $f)
+ {
+ $field_name = $this->fields[$f]->getVar('field_name');
+ $language = $language . strtoupper($table_name) . '_' . strtoupper($field_name);
+ $required = ( $this->fields[$f]->getVar('field_required') == 1 ) ? 'true' : 'false';
+ //
+ switch($this->fields[$f]->getVar('field_element'))
+ {
+ case 1:
+ $ret .= $this->getXoopsFormText($language, $field_name, $required);
+ break;
+ case 2:
+ $ret .= $this->getXoopsFormTextArea($language, $field_name, $required);
+ break;
+ case 3:
+ $ret .= $this->getXoopsFormDhtmlTextArea($language, $module_name, $field_name, $required);
+ break;
+ case 4:
+ $ret .= $this->getXoopsFormCheckBox($language, $field_name, $required);
+ break;
+ case 5:
+ $ret .= $this->getXoopsFormHidden($field_name);
+ break;
+ case 6:
+ $ret .= $this->getXoopsFormUploadFile($language, $field_name, $required);
+ break;
+ case 7:
+ $ret .= $this->getXoopsFormUploadImage($language, $field_name, $required);
+ break;
+ case 8:
+ $ret .= $this->getXoopsFormColorPicker($language, $field_name, $required);
+ break;
+ case 9:
+ $ret .= $this->getXoopsFormSelectUser($language, $field_name, $required);
+ break;
+ case 10:
+ $ret .= $this->getXoopsFormRadioYN($language, $field_name, $required);
+ break;
+ case 11:
+ $ret .= $this->getXoopsFormTextDateSelect($language, $field_name, $required);
+ break;
+ default:
+ if($this->table->getVar('table_category') == 0) {
+ $ret .= $this->getXoopsFormTable($language, $module_name, $table_name, $required);
+ } else {
+ $ret .= $this->getXoopsFormTopic($language, $module_name, $table_name, $required);
+ }
+ break;
+ }
+ }
+ return $ret;
+ }
+}
\ No newline at end of file
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-21 22:01:47 UTC (rev 12543)
+++ XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/class/files/sql_files.php 2014-05-22 15:51:24 UTC (rev 12544)
@@ -26,17 +26,26 @@
* @var string
*/
private $tdmcfile = null;
-
/*
+ * @var string
+ */
+ private $table = null;
+ /*
+ * @var string
+ */
+ private $fields = null;
+ /*
* @public function constructor
* @param string $module
* @param string $file_name
*/
- public function __construct($module, $table, $file_name) {
+ public function __construct($module, $table, $fields, $file_name) {
$this->tdmcfile = TDMCreateFile::getInstance();
$this->setModule($module);
- $this->setTable($table);
+ //$this->setTable($table);
$this->setFileName($file_name);
+ $this->table = $table;
+ $this->fields = $fields;
}
/*
@@ -45,14 +54,33 @@
* @param mixed $table
* @param string $filename
*/
- public static function &getInstance($module, $table, $filename)
+ public static function &getInstance($module, $table, $fields, $filename)
{
static $instance = false;
if (!$instance) {
- $instance = new self($module, $table, $filename);
+ $instance = new self($module, $table, $fields, $filename);
}
return $instance;
- }
+ }
+
+ /*
+ * @public function getHeaderSqlComments
+ * @param string $module_name
+ */
+ public function getHeaderSqlComments($module_name) {
+ // Comma issue
+ $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;
+ return $ret;
+ }
/*
* @public function getHeadDatabaseTable
@@ -60,33 +88,38 @@
* @param string $table_name
* @param integer $nb_fields
*/
- public function getHeadDatabaseTable($module_name, $table_name, $nb_fields) {
+ public function getHeadDatabaseTable($module_name, $table_name, $nb_fields)
+ {
$ret = <<<EOT
- #
- # Structure table for `mod_{$module_name}_{$table_name}` {$nb_fields}
- #
-
- CREATE TABLE `mod_{$module_name}_{$table_name}` (
+#
+# Structure table for `mod_{$module_name}_{$table_name}` {$nb_fields}
+#
+
+CREATE TABLE IF NOT EXISTS `mod_{$module_name}_{$table_name}` (\n
EOT;
return $ret;
}
/*
* @public function getDatabaseTable
- * @param array $fields
+ * @param string $module_name
+ * @param string $table_name
*/
- public function getDatabaseTable($module_name, $table_name, $fields) {
+ public function getDatabaseTable($module_name, $table_name) {
- $nb_fields = $fields->getVar('field_numb');
- // Creation of database table
- $ret = $this->getHeadDatabaseTable($module_name, $table_name, $nb_fields);
+ $nb_fields = $this->table->getVar('table_nbfields');
+ $ret = '';
$j = 0;
- for ($i = 0; $i < $nb_fields; $i++)
+ foreach(array_keys($this->fields) as $f)
{
- $field_name = $fields[$i]->getVar('field_name');
- $field_type = $fields[$i]->getVar('field_type');
- $field_value = $fields[$i]->getVar('field_value');
- $field_default = $fields[$i]->getVar('field_default');
- $field_key = $fields[$i]->getVar('field_key');
+ // Creation of database table
+ $ret = $this->getHeadDatabaseTable($module_name, $table_name, $nb_fields);
+ $field_name = $this->fields[$f]->getVar('field_name');
+ $field_type = $this->fields[$f]->getVar('field_type');
+ $field_value = $this->fields[$f]->getVar('field_value');
+ $field_attribute = $this->fields[$f]->getVar('field_attribute');
+ $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)
@@ -143,9 +176,9 @@
break;
}
- if ( $i == 0 ) {
- $ret .= $this->getFieldNameLine($type, $struct, 'auto_increment');
- $comma[$j] = $this->getKey(1, $struct);
+ 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');
+ $comma[$j] = $this->getKey(1, $field_name);
$j++;
} else {
switch( $field_key ) {
@@ -154,21 +187,21 @@
case 'fulltext':
switch( $field_key ) {
case 'unique':
- $ret .= $this->getFieldNameLine($type, $struct, $default);
- $comma[$j] = $this->getKey(2, $struct);
+ $ret .= $this->getFieldNameLine($field_name, $field_type, $field_value, $field_attribute, $field_null, $field_default);
+ $comma[$j] = $this->getKey(2, $field_name);
break;
case 'index':
- $ret .= $this->getFieldNameLine($type, $struct, $default);
- $comma[$j] = $this->getKey(3, $struct);
+ $ret .= $this->getFieldNameLine($field_name, $field_type, $field_value, $field_attribute, $field_null, $field_default);
+ $comma[$j] = $this->getKey(3, $field_name);
break;
case 'fulltext':
- $ret .= $this->getFieldNameLine($type, $struct, $default);
- $comma[$j] = $this->getKey(4, $struct);
+ $ret .= $this->getFieldNameLine($field_name, $field_type, $field_value, $field_attribute, $field_null, $field_default);
+ $comma[$j] = $this->getKey(4, $field_name);
break;
}
break;
default:
- $ret .= $this->getFieldNameLine($type, $struct, $default);
+ $ret .= $this->getFieldNameLine($...
[truncated message content] |