|
From: <txm...@us...> - 2014-06-09 19:09:04
|
Revision: 12570
http://sourceforge.net/p/xoops/svn/12570
Author: txmodxoops
Date: 2014-06-09 19:08:59 +0000 (Mon, 09 Jun 2014)
Log Message:
-----------
- Fixed bugs
- Work in progress
Modified Paths:
--------------
XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/class/files/blocks_files.php
XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/class/files/class_files.php
XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/class/files/formelements.php
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-06-09 00:03:18 UTC (rev 12569)
+++ XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/class/files/blocks_files.php 2014-06-09 19:08:59 UTC (rev 12570)
@@ -113,41 +113,32 @@
}
/*
* @public function getBlocksEdit
- * @param null
+ * @param string $module_name
+ * @param string $table_name
+ * @param string $fpif
+ * @param string $fpmf
+ * @param string $language
*/
- public function getBlocksEdit($module_name, $table_name, $table_category, $fpif, $fpmf, $language) {
+ public function getBlocksEdit($module_name, $table_name, $fpif, $fpmf, $language) {
$mod_name_lowercase = strtolower($module_name);
$ret = <<<EOT
function b_{$mod_name_lowercase}_{$table_name}_edit(\$options)
-{\n
-EOT;
- if ( $table_category == 1 ) {
- $ret .=<<<EOT
- include_once XOOPS_ROOT_PATH.'/modules/{$module_name}/class/category.php';
-
- \$categoryHandler =& xoops_getModuleHandler('category', "{$module_name}");
- \$criteria = new CriteriaCompo();
- \$criteria->setSort("{$fpmf}");
- \$criteria->setOrder("ASC");
- \${$table_name}_arr = \$categoryHandler->getall(\$criteria);\n
-EOT;
- }
- $ret .= <<<EOT
- include_once XOOPS_ROOT_PATH.'/modules/{$module_name}/class/{$table_name}.php';
-
+{
+ include_once XOOPS_ROOT_PATH.'/modules/{$module_name}/class/{$table_name}.php';
+ \${$table_name}Handler =& xoops_getModuleHandler('{$table_name}', '{$module_name}');
\$form = {$language}DISPLAY;
\$form .= "<input type='hidden' name='options[0]' value='".\$options[0]."' />";
\$form .= "<input name='options[1]' size='5' maxlength='255' value='".\$options[1]."' type='text' /> <br />";
- \$form .= {$language}TITLELENGTH." : <input name='options[2]' size='5' maxlength='255' value='".\$options[2]."' type='text' /><br /><br />";
- \${$table_name}Handler =& xoops_getModuleHandler('{$table_name}', '{$module_name}');
- \$criteria = new CriteriaCompo();
+ \$form .= {$language}TITLELENGTH." : <input name='options[2]' size='5' maxlength='255' value='".\$options[2]."' type='text' /><br /><br />";
array_shift(\$options);
array_shift(\$options);
array_shift(\$options);
+ \$criteria = new CriteriaCompo();
\$criteria->add(new Criteria('{$fpif}', 0, '!='));
\$criteria->setSort('{$fpif}');
\$criteria->setOrder('ASC');
\${$table_name}_arr = \${$table_name}Handler->getAll(\$criteria);
+ unset(\$criteria)
\$form .= {$language}CATTODISPLAY."<br /><select name='options[]' multiple='multiple' size='5'>";
\$form .= "<option value='0' " . (array_search(0, \$options) === false ? "" : "selected='selected'") . ">" .{$language}ALLCAT . "</option>";
foreach (array_keys(\${$table_name}_arr) as \$i) {
@@ -161,14 +152,14 @@
return $ret;
}
/*
- * @public function render
+ * @public function renderFile
* @param null
*/
public function renderFile($filename)
{
$module = $this->getModule();
$table = $this->getTable();
- $module_name = $module->getVar('mod_name');
+ $module_name = strtolower($module->getVar('mod_name'));
$table_name = $table->getVar('table_name');
$table_fieldname = $table->getVar('table_fieldname');
$table_category = $table->getVar('table_category');
@@ -185,7 +176,7 @@
}
$content = $this->getHeaderFilesComments($module, $filename);
$content .= $this->getBlocksShow($module_name, $table_name, $table_fieldname, $table_category, $fields, $fpif, $fpmf);
- $content .= $this->getBlocksEdit($module_name, $table_name, $table_category, $fpif, $fpmf, $language);
+ $content .= $this->getBlocksEdit($module_name, $table_name, $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/class_files.php
===================================================================
--- XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/class/files/class_files.php 2014-06-09 00:03:18 UTC (rev 12569)
+++ XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/class/files/class_files.php 2014-06-09 19:08:59 UTC (rev 12570)
@@ -66,7 +66,7 @@
*/
public function getInitVar($field_name, $type = 'INT') {
$ret = <<<EOT
- \$this->initVar('{$field_name}', XOBJ_DTYPE_{$type});\n
+ \n\$this->initVar('{$field_name}', XOBJ_DTYPE_{$type});
EOT;
return $ret;
}
@@ -127,7 +127,9 @@
}
/*
* @public function getHeadClass
- * @param mixed $constructor
+ * @param string $module_name
+ * @param string $table_name
+ * @param array $fields
*/
public function getHeadClass($module_name, $table_name, $fields) {
$ucf_module_name = ucfirst($module_name);
@@ -147,19 +149,35 @@
public function __construct()
{
\$this->XoopsObject();
- {$this->getInitVars($fields)}
- }\n
+{$this->getInitVars($fields)}
+ }
+ /*
+ * @static function &getInstance
+ * @param null
+ */
+ public static function &getInstance()
+ {
+ static \$instance = false;
+ if (!\$instance) {
+ \$instance = new self();
+ }
+ return \$instance;
+ }\n
EOT;
return $ret;
}
/*
* @public function getHeadFunctionForm
- * @param string $form
+ * @param string $module
+ * @param string $table
*/
- public function getHeadFunctionForm($module_name, $elements_form) {
+ public function getHeadFunctionForm($module, $table)
+ {
+ $module_name = strtolower($module->getVar('mod_name'));
$lang_add = $this->getLanguage($module_name, 'AM', 'ADD');
$lang_edit = $this->getLanguage($module_name, 'AM', 'EDIT');
+ $this->formelements->initForm($module, $table);
$ret = <<<EOT
/*
* Get form
@@ -177,12 +195,13 @@
xoops_load('XoopsFormLoader');
\$form = new XoopsThemeForm(\$title, 'form', \$action, 'post', true);
\$form->setExtra('enctype="multipart/form-data"');\n
-{$elements_form}\n
+{$this->formelements->renderElements()}\n
EOT;
return $ret;
}
/*
* @public function getPermissionsInFunctionForm
+ * @param string $module_name
* @param string $fpif
*/
public function getPermissionsInFunctionForm($module_name, $fpif) {
@@ -190,7 +209,7 @@
$perm_submit = $this->getLanguage($module_name, 'AM', 'PERMISSIONS_SUBMIT');
$perm_view = $this->getLanguage($module_name, 'AM', 'PERMISSIONS_VIEW');
$ret = <<<EOT
- //permissions
+ // Permissions
\$member_handler = & xoops_gethandler ( 'member' );
\$group_list = &\$member_handler->getGroupList();
\$gperm_handler = &xoops_gethandler ( 'groupperm' );
@@ -220,7 +239,7 @@
\$form->addElement ( \$groups_can_submit_checkbox );
// For view
\$groups_can_view_checkbox->addOptionArray ( \$group_list );
- \$form->addElement ( \$groups_can_view_checkbox );\n
+ \$form->addElement ( \$groups_can_view_checkbox );\n\n
EOT;
return $ret;
}
@@ -240,6 +259,8 @@
}
/*
* @public function getClassHandler
+ * @param string $module_name
+ * @param string $table_name
* @param string $fpif
* @param string $fpmf
*/
@@ -247,7 +268,6 @@
$ucf_module_name = ucfirst($module_name);
$ucf_table_name = ucfirst($table_name);
$ucf_mod_table_handler = $ucf_module_name . $ucf_table_name;
-
$ret = <<<EOT
/*
* Class Object Handler {$ucf_module_name}{$ucf_table_name}
@@ -268,19 +288,15 @@
return $ret;
}
/*
- * @public function render
- * @param null
+ * @public function renderFile
+ * @param string $filename
*/
public function renderFile($filename) {
$module = $this->getModule();
$table = $this->getTable();
$table_nbfields = $table->getVar('table_nbfields');
$table_name = $table->getVar('table_name');
- //$fields = $this->getFields();
- //$filename = $this->getFileName();
$module_name = strtolower($module->getVar('mod_name'));
- $fpif = ''; $fpmf = '';
- $initvar_functions = array();
$fields = $this->getTableFields($table->getVar('table_id'));
foreach(array_keys($fields) as $f)
{
@@ -291,14 +307,10 @@
if($fields[$f]->getVar('field_main') == 1) {
$fpmf = $field_name;
}
- }
- //$initvar = $this->getInitVars($fields);
- $this->formelements->initForm($module, $table);
- $elements_form = $this->formelements->renderElement();
-
+ }
$content = $this->getHeaderFilesComments($module, $filename);
$content .= $this->getHeadClass($module_name, $table_name, $fields);
- $content .= $this->getHeadFunctionForm($module_name, $elements_form);
+ $content .= $this->getHeadFunctionForm($module, $table);
if ($table->getVar('table_permissions') == 1) {
$content .= $this->getPermissionsInFunctionForm($module_name, $fpif);
}
Modified: XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/class/files/formelements.php
===================================================================
--- XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/class/files/formelements.php 2014-06-09 00:03:18 UTC (rev 12569)
+++ XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/class/files/formelements.php 2014-06-09 19:08:59 UTC (rev 12570)
@@ -54,11 +54,11 @@
/*
* @public function initForm
* @param string $module
- * @param array $table
+ * @param string $table
*/
public function initForm($module, $table) {
- $this->module = $module;
- $this->table = $table;
+ $this->setModule($module);
+ $this->setTable($table);
}
/*
* @public function getXoopsFormText
@@ -280,26 +280,24 @@
return $ret;
}
/*
- * @public function render
+ * @public function renderElements
* @param null
*/
- public function renderElement() {
- $module_name = $this->module->getVar('mod_name');
- $table_name = $this->table->getVar('table_name');
+ public function renderElements() {
+ $module = $this->getModule();
+ $table = $this->getTable();
+ $module_name = $module->getVar('mod_name');
+ $table_name = $table->getVar('table_name');
$language_funct = $this->getLanguage($module_name, 'AM');
$language_table = $language_funct . strtoupper($table_name);
$ret = '';
- $table_id = $this->table->getVar('table_id');
- $criteria_fields = new CriteriaCompo();
- $criteria_fields->add(new Criteria('field_tid', $table_id));
- $fields_all = $this->tdmcreate->getHandler('fields')->getObjects($criteria_fields);
- unset($criteria_fields);
- foreach(array_keys($fields_all) as $f)
+ $fields = $this->getTableFields($table->getVar('table_id'));
+ foreach(array_keys($fields) as $f)
{
- $field_name = $fields_all[$f]->getVar('field_name');
- $field_element = $fields_all[$f]->getVar('field_element');
+ $field_name = $fields[$f]->getVar('field_name');
+ $field_element = $fields[$f]->getVar('field_element');
$language = $language_funct . strtoupper($field_name);
- $required = ( $fields_all[$f]->getVar('field_required') == 1 ) ? ', true' : '';
+ $required = ( $fields[$f]->getVar('field_required') == 1 ) ? ', true' : '';
//
switch($field_element)
{
@@ -341,10 +339,10 @@
break;
}
if ($field_element > 11) {
- if($this->table->getVar('table_category') == 1) {
- $ret .= $this->getXoopsFormTopic($language, $module_name, $table_name, $fields_all, $required);
+ if($table->getVar('table_category') == 1) {
+ $ret .= $this->getXoopsFormTopic($language, $module_name, $table_name, $fields, $required);
} else {
- $ret .= $this->getXoopsFormTable($language, $module_name, $table_name, $fields_all, $required);
+ $ret .= $this->getXoopsFormTable($language, $module_name, $table_name, $fields, $required);
}
}
}
|