|
From: <txm...@us...> - 2014-06-10 22:48:20
|
Revision: 12576
http://sourceforge.net/p/xoops/svn/12576
Author: txmodxoops
Date: 2014-06-10 22:48:07 +0000 (Tue, 10 Jun 2014)
Log Message:
-----------
- Fixed bugs Edit/Save fields
- Updated
- Work in progress
Modified Paths:
--------------
XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/admin/fields.php
XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/class/fields.php
XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/class/files/admin/index.php
XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/class/files/admin/menu.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/class/classes.php
Added Paths:
-----------
XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/class/files/class/formelements.php
Removed Paths:
-------------
XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/class/files/formelements.php
Modified: XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/admin/fields.php
===================================================================
--- XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/admin/fields.php 2014-06-10 12:14:51 UTC (rev 12575)
+++ XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/admin/fields.php 2014-06-10 22:48:07 UTC (rev 12576)
@@ -161,17 +161,33 @@
$fieldelement_fid = TDMCreateRequest::getInt('fieldelement_fid');
//
if (isset($field_tid)) {
- $fieldsObj =& $tdmcreate->getHandler('fields')->get($field_tid);
+ //$fieldsObj =& $tdmcreate->getHandler('fields')->get($field_tid);
if (isset($fieldelement_fid)) {
$fieldelementObj =& $tdmcreate->getHandler('fieldelements')->get($fieldelement_fid);
}
} else {
- $fieldsObj =& $tdmcreate->getHandler('fields')->create();
+ //$fieldsObj =& $tdmcreate->getHandler('fields')->create();
$fieldelementObj =& $tdmcreate->getHandler('fieldelements')->create();
}
// Set Variables
+ $isNew = false;
if ($field_numb > 0) {
- for( $i = 1; $i <= $field_numb; $i++ ) {
+ $fields =& $tdmcreate->getHandler('fields')->get($field_tid);
+ foreach($field_id as $i => $value)
+ {
+ switch($value){
+ case 'new':
+ $fieldsObj = $tdmcreate->getHandler('fields')->create();
+ $fieldelementObj =& $tdmcreate->getHandler('fieldelements')->create();
+ $isNew = true;
+ break;
+ default:
+ $fieldsObj = $tdmcreate->getHandler('fields')->get($value);
+ $fieldelementObj =& $tdmcreate->getHandler('fieldelements')->get($fieldelement_fid);
+ break;
+ }
+ //}
+ //for( $i = 1; $i <= $field_numb; $i++ ) {
// Set Data
$fieldsObj->setVar( 'field_mid', $field_mid );
$fieldsObj->setVar( 'field_tid', $field_tid );
@@ -206,7 +222,7 @@
$GLOBALS['xoopsTpl']->assign('error', $fieldelementObj->getHtmlErrors() . ' Field element');
}
//
- if ($fieldsObj->isNew()) {
+ if ($isNew) {
redirect_header('fields.php', 2, sprintf(_AM_TDMCREATE_FIELD_FORM_SAVED_OK, $table_name));
} else {
redirect_header('fields.php', 2, sprintf(_AM_TDMCREATE_FIELD_FORM_UPDATED_OK, $table_name));
@@ -228,7 +244,7 @@
$adminMenu->addItemButton(_AM_TDMCREATE_FIELDS_LIST, 'fields.php', 'list');
$GLOBALS['xoopsTpl']->assign('buttons', $adminMenu->renderButton());
- $fieldsObj = $tdmcreate->getHandler('fields')->get( $field_tid, array('field_id', 'field_name') );
+ $fieldsObj = $tdmcreate->getHandler('fields')->get( $field_tid );
$form = $fieldsObj->getForm(null, $field_tid);
$GLOBALS['xoopsTpl']->assign('form', $form->render());
Modified: XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/class/fields.php
===================================================================
--- XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/class/fields.php 2014-06-10 12:14:51 UTC (rev 12575)
+++ XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/class/fields.php 2014-06-10 22:48:07 UTC (rev 12576)
@@ -30,21 +30,15 @@
/**
* @var mixed
*/
- private $tdmcreate = null;
+ private $tdmcreate = null;
- /**
- * @var mixed
- */
- private $table = null;
-
/*
* @public function constructor class
* @param null
*/
public function __construct()
{
- $this->tdmcreate = TDMCreate::getInstance();
- //$this->table = TDMCreateTables::getInstance();
+ $this->tdmcreate = TDMCreate::getInstance();
$this->initVar('field_id', XOBJ_DTYPE_INT);
$this->initVar('field_mid', XOBJ_DTYPE_INT);
$this->initVar('field_tid', XOBJ_DTYPE_INT);
@@ -113,7 +107,7 @@
$field_tid = $isNew ? $f_tid : $this->getVar('field_tid');
// Get the list of fields
$criteria = new CriteriaCompo();
- $criteria->add(new Criteria('field_tid', $this->getVar('field_tid')));
+ $criteria->add(new Criteria('field_tid', $f_tid));
$field_numb = $isNew ? $f_numb : $this->tdmcreate->getHandler('fields')->getCount($criteria); //$this->getVar('field_numb')
$form = new TDMCreateThemeForm(null, 'form', $action, 'post', true);
@@ -134,13 +128,14 @@
$form->addElement(new TDMCreateFormLabel('<td>'._AM_TDMCREATE_FIELD_KEY.'</th>'));
$form->addElement(new TDMCreateFormLabel('<td>'._AM_TDMCREATE_FIELD_PARAMETERS.'</th>'));
$form->addElement(new TDMCreateFormLabel('</tr></thead>'));
- $form->addElement(new TDMCreateFormLabel('<tbody>'));
-
- var_dump($field_numb);
- $class = '';
- for($i = 1; $i <= $field_numb; $i++)
- {
- $form->addElement(new XoopsFormHidden('field_id['.$i.']', $this->getVar('field_id')));
+ $form->addElement(new TDMCreateFormLabel('<tbody>'));
+ $fields = $this->tdmcreate->getHandler('fields')->getObjects($criteria);
+ unset($criteria);
+ //var_dump($field_numb);
+ $class = ''; $id = 1;
+ foreach ($fields as $field)
+ {
+ $form->addElement(new XoopsFormHidden('field_id['.$id.']', $field->getVar('field_id')));
$form->addElement(new XoopsFormHidden('field_mid', $field_mid));
$form->addElement(new XoopsFormHidden('field_tid', $field_tid));
$form->addElement(new XoopsFormHidden('field_numb', $field_numb));
@@ -148,36 +143,36 @@
$class = ($class == 'even') ? 'odd' : 'even';
$form->addElement(new TDMCreateFormLabel('<tr class="'.$class.'">'));
// Index ID
- $form->addElement(new TDMCreateFormLabel('<td class="center">'.$i.'</td>'));
+ $form->addElement(new TDMCreateFormLabel('<td class="center">'.$id.'</td>'));
// Field Name
- $this_field_name = $isNew ? (!empty($f_name) ? $f_name . '_' : '') : $this->getVar('field_name');
- $field_name = new XoopsFormText(_AM_TDMCREATE_FIELD_NAME, 'field_name['.$i.']', 15, 255, $this_field_name);
+ $this_field_name = $isNew ? (!empty($f_name) ? $f_name . '_' : '') : $field->getVar('field_name');
+ $field_name = new XoopsFormText(_AM_TDMCREATE_FIELD_NAME, 'field_name['.$id.']', 15, 255, $this_field_name);
$form->addElement(new TDMCreateFormLabel('<td class="center">'.$field_name->render().'</td>'));
// Field Type
- $fieldtype_select = new XoopsFormSelect(_AM_TDMCREATE_FIELD_TYPE, 'field_type['.$i.']', $this->getVar('field_type'));
+ $fieldtype_select = new XoopsFormSelect(_AM_TDMCREATE_FIELD_TYPE, 'field_type['.$id.']', $field->getVar('field_type'));
$fieldtype_select->addOptionArray($this->tdmcreate->getHandler('fieldtype')->getList());
$form->addElement(new TDMCreateFormLabel('<td class="center">'.$fieldtype_select->render().'</td>'));
// Field Value
- $field_value = new XoopsFormText(_AM_TDMCREATE_FIELD_VALUE, 'field_value['.$i.']', 5, 20, $this->getVar('field_value'));
+ $field_value = new XoopsFormText(_AM_TDMCREATE_FIELD_VALUE, 'field_value['.$id.']', 5, 20, $field->getVar('field_value'));
$form->addElement(new TDMCreateFormLabel('<td class="center">'.$field_value->render().'</td>'));
// Field Attributes
- $field_attributes_select = new XoopsFormSelect(_AM_TDMCREATE_FIELD_TYPE, 'field_attribute['.$i.']', $this->getVar('field_attribute'));
+ $field_attributes_select = new XoopsFormSelect(_AM_TDMCREATE_FIELD_TYPE, 'field_attribute['.$id.']', $field->getVar('field_attribute'));
$field_attributes_select->addOptionArray($this->tdmcreate->getHandler('fieldattributes')->getList());
$form->addElement(new TDMCreateFormLabel('<td class="center">'.$field_attributes_select->render().'</td>'));
// Field Null
- $field_null_select = new XoopsFormSelect(_AM_TDMCREATE_FIELD_NULL, 'field_null['.$i.']', $this->getVar('field_null'));
+ $field_null_select = new XoopsFormSelect(_AM_TDMCREATE_FIELD_NULL, 'field_null['.$id.']', $field->getVar('field_null'));
$field_null_select->addOptionArray($this->tdmcreate->getHandler('fieldnull')->getList());
$form->addElement(new TDMCreateFormLabel('<td class="center">'.$field_null_select->render().'</td>'));
// Field Default
- $field_default = new XoopsFormText(_AM_TDMCREATE_FIELD_DEFAULT, 'field_default['.$i.']', 15, 25, $this->getVar('field_default'));
+ $field_default = new XoopsFormText(_AM_TDMCREATE_FIELD_DEFAULT, 'field_default['.$id.']', 15, 25, $field->getVar('field_default'));
$form->addElement(new TDMCreateFormLabel('<td class="center">'.$field_default->render().'</td>'));
// Field Key
- $field_key_select = new XoopsFormSelect(_AM_TDMCREATE_FIELD_KEY, 'field_key['.$i.']', $this->getVar('field_key'));
+ $field_key_select = new XoopsFormSelect(_AM_TDMCREATE_FIELD_KEY, 'field_key['.$id.']', $field->getVar('field_key'));
$field_key_select->addOptionArray($this->tdmcreate->getHandler('fieldkey')->getList());
$form->addElement(new TDMCreateFormLabel('<td class="center">'.$field_key_select->render().'</td>'));
// Field Void
$table_autoincrement = $this->tdmcreate->getHandler('tables')->get($f_tid);
- if( ($i == 1) && ($table_autoincrement->getVar('table_autoincrement') == 1)) {
+ if( ($id == 1) && ($table_autoincrement->getVar('table_autoincrement') == 1)) {
$form->addElement(new TDMCreateFormLabel('<td> </td></tr>'));
} else {
// Box header row
@@ -189,60 +184,61 @@
$criteria_element->add(new Criteria('fieldelement_tid', 0));
$criteria_table = new CriteriaCompo();
$criteria_table->add(new Criteria('fieldelement_mid', $field_mid));
- $field_elements_select = new XoopsFormSelect(_AM_TDMCREATE_FIELD_ELEMENT_NAME, 'field_element['.$i.']', $this->getVar('field_element'));
+ $field_elements_select = new XoopsFormSelect(_AM_TDMCREATE_FIELD_ELEMENT_NAME, 'field_element['.$id.']', $field->getVar('field_element'));
$field_elements_select->addOptionArray($this->tdmcreate->getHandler('fieldelements')->getList($criteria_element));
$field_elements_select->addOptionArray($this->tdmcreate->getHandler('fieldelements')->getList($criteria_table));
unset($criteria_element); unset($criteria_table);
$parameters_tray->addElement($field_elements_select);
- $field_parent = $isNew ? ( $i == 1 ? 1 : 0 ) : $this->getVar('field_parent');
+ $field_parent = $isNew ? ( $id == 1 ? 1 : 0 ) : $field->getVar('field_parent');
$check_field_parent = new XoopsFormCheckBox(' ', 'field_parent', $field_parent);
- $check_field_parent->addOption($i, _AM_TDMCREATE_FIELD_PARENT );
+ $check_field_parent->addOption($id, _AM_TDMCREATE_FIELD_PARENT );
$parameters_tray->addElement($check_field_parent);
- $field_inlist = $isNew ? 0 : $this->getVar('field_inlist');
- $check_field_inlist = new XoopsFormCheckBox(' ', 'field_inlist['.$i.']', $field_inlist);
+ $field_inlist = $isNew ? 0 : $field->getVar('field_inlist');
+ $check_field_inlist = new XoopsFormCheckBox(' ', 'field_inlist['.$id.']', $field_inlist);
$check_field_inlist->addOption(1, _AM_TDMCREATE_FIELD_INLIST);
$parameters_tray->addElement($check_field_inlist);
- $field_inform = $isNew ? 0 : $this->getVar('field_inform');
- $check_field_inform = new XoopsFormCheckBox(' ', 'field_inform['.$i.']', $field_inform);
+ $field_inform = $isNew ? 0 : $field->getVar('field_inform');
+ $check_field_inform = new XoopsFormCheckBox(' ', 'field_inform['.$id.']', $field_inform);
$check_field_inform->addOption(1, _AM_TDMCREATE_FIELD_INFORM);
$parameters_tray->addElement($check_field_inform);
- $field_admin = $isNew ? 0 : $this->getVar('field_admin');
- $check_field_admin = new XoopsFormCheckBox(' ', 'field_admin['.$i.']', $field_admin);
+ $field_admin = $isNew ? 0 : $field->getVar('field_admin');
+ $check_field_admin = new XoopsFormCheckBox(' ', 'field_admin['.$id.']', $field_admin);
$check_field_admin->addOption(1, _AM_TDMCREATE_FIELD_ADMIN);
$parameters_tray->addElement($check_field_admin);
- $field_user = $isNew ? 0 : $this->getVar('field_user');
- $check_field_user = new XoopsFormCheckBox(' ', 'field_user['.$i.']', $field_user);
+ $field_user = $isNew ? 0 : $field->getVar('field_user');
+ $check_field_user = new XoopsFormCheckBox(' ', 'field_user['.$id.']', $field_user);
$check_field_user->addOption(1, _AM_TDMCREATE_FIELD_USER);
$parameters_tray->addElement($check_field_user);
- $field_block = $isNew ? 0 : $this->getVar('field_block');
- $check_field_block = new XoopsFormCheckBox('', 'field_block['.$i.']', $field_block);
+ $field_block = $isNew ? 0 : $field->getVar('field_block');
+ $check_field_block = new XoopsFormCheckBox('', 'field_block['.$id.']', $field_block);
$check_field_block->addOption(1, _AM_TDMCREATE_FIELD_BLOCK);
$parameters_tray->addElement($check_field_block);
- $field_main = $isNew ? ( $i == 1 ? 1 : 0 ) : $this->getVar('field_main');
+ $field_main = $isNew ? ( $id == 1 ? 1 : 0 ) : $field->getVar('field_main');
$check_field_main = new XoopsFormRadio('', 'field_main', $field_main);
$check_field_main->addOption('', _AM_TDMCREATE_FIELD_MAINFIELD );
$parameters_tray->addElement($check_field_main);
- $field_search = $isNew ? 0 : $this->getVar('field_search');
- $check_field_search = new XoopsFormCheckBox(' ', 'field_search['.$i.']', $field_search);
+ $field_search = $isNew ? 0 : $field->getVar('field_search');
+ $check_field_search = new XoopsFormCheckBox(' ', 'field_search['.$id.']', $field_search);
$check_field_search->addOption(1, _AM_TDMCREATE_FIELD_SEARCH);
$parameters_tray->addElement($check_field_search);
- $field_required = $isNew ? 0 : $this->getVar('field_required');
- $check_field_required = new XoopsFormCheckBox(' ', 'field_required['.$i.']', $field_required);
+ $field_required = $isNew ? 0 : $field->getVar('field_required');
+ $check_field_required = new XoopsFormCheckBox(' ', 'field_required['.$id.']', $field_required);
$check_field_required->addOption(1, _AM_TDMCREATE_FIELD_REQUIRED);
$parameters_tray->addElement($check_field_required);
$form->addElement(new TDMCreateFormLabel('<td><div class="portlet"><div class="portlet-header">'._AM_TDMCREATE_FIELD_PARAMETERS_LIST.'</div><div class="portlet-content">'.$parameters_tray->render().'</div></div></td></tr>'));
- }
+ }
+ $id++;
}
-
+ unset($id);
$form->addElement(new TDMCreateFormLabel('</tbody>'));
$form->addElement(new TDMCreateFormLabel('<tfoot><tr>'));
$form_hidden = new XoopsFormHidden('op', 'save');
Modified: XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/class/files/admin/index.php
===================================================================
--- XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/class/files/admin/index.php 2014-06-10 12:14:51 UTC (rev 12575)
+++ XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/class/files/admin/index.php 2014-06-10 22:48:07 UTC (rev 12576)
@@ -44,14 +44,13 @@
/*
* @public function write
* @param string $module
- * @param mixed $table
+ * @param mixed $tables
* @param string $filename
*/
- public function write($module, $table, $tables, $filename) {
+ public function write($module, $tables, $filename) {
$this->setModule($module);
- $this->setFileName($filename);
- $this->table = $table;
- $this->tables = $tables;
+ $this->setTables($tables);
+ $this->setFileName($filename);
}
/*
* @public function render
@@ -59,8 +58,8 @@
*/
public function render() {
$module = $this->getModule();
- $filename = $this->getFileName();
- //$table = $this->getTable();
+ $tables = $this->getTables();
+ $filename = $this->getFileName();
$module_name = strtolower($module->getVar('mod_name'));
$language = $this->getLanguage($module_name, 'AM');
$language_thereare = $this->getLanguage($module_name, 'AM', 'THEREARE_');
@@ -68,9 +67,9 @@
$content .= <<<EOT
include_once 'header.php';\n
EOT;
- foreach (array_keys($this->tables) as $i)
+ foreach (array_keys($tables) as $i)
{
- $table_name = $this->tables[$i]->getVar('table_name');
+ $table_name = $tables[$i]->getVar('table_name');
$content .= <<<EOT
//count "{$table_name}"
\$count_{$table_name} = \${$table_name}Handler->getCount();\n
@@ -81,12 +80,12 @@
\$adminMenu->addInfoBox({$language}STATISTICS);
// InfoBox\n
EOT;
- foreach (array_keys($this->tables) as $i)
+ foreach (array_keys($tables) as $i)
{
- $table_name = $this->tables[$i]->getVar('table_name');
+ $table_name = $tables[$i]->getVar('table_name');
$ta_stutable_name = $language_thereare.strtoupper($table_name);
$content .= <<<EOT
-\$adminMenu->addInfoBoxLine({$language}STATISTICS, '<label>'.{$ta_stutable_name}.'</label>', \$count_{$table_name});\n
+\$adminMenu->addInfoBoxLine({$language}STATISTICS, '<label>'.{$ta_stutable_name}.'</label>', \$count_{$table_name});\n
EOT;
}
$content .= <<<EOT
Modified: XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/class/files/admin/menu.php
===================================================================
--- XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/class/files/admin/menu.php 2014-06-10 12:14:51 UTC (rev 12575)
+++ XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/class/files/admin/menu.php 2014-06-10 22:48:07 UTC (rev 12576)
@@ -44,15 +44,13 @@
/*
* @public function write
* @param string $module
- * @param mixed $table
* @param mixed $tables
* @param string $filename
*/
- public function write($module, $table, $tables, $filename) {
+ public function write($module, $tables, $filename) {
$this->setModule($module);
+ $this->setTables($tables);
$this->setFileName($filename);
- $this->table = $table;
- $this->tables = $tables;
}
/*
* @public function render
@@ -60,9 +58,9 @@
*/
public function render() {
$module = $this->getModule();
- $module_name = $module->getVar('mod_name');
- //$table = $this->getTable();
+ $tables = $this->getTables();
$filename = $this->getFileName();
+ $module_name = $module->getVar('mod_name');
$language = $this->getLanguage($module_name, 'MI', 'ADMENU');
$menu = 1;
$content = $this->getHeaderFilesComments($module, $filename);
@@ -79,20 +77,21 @@
\$adminmenu[\$i]['icon'] = \$sysPathIcon32.'/home.png';
\$i++;
EOT;
- foreach (array_keys($this->tables) as $i)
+ foreach (array_keys($tables) as $i)
{
- if ( $this->tables[$i]->getVar('table_admin') == 1 )
+ $table_permissions = $tables[$i]->getVar('table_permissions');
+ if ( $tables[$i]->getVar('table_admin') == 1 )
{
$menu++;
$content .= <<<EOT
\n\$adminmenu[\$i]['title'] = {$language}{$menu};
-\$adminmenu[\$i]['link'] = 'admin/{$this->tables[$i]->getVar('table_name')}.php';
-\$adminmenu[\$i]['icon'] = \$sysPathIcon32.'/{$this->tables[$i]->getVar('table_image')}';
+\$adminmenu[\$i]['link'] = 'admin/{$tables[$i]->getVar('table_name')}.php';
+\$adminmenu[\$i]['icon'] = \$sysPathIcon32.'/{$tables[$i]->getVar('table_image')}';
\$i++;
EOT;
}
}
- if( $this->table->getVar('table_permissions') == 1 ) {
+ if( $table_permissions == 1 ) {
$menu++;
$content .= <<<EOT
\n\$adminmenu[\$i]['title'] = {$language}{$menu};
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-06-10 12:14:51 UTC (rev 12575)
+++ XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/class/files/admin/objects.php 2014-06-10 22:48:07 UTC (rev 12576)
@@ -41,7 +41,7 @@
*/
public function getSimpleSetVar($table_name, $field_name) {
$ret = <<<EOT
- \${$table_name}_obj->setVar('{$field_name}', \$_POST['{$field_name}']);\n
+ \${$table_name}Obj->setVar('{$field_name}', \$_POST['{$field_name}']);\n
EOT;
return $ret;
}
@@ -52,7 +52,7 @@
*/
public function getTextDateSelect($table_name, $field_name) {
$ret = <<<EOT
- \${$table_name}_obj->setVar('{$field_name}', strtotime(\$_POST['{$field_name}']));\n
+ \${$table_name}Obj->setVar('{$field_name}', strtotime(\$_POST['{$field_name}']));\n
EOT;
return $ret;
}
@@ -63,7 +63,7 @@
*/
public function getCheckBoxOrRadioYN($table_name, $field_name) {
$ret = <<<EOT
- \${$table_name}_obj->setVar('{$field_name}', ((\$_REQUEST['{$field_name}'] == 1) ? '1' : '0'));\n
+ \${$table_name}Obj->setVar('{$field_name}', ((\$_REQUEST['{$field_name}'] == 1) ? '1' : '0'));\n
EOT;
return $ret;
}
@@ -75,6 +75,7 @@
*/
public function getUploadImage($module_name, $table_name, $field_name) {
$ret = <<<EOT
+ // Set Var Image
include_once XOOPS_ROOT_PATH.'/class/uploader.php';
\$uploaddir = XOOPS_UPLOAD_PATH.'/{$module_name}/images/{$table_name}/';
\$uploader = new XoopsMediaUploader(\$uploaddir, xoops_getModuleOption('mimetypes', '{$module_name}'),
@@ -86,10 +87,10 @@
\$errors = \$uploader->getErrors();
redirect_header('javascript:history.go(-1)', 3, \$errors);
} else {
- \${$table_name}_obj->setVar('{$field_name}', \$uploader->getSavedFileName());
+ \${$table_name}Obj->setVar('{$field_name}', \$uploader->getSavedFileName());
}
} else {
- \${$table_name}_obj->setVar('{$field_name}', \$_POST['{$field_name}']);
+ \${$table_name}Obj->setVar('{$field_name}', \$_POST['{$field_name}']);
}\n
EOT;
return $ret;
@@ -102,6 +103,7 @@
*/
public function getUploadFile($module_name, $table_name, $field_name) {
$ret = <<<EOT
+ // Set Var File
include_once XOOPS_ROOT_PATH.'/class/uploader.php';
\$uploaddir = XOOPS_UPLOAD_PATH.'/{$module_name}/files/{$table_name}/';
\$uploader = new XoopsMediaUploader(\$uploaddir, xoops_getModuleOption('mimetypes', '{$module_name}'),
@@ -113,7 +115,7 @@
\$errors = \$uploader->getErrors();
redirect_header('javascript:history.go(-1)', 3, \$errors);
} else {
- \${$table_name}_obj->setVar('{$field_name}', \$uploader->getSavedFileName());
+ \${$table_name}Obj->setVar('{$field_name}', \$uploader->getSavedFileName());
}
}\n
EOT;
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-06-10 12:14:51 UTC (rev 12575)
+++ XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/class/files/admin/pages.php 2014-06-10 22:48:07 UTC (rev 12576)
@@ -67,7 +67,7 @@
\ninclude_once 'header.php';
//It recovered the value of argument op in URL$
\$op = {$mod_name}_CleanVars(\$_REQUEST, 'op', 'list', 'string');
-
+// Navigation
echo \$adminMenu->addNavigation('{$table_name}.php');
switch (\$op)
{\n
@@ -145,7 +145,7 @@
case 'new':
\$adminMenu->addItemButton({$language}{$stu_table_name}_LIST, '{$table_name}.php', 'list');
echo \$adminMenu->renderButton();
-
+ // Get Form
\${$table_name}Obj =& \${$table_name}Handler->create();
\$form = \${$table_name}Obj->getForm();
\$form->display();
@@ -170,13 +170,14 @@
\${$table_name}Obj =& \${$table_name}Handler->get(\$_REQUEST['{$fpif}']);
} else {
\${$table_name}Obj =& \${$table_name}Handler->create();
- }\n
+ }
+ // Set Vars\n
EOT;
foreach (array_keys($fields) as $f)
{
$field_name = $fields[$f]->getVar('field_name');
$field_element = $fields[$f]->getVar('field_element');
- if($f > 0) {
+ if($f > 0) { // If we want to hide field id
switch($field_element) {
case 4:
case 5:
@@ -199,11 +200,11 @@
}
$ret .= <<<EOT
-
+ // Insert Data
if (\${$table_name}Handler->insert(\${$table_name}Obj)) {
redirect_header('{$table_name}.php?op=list', 2, {$language}FORMOK);
}
-
+ // Get Form
echo \${$table_name}Obj->getHtmlErrors();
\$form =& \${$table_name}Obj->getForm();
\$form->display();
@@ -224,6 +225,7 @@
\$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();
+ // Get Form
\${$table_name}Obj = \${$table_name}Handler->get(\$_REQUEST['{$fpif}']);
\$form = \${$table_name}Obj->getForm();
\$form->display();
@@ -282,7 +284,6 @@
$module_name = $module->getVar('mod_name');
$table_name = $table->getVar('table_name');
$language = $this->getLanguage($module_name, 'AM');
- $fpif = ''; $fpmf = '';
$fields = $this->getTableFields($table->getVar('table_id'));
foreach(array_keys($fields) as $f)
{
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-06-10 12:14:51 UTC (rev 12575)
+++ XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/class/files/admin/permissions.php 2014-06-10 22:48:07 UTC (rev 12576)
@@ -151,7 +151,7 @@
$fields = $this->getTableFields($table_id);
foreach(array_keys($fields) as $f)
{
- if($f == 1) {
+ if($f == 0) {
$fpif = $fields[$f]->getVar('field_name');
}
if($fields[$f]->getVar('field_main') == 1) {
Modified: XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/class/files/architecture.php
===================================================================
--- XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/class/files/architecture.php 2014-06-10 12:14:51 UTC (rev 12575)
+++ XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/class/files/architecture.php 2014-06-10 22:48:07 UTC (rev 12576)
@@ -249,47 +249,18 @@
$ret[] = $userTemplates->renderFile($table_name.'.tpl');
}
/*var_dump($table_name); */
- }
- // Creation of admin language file
- if ( $table_admin == 1) {
- // Language Admin File
- $languageAdmin = LanguageAdmin::getInstance();
- $languageAdmin->write($module, $tables, 'admin.php');
- $ret[] = $languageAdmin->render();
- }
+ }
// Creation of blocks language file
if ( $table_blocks == 1) {
// Language Blocks File
$languageBlocks = LanguageBlocks::getInstance();
$languageBlocks->write($module, $tables, 'blocks.php');
$ret[] = $languageBlocks->render();
- }
- // Creation of user language file
- if ( $table_user == 1) {
- // Language Main File
- $languageMain = LanguageMain::getInstance();
- $languageMain->write($module, $table, $tables, 'main.php');
- $ret[] = $languageMain->render();
- }
+ }
// Language Modinfo File
$languageModinfo = LanguageModinfo::getInstance();
$languageModinfo->write($module, $table, $tables, 'modinfo.php');
- $ret[] = $languageModinfo->render();
- // Creation of user files
- if ( $table_user == 1) {
- // Templates Footer File
- $templatesFooter = TemplatesFooter::getInstance();
- $templatesFooter->write($module, $table, 'footer.tpl');
- $ret[] = $templatesFooter->render();
- // Templates Header File
- $templatesHeader = TemplatesHeader::getInstance();
- $templatesHeader->write($module, $tables, 'header.tpl');
- $ret[] = $templatesHeader->render();
- // User Index File
- $userIndex = UserIndex::getInstance();
- $userIndex->write($module, 'index.php');
- $ret[] = $userIndex->render();
- }
+ $ret[] = $languageModinfo->render();
// Creation of admin files
if ( $table_admin == 1) {
// Admin Header File
@@ -298,20 +269,32 @@
$ret[] = $adminHeader->render();
// Admin Index File
$adminIndex = AdminIndex::getInstance();
- $adminIndex->write($module, $table, $tables, 'index.php');
+ $adminIndex->write($module, $tables, 'index.php');
$ret[] = $adminIndex->render();
// Admin Menu File
$adminMenu = AdminMenu::getInstance();
- $adminMenu->write($module, $table, $tables, 'menu.php');
+ $adminMenu->write($module, $tables, 'menu.php');
$ret[] = $adminMenu->render();
- }
- // Creation of admin permission file
- if (( $table_permissions == 1) && ( $table_admin == 1 )) {
- // Admin Permissions File
- $adminPermissions = AdminPermissions::getInstance();
- $adminPermissions->write($module, $tables, 'permissions.php');
- $ret[] = $adminPermissions->render();
- }
+ // Creation of admin permission file
+ if (( $table_permissions == 1)) {
+ // Admin Permissions File
+ $adminPermissions = AdminPermissions::getInstance();
+ $adminPermissions->write($module, $tables, 'permissions.php');
+ $ret[] = $adminPermissions->render();
+ }
+ // Admin Aboutr File
+ $adminAbout = AdminAbout::getInstance();
+ $adminAbout->write($module, 'about.php');
+ $ret[] = $adminAbout->render();
+ // Admin Footer File
+ $adminFooter = AdminFooter::getInstance();
+ $adminFooter->write($module, 'footer.php');
+ $ret[] = $adminFooter->render();
+ // Language Admin File
+ $languageAdmin = LanguageAdmin::getInstance();
+ $languageAdmin->write($module, $tables, 'admin.php');
+ $ret[] = $languageAdmin->render();
+ }
// Creation of notifications files
if ( $table_notifications == 1 ) {
// Include Notifications File
@@ -360,25 +343,8 @@
$includeComments->write($module, $table);
$ret[] = $includeComments->renderCommentsNew($module, 'comment_new');
}
- if ( ($table_user == 1) && ($table_notifications == 1)){
- // User Notification Update File
- $userNotificationUpdate = UserNotificationUpdate::getInstance();
- $userNotificationUpdate->write($module, 'notification_update.php');
- $ret[] = $userNotificationUpdate->render();
- }
- // Creation of admin files
- if ( $table->getVar('table_admin') == 1 ) {
- // Admin Aboutr File
- $adminAbout = AdminAbout::getInstance();
- $adminAbout->write($module, 'about.php');
- $ret[] = $adminAbout->render();
- // Admin Footer File
- $adminFooter = AdminFooter::getInstance();
- $adminFooter->write($module, 'footer.php');
- $ret[] = $adminFooter->render();
- }
// Creation of user files
- if ( $table->getVar('table_user') == 1 ) {
+ if ( ($table_user == 1)){
// Templates Index File
$templatesIndex = TemplatesIndex::getInstance();
$templatesIndex->write($module, 'index.tpl');
@@ -390,7 +356,29 @@
// User Header File
$userHeader = UserHeader::getInstance();
$userHeader->write($module, 'header.php');
- $ret[] = $userHeader->render();
+ $ret[] = $userHeader->render();
+ // User Notification Update File
+ if ( ($table_notifications == 1 )){
+ $userNotificationUpdate = UserNotificationUpdate::getInstance();
+ $userNotificationUpdate->write($module, 'notification_update.php');
+ $ret[] = $userNotificationUpdate->render();
+ }
+ // Templates Footer File
+ $templatesFooter = TemplatesFooter::getInstance();
+ $templatesFooter->write($module, $table, 'footer.tpl');
+ $ret[] = $templatesFooter->render();
+ // Templates Header File
+ $templatesHeader = TemplatesHeader::getInstance();
+ $templatesHeader->write($module, $tables, 'header.tpl');
+ $ret[] = $templatesHeader->render();
+ // User Index File
+ $userIndex = UserIndex::getInstance();
+ $userIndex->write($module, 'index.php');
+ $ret[] = $userIndex->render();
+ // Language Main File
+ $languageMain = LanguageMain::getInstance();
+ $languageMain->write($module, $table, $tables, 'main.php');
+ $ret[] = $languageMain->render();
}
// Css Styles File
$cssStyles = CssStyles::getInstance($module, 'style.css');
Modified: XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/class/files/class/classes.php
===================================================================
--- XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/class/files/class/classes.php 2014-06-10 12:14:51 UTC (rev 12575)
+++ XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/class/files/class/classes.php 2014-06-10 22:48:07 UTC (rev 12576)
@@ -19,7 +19,7 @@
* @version $Id: class_files.php 12258 2014-01-02 09:33:29Z timgno $
*/
defined('XOOPS_ROOT_PATH') or die('Restricted access');
-require_once TDMC_PATH . '/class/files/formelements.php';
+require_once 'formelements.php';
class ClassFiles extends TDMCreateFormElements
{
/*
Added: XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/class/files/class/formelements.php
===================================================================
--- XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/class/files/class/formelements.php (rev 0)
+++ XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/class/files/class/formelements.php 2014-06-10 22:48:07 UTC (rev 12576)
@@ -0,0 +1,353 @@
+<?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
+{
+ /*
+ * @public function constructor
+ * @param null
+ */
+ public function __construct() {
+ parent::__construct();
+ $this->tdmcreate = TDMCreate::getInstance();
+ }
+ /**
+ * @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 string $table
+ */
+ public function initForm($module, $table) {
+ $this->setModule($module);
+ $this->setTable($table);
+ }
+ /*
+ * @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});\n
+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});\n
+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});\n
+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});\n
+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}')));\n
+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});\n
+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});\n
+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});\n
+EOT;
+ return $ret;
+ }
+ /*
+ * @public function getXoopsFormSelect
+ * @param string $language
+ * @param string $table_name
+ * @param string $field_name
+ * @param string $required
+ */
+ public function getXoopsFormSelect($language, $table_name, $field_name, $required = 'false') {
+ $ret = <<<EOT
+ \${$field_name}_select = new XoopsFormSelect({$language}, '{$field_name}', \$this->getVar('{$field_name}'));
+ \${$field_name}_select->addOptionArray({$table_name}Handler->getList());
+ \$form->addElement(\${$field_name}_select{$required});\n
+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});\n
+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});\n
+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});\n
+EOT;
+ return $ret;
+ }
+ /*
+ * @public function getXoopsFormTable
+ * @param string $language
+ * @param string $module_name
+ * @param string $table_name
+ * @param string $fields
+ * @param string $required
+ */
+ public function getXoopsFormTable($language, $module_name, $table_name, $fields, $required = 'false')
+ {
+ $field_name = '';
+ foreach(array_keys($fields) as $f)
+ {
+ if(($fields[$f]->getVar('field_parent') == 1)) {
+ $field_name = $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});\n
+XFT;
+ return $ret;
+ }
+ /*
+ * @public function getXoopsFormTopic
+ * @param string $language
+ * @param string $module_name
+ * @param string $table_name
+ * @param string $fields
+ * @param string $required
+ */
+ public function getXoopsFormTopic($language, $module_name, $table_name, $fields, $required = 'false')
+ {
+ foreach(array_keys($fields) as $f)
+ {
+ $field_name = $fields[$f]->getVar('field_name');
+ if($fields[$f]->getVar('field_id') == 1) {
+ $field_id = $field_name;
+ }
+ if($fields[$f]->getVar('field_parent') == 1) {
+ $field_pid = $field_name;
+ }
+ if($fields[$f]->getVar('field_main') == 1) {
+ $field_main = $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});
+ }\n
+XFT;
+ return $ret;
+ }
+ /*
+ * @public function renderElements
+ * @param null
+ */
+ 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 = '';
+ $fields = $this->getTableFields($table->getVar('table_id'));
+ foreach(array_keys($fields) as $f)
+ {
+ $field_name = $fields[$f]->getVar('field_name');
+ $field_element = $fields[$f]->getVar('field_element');
+ $language = $language_funct . strtoupper($field_name);
+ $required = ( $fields[$f]->getVar('field_required') == 1 ) ? ', true' : '';
+ //
+ //if($f > 0) { // If we want to hide XoopsFormHidden() or field id
+ switch($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->getXoopsFormRadioYN($language, $field_name, $required);
+ break;
+ case 6:
+ $ret .= $this->getXoopsFormSelect($language, $table_name, $field_name, $required);
+ break;
+ case 7:
+ $ret .= $this->getXoopsFormSelectUser($language, $field_name, $required);
+ break;
+ case 8:
+ $ret .= $this->getXoopsFormColorPicker($language, $field_name, $required);
+ break;
+ case 9:
+ $ret .= $this->getXoopsFormUploadImage($language, $field_name, $required);
+ break;
+ case 10:
+ $ret .= $this->getXoopsFormUploadFile($language, $field_name, $required);
+ break;
+ case 11:
+ $ret .= $this->getXoopsFormTextDateSelect($language, $field_name, $required);
+ break;
+ default:
+ $ret .= $this->getXoopsFormHidden($field_name);
+ break;
+ }
+ if ($field_element > 11) {
+ 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, $required);
+ }
+ }
+ //}
+ }
+ return $ret;
+ }
+}
\ No newline at end of file
Deleted: XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/class/files/formelements.php
===================================================================
--- XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/class/files/formelements.php 2014-06-10 12:14:51 UTC (rev 12575)
+++ XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/class/files/formelements.php 2014-06-10 22:48:07 UTC (rev 12576)
@@ -1,351 +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 TDMCreateFormElements extends TDMCreateFile
-{
- /*
- * @public function constructor
- * @param null
- */
- public function __construct() {
- parent::__construct();
- $this->tdmcreate = TDMCreate::getInstance();
- }
- /**
- * @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 string $table
- */
- public function initForm($module, $table) {
- $this->setModule($module);
- $this->setTable($table);
- }
- /*
- * @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});\n
-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});\n
-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});\n
-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});\n
-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}')));\n
-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});\n
-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});\n
-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});\n
-EOT;
- return $ret;
- }
- /*
- * @public function getXoopsFormSelect
- * @param string $language
- * @param string $table_name
- * @param string $field_name
- * @param string $required
- */
- public function getXoopsFormSelect($language, $table_name, $field_name, $required = 'false') {
- $ret = <<<EOT
- \${$field_name}_select = new XoopsFormSelect({$language}, '{$field_name}', \$this->getVar('{$field_name}'));
- \${$field_name}_select->addOptionArray({$table_name}Handler->getList());
- \$form->addElement(\${$field_name}_select{$required});\n
-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});\n
-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});\n
-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});\n
-EOT;
- return $ret;
- }
- /*
- * @public function getXoopsFormTable
- * @param string $language
- * @param string $module_name
- * @param string $table_name
- * @param string $fields
- * @param string $required
- */
- public function getXoopsFormTable($language, $module_name, $table_name, $fields, $required = 'false')
- {
- $field_name = '';
- foreach(array_keys($fields) as $f)
- {
- if(($fields[$f]->getVar('field_parent') == 1)) {
- $field_name = $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});\n
-XFT;
- return $ret;
- }
- /*
- * @public function getXoopsFormTopic
- * @param string $language
- * @param string $module_name
- * @param string $table_name
- * @param string $fields
- * @param string $required
- */
- public function getXoopsFormTopic($language, $module_name, $table_name, $fields, $required = 'false')
- {
- foreach(array_keys($fields) as $f)
- {
- $field_name = $fields[$f]->getVar('field_name');
- if($fields[$f]->getVar('field_id') == 1) {
- $field_id = $field_name;
- }
- if($fields[$f]->getVar('field_parent') == 1) {
- $field_pid = $field_name;
- }
- if($fields[$f]->getVar('field_main') == 1) {
- $field_main = $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});
- }\n
-XFT;
- return $ret;
- }
- /*
- * @public function renderElements
- * @param null
- */
- 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 = '';
- $fields = $this->getTableFields($table->getVar('table_id'));
- foreach(array_keys($fields) as $f)
- {
- $field_name = $fields[$f]->getVar('field_name');
- $field_element = $fields[$f]->getVar('field_element');
- $language = $language_funct . strtoupper($field_name);
- $required = ( $fields[$f]->getVar('field_required') == 1 ) ? ', true' : '';
- //
- switch($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->getXoopsFormRadioYN($language, $field_name, $required);
- break;
- case 6:
- $ret .= $this->getXoopsFormSelect($language, $table_name, $field_name, $required);
- break;
- case 7:
- $ret .= $this->getXoopsFormSelectUser($language, $field_name, $required);
- break;
- case 8:
- $ret .= $this->getXoopsFormColorPicker($language, $field_name, $required);
- break;
- case 9:
- $ret .= $this->getXoopsFormUploadImage($language, $field_name, $required);
- break;
- case 10:
- $ret .= $this->getXoopsFormUploadFile($language, $field_name, $required);
- break;
- case 11:
- $ret .= $this->getXoopsFormTextDateSelect($language, $field_name, $required);
- break;
- default:
- $ret .= $this->getXoopsFormHidden($field_name);
- break;
- }
- if ($field_element > 11) {
- 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, $required);
- }
- }
- }
- return $ret;
- }
-}
\ No newline at end of file
|