|
From: <txm...@us...> - 2014-03-04 19:20:12
|
Revision: 12346
http://sourceforge.net/p/xoops/svn/12346
Author: txmodxoops
Date: 2014-03-04 19:20:06 +0000 (Tue, 04 Mar 2014)
Log Message:
-----------
Only for repository, no tests
Modified Paths:
--------------
XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/class/files/class_files.php
XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/class/files/headerfiles.php
XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/class/files/htmlsmartycodes.php
XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/class/logoGenerator.php
XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/class/structure.php
Added Paths:
-----------
XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/class/architecture.php
XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/class/fields.php
XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/class/fields_class.php
XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/class/fields_database.php
XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/class/fields_parameters.php
XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/class/files/user_templates.php
XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/class/form_elements.php
XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/class/tables_fields.php
Added: XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/class/architecture.php
===================================================================
--- XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/class/architecture.php (rev 0)
+++ XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/class/architecture.php 2014-03-04 19:20:06 UTC (rev 12346)
@@ -0,0 +1,110 @@
+<?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: architecture.php 12258 2014-01-02 09:33:29Z timgno $
+ */
+if (!defined('XOOPS_ROOT_PATH')) {
+ die('XOOPS root path not defined');
+}
+
+class Architecture extends Structure
+{
+ /*
+ * @public function constructor class
+ * @param string $path
+ */
+ public function __construct($path) {
+ $this->path = $path;
+ }
+ /*
+ * @public function isDir
+ * @param string $dname
+ */
+ public function ArchitectureFiles( $module, $pathName )
+ {
+ $indexFile = $pathName.'/index.html';
+ $this->path = XOOPS_ROOT_PATH.'/modules/TDMCreate';
+ $fdocs = $this->path.'/docs';
+ $fimages = $this->path.'/images';
+ //Creation of the Directory of modules
+ $targetDirectory = $pathName.'/modules/'.strtolower($module->getVar('mod_name'));
+
+ // Making of a new object
+ $classStruct = Structure::Structure($targetDirectory);
+ // Creation of "module" folder
+ $classStruct->makeDir($targetDirectory);
+ // Creation of "admin" folder and index.html file
+ $classStruct->makeDirAndCopyFile('admin/', $indexFile, 'index.html');
+ // Creation of "blocks" folder and index.html file
+ $classStruct->makeDirAndCopyFile('blocks/', $indexFile, 'index.html');
+ // Creation of "class" folder and index.html file
+ $classStruct->makeDirAndCopyFile('class/', $indexFile, 'index.html');
+ // Creation of "css" folder and index.html file
+ $classStruct->makeDirAndCopyFile('css/', $indexFile, 'index.html');
+ // Creation of "images" folder and index.html file
+ $classStruct->makeDirAndCopyFile('images/', $indexFile, 'index.html');
+ //Copy the logo of the module
+ $mod_image = str_replace(' ', '', strtolower($module->getVar('mod_image')));
+ $classStruct->copyFile('images/', $fimages.'/uploads/modules/'.$mod_image, $mod_image);
+
+ // Creation of 'images/icons' folder and index.html file - Added in Version 1.15
+ $classStruct->makeDirAndCopyFile('images/icons/', $indexFile, 'index.html');
+ // Creation of "images/icons/16" folder and index.html file
+ $classStruct->makeDirAndCopyFile('images/icons/16/', $indexFile, 'index.html');
+ // Creation of "images/icons/32" folder and index.html file
+ $classStruct->makeDirAndCopyFile('images/icons/32/', $indexFile, 'index.html');
+ // Creation of 'on.png' file
+ $classStruct->copyFile('images/icons/16/', $fimages.'/icons/16/on.png', 'on.png');
+ // Creation of 'off.png' file
+ $classStruct->copyFile('images/icons/16/', $fimages.'/icons/16/off.png', 'off.png');
+ // Creation of 'arrow.gif' file
+ $classStruct->copyFile('images/icons/16/', $fimages.'/icons/16/arrow.gif', 'arrow.gif');
+ // Creation of 'txmodxoops_logo.png' file
+ $classStruct->copyFile('images/', $fimages.'/txmodxoops_logo.png', 'txmodxoops_logo.png');
+
+ // Creation of 'docs' folder and index.html file
+ $classStruct->makeDirAndCopyFile('docs/', $indexFile, 'index.html');
+ // Creation of 'credits.txt' file
+ $classStruct->copyFile('docs/', $fdocs.'/credits.txt', 'credits.txt');
+ // Creation of 'install.txt' file
+ $classStruct->copyFile('docs/', $fdocs.'/install.txt', 'install.txt');
+ // Creation of 'lang_diff.txt' file
+ $classStruct->copyFile('docs/', $fdocs.'/lang_diff.txt', 'lang_diff.txt');
+ // Creation of 'license.txt' file
+ $classStruct->copyFile('docs/', $fdocs.'/license.txt', 'license.txt');
+ // Creation of 'readme.txt' file
+ $classStruct->copyFile('docs/', $fdocs.'/readme.txt', 'readme.txt');
+
+ // Creation of "include" folder and index.html file
+ $classStruct->makeDirAndCopyFile('include/', $indexFile, 'index.html');
+ // Creation of "language" folder and index.html file
+ $classStruct->makeDirAndCopyFile('language/', $indexFile, 'index.html');
+ // Creation of "language/local_language" folder and index.html file
+ $classStruct->makeDirAndCopyFile('language/'.$GLOBALS['xoopsConfig']['language']. '/', $indexFile, 'index.html');
+ // Creation of "language/local_language/help" folder and index.html file
+ $classStruct->makeDirAndCopyFile('language/'.$GLOBALS['xoopsConfig']['language']. '/help/', $indexFile, 'index.html');
+ // Creation of "templates" folder and index.html file
+ $classStruct->makeDirAndCopyFile('templates/', $indexFile, 'index.html');
+ // Creation of "templates/admin" folder and index.html file
+ $classStruct->makeDirAndCopyFile('templates/admin/', $indexFile, 'index.html');
+ // Creation of "templates/blocks" folder and index.html file
+ $classStruct->makeDirAndCopyFile('templates/blocks/', $indexFile, 'index.html');
+ // Creation of "sql" folder and index.html file
+ $classStruct->makeDirAndCopyFile('sql/', $indexFile, 'index.html');
+ }
+}
\ No newline at end of file
Added: XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/class/fields.php
===================================================================
--- XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/class/fields.php (rev 0)
+++ XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/class/fields.php 2014-03-04 19:20:06 UTC (rev 12346)
@@ -0,0 +1,222 @@
+<?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: fields.php 12258 2014-01-02 09:33:29Z timgno $
+ */
+if (!defined("XOOPS_ROOT_PATH")) {
+ die("XOOPS root path not defined");
+}
+require_once "tdmcreate_htmltable.php";
+class TDMCreateFields extends XoopsObject
+{
+ //Constructor
+ public function __construct()
+ {
+ $this->XoopsObject();
+ $this->initVar("field_id", XOBJ_DTYPE_INT, null, false, 8);
+ $this->initVar("field_table", XOBJ_DTYPE_INT, null, false, 5);
+ $this->initVar("field_name", XOBJ_DTYPE_TXTBOX, null, false, 255);
+ $this->initVar("field_type", XOBJ_DTYPE_TXTBOX, null, false, 100);
+ $this->initVar("field_value", XOBJ_DTYPE_TXTBOX, null, false, 4);
+ $this->initVar("field_attribute", XOBJ_DTYPE_TXTBOX, null, false, 50);
+ $this->initVar("field_null", XOBJ_DTYPE_TXTBOX, null, false, 10);
+ $this->initVar("field_default", XOBJ_DTYPE_TXTBOX, null, false, 150);
+ $this->initVar("field_key", XOBJ_DTYPE_TXTBOX, null, false, 10);
+ $this->initVar("field_auto_increment", XOBJ_DTYPE_INT, null, false, 1);
+ $this->initVar("field_display_admin", XOBJ_DTYPE_INT, null, false, 1);
+ $this->initVar("field_display_user", XOBJ_DTYPE_INT, null, false, 1);
+ $this->initVar("field_display_block", XOBJ_DTYPE_INT, null, false, 1);
+ $this->initVar("field_mainfield", XOBJ_DTYPE_INT, null, false, 1);
+ $this->initVar("field_search", XOBJ_DTYPE_INT, null, false, 1);
+ $this->initVar("field_required", XOBJ_DTYPE_INT, null, false, 1);
+ // For relationship
+ $this->initVar("table_id", XOBJ_DTYPE_INT, null, false, 8);
+ $this->initVar("table_module", XOBJ_DTYPE_INT, null, false, 5);
+ $this->initVar("table_name", XOBJ_DTYPE_TXTBOX, null, false, 255);
+ $this->initVar("table_nbfields", XOBJ_DTYPE_INT, null, false, 5);
+ $this->initVar("table_fieldname", XOBJ_DTYPE_TXTBOX, null, false, 50);
+
+ $this->initVar("fieldtype_id", XOBJ_DTYPE_INT, null, false, 5);
+ $this->initVar("fieldtype_value", XOBJ_DTYPE_TXTBOX, null, false, 25);
+ $this->initVar("fieldtype_name", XOBJ_DTYPE_TXTBOX, null, false, 255);
+ }
+
+ public function getForm($action = false)
+ {
+ if ($action === false) {
+ $action = $_SERVER["REQUEST_URI"];
+ }
+
+ $title = $this->isNew() ? sprintf(_AM_TDMCREATE_FIELD_ADD) : sprintf(_AM_TDMCREATE_FIELD_EDIT);
+
+ include_once(XOOPS_ROOT_PATH."/class/xoopsformloader.php");
+ include_once(XOOPS_ROOT_PATH."/modules/TDMCreate/class/tdmcreate_themeform.php");
+ $form = new TDMCreate_XoopsThemeForm($title, "form", $action, "post", true);
+ $form->setExtra('enctype="multipart/form-data"');
+
+ if (!$this->isNew()) {
+ $field_table = $this->getVar('field_table');
+ } else {
+ $field_table = array( 1 => 0 );
+ }
+
+ //$option_tray = new XoopsFormElementTray(' ');
+ //$option_tray->setExtra('colspan="2"');//_AM_TDMCREATE_FIELD_TYPE
+
+ // New Object HtmlTable
+ $tableForm = new TDMCreate_HtmlTable(null, 'display outer');
+ // header row
+ $tableForm->addRow('center bgblue');
+ $cells = array(_AM_TDMCREATE_FIELD_NUMBER, _AM_TDMCREATE_FIELD_NAME, _AM_TDMCREATE_FIELD_TYPE, _AM_TDMCREATE_FIELD_VALUE, _AM_TDMCREATE_FIELD_ATTRIBUTE, _AM_TDMCREATE_FIELD_NULL, _AM_TDMCREATE_FIELD_DEFAULT, _AM_TDMCREATE_FIELD_KEY, _AM_TDMCREATE_FIELD_OTHERS);
+ $tableForm->addCells($cells, 'first', 'header');
+
+ $tablesHandler = xoops_getModuleHandler('tdmcreate_tables');
+ $criteria = new CriteriaCompo(new Criteria('table_name', $this->getVar('table_name')));
+ $criteria->add(new Criteria('table_nbfields', $this->getVar('table_nbfields')));
+ $nb_fields = $tablesHandler->getAll($criteria);
+ unset($criteria);
+ for($i = 1; $i <= count($nb_fields); $i++)
+ {
+ $field_name = $this->isNew() ? $this->getVar("table_fieldname") : $this->getVar("field_name");
+ $field_name = new XoopsFormText(_AM_TDMCREATE_FIELD_NAME, "field_name", 15, 255, $field_name);
+ // fieldtype
+ $fieldtypeHandler=& xoops_getModuleHandler('tdmcreate_fieldtype');
+ $fieldtype_select = new XoopsFormSelect(_AM_TDMCREATE_FIELD_TYPE, "field_type", $this->getVar("field_type"));
+ $fieldtype_select->addOptionArray($fieldtypeHandler->getList());
+ // fieldvalue
+ $field_value = new XoopsFormText(_AM_TDMCREATE_FIELD_VALUE, "field_value", 5, 20, $this->getVar("field_value"));
+ // fieldattributes
+ $fieldattrsHandler=& xoops_getModuleHandler('tdmcreate_fieldattributes');
+ $field_attributes_select = new XoopsFormSelect(_AM_TDMCREATE_FIELD_TYPE, "field_attribute", $this->getVar("field_attribute"));
+ $field_attributes_select->addOptionArray($fieldattrsHandler->getList());
+ // fieldnull
+ $fieldnullHandler=& xoops_getModuleHandler('tdmcreate_fieldnull');
+ $field_null_select = new XoopsFormSelect(_AM_TDMCREATE_FIELD_NULL, "field_null", $this->getVar("field_null"));
+ $field_null_select->addOptionArray($fieldnullHandler->getList());
+ // fielddefault
+ $field_default = new XoopsFormText(_AM_TDMCREATE_FIELD_DEFAULT, "field_default", 15, 25, $this->getVar("field_default"));
+ // fieldkey
+ $fieldkeyHandler=& xoops_getModuleHandler('tdmcreate_fieldkey');
+ $field_key_select = new XoopsFormSelect(_AM_TDMCREATE_FIELD_KEY, "field_key", $this->getVar("field_key"));
+ $field_key_select->addOptionArray($fieldkeyHandler->getList());
+ // render fields
+ $tableFormDataArray = array($i, $field_name->render(), $fieldtype_select->render(), $field_value->render(), $field_attributes_select->render(), $field_null_select->render(), $field_default->render(), $field_key_select->render());
+ // data row
+ $tableForm->addRow('center bgyellow');
+ $tableForm->addCells($tableFormDataArray, 'first', 'data');
+ $tableOtherForm = new TDMCreate_HtmlTable(null, 'display');
+ if($i == 1) {
+ $field_autoincrement = $this->isNew() ? 0 : $this->getVar("field_auto_increment");
+ $check_field_autoincrement = new XoopsFormCheckBox(" ", "field_auto_increment", $field_autoincrement);
+ $check_field_autoincrement->addOption(1, _AM_TDMCREATE_FIELD_AUTO_INCREMENT);
+ // data row
+ $tableOtherForm->addRow();
+ $tableOtherForm->addCell($check_field_autoincrement->render(), null, 'data');
+ } elseif($i > 1) {
+ // Box header row
+ $tableOtherForm->addRow('center bgyellow');
+ $tableOtherForm->addCell(_AM_TDMCREATE_FIELD_ELEMENTS, 'first', 'header');
+ // fieldelements
+ $fieldelementsHandler=& xoops_getModuleHandler('tdmcreate_fieldelements');
+ $field_elements_select = new XoopsFormSelect(_AM_TDMCREATE_FIELD_ELEMENT_NAME, 'field_element_name', $this->getVar("field_element_name"));
+ $field_elements_select->addOptionArray($fieldelementsHandler->getList());
+ $criteria = new CriteriaCompo(new Criteria('table_id', $this->getVar('table_id')));
+ $criteria->add(new Criteria('table_module', $this->getVar('table_module')));
+ $criteria->setSort('table_name');
+ $criteria->setOrder('ASC');
+ $tbls_arr1 = $tablesHandler->getall($criteria);
+ unset($criteria);
+ foreach (array_keys($tbls_arr1) as $j)
+ {
+ $tbls_name1 = $tbls_arr1[$j]->getVar('table_name');
+ if ( $j[$i] == 'XoopsFormTables-'.$tbls_name1 ) {
+ $field_elements_select->addOption('XoopsFormTables-'.$tbls_name1, 'Table : '.$tbls_name1);
+ }
+ }
+ // data row
+ $tableOtherForm->addRow();
+ $tableOtherForm->addCell($field_elements_select->render(), null, 'data');
+ $field_display_admin = $this->isNew() ? 0 : $this->getVar("field_display_admin");
+ $check_field_display_admin = new XoopsFormCheckBox(" ", "field_display_admin", $field_display_admin);
+ $check_field_display_admin->addOption(1, _AM_TDMCREATE_FIELD_DISPLAY_ADMIN);
+ // data row
+ $tableOtherForm->addRow();
+ $tableOtherForm->addCell($check_field_display_admin->render(), null, 'data');
+ $field_display_user = $this->isNew() ? 0 : $this->getVar("field_display_user");
+ $check_field_display_user = new XoopsFormCheckBox(" ", "field_display_user", $field_display_user);
+ $check_field_display_user->addOption(1, _AM_TDMCREATE_FIELD_DISPLAY_USER);
+ // data row
+ $tableOtherForm->addRow();
+ $tableOtherForm->addCell($check_field_display_user->render(), null, 'data');
+ $field_display_block = $this->isNew() ? 0 : $this->getVar("field_display_block");
+ $check_field_display_block = new XoopsFormCheckBox(" ", "field_display_block", $field_display_block);
+ $check_field_display_block->addOption(1, _AM_TDMCREATE_FIELD_DISPLAY_BLOCK);
+ // data row
+ $tableOtherForm->addRow();
+ $tableOtherForm->addCell($check_field_display_block->render(), null, 'data');
+ $field_mnfield = $this->isNew() ? 0 : $this->getVar("field_mainfield");
+ $field_mainfield = new XoopsFormRadio(" ", "field_mainfield", $field_mnfield);
+ $field_mainfield->addOption( ' ', _AM_TDMCREATE_FIELD_MAINFIELD );
+ // data row
+ $tableOtherForm->addRow();
+ $tableOtherForm->addCell($field_mainfield->render(), null, 'data');
+ $field_search = $this->isNew() ? 0 : $this->getVar("field_search");
+ $check_field_search = new XoopsFormCheckBox(" ", "field_search", $field_search);
+ $check_field_search->addOption(1, _AM_TDMCREATE_FIELD_SEARCH);
+ // data row
+ $tableOtherForm->addRow();
+ $tableOtherForm->addCell($check_field_search->render(), null, 'data');
+ $field_required = $this->isNew() ? 0 : $this->getVar("field_required");
+ $check_field_required = new XoopsFormCheckBox(" ", "field_required", $field_required);
+ $check_field_required->addOption(1, _AM_TDMCREATE_FIELD_REQUIRED);
+ // data row
+ $tableOtherForm->addRow();
+ $tableOtherForm->addCell($check_field_required->render(), null, 'data');
+ }
+ $tableForm->addCell($tableOtherForm->display(), null, 'data');
+
+ if (!$this->isNew()) {
+ $tableFormHiddenId = new XoopsFormHidden('table_id', $this->getVar('table_id'));
+ //$form->addElement(new XoopsFormHidden('fields_modified', true));
+ }
+ }
+ $form->addElement($tableForm->display());
+ /*if (!$this->isNew()) {
+ $form->addElement(new XoopsFormHidden('table_id', $this->getVar('table_id')));
+ $form->addElement(new XoopsFormHidden('fields_modified', true));
+ }
+
+ $form->addElement(new XoopsFormHidden("op", "save_fields"));
+ $form->addElement(new XoopsFormHidden("field_table", $this->getVar("field_table")));
+ $form->addElement(new XoopsFormButton("", "submit", _SUBMIT, "submit"));*/
+ $tableFormButton = new XoopsFormButton("", "submit", _SUBMIT, "submit");
+ $tableForm->addRow('right grey');
+ $tableForm->addCell($tableFormButton, null, 'data');
+ $form->addElement(new XoopsFormHidden("op", "save_fields"));
+ $form->addElement($tableForm);
+ $form->addElement($tableFormButton);
+ return $form;
+ }
+}
+class TDMCreateFieldsHandler extends XoopsPersistableObjectHandler
+{
+ function __construct(&$db)
+ {
+ parent::__construct($db, "tdmcreate_fields", "tdmcreatefields", "field_id", "field_table");
+ }
+}
\ No newline at end of file
Added: XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/class/fields_class.php
===================================================================
--- XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/class/fields_class.php (rev 0)
+++ XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/class/fields_class.php 2014-03-04 19:20:06 UTC (rev 12346)
@@ -0,0 +1,249 @@
+<?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: fields_class.php 12258 2014-01-02 09:33:29Z timgno $
+ */
+if (!defined('XOOPS_ROOT_PATH')) {
+ die('XOOPS root path not defined');
+}
+
+class FieldsClass /*extends HeaderFile*/
+{
+ /*
+ * @var string
+ */
+ public $_module = null;
+ /*
+ * @var array
+ */
+ public $_table = array();
+ /*
+ * @var array
+ */
+ public $_type = array();
+ /*
+ * @var string
+ */
+ public $file_name = null;
+ /*
+ * @public function constructor
+ * @param string $modules
+ */
+ public function __construct($module, $table, $file_name) {
+ $this->_module = $module;
+ $this->_table[] = $table;
+ $this->file_name = $file_name;
+ }
+ /*
+ * @public function getInitVar
+ * @param array $element_name
+ * @param mixed $xobj_dtype
+ */
+ public function getInitVar(array $element_name, $xobj_dtype) {
+ $ret = <<<EOT
+ \$this->initVar('{$element_name[0]}', {$xobj_dtype});
+EOT;
+ return $ret;
+ }
+ /*
+ * @public function render
+ * @param null
+ */
+ public function render() {
+ $module_name = $this->getModuleName();
+ $language = $this->getLanguage('_AM_', '_');
+ // fpda = fields parameter display admin
+ // fpe = fields parameter element
+ // fprf = fields parameter required field
+ $mod_name = strtolower($mod_name);
+ $table_name = strtolower($table_name);
+ $table_fieldname = strtolower($table_fieldname);
+ $ret = '';
+ // Counts the number of fields
+ $fields = explode('|', $table_fields);
+ $nb_fields = count($fields);
+ // Retrieve the data
+ if ( $option == 0 )
+ {
+ // Creation of the constructor
+ for ($i = 0; $i < $nb_fields; $i++)
+ {
+ $struct = explode(':', $fields[$i]);
+ if ( $struct[1] == 'int' || $struct[1] == 'tinyint' || $struct[1] == 'mediumint' || $struct[1] == 'smallint' ) {
+ $ret .= <<<EOT
+ \$this->initVar(\''.$struct[0].'\', XOBJ_DTYPE_INT);
+EOT;
+ } elseif ( $struct[1] == 'char' || $struct[1] == 'varchar' ) {
+ $ret .= <<<EOT
+ \$this->initVar(\''.$struct[0].'\', XOBJ_DTYPE_TXTBOX);
+EOT;
+ } elseif ( $struct[1] == 'text' || $struct[1] == 'tinytext' || $struct[1] == 'mediumtext' || $struct[1] == 'longtext' ) {
+ $ret .= <<<EOT
+ \$this->initVar(\''.$struct[0].'\', XOBJ_DTYPE_TXTAREA);';
+ } elseif ( $struct[1] == 'float' ) {
+ $ret .= <<<EOT
+ \$this->initVar(\''.$struct[0].'\', XOBJ_DTYPE_FLOAT);';
+ } elseif ( $struct[1] == 'decimal' || $struct[1] == 'double' ) {
+ $ret .= <<<EOT
+ \$this->initVar(\''.$struct[0].'\', XOBJ_DTYPE_DECIMAL);';
+ } elseif ( $struct[1] == 'enum' ) {
+ $ret .= <<<EOT
+ \$this->initVar(\''.$struct[0].'\', XOBJ_DTYPE_ENUM);';
+ } elseif ( $struct[1] == 'email' ) {
+ $ret .= <<<EOT
+ \$this->initVar(\''.$struct[0].'\', XOBJ_DTYPE_EMAIL);';
+ } elseif ( $struct[1] == 'url' ) {
+ $ret .= <<<EOT
+ \$this->initVar(\''.$struct[0].'\', XOBJ_DTYPE_URL);';
+ } elseif ( $struct[1] == 'date' || $struct[1] == 'datetime' || $struct[1] == 'timestamp' || $struct[1] == 'time' || $struct[1] == 'year' ) {
+ $ret .= <<<EOT
+ \$this->initVar(\''.$struct[0].'\', XOBJ_DTYPE_LTIME);';
+ }/* elseif ( $struct[1] == 'other' ) {
+ $ret .= <<<EOT
+ \$this->initVar(\''.$struct[0].'\', XOBJ_DTYPE_OTHER, '.$struct[2].', false);';
+ }*/
+ }
+ } else if ( $option == 1 ) {
+ // Creation form
+ for ($i=0; $i < $nb_fields; $i++)
+ {
+ if ( $i != 0 ) {
+ $struct = explode(':', $fields[$i]);
+ $lng_form = $language.strtoupper($struct[0]);
+ $ret .= <<<EOT
+ $this->form_elements($i, $mod_name, $table_name, $table_fieldname, $fpe, $fprf, $lng_form, $struct[0]);
+ }
+ }
+ } else if ( $option == 2 ) {
+ // Creation of file mysql.sql
+ $ret .= <<<EOT
+
+#
+# Structure table for `mod_'.$mod_name.'_'.strtolower($table_name).'` '.$nb_fields.'
+#
+
+CREATE TABLE `mod_'.$mod_name.'_'.strtolower($table_name).'` (
+';
+ $j = 0;
+ for ($i=0; $i < $nb_fields; $i++)
+ {
+ $struct = explode(':', $fields[$i]);
+// echo "--- START ----------------- STRUCTURE -------------------------------------</br>";
+// var_dump($struct);
+ //Debut
+ if ( $struct[0] != ' ' )
+ {
+ //If as text, (not value)
+ if ( $struct[1] == 'text' || $struct[1] == 'date' || $struct[1] == 'timestamp' ) {
+ $type = $struct[1];
+ } else {
+ $type = $struct[1].' ('.$struct[2].')';
+ }
+ //If as empty is default not string(not value), if as text not default, if as numeric default is 0 or 0.0000
+ //echo $struct[5]." struct[5] --------------- </br>";
+ if ( $struct[5] == '' ) {
+ $default = "default ''";
+ //echo " default 1 </br>";
+ } elseif ( $struct[1] == 'text' || $struct[1] == 'tinytext' || $struct[1] == 'mediumtext' || $struct[1] == 'longtext' ) {
+ $default = "";
+ // echo " default 2 </br>";
+ } elseif ( $struct[1] == 'int' || $struct[1] == 'tinyint' || $struct[1] == 'mediumint' || $struct[1] == 'smallint') {
+ $default = "default '0'";
+ //echo " default 3 </br>";
+ } elseif ( $struct[1] == 'decimal' || $struct[1] == 'double' || $struct[1] == 'float' ) {
+ $default = "default '0.0000'";
+ // echo " default 4 </br>";
+ } elseif ( $struct[1] == 'date' ) {
+ // echo " default 5 </br>";
+ $default = "default '0000-00-00'";
+ } elseif ( $struct[1] == 'datetime' || $struct[1] == 'timestamp') {
+ $default = "default '0000-00-00 00:00:00'";
+ //echo " default 6 </br>";
+ } elseif ( $struct[1] == 'time' ) {
+ $default = "default '00:00:00'";
+ // echo " default 7 </br>";
+ } elseif ( $struct[1] == 'year' ) {
+ $default = "default '0000'";
+ //echo " default 8 </br>";
+ } elseif ( $struct[1] == 'other' ) {
+ $default = "default '".$struct[5]."'";
+ //echo " default 9 </br>";
+ } else {
+ $default = "default ''";
+ //echo " default 10 </br>";
+ }
+
+// echo $default." Default </br>";
+// echo $struct[0]." struct[0] </br>";
+// echo $struct[6]." struct[6] </br>";
+
+ if ( $i == 0 ) {
+ $comma[$j] = 'PRIMARY KEY (`'.$struct[0].'`)';
+ $j++;
+ $ret .= <<<EOT`'.$struct[0].'` '.$type.' '.$struct[3].' '.$struct[4].' auto_increment,
+';
+ } else {
+ if ( $struct[6] == 'unique' || $struct[6] == 'index' || $struct[6] == 'fulltext')
+ {
+ if ( $struct[6] == 'unique' ) {
+ $ret .= <<<EOT`'.$struct[0].'` '.$type.' '.$struct[3].' '.$struct[4].' '.$default.',
+';
+ $comma[$j] = 'KEY `'.$struct[0].'` (`'.$struct[0].'`)';
+ } else if ( $struct[6] == 'index' ) {
+ $ret .= <<<EOT`'.$struct[0].'` '.$type.' '.$struct[3].' '.$struct[4].' '.$default.',
+';
+ $comma[$j] = 'INDEX (`'.$struct[0].'`)';
+ } else if ( $struct[6] == 'fulltext' ) {
+ $ret .= <<<EOT`'.$struct[0].'` '.$type.' '.$struct[3].' '.$struct[4].' '.$default.',
+';
+ $comma[$j] = 'FULLTEXT KEY `'.$struct[0].'` (`'.$struct[0].'`)';
+ }
+ $j++;
+ } else {
+ $ret .= <<<EOT`'.$struct[0].'` '.$type.' '.$struct[3].' '.$struct[4].' '.$default.',
+';
+ }
+ }
+ }
+// echo $i."--- i -------</br>";
+// echo $j."--- j -------</br>";
+// var_dump($comma);
+// echo $comma[$i]."comma[i] </br>";
+// echo $text."</br>";
+ }
+ //Problem comma
+ $key = '';
+ for ($i=0; $i < $j; $i++)
+ {
+ if ( $i != $j - 1 ) {
+ $key .= $comma[$i].',
+';
+ } else {
+ $key .= $comma[$i].'
+';
+ }
+ }
+ // echo $key."================= KEY ========================= </br>";
+ $ret .= <<<EOT$key;
+ $ret .= <<<EOT) ENGINE=MyISAM;';
+ }
+ return $text;
+EOT;
+ return $ret;
+ }
+}
\ No newline at end of file
Added: XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/class/fields_database.php
===================================================================
--- XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/class/fields_database.php (rev 0)
+++ XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/class/fields_database.php 2014-03-04 19:20:06 UTC (rev 12346)
@@ -0,0 +1,250 @@
+<?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: fields_database.php 12258 2014-01-02 09:33:29Z timgno $
+ */
+if (!defined('XOOPS_ROOT_PATH')) {
+ die('XOOPS root path not defined');
+}
+
+class FieldsDatabase /*extends HeaderFile*/
+{
+ /*
+ * @var string
+ */
+ public $_module = null;
+ /*
+ * @var string
+ */
+ public $_table = array();
+ /*
+ * @var string
+ */
+ public $file_name = null;
+ /*
+ * @public function constructor
+ * @param string $modules
+ */
+ public function __construct($module, $table, $file_name) {
+ $this->_module = $module;
+ $this->_table[] = $table;
+ $this->file_name = $file_name;
+ }
+ /*
+ * @public function getSupportName
+ * @param null
+ */
+ public function getDatabaseTypes() {
+ $ret = $this->_module->getVar('mod_support_name');
+ return $ret;
+ }
+ /*
+ * @public function getSupportName
+ * @param null
+ */
+ public function getDatabaseFields() {
+ $ret = $this->_module->getVar('mod_support_url');
+ return $ret;
+ }
+ /*
+ * @public function render
+ * @param null
+ */
+ public function render() {
+ $module_name = $this->getModuleName();
+ $language = $this->getLanguage('_AM_', '_');
+ // fpda = fields parameter display admin
+ // fpe = fields parameter element
+ // fprf = fields parameter required field
+ $mod_name = strtolower($mod_name);
+ $table_name = strtolower($table_name);
+ $table_fieldname = strtolower($table_fieldname);
+ $text = '';
+ // Counts the number of fields
+ $fields = explode('|', $table_fields);
+ $nb_fields = count($fields);
+ // Retrieve the data
+ if ( $option == 0 )
+ {
+ // Creation of the constructor
+ for ($i = 0; $i < $nb_fields; $i++)
+ {
+ $struct = explode(':', $fields[$i]);
+ if ( $struct[1] == 'int' || $struct[1] == 'tinyint' || $struct[1] == 'mediumint' || $struct[1] == 'smallint' ) {
+ $ret .= <<<EOT
+ \$this->initVar(\''.$struct[0].'\', XOBJ_DTYPE_INT);
+EOT;
+ } elseif ( $struct[1] == 'char' || $struct[1] == 'varchar' ) {
+ $ret .= <<<EOT
+ \$this->initVar(\''.$struct[0].'\', XOBJ_DTYPE_TXTBOX);
+EOT;
+ } elseif ( $struct[1] == 'text' || $struct[1] == 'tinytext' || $struct[1] == 'mediumtext' || $struct[1] == 'longtext' ) {
+ $ret .= <<<EOT
+ \$this->initVar(\''.$struct[0].'\', XOBJ_DTYPE_TXTAREA);';
+ } elseif ( $struct[1] == 'float' ) {
+ $ret .= <<<EOT
+ \$this->initVar(\''.$struct[0].'\', XOBJ_DTYPE_FLOAT);';
+ } elseif ( $struct[1] == 'decimal' || $struct[1] == 'double' ) {
+ $ret .= <<<EOT
+ \$this->initVar(\''.$struct[0].'\', XOBJ_DTYPE_DECIMAL);';
+ } elseif ( $struct[1] == 'enum' ) {
+ $ret .= <<<EOT
+ \$this->initVar(\''.$struct[0].'\', XOBJ_DTYPE_ENUM);';
+ } elseif ( $struct[1] == 'email' ) {
+ $ret .= <<<EOT
+ \$this->initVar(\''.$struct[0].'\', XOBJ_DTYPE_EMAIL);';
+ } elseif ( $struct[1] == 'url' ) {
+ $ret .= <<<EOT
+ \$this->initVar(\''.$struct[0].'\', XOBJ_DTYPE_URL);';
+ } elseif ( $struct[1] == 'date' || $struct[1] == 'datetime' || $struct[1] == 'timestamp' || $struct[1] == 'time' || $struct[1] == 'year' ) {
+ $ret .= <<<EOT
+ \$this->initVar(\''.$struct[0].'\', XOBJ_DTYPE_LTIME);';
+ }/* elseif ( $struct[1] == 'other' ) {
+ $ret .= <<<EOT
+ \$this->initVar(\''.$struct[0].'\', XOBJ_DTYPE_OTHER, '.$struct[2].', false);';
+ }*/
+ }
+ } else if ( $option == 1 ) {
+ // Creation form
+ for ($i=0; $i < $nb_fields; $i++)
+ {
+ if ( $i != 0 ) {
+ $struct = explode(':', $fields[$i]);
+ $lng_form = $language.strtoupper($struct[0]);
+ $ret .= <<<EOT
+ $this->form_elements($i, $mod_name, $table_name, $table_fieldname, $fpe, $fprf, $lng_form, $struct[0]);
+ }
+ }
+ } else if ( $option == 2 ) {
+ // Creation of file mysql.sql
+ $ret .= <<<EOT
+
+#
+# Structure table for `mod_'.$mod_name.'_'.strtolower($table_name).'` '.$nb_fields.'
+#
+
+CREATE TABLE `mod_'.$mod_name.'_'.strtolower($table_name).'` (
+';
+ $j = 0;
+ for ($i=0; $i < $nb_fields; $i++)
+ {
+ $struct = explode(':', $fields[$i]);
+// echo "--- START ----------------- STRUCTURE -------------------------------------</br>";
+// var_dump($struct);
+ //Debut
+ if ( $struct[0] != ' ' )
+ {
+ //If as text, (not value)
+ if ( $struct[1] == 'text' || $struct[1] == 'date' || $struct[1] == 'timestamp' ) {
+ $type = $struct[1];
+ } else {
+ $type = $struct[1].' ('.$struct[2].')';
+ }
+ //If as empty is default not string(not value), if as text not default, if as numeric default is 0 or 0.0000
+ //echo $struct[5]." struct[5] --------------- </br>";
+ if ( $struct[5] == '' ) {
+ $default = "default ''";
+ //echo " default 1 </br>";
+ } elseif ( $struct[1] == 'text' || $struct[1] == 'tinytext' || $struct[1] == 'mediumtext' || $struct[1] == 'longtext' ) {
+ $default = "";
+ // echo " default 2 </br>";
+ } elseif ( $struct[1] == 'int' || $struct[1] == 'tinyint' || $struct[1] == 'mediumint' || $struct[1] == 'smallint') {
+ $default = "default '0'";
+ //echo " default 3 </br>";
+ } elseif ( $struct[1] == 'decimal' || $struct[1] == 'double' || $struct[1] == 'float' ) {
+ $default = "default '0.0000'";
+ // echo " default 4 </br>";
+ } elseif ( $struct[1] == 'date' ) {
+ // echo " default 5 </br>";
+ $default = "default '0000-00-00'";
+ } elseif ( $struct[1] == 'datetime' || $struct[1] == 'timestamp') {
+ $default = "default '0000-00-00 00:00:00'";
+ //echo " default 6 </br>";
+ } elseif ( $struct[1] == 'time' ) {
+ $default = "default '00:00:00'";
+ // echo " default 7 </br>";
+ } elseif ( $struct[1] == 'year' ) {
+ $default = "default '0000'";
+ //echo " default 8 </br>";
+ } elseif ( $struct[1] == 'other' ) {
+ $default = "default '".$struct[5]."'";
+ //echo " default 9 </br>";
+ } else {
+ $default = "default ''";
+ //echo " default 10 </br>";
+ }
+
+// echo $default." Default </br>";
+// echo $struct[0]." struct[0] </br>";
+// echo $struct[6]." struct[6] </br>";
+
+ if ( $i == 0 ) {
+ $comma[$j] = 'PRIMARY KEY (`'.$struct[0].'`)';
+ $j++;
+ $ret .= <<<EOT`'.$struct[0].'` '.$type.' '.$struct[3].' '.$struct[4].' auto_increment,
+';
+ } else {
+ if ( $struct[6] == 'unique' || $struct[6] == 'index' || $struct[6] == 'fulltext')
+ {
+ if ( $struct[6] == 'unique' ) {
+ $ret .= <<<EOT`'.$struct[0].'` '.$type.' '.$struct[3].' '.$struct[4].' '.$default.',
+';
+ $comma[$j] = 'KEY `'.$struct[0].'` (`'.$struct[0].'`)';
+ } else if ( $struct[6] == 'index' ) {
+ $ret .= <<<EOT`'.$struct[0].'` '.$type.' '.$struct[3].' '.$struct[4].' '.$default.',
+';
+ $comma[$j] = 'INDEX (`'.$struct[0].'`)';
+ } else if ( $struct[6] == 'fulltext' ) {
+ $ret .= <<<EOT`'.$struct[0].'` '.$type.' '.$struct[3].' '.$struct[4].' '.$default.',
+';
+ $comma[$j] = 'FULLTEXT KEY `'.$struct[0].'` (`'.$struct[0].'`)';
+ }
+ $j++;
+ } else {
+ $ret .= <<<EOT`'.$struct[0].'` '.$type.' '.$struct[3].' '.$struct[4].' '.$default.',
+';
+ }
+ }
+ }
+// echo $i."--- i -------</br>";
+// echo $j."--- j -------</br>";
+// var_dump($comma);
+// echo $comma[$i]."comma[i] </br>";
+// echo $text."</br>";
+ }
+ //Problem comma
+ $key = '';
+ for ($i=0; $i < $j; $i++)
+ {
+ if ( $i != $j - 1 ) {
+ $key .= $comma[$i].',
+';
+ } else {
+ $key .= $comma[$i].'
+';
+ }
+ }
+ // echo $key."================= KEY ========================= </br>";
+ $ret .= <<<EOT$key;
+ $ret .= <<<EOT) ENGINE=MyISAM;';
+ }
+ return $text;
+EOT;
+ return $ret;
+ }
+}
\ No newline at end of file
Added: XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/class/fields_parameters.php
===================================================================
--- XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/class/fields_parameters.php (rev 0)
+++ XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/class/fields_parameters.php 2014-03-04 19:20:06 UTC (rev 12346)
@@ -0,0 +1,128 @@
+<?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: fields_parameters.php 12258 2014-01-02 09:33:29Z timgno $
+ */
+if (!defined('XOOPS_ROOT_PATH')) {
+ die('XOOPS root path not defined');
+}
+
+class FieldsParameters
+{
+ /*
+ * @var string
+ */
+ public $module = null;
+ /*
+ * @var mixed
+ */
+ public $table = null;
+ /*
+ * @public function constructor
+ * @param string $module
+ * @param string $table
+ */
+ public function __construct($module, $table) {
+ $this->module = $module;
+ $this->table = $table;
+ }
+ /*
+ * @public function getTextDateSelect
+ * @param null
+ */
+ public function getTextDateSelect($field_name) {
+ $table_name = $this->table->getVar('table_name');
+ $ret = <<<EOT
+ \${$table_name}_obj->setVar('{$field_name}', strtotime(\$_REQUEST['{$field_name}']));
+EOT;
+ return $ret;
+ }
+ /*
+ * @public function getCheckBoxOrRadioYN
+ * @param null
+ */
+ public function getCheckBoxOrRadioYN($field_name) {
+ $table_name = $this->table->getVar('table_name');
+ $ret = <<<EOT
+ \${$table_name}_obj->setVar('{$field_name}', strtotime(\$_REQUEST['{$field_name}'] == 1) ? '1' : '0');
+EOT;
+ return $ret;
+ }
+ /*
+ * @public function getUploadImage
+ * @param null
+ */
+ public function getUploadImage($field_name) {
+ $mod_name = $this->module->getVar('mod_name');
+ $table_name = $this->table->getVar('table_name');
+ $ret = <<<EOT
+ include_once XOOPS_ROOT_PATH.'/class/uploader.php';
+ \$uploaddir = XOOPS_UPLOAD_PATH.'/{$mod_name}/images/{$table_name}/';
+ \$uploader = new XoopsMediaUploader(\$uploaddir, xoops_getModuleOption('mimetypes', '{$mod_name}'),
+ xoops_getModuleOption('maxsize', '{$mod_name}'), null, null);
+ if (\$uploader->fetchMedia(\$_POST['xoops_upload_file'][0])) {
+ \$uploader->setPrefix('{$field_name}_');
+ \$uploader->fetchMedia(\$_POST['xoops_upload_file'][0]);
+ if (!\$uploader->upload()) {
+ \$errors = \$uploader->getErrors();
+ redirect_header('javascript:history.go(-1)', 3, \$errors);
+ } else {
+ \${$table_name}_obj->setVar('{$field_name}', \$uploader->getSavedFileName());
+ }
+ } else {
+ \${$table_name}_obj->setVar('{$field_name}', \$_REQUEST['{$field_name}']);
+ }
+EOT;
+ return $ret;
+ }
+ /*
+ * @public function getUploadFile
+ * @param null
+ */
+ public function getUploadFile() {
+ $mod_name = $this->module->getVar('mod_name');
+ $table_name = $this->table->getVar('table_name');
+ $ret = <<<EOT
+ include_once XOOPS_ROOT_PATH.'/class/uploader.php';
+ \$uploaddir = XOOPS_UPLOAD_PATH.'/{$mod_name}/files/{$table_name}/';
+ \$uploader = new XoopsMediaUploader(\$uploaddir, xoops_getModuleOption('mimetypes', '{$mod_name}'),
+ xoops_getModuleOption('maxsize', '{$mod_name}'), null, null);
+ if (\$uploader->fetchMedia(\$_POST['xoops_upload_file'][0])) {
+ \$uploader->setPrefix('{$field_name}_') ;
+ \$uploader->fetchMedia(\$_POST['xoops_upload_file'][0]);
+ if (!\$uploader->upload()) {
+ \$errors = \$uploader->getErrors();
+ redirect_header('javascript:history.go(-1)', 3, \$errors);
+ } else {
+ \${$table_name}_obj->setVar('{$field_name}', \$uploader->getSavedFileName());
+ }
+ }
+EOT;
+ return $ret;
+ }
+ /*
+ * @public function render
+ * @param null
+ */
+ public function render() {
+
+ /*$ret = $this->getUploadImage();
+ $ret = $this->getUploadFile();
+ return $ret;*/
+ }
+}
\ No newline at end of file
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-03-04 17:04:48 UTC (rev 12345)
+++ XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/class/files/class_files.php 2014-03-04 19:20:06 UTC (rev 12346)
@@ -25,38 +25,99 @@
class ClassFiles extends HeaderFile
{
/*
- * @var string
+ * @var null
*/
- public $_module = '';
+ public $table = null;
/*
- * @var string
- */
- public $_table = array();
- /*
- * @var string
- */
- public $file_name = null;
- /*
* @public function constructor
* @param string $module
+ * @param string $table
* @param string $file_name
*/
- public function __construct($module, $_table, $file_name) {
- $this->_module = $module;
- $this->_table[] = $_table;
+ public function __construct($module, $table, $file_name) {
+ $this->module = $module;
+ $this->table = $table;
$this->file_name = $file_name;
- }
+ }
/*
- * @public function render
- * @param null
+ * @public function getInitVar
+ * @param array $type
+ * @param string $obj
*/
- public function render() {
- $module_name = $this->getModuleName();
- $language = $this->getLanguage('_AM_', '_');
- $ret <<<EOT
+ public function getInitVar(array $type, $obj = 'INT') {
+ $ret = <<<EOT
+ \$this->initVar('{$type}', XOBJ_DTYPE_{$obj});
+EOT;
+ return $ret;
+ }
+ /*
+ * @public function getInitVars
+ * @param array $type
+ * @param array $fields
+ */
+ public function getInitVars(array $fields) {
+ $ret = '';
+ $nb_fields = count($fields);
+ // Creation of the initVar functions list
+ for ($i = 0; $i < $nb_fields; $i++) {
+ $type = explode(':', $fields[$i]);
+ switch($type[1]) {
+ case 'int':
+ case 'tinyint':
+ case 'mediumint':
+ case 'smallint':
+ $ret .= $this->getInitVar($type[0], 'INT');
+ break;
+ case 'char':
+ case 'varchar':
+ $ret .= $this->getInitVar($type[0], 'TXTBOX');
+ break;
+ case 'text':
+ case 'tinytext':
+ case 'mediumtext':
+ case 'longtext':
+ $ret .= $this->getInitVar($type[0], 'TXTAREA');
+ break;
+ case 'float':
+ $ret .= $this->getInitVar($type[0], 'FLOAT');
+ break;
+ case 'decimal':
+ case 'double':
+ $ret .= $this->getInitVar($type[0], 'DECIMAL');
+ break;
+ case 'enum':
+ $ret .= $this->getInitVar($type[0], 'ENUM');
+ break;
+ case 'email':
+ $ret .= $this->getInitVar($type[0], 'EMAIL');
+ break;
+ case 'url':
+ $ret .= $this->getInitVar($type[0], 'URL');
+ break;
+ case 'date':
+ case 'datetime':
+ case 'timestamp':
+ case 'time':
+ case 'year':
+ $ret .= $this->getInitVar($type[0], 'LTIME');
+ break;
+ }
+ }
+ return $ret;
+ }
+ /*
+ * @public function getHeadClass
+ * @param mixed $constructor
+ */
+ public function getHeadClass($mod_name, $initvar_functions) {
+ $ucf_mod_name = ucfirst($mod_name);
+ $ucf_table_name = ucfirst($this->table->getVar('table_name'));
+ $ret = <<<EOT
\ndefined('XOOPS_ROOT_PATH') or die("Restricted access");
-
-class {$ucf_mod_name_table_name} extends XoopsObject
+/*
+ * Class Object {$ucf_mod_name}{$ucf_table_name}
+ */
+class {$ucf_mod_name}{$ucf_table_name} extends XoopsObject
{
/*
* Constructor
@@ -66,85 +127,110 @@
function __construct()
{
\$this->XoopsObject();
+ {$intivar_functions}
+\n\t}
EOT;
- $ret .= $constructor;
-$ret .= <<<EOT
-\n\t}
+ return $ret;
+ }
- /*
+ /*
+ * @public function getHeadFunctionForm
+ * @param string $form
+ */
+ public function getHeadFunctionForm($elements_form) {
+ $lang_add = $this->getLanguage('_AM_', '_ADD');
+ $lang_edit = $this->getLanguage('_AM_', '_EDIT');
+ $ret = <<<EOT
+ /*
* Get form
*
* @param mixed \$action
*/
function getForm(\$action = false)
- {
- global \$xoopsDB, \$xoopsModuleConfig;
-
+ {
if (\$action === false) {
\$action = \$_SERVER['REQUEST_URI'];
}
- \$title = \$this->isNew() ? sprintf({$language}ADD) : sprintf({$language}EDIT);
+ \$title = \$this->isNew() ? sprintf({$lang_add}) : sprintf({$lang_edit});
include_once(XOOPS_ROOT_PATH.'/class/xoopsformloader.php');
\$form = new XoopsThemeForm(\$title, 'form', \$action, 'post', true);
- \$form->setExtra('enctype="multipart/form-data"');\n
-
+ \$form->setExtra('enctype="multipart/form-data"');\n
+ {$elements_form}
EOT;
+ return $ret;
+ }
+ /*
+ * @public function getPermissionsInFunctionForm
+ * @param string $fpif
+ */
+ public function getPermissionsInFunctionForm($mod_name, $fpif) {
+ $perm_approve = $this->getLanguage('_AM_', '_PERMISSIONS_APPROVE');
+ $perm_submit = $this->getLanguage('_AM_', '_PERMISSIONS_SUBMIT');
+ $perm_view = $this->getLanguage('_AM_', '_PERMISSIONS_VIEW');
+ $ret = <<<EOT
+ \n//permissions
+ \$member_handler = & xoops_gethandler ( 'member' );
+ \$group_list = &\$member_handler->getGroupList();
+ \$gperm_handler = &xoops_gethandler ( 'groupperm' );
+ \$full_list = array_keys ( \$group_list );
+ global \$xoopsModule;
+ if ( !\$this->isNew() ) {
+ \$groups_ids_approve = \$gperm_handler->getGroupIds ( '{$mod_name}_approve', \$this->getVar ( '{$fpif}' ), \$xoopsModule->getVar ( 'mid' ) );
+ \$groups_ids_submit = \$gperm_handler->getGroupIds ( '{$mod_name}_submit', \$this->getVar ( '{$fpif}' ), \$xoopsModule->getVar ( 'mid' ) );
+ \$groups_ids_view = \$gperm_handler->getGroupIds ( '{$mod_name}_view', \$this->getVar ( '{$fpif}' ), \$xoopsModule->getVar ( 'mid' ) );
+ \$groups_ids_approve = array_values ( \$groups_ids_approve );
+ \$groups_can_approve_checkbox = new XoopsFormCheckBox ( {$perm_approve}, 'groups_approve[]', \$groups_ids_approve );
+ \$groups_ids_submit = array_values ( \$groups_ids_submit );
+ \$groups_can_submit_checkbox = new XoopsFormCheckBox ( {$perm_submit}, 'groups_submit[]', \$groups_ids_submit );
+ \$groups_ids_view = array_values ( \$groups_ids_view );
+ \$groups_can_view_checkbox = new XoopsFormCheckBox ( {$perm_view}, 'groups_view[]', \$groups_ids_view );
+ } else {
+ \$groups_can_approve_checkbox = new XoopsFormCheckBox ( {$perm_approve}, 'groups_approve[]', \$full_list );
+ \$groups_can_submit_checkbox = new XoopsFormCheckBox ( {$perm_submit}, 'groups_submit[]', \$full_list );
+ \$groups_can_view_checkbox = new XoopsFormCheckBox ( {$perm_view}, 'groups_view[]', \$full_list );
+ }
- $ret .= $form;
-
- if( $modules->getVar('mod_permissions') == 1 && $table_permissions == 1) {
-
- $up_mod_name = strtoupper($mod_name);
- $perm_approve = '_AM_'.$up_mod_name.'_PERMISSIONS_APPROVE';
- $perm_submit = '_AM_'.$up_mod_name.'_PERMISSIONS_SUBMIT';
- $perm_view = '_AM_'.$up_mod_name.'_PERMISSIONS_VIEW';
-
-$ret .= <<<EOT
-\n\t\t//permissions
-\n\t\t\$member_handler = & xoops_gethandler ( 'member' );
-\n\t\t\$group_list = &\$member_handler->getGroupList();
-\n\t\t\$gperm_handler = &xoops_gethandler ( 'groupperm' );
-\n\t\t\$full_list = array_keys ( \$group_list );
-\n\t\tglobal \$xoopsModule;
-\n\t\tif ( !\$this->isNew() ) {
-\n\t\t\t\$groups_ids_approve = \$gperm_handler->getGroupIds ( '{$mod_name}_approve', \$this->getVar ( '{$fpif}' ), \$xoopsModule->getVar ( 'mid' ) );
-\n\t\t\t\$groups_ids_submit = \$gperm_handler->getGroupIds ( '{$mod_name}_submit', \$this->getVar ( '{$fpif}' ), \$xoopsModule->getVar ( 'mid' ) );
-\n\t\t\t\$groups_ids_view = \$gperm_handler->getGroupIds ( '{$mod_name}_view', \$this->getVar ( '{$fpif}' ), \$xoopsModule->getVar ( 'mid' ) );
-\n\t\t\t\$groups_ids_approve = array_values ( \$groups_ids_approve );
-\n\t\t\t\$groups_can_approve_checkbox = new XoopsFormCheckBox ( {$perm_approve}, 'groups_approve[]', \$groups_ids_approve );
-\n\t\t\t\$groups_ids_submit = array_values ( \$groups_ids_submit );
-\n\t\t\t\$groups_can_submit_checkbox = new XoopsFormCheckBox ( {$perm_submit}, 'groups_submit[]', \$groups_ids_submit );
-\n\t\t\t\$groups_ids_view = array_values ( \$groups_ids_view );
-\n\t\t\t\$groups_can_view_checkbox = new XoopsFormCheckBox ( {$perm_view}, 'groups_view[]', \$groups_ids_view );
-\n\t\t} else {
-\n\t\t\t\$groups_can_approve_checkbox = new XoopsFormCheckBox ( {$perm_approve}, 'groups_approve[]', \$full_list );
-\n\t\t\t\$groups_can_submit_checkbox = new XoopsFormCheckBox ( {$perm_submit}, 'groups_submit[]', \$full_list );
-\n\t\t\t\$groups_can_view_checkbox = new XoopsFormCheckBox ( {$perm_view}, 'groups_view[]', \$full_list );
-\n\t\t}
-
-\n\t\t// For approve
-\n\t\t\$groups_can_approve_checkbox->addOptionArray ( \$group_list );
-\n\t\t\$form->addElement ( \$groups_can_approve_checkbox );
-\n\t\t// For submit
-\n\t\t\$groups_can_submit_checkbox->addOptionArray ( \$group_list );
-\n\t\t\$form->addElement ( \$groups_can_submit_checkbox );
-\n\t\t// For view
-\n\t\t\$groups_can_view_checkbox->addOptionArray ( \$group_list );
-\n\t\t\$form->addElement ( \$groups_can_view_checkbox );
+ // For approve
+ \$groups_can_approve_checkbox->addOptionArray ( \$group_list );
+ \$form->addElement ( \$groups_can_approve_checkbox );
+ // For submit
+ \$groups_can_submit_checkbox->addOptionArray ( \$group_list );
+ \$form->addElement ( \$groups_can_submit_checkbox );
+ // For view
+ \$groups_can_view_checkbox->addOptionArray ( \$group_list );
+ \$form->addElement ( \$groups_can_view_checkbox );
EOT;
- }
-$ret .= <<<EOT
-\n\t\t\$form->addElement(new XoopsFormHidden('op', 'save'));
-\n\t\t\$form->addElement(new XoopsFormButton('', 'submit', _SUBMIT, 'submit'));
-\n\t\treturn \$form;
-\n\t}
+ return $ret;
+ }
+ /*
+ * @public function getFootFunctionForm
+ * @param null
+ */
+ public function getFootFunctionForm() {
+ $ret = <<<EOT
+ \n\$form->addElement(new XoopsFormHidden('op', 'save'));
+ \$form->addElement(new XoopsFormButton('', 'submit', _SUBMIT, 'submit'));
+ return \$form;
+ }
}\n\n
EOT;
-$ucf_mod_table_handler = ucfirst($mod_name).ucfirst($table_name);
-$ret .= <<<EOT
+ return $ret;
+ }
+ /*
+ * @public function getClassHandler
+ * @param string $fpif
+ * @param string $fpmf
+ */
+ public function getClassHandler($mod_name, $fpif, $fpmf) {
+ $table_name = $this->table->getVar('table_name');
+ $ucf_mod_table_handler = ucfirst($mod_name).ucfirst($table_name);
+ $ret = <<<EOT
+/*
+ * Class Object Handler {$ucf_mod_name}{$ucf_table_name}
+ */
class {$ucf_mod_table_handler}Handler extends XoopsPersistableObjectHandler
{
/*
@@ -160,4 +246,18 @@
EOT;
return $ret;
}
+ /*
+ * @public function render
+ * @param null
+ */
+ public function render() {
+ $module_name = $this->getModuleName();
+
+ $ret = $this->getHeadClass($module_name, $constructor);
+ $ret .= $this->getHeadFunctionForm($form);
+ $ret .= $this->getPermissionsInFunctionForm($module_name, $fpif);
+ $ret .= $this->getFootFunctionForm();
+ $ret .= $this->getClassHandler($module_name, $fpif, $fpmf);
+ return $ret;
+ }
}
\ No newline at end of file
Modified: XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/class/files/headerfiles.php
===================================================================
--- XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/class/files/headerfiles.php 2014-03-04 17:04:48 UTC (rev 12345)
+++ XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/class/files/headerfiles.php 2014-03-04 19:20:06 UTC (rev 12346)
@@ -80,11 +80,11 @@
}
/*
- * @public function getHeaderComment
+ * @public function getHeaderComments
* @param string $module
* @param string $file_name
*/
- public function getHeaderComment($module, $file_name) {
+ public function getHeaderComments($module, $file_name) {
$this->module = $module;
$this->file_name = $file_name;
Modified: XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/class/files/htmlsmartycodes.php
===================================================================
--- XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/class/files/htmlsmartycodes.php 2014-03-04 17:04:48 UTC (rev 12345)
+++ XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/class/files/htmlsmartycodes.php 2014-03-04 19:20:06 UTC (rev 12346)
@@ -25,23 +25,10 @@
class HtmlSmartyCodes extends HeaderFile
{
/*
- * @var mixed
- */
- public $table = null;
- /*
- * @var string
- */
- public $language = null;
- /*
* @public function constructor
- * @param string $module
- * @param mixed $table
- * @param string $file_name
+ * @param null
*/
- public function __construct($module, $table, $lang_pref = '_AM_', $lang_post = '') {
- $this->module = $module;
- $this->table = $table;
- $this->language = $this->geLanguage($lang_pref, $lang_post);
+ public function __construct() {
}
/*
* @public function getHtmlDiv
@@ -151,12 +138,12 @@
/*
* @public function getHtmlTableHead
* @param string $class
+ * @param string $language
* @param mixed $field_name
*/
- public function getHtmlTableHead($class = 'bnone', $field_name) {
- $field_name = strtoupper($field_name);
+ public function getHtmlTableHead($class = 'bnone', $language, $field_name) {
$ret = <<<EOT
- <th class='{$class}'><{{$this->language}{$field_name}}></th>
+ <th class='{$class}'><{\$smarty.const.{$language}{$field_name}}></th>
EOT;
return $ret;
}
@@ -176,23 +163,32 @@
/*
* @public function getHtmlTableData
* @param string $class
- * @param mixed $field_name
+ * @param string $content
*/
- public function getHtmlTableData($class = 'bnone', $field_name) {
- $table_fieldname = $this->table->getVar('table_fieldname');
+ public function getHtmlTableData($class = 'bnone', $content = '') {
$ret = <<<EOT
- <td class='{$class}'><{\${$table_fieldname}.{$field_name}}></td>
+ <td class='{$class}'>{$content}</td>
EOT;
return $ret;
}
/*
+ * @public function getSmartyTableField
+ * @param string $table_fieldname
+ * @param string $field_name
+ */
+ public function getSmartyTableFieldData($table_fieldname = '', $fieldname = '') {
+ $ret = <<<EOT
+ <{\${$table_fieldname}.{$fieldname}}>
+EOT;
+ return $ret;
+ }
+ /*
* @public function getSmartyIncludeFile
* @param string $name
*/
- public function getSmartyIncludeFile($name = 'header') {
- $module_name = $this->module->getVar('mod_name');
+ public function getSmartyIncludeFile($module_name, $fieldname = 'header') {
$ret = <<<EOT
- <{include file='db:{$module_name}_{$name}.html'}>
+ <{include file='db:{$module_name}_{$fieldname}.html'}>
EOT;
return $ret;
}
Added: XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/class/files/user_templates.php
===================================================================
--- XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/class/files/user_templates.php (rev 0)
+++ XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/class/files/user_templates.php 2014-03-04 19:20:06 UTC (rev 12346)
@@ -0,0 +1,101 @@
+<?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: user_templates.php 12258 2014-01-02 09:33:29Z timgno $
+ */
+if (!defined('XOOPS_ROOT_PATH')) {
+ die('XOOPS root path not defined');
+}
+
+class UserTemplates extends HtmlSmartyCodes
+{
+ /*
+ * @var string
+ */
+ public $_table = array();
+ /*
+ * @public function constructor
+ * @param string $module
+ * @param string $file_name
+ */
+ public function __construct($module, $table, $file_name) {
+ $this->_module = $module;
+ $this->_table[] = $table;
+ $this->file_name = $file_name;
+ }
+ /*
+ * @public function render
+ * @param null
+ */
+ public function render() {
+ $module_name = $this->getModuleName();
+ $language = $this->getLanguage('_MA_');
+ $ret <<<EOT
+<div class="outer">
+ <table class="{$table_name}" cellpadding="0" cellspacing="0" width="100%">
+ <tr class="head">
+EOT;
+ for ($i = 0; $i < $nb_fields; $i++)
+ {
+ $structure_fields = explode(':', $fields_total[$i]);
+ $ret .= <<<EOT
+<th class="center"><{\$smarty.const.{$language.strtoupper($structure_fields[0])}}></th>
+EOT;
+ }
+ $ret .= <<<EOT
+</tr>
+ <{foreach item={$table_fieldname} from=${$table_name}}>
+ <tr class="<{cycle values='odd, even'}>">
+EOT;
+ for ($i = 0; $i < $nb_fields; $i++)
+ {
+ $structure_fields = explode(':', $fields_total[$i]);
+ if( $fpe[$i] == 'XoopsFormUploadImage' ) {
+ $ret .= <<<EOT
+<td class="center"><img src="<{$xoops_url}>/uploads/{$mod_name}/images/{$table_name}/<{${$table_fieldname}{$structure_fields[0]}}>" alt="{$table_name}"></td>
+EOT;
+ } else if( $fpe[$i] == 'XoopsFormColorPicker' ) {
+ $ret .= <<<EOT
+<td class="center"><span style="background-color: <{${$table_fieldname}{$structure_fields[0]}}>;"> </span></td>
+EOT;
+ } else {
+ $ret .= <<<EOT
+<td class="center"><{${$table_fieldname}{$structure_fields[0]}}></td>
+EOT;
+ }
+ }
+ $ret .= <<<EOT
+</tr>
+ <{/foreach}>
+ </table>
+</div>
+EOT;
+ } else {
+ $ret .= <<<EOT
+<div class="outer">
+ <div class="center">None</div>
+ <br />
+</div>
+EOT;
+ }
+ $ret .= <<<EOT
+<{include file="db:{$mod_name}_footer.html"}>
+EOT;
+ return $ret;
+ }
+}
\ No newline at end of file
Added: XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/class/form_elements.php
===================================================================
--- XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/class/form_elements.php (rev 0)
+++ XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/class/form_elements.php 2014-03-04 19:20:06 UTC (rev 12346)
@@ -0,0 +1,205 @@
+<?php
+/*
+ You may not change or alter any portion of ...
[truncated message content] |