|
From: <txm...@us...> - 2014-05-16 14:20:35
|
Revision: 12534
http://sourceforge.net/p/xoops/svn/12534
Author: txmodxoops
Date: 2014-05-16 14:20:30 +0000 (Fri, 16 May 2014)
Log Message:
-----------
Fixed bugs
Added class/files/admin_about.php file.php
Work in progress
Modified Paths:
--------------
XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/admin/building.php
XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/admin/fields.php
XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/admin/modules.php
XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/admin/tables.php
XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/class/fieldelements.php
XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/class/fields.php
XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/class/files/abstractfiles.php
XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/class/files/admin_footer.php
XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/class/files/admin_header.php
XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/class/files/admin_index.php
XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/class/files/architecture.php
XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/class/files/css_styles.php
XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/class/files/file.php
XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/class/files/include_functions.php
XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/class/modules.php
XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/include/functions.php
XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/js/functions.js
XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/templates/admin/building.tpl
XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/templates/admin/fields.tpl
XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/templates/admin/modules.tpl
XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/templates/admin/tables.tpl
Added Paths:
-----------
XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/class/files/admin_about.php
Modified: XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/admin/building.php
===================================================================
--- XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/admin/building.php 2014-05-14 20:51:54 UTC (rev 12533)
+++ XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/admin/building.php 2014-05-16 14:20:30 UTC (rev 12534)
@@ -26,6 +26,12 @@
} else {
$modules =& $modulesHandler;
}
+$tname = TDMCreate_CleanVars( $_REQUEST, 'table_name', '', 'string' );
+if ( $tname ) {
+ $tables =& $tablesHandler->get( $tname );
+} else {
+ $tables =& $tablesHandler;
+}
$mod_name = $modules->getVar('mod_name');
$from_dir = TDMC_UPLOAD_MODULES_PATH.'/'.strtolower($mod_name);
$to_dir = XOOPS_ROOT_PATH.'/modules/'.strtolower($mod_name);
@@ -45,17 +51,23 @@
$handler = TDMCreateArchitecture::getInstance();
$handler->getPath( TDMC_PATH );
$handler->getUploadPath( TDMC_UPLOAD_PATH );
- $base_architecture = $handler->getArchitectureFiles( $modules );
- /*if($base_architecture !== false) { */
- $GLOBALS['xoopsTpl']->assign('base_architecture', $base_architecture);
- /*} else {
+ $base_architecture = $handler->createBaseFoldersFiles( $modules );
+ if($base_architecture !== false) {
+ $GLOBALS['xoopsTpl']->assign('base_architecture', true);
+ } else {
$GLOBALS['xoopsTpl']->assign('base_architecture', false);
- }*/
+ }/**/
+ //$builds = array();
+ $building_files = $handler->createBuildingFiles( $modules, $tables );
+ /*foreach($building_files as $key => $value) {$builds
+ $builds['list'] = $key;*/
+ $GLOBALS['xoopsTpl']->assign('builds', $building_files);
+ //}
$mod_name = 'uploads/tdmcreate/modules/' . str_replace(' ', '', strtolower($mod_name));
// Creation of the structure of folders and files
- $GLOBALS['xoopsTpl']->assign('build_list', 'Under new construction - Temporary build only folders of this selected module "'.$mod_name.'/"');
- if ( $modules->getVar('mod_install') == 1 ) {
- copyInRootModules($from_dir, $to_dir);
+ $GLOBALS['xoopsTpl']->assign('build_list', '<b>Under new construction</b> - Temporary build only folders of this selected module "'.$mod_name.'/"');
+ if ( $modules->getVar('mod_inroot_copy') == 1 ) {
+ TDMCreate_copyr($from_dir, $to_dir);
}
break;
Modified: XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/admin/fields.php
===================================================================
--- XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/admin/fields.php 2014-05-14 20:51:54 UTC (rev 12533)
+++ XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/admin/fields.php 2014-05-16 14:20:30 UTC (rev 12534)
@@ -22,20 +22,21 @@
// Recovered value of arguments op in the URL $
$op = TDMCreateRequest::getString('op', 'list');
// Get table Variables
-$table_id = TDMCreate_CleanVars($_REQUEST, 'table_id');
+/*$table_id = TDMCreate_CleanVars($_REQUEST, 'table_id');
$table_mid = TDMCreate_CleanVars($_REQUEST, 'table_mid');
$table_nbfields = TDMCreate_CleanVars($_REQUEST, 'table_nbfields');
-/*$table_id = TDMCreateRequest::getInt('table_id');
+$table_id = TDMCreateRequest::getInt('table_id');
$table_mid = TDMCreateRequest::getInt('table_mid');
-$table_nbfields = TDMCreateRequest::getInt('table_nbfields');*/
+$table_nbfields = TDMCreateRequest::getInt('table_nbfields');
// Get field Variables
-$field_id = TDMCreate_CleanVars($_REQUEST, 'field_id');
+$field_id = TDMCreate_CleanVars($_REQUEST, 'field_id');*/
+$table_name = TDMCreate_CleanVars($_REQUEST, 'table_name', '', 'string');
$field_mid = TDMCreate_CleanVars($_REQUEST, 'field_mid');
$field_tid = TDMCreate_CleanVars($_REQUEST, 'field_tid');
$field_numb = TDMCreate_CleanVars($_REQUEST, 'field_numb');
$field_name = TDMCreate_CleanVars($_REQUEST, 'field_name', '', 'string');
-/*$field_id = TDMCreateRequest::getInt('field_id');
-$field_mid = TDMCreateRequest::getInt('field_mid');
+$field_id = TDMCreateRequest::getInt('field_id');
+/*$field_mid = TDMCreateRequest::getInt('field_mid');
$field_tid = TDMCreateRequest::getInt('field_tid');
$field_numb = TDMCreateRequest::getInt('field_numb');
$field_name = TDMCreateRequest::getString('field_name', ''); */
@@ -72,8 +73,8 @@
unset($nb_tables);
// Get the list of tables
$criteria = new CriteriaCompo();
- $criteria->add(new Criteria('table_mid', $table_mid));
- $criteria->add(new Criteria('table_id', $table_id));
+ $criteria->add(new Criteria('table_mid', $field_mid));
+ $criteria->add(new Criteria('table_id', $field_tid));
$criteria->setSort('table_id ASC, table_name');
$criteria->setOrder('ASC');
$nb_tables = $tablesHandler->getCount($criteria);
@@ -82,25 +83,27 @@
if ($nb_tables > 0)
{
foreach (array_keys($tables_arr) as $t)
- {
+ {
+ // Display tables list
$table['id'] = $t;
- $table['name'] = ucfirst($tables_arr[$t]->getVar('table_name'));
+ $table['mid'] = $tables_arr[$t]->getVar('table_mid');
+ $table['name'] = ucfirst($tables_arr[$t]->getVar('table_name'));
$table['image'] = $tables_arr[$t]->getVar('table_image');
$table['nbfields'] = $tables_arr[$t]->getVar('table_nbfields');
$table['blocks'] = $tables_arr[$t]->getVar('table_blocks');
$table['admin'] = $tables_arr[$t]->getVar('table_admin');
$table['user'] = $tables_arr[$t]->getVar('table_user');
$table['search'] = $tables_arr[$t]->getVar('table_search');
- // Get the list of tables
+ // Get the list of fields
$criteria = new CriteriaCompo();
- $criteria->add(new Criteria('field_mid', $table_mid));
+ $criteria->add(new Criteria('field_mid', $field_mid));
$criteria->add(new Criteria('field_tid', $t));
$criteria->setSort('field_id ASC, field_name');
$criteria->setOrder('ASC');
$nb_fields = $fieldsHandler->getCount($criteria);
$fields_arr = $fieldsHandler->getAll($criteria);
unset($criteria);
- // Display tables list
+ // Display fields list
$fields = array();
$lid = 1;
if ( $nb_fields > 0 )
@@ -157,15 +160,20 @@
if ( !$GLOBALS['xoopsSecurity']->check() ) {
redirect_header('fields.php', 3, implode(',', $GLOBALS['xoopsSecurity']->getErrors()));
}
+ $fieldelement_fid = $field_id = TDMCreateRequest::getInt('fieldelement_fid');
//
- if (isset($field_id)) {
+ if (isset($field_id)) {
$obj =& $fieldsHandler->get($field_id);
+ if (isset($fieldelement_fid)) {
+ $objfieldelement =& $fieldelementsHandler->get($fieldelement_fid);
+ }
} else {
$obj =& $fieldsHandler->create();
- }
- //
+ $objfieldelement =& $fieldelementsHandler->create();
+ }
if ($field_numb > 0) {
- for( $i = 1; $i <= $field_numb; $i++ ) {
+ for( $i = 1; $i <= $field_numb; $i++ ) {
+ //
$obj->setVar( 'field_mid', $field_mid );
$obj->setVar( 'field_tid', $field_tid );
$obj->setVar( 'field_numb', $field_numb );
@@ -190,6 +198,10 @@
$fieldsHandler->insert($obj);
}
}
+ $objfieldelement->setVar( 'fieldelement_name', 'Table : '.$_REQUEST['table_name'] );
+ $objfieldelement->setVar( 'fieldelement_value', 'XoopsFormTables-'.$_REQUEST['table_name'] );
+ // Insert new table name
+ $fieldelementsHandler->insert($objfieldelement);
//
if ($obj->isNew()) {
redirect_header('fields.php', 2, sprintf(_AM_TDMCREATE_FIELD_FORM_SAVED_OK, $_REQUEST['table_name']));
@@ -209,11 +221,32 @@
$adminMenu->addItemButton(_AM_TDMCREATE_ADD_TABLE, 'tables.php?op=new', 'add');
$adminMenu->addItemButton(_AM_TDMCREATE_TABLES_LIST, 'tables.php', 'list');
$adminMenu->addItemButton(_AM_TDMCREATE_FIELDS_LIST, 'fields.php', 'list');
- $GLOBALS['xoopsTpl']->assign('buttons', $adminMenu->renderButton());
+ $GLOBALS['xoopsTpl']->assign('buttons', $adminMenu->renderButton());
$obj = $fieldsHandler->get( $field_id );
$form = $obj->getForm($field_mid, $field_tid, $field_numb);
$GLOBALS['xoopsTpl']->assign('form', $form->render());
+
+ // Get the list of fields
+ $criteria = new CriteriaCompo();
+ $criteria->add(new Criteria('field_mid', $field_mid));
+ $criteria->add(new Criteria('field_tid', $field_tid));
+ $criteria->setSort('field_id ASC, field_name');
+ $criteria->setOrder('ASC');
+ $nb_fields = $fieldsHandler->getCount($criteria);
+ $fields_arr = $fieldsHandler->getAll($criteria);
+ unset($criteria);
+ if ( $nb_fields > 0 )
+ {
+ foreach (array_keys($fields_arr) as $f)
+ {
+ $field_id = $fields_arr[$f]->getVar('field_id');
+ var_dump($field_id);
+ }
+ }
+ var_dump($field_mid);
+ var_dump($field_tid);
+ var_dump($field_numb);
break;
case 'drag':
Modified: XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/admin/modules.php
===================================================================
--- XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/admin/modules.php 2014-05-14 20:51:54 UTC (rev 12533)
+++ XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/admin/modules.php 2014-05-16 14:20:30 UTC (rev 12534)
@@ -32,6 +32,7 @@
$limit = TDMCreateRequest::getInt('limit', $tdmcreate->getConfig('modules_adminpager'));
// Define main template
$template_main = 'modules.tpl';
+ $GLOBALS['xoTheme']->addScript('modules/TDMCreate/js/functions.js');
$GLOBALS['xoTheme']->addStylesheet( 'modules/TDMCreate/css/admin/style.css' );
$GLOBALS['xoopsTpl']->assign('navigation', $adminMenu->addNavigation('modules.php'));
$adminMenu->addItemButton(_AM_TDMCREATE_ADD_MODULE, 'modules.php?op=new', 'add');
@@ -197,33 +198,33 @@
case 'toggle':
if (isset($_GET['mod_id'])) {
if (isset($_GET['mod_admin'])) {
- $mod_admin = intval($_GET['mod_admin']);
- $mod_admin = ($mod_admin == 1) ? 0 : 1;
+ $madmin = intval($_GET['mod_admin']);
+ $mod_admin = ($madmin == 1) ? 0 : 1;
$obj =& $modulesHandler->get($mod_id);
$obj->setVar('mod_admin', $mod_admin);
} elseif (isset($_GET['mod_user'])) {
- $mod_user = intval($_GET['mod_user']);
- $mod_user = ($mod_user == 1) ? 0 : 1;
+ $muser = intval($_GET['mod_user']);
+ $mod_user = ($muser == 1) ? 0 : 1;
$obj =& $modulesHandler->get($mod_id);
$obj->setVar('mod_user', $mod_user);
} elseif (isset($_GET['mod_search'])) {
- $mod_search = intval($_GET['mod_search']);
- $mod_search = ($mod_search == 1) ? 0 : 1;
+ $msearch = intval($_GET['mod_search']);
+ $mod_search = ($msearch == 1) ? 0 : 1;
$obj =& $modulesHandler->get($mod_id);
$obj->setVar('mod_search', $mod_search);
} elseif (isset($_GET['mod_comments'])) {
- $mod_comments = intval($_GET['mod_comments']);
- $mod_comments = ($mod_comments == 1) ? 0 : 1;
+ $mcomments = intval($_GET['mod_comments']);
+ $mod_comments = ($mcomments == 1) ? 0 : 1;
$obj =& $modulesHandler->get($mod_id);
$obj->setVar('mod_comments', $mod_comments);
} elseif (isset($_GET['mod_notifications'])) {
- $mod_notifications = intval($_GET['mod_notifications']);
- $mod_notifications = ($mod_notifications == 1) ? 0 : 1;
+ $mnotifications = intval($_GET['mod_notifications']);
+ $mod_notifications = ($mnotifications == 1) ? 0 : 1;
$obj =& $modulesHandler->get($mod_id);
$obj->setVar('mod_notifications', $mod_notifications);
} elseif (isset($_GET['mod_permissions'])) {
- $mod_permissions = intval($_GET['mod_permissions']);
- $mod_permissions = ($mod_permissions == 1) ? 0 : 1;
+ $mpermissions = intval($_GET['mod_permissions']);
+ $mod_permissions = ($mpermissions == 1) ? 0 : 1;
$obj =& $modulesHandler->get($mod_id);
$obj->setVar('mod_permissions', $mod_permissions);
}
Modified: XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/admin/tables.php
===================================================================
--- XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/admin/tables.php 2014-05-14 20:51:54 UTC (rev 12533)
+++ XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/admin/tables.php 2014-05-16 14:20:30 UTC (rev 12534)
@@ -171,7 +171,7 @@
$tdmcreate->getConfig('maxsize'), null, null);
if ($uploader->fetchMedia($_POST['xoops_upload_file'][0])) {
$extension = preg_replace( '/^.+\.([^.]+)$/sU' , '\\1' , $_FILES['table_image']['name']);
- $name_img = $_GET['table_name'].'.'.$extension;
+ $name_img = $_POST['table_name'].'.'.$extension;
$uploader->setPrefix($name_img);
$uploader->fetchMedia($_POST['xoops_upload_file'][0]);
if (!$uploader->upload()) {
Modified: XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/class/fieldelements.php
===================================================================
--- XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/class/fieldelements.php 2014-05-14 20:51:54 UTC (rev 12533)
+++ XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/class/fieldelements.php 2014-05-16 14:20:30 UTC (rev 12534)
@@ -32,11 +32,10 @@
* @param null
*/
public function __construct()
- {
- $this->htmltable = TDMCreateHtmlTable::getInstance();
- $this->initVar('fieldelement_fid', XOBJ_DTYPE_INT);
+ {
+ $this->initVar('fieldelement_fid', XOBJ_DTYPE_INT);
+ $this->initVar('fieldelement_name', XOBJ_DTYPE_TXTBOX);
$this->initVar('fieldelement_value', XOBJ_DTYPE_TXTBOX);
- $this->initVar('fieldelement_name', XOBJ_DTYPE_TXTBOX);
}
/**
Modified: XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/class/fields.php
===================================================================
--- XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/class/fields.php 2014-05-14 20:51:54 UTC (rev 12533)
+++ XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/class/fields.php 2014-05-16 14:20:30 UTC (rev 12534)
@@ -142,22 +142,35 @@
$obj = $fieldsHandler->getObjects(null);
+ // Get the list of fields
+ $criteria = new CriteriaCompo();
+ $criteria->add(new Criteria('field_mid', $field_mid));
+ $criteria->add(new Criteria('field_tid', $field_tid));
+ $criteria->setSort('field_id ASC, field_name');
+ $criteria->setOrder('ASC');
+ $fields_arr = $fieldsHandler->getAll($criteria);
+ unset($criteria);
+
$class = '';
for($i = 1; $i <= $field_numb; $i++)
{
+ $form->addElement(new XoopsFormHidden('field_id['.$i.']', $i));
+ $form->addElement(new XoopsFormHidden('field_mid', $field_mid));
+ $form->addElement(new XoopsFormHidden('field_tid', $field_tid));
+
$class = ($class == 'even') ? 'odd' : 'even';
$form->addElement(new TDMCreateFormLabel('<tr class="'.$class.'">'));
- // Index ID
+ // Index ID
$form->addElement(new TDMCreateFormLabel('<td class="center">'.$i.'</td>'));
- // Field Name
+ // 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);
$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->addOptionArray($fieldtypeHandler->getList());
+ $fieldtype_select->addOptionArray($fieldtypeHandler->getList());
$form->addElement(new TDMCreateFormLabel('<td class="center">'.$fieldtype_select->render().'</td>'));
- // Field Value
+ // Field Value
$field_value = new XoopsFormText(_AM_TDMCREATE_FIELD_VALUE, 'field_value['.$i.']', 5, 20, $this->getVar('field_value'));
$form->addElement(new TDMCreateFormLabel('<td class="center">'.$field_value->render().'</td>'));
// Field Attributes
@@ -181,10 +194,10 @@
$form->addElement(new TDMCreateFormLabel('<td> </td></tr>'));
} else {
// Box header row
- $parameters_tray = new XoopsFormElementTray('', '<br />');
+ $parameters_tray = new XoopsFormElementTray('', '<br />');
// Field Elements
$field_elements_select = new XoopsFormSelect(_AM_TDMCREATE_FIELD_ELEMENT_NAME, 'field_element['.$i.']', $this->getVar('field_element'));
- $field_elements_select->addOptionArray($fieldelementsHandler->getList());
+ $field_elements_select->addOptionArray($fieldelementsHandler->getList());
$criteria = new CriteriaCompo(new Criteria('table_id', $f_tid));
$criteria->add(new Criteria('table_mid', $f_mid));
$criteria->setSort('table_name');
@@ -199,10 +212,10 @@
}
}
$parameters_tray->addElement($field_elements_select);
-
- $field_parent = $isNew ? ( $i == 1 ) : $this->getVar('field_parent');
- $check_field_parent = new XoopsFormRadio(' ', 'field_parent', $field_parent);
- $check_field_parent->addOption('', _AM_TDMCREATE_FIELD_PARENT );
+
+ $field_parent = $isNew ? ( $i == 1 ? 1 : 0 ) : $this->getVar('field_parent');
+ $check_field_parent = new XoopsFormCheckBox(' ', 'field_parent', $field_parent);
+ $check_field_parent->addOption($i, _AM_TDMCREATE_FIELD_PARENT );
$parameters_tray->addElement($check_field_parent);
$field_inlist = $isNew ? 0 : $this->getVar('field_inlist');
@@ -230,7 +243,7 @@
$check_field_block->addOption(1, _AM_TDMCREATE_FIELD_BLOCK);
$parameters_tray->addElement($check_field_block);
- $field_main = $isNew ? ( $i == 1 ) : $this->getVar('field_main');
+ $field_main = $isNew ? ( $i == 1 ? 1 : 0 ) : $this->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);
@@ -246,12 +259,9 @@
$parameters_tray->addElement($check_field_required);
$form->addElement(new TDMCreateFormLabel('<td>'.$parameters_tray->render().'</td></tr>'));
- }
- $form->addElement(new XoopsFormHidden('field_id['.$i.']', $i));
- $form->addElement(new XoopsFormHidden('field_mid', $field_mid));
- $form->addElement(new XoopsFormHidden('field_tid', $field_tid));
+ }
}
-
+
$form->addElement(new TDMCreateFormLabel('</tbody>'));
$form->addElement(new TDMCreateFormLabel('<tfoot><tr>'));
$form_hidden = new XoopsFormHidden('op', 'save');
@@ -323,7 +333,18 @@
public function &get($id)
{
return parent::get($id);
- }
+ }
+
+ /**
+ * get IDs of objects matching a condition
+ *
+ * @param object $criteria {@link CriteriaElement} to match
+ * @return array of object IDs
+ */
+ function &getIds($criteria)
+ {
+ return parent::getIds($criteria);
+ }
/**
* insert a new field in the database
Modified: XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/class/files/abstractfiles.php
===================================================================
--- XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/class/files/abstractfiles.php 2014-05-14 20:51:54 UTC (rev 12533)
+++ XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/class/files/abstractfiles.php 2014-05-16 14:20:30 UTC (rev 12534)
@@ -16,7 +16,7 @@
* @package tdmcreate
* @since 2.5.0
* @author Txmod Xoops http://www.txmodxoops.org
- * @version $Id: headerfiles.php 12258 2014-01-02 09:33:29Z timgno $
+ * @version $Id: abstractfiles.php 12258 2014-01-02 09:33:29Z timgno $
*/
defined('XOOPS_ROOT_PATH') or die('Restricted access');
@@ -69,21 +69,12 @@
private $folder = null;
/**
- * "file_name" attribute of the files
+ * "filename" attribute of the files
*
* @var mixed
*/
- private $file_name = null;
-
- /**
- * Generates output for the files.
- *
- * This method is abstract and must be overwritten by the child classes.
- *
- * @abstract
- */
- abstract function render();
-
+ private $filename = null;
+
/*
* @public function getHeader
* @param string $path
@@ -91,231 +82,21 @@
* @param string $folder
* @param string $file_name
*/
- public function getHeader($path, $module, $folder, $file_name) {
+ public function getHeader($path, $module, $folder, $filename) {
$this->path = $path;
$this->folder = $folder;
$this->module = $module;
- $this->file_name = $file_name;
- $ret = $this->path . DIRECTORY_SEPARATOR . $this->module . DIRECTORY_SEPARATOR . $this->folder . DIRECTORY_SEPARATOR . $this->file_name;
+ $this->filename = $filename;
+ $ret = $this->path . DIRECTORY_SEPARATOR . $this->module . DIRECTORY_SEPARATOR . $this->folder . DIRECTORY_SEPARATOR . $this->filename;
return $ret;
- }
+ }
- /*
- * @private function setPath
- * @param string $path
- */
- private function setPath($path) {
- $this->path = $path;
- }
-
- /*
- * @private function getPath
- * @param null
- */
- private function getPath() {
- return $this->path;
- }
-
- /*
- * @public function getLocalPath
- * @param mixed $subdir
- */
- public function getLocalPath($subdir = false)
- {
- if ($subdir) {
- $ret = $this->getUploadPath() . DIRECTORY_SEPARATOR . $this->getModuleName() . DIRECTORY_SEPARATOR . $subdir;
- } else {
- $ret = $this->getUploadPath() . DIRECTORY_SEPARATOR . $this->getModuleName();
- }
- return $ret;
- }
-
- /*
- * @private function setUploadPath
- * @param string $upload_path
- */
- private function setUploadPath($upload_path) {
- $this->upload_path = $upload_path;
- }
-
- /*
- * @public function getUploadPath
- * @param null
- */
- public function getUploadPath()
- {
- return $this->upload_path;
- }
-
- /**
- * public function setFileName
- * @param mixed $module
+ /**
+ * Generates output for the files.
+ *
+ * This method is abstract and must be overwritten by the child classes.
+ *
+ * @abstract
*/
- public function setModule($module)
- {
- $this->module = $module;
- }
-
- /*
- * @public function getModule
- * @param null
- */
- public function getModule()
- {
- return $this->module;
- }
-
- /**
- * public function setFileName
- * @param mixed $file_name
- */
- public function setFileName($file_name)
- {
- $this->file_name = $file_name;
- }
-
- /*
- * @public function getFileName
- * @param null
- */
- public function getFileName()
- {
- return $this->file_name;
- }
-
- /*
- * @public function getModuleName
- * @param null
- */
- public function getModuleName() {
- $ret = $this->module->getVar('mod_name');
- return $ret;
- }
-
- /**
- * public function setTable
- * @param mixed $table
- */
- public function setTable($table)
- {
- if (is_array($table)) {
- foreach($table as $t) {
- $this->table[] = $t;
- }
- } elseif (is_array($this->table)) {
- $this->table[] = $table;
- } else {
- $this->table = $table;
- }
- }
-
- /*
- * @public function getTable
- * @param null
- */
- public function getTable() {
- if (is_array($this->table)) {
- $ret = array();
- foreach ($this->table as $table) {
- $ret[] = $table;
- }
- return $ret;
- }
- }
-
- /**
- * @public function setFields
- * @param mixed $fields
- */
- public function setFields($fields)
- {
- if (is_array($fields)) {
- foreach($fields as $f) {
- $this->fields[] = $f;
- }
- } elseif (is_array($this->fields)) {
- $this->fields[] = $fields;
- } else {
- $this->fields = $fields;
- }
- }
-
- /*
- * @public function getFields
- * @param null
- */
- public function getFields() {
- if (is_array($this->fields)) {
- $ret = array();
- foreach ($this->fields as $fields) {
- $ret[] = $fields;
- }
- return $ret;
- }
- }
-
- /*
- * @public function getLanguage
- * @param string $prefix
- * @param string $postfix
- */
- public function getLanguage($prefix = '', $postfix = '') {
- $lang = '_' . $prefix . '_' . strtoupper($this->module->getVar('mod_name'));
- if(!empty($postfix) || $postfix != '_') {
- $ret = $lang . '_' . $postfix;
- } elseif($postfix == '_') {
- $ret = $lang . '_';
- } else {
- $ret = $lang;
- }
- return $ret;
- }
-
- /*
- * @public function getHeaderFilesComments
- * @param string $module
- * @param string $file_name
- */
- public function getHeaderFilesComments($module, $file_name) {
- $this->module = $module;
- $this->file_name = $file_name;
-
- $mod_name = $this->module->getVar('mod_name');
- $mod_version = $this->module->getVar('mod_version');
- $mod_since = $this->module->getVar('mod_since');
- $mod_min_xoops = $this->module->getVar('mod_min_xoops');
- $mod_author = $this->module->getVar('mod_author');
- $mod_credits = $this->module->getVar('mod_credits');
- $mod_author_mail = $this->module->getVar('mod_author_mail');
- $mod_author_website_url = $this->module->getVar('mod_author_website_url');
- $mod_license = $this->module->getVar('mod_license');
- $mod_subversion = $this->module->getVar('mod_subversion');
- $date = date('D Y/m/d G:i:s');
- $package = strtolower($mod_name);
-
- $ret = <<<EOT
-<?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.
-*/
-/**
- * {$mod_name} module for xoops
- *
- * @copyright The XOOPS Project http://sourceforge.net/projects/xoops/
- * @license {$mod_license}
- * @package {$package}
- * @since {$mod_since}
- * @min_xoops {$mod_min_xoops}
- * @author {$mod_author} <{$mod_author_mail}> - <{$mod_author_website_url}>
- * @version \$Id: {$mod_version} {$file_name} {$mod_subversion} {$date}Z {$mod_credits} \$
- */\n
-EOT;
- return $ret;
- }
+ public function render() {}
}
\ No newline at end of file
Added: XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/class/files/admin_about.php
===================================================================
--- XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/class/files/admin_about.php (rev 0)
+++ XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/class/files/admin_about.php 2014-05-16 14:20:30 UTC (rev 12534)
@@ -0,0 +1,71 @@
+<?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: 1.91 admin_about.php 12258 2014-01-02 09:33:29Z timgno $
+ */
+defined('XOOPS_ROOT_PATH') or die('Restricted access');
+
+class AdminAbout extends TDMCreateFile
+{
+ /*
+ * @var string
+ */
+ private $tdmcfile = null;
+
+ /*
+ * @public function constructor
+ * @param string $modules
+ * @param string $filename
+ */
+ public function __construct($module, $filename) {
+ $this->tdmcfile = TDMCreateFile::getInstance();
+ $this->setModule($module);
+ $this->setFileName($filename);
+ }
+ /*
+ * @static function &getInstance
+ * @param null
+ */
+ public static function &getInstance($module, $filename)
+ {
+ static $instance = false;
+ if (!$instance) {
+ $instance = new self($module, $filename);
+ }
+ return $instance;
+ }
+ /*
+ * @public function render
+ * @param null
+ */
+ public function render() {
+ $module = $this->getModule();
+ $filename = $this->getFileName();
+ $module_name = strtolower($module->getVar('mod_name'));
+ $module_donations = $module->getVar('mod_donations');
+ $content = $this->getHeaderFilesComments($module, $filename);
+ $content .= <<<EOT
+include 'header.php';
+echo \$adminMenu->addNavigation('about.php');
+echo \$adminMenu->renderAbout('$module_donations', false);
+include 'footer.php';
+EOT;
+ $this->tdmcfile->create($module_name, 'admin', $filename, $content, _AM_TDMCREATE_FILE_CREATED, _AM_TDMCREATE_FILE_NOTCREATED);
+ return $this->tdmcfile->renderFile();
+ }
+}
\ No newline at end of file
Modified: XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/class/files/admin_footer.php
===================================================================
--- XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/class/files/admin_footer.php 2014-05-14 20:51:54 UTC (rev 12533)
+++ XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/class/files/admin_footer.php 2014-05-16 14:20:30 UTC (rev 12534)
@@ -16,7 +16,7 @@
* @package tdmcreate
* @since 2.5.0
* @author Txmod Xoops http://www.txmodxoops.org
- * @version $Id: admin_footer.php 12258 2014-01-02 09:33:29Z timgno $
+ * @version $Id: 1.91 admin_footer.php 12258 2014-01-02 09:33:29Z timgno $
*/
defined('XOOPS_ROOT_PATH') or die('Restricted access');
@@ -26,26 +26,40 @@
* @var string
*/
private $tdmcfile = null;
+
/*
* @public function constructor
* @param string $modules
+ * @param string $filename
*/
- public function __construct($module, $file_name) {
+ public function __construct($module, $filename) {
$this->tdmcfile = TDMCreateFile::getInstance();
$this->setModule($module);
- $this->setFileName($file_name);
- }
+ $this->setFileName($filename);
+ }
/*
+ * @static function &getInstance
+ * @param null
+ */
+ public static function &getInstance($module, $filename)
+ {
+ static $instance = false;
+ if (!$instance) {
+ $instance = new self($module, $filename);
+ }
+ return $instance;
+ }
+ /*
* @public function render
* @param null
*/
- public function render() {
- $path = $this->getLocalPath('admin');
+ public function render() {
$module = $this->getModule();
$filename = $this->getFileName();
+ $module_name = strtolower($module->getVar('mod_name'));
$support_name = $module->getVar('mod_support_name');
$support_url = $module->getVar('mod_support_url');
- $language = $this->getLanguage('AM');
+ $language = $this->getLanguage($module_name, 'AM');
$content = $this->getHeaderFilesComments($module, $filename);
$content .= <<<EOT
\necho "<div class='center'><a href='http://www.xoops.org' title='Visit XOOPS' target='_blank'>
@@ -55,7 +69,7 @@
<a href='{$support_url}' title='Visit {$support_name}' class='tooltip' rel='external'>{$support_name}</a></div>";
xoops_cp_footer();
EOT;
- $this->tdmcfile->create($path, $filename, $content, _AM_TDMCREATE_FILE_CREATED, _AM_TDMCREATE_FILE_NOTCREATED);
+ $this->tdmcfile->create($module_name, 'admin', $filename, $content, _AM_TDMCREATE_FILE_CREATED, _AM_TDMCREATE_FILE_NOTCREATED);
return $this->tdmcfile->renderFile();
}
}
\ No newline at end of file
Modified: XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/class/files/admin_header.php
===================================================================
--- XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/class/files/admin_header.php 2014-05-14 20:51:54 UTC (rev 12533)
+++ XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/class/files/admin_header.php 2014-05-16 14:20:30 UTC (rev 12534)
@@ -36,19 +36,30 @@
$this->setModule($module);
$this->setTable($table);
$this->setFileName($file_name);
- }
+ }
/*
+ * @static function &getInstance
+ * @param null
+ */
+ public static function &getInstance($module, $table, $file_name)
+ {
+ static $instance = false;
+ if (!$instance) {
+ $instance = new self($module, $table, $file_name);
+ }
+ return $instance;
+ }
+ /*
* @public function render
* @param null
*/
public function render() {
- $path = $this->getLocalPath('admin');
$module = $this->getModule();
$filename = $this->getFileName();
$module_name = $module->getVar('mod_name');
+ $table = $this->getTable();
$stl_mod_name = strtolower($module_name);
- $ucfmod_name = ucfirst($module_name);
-
+ $ucfmod_name = ucfirst($module_name);
$language = $this->getLanguage('AM');
$content = $this->getHeaderFilesComments($module, $filename);
$content .= <<<EOT
@@ -57,7 +68,7 @@
include_once \$thisPath.'/include/common.php';
include_once \$thisPath.'/include/functions.php';
EOT;
- if ( $this->getTable()->getVar('table_name') != '' ) {
+ if ( $table->getVar('table_name') != '' ) {
$content .= <<<EOT
\ninclude_once \$thisPath.'/class/helper.php';
// Get instance
@@ -74,9 +85,9 @@
\$modPathIcon16 = \$xoopsModule->getInfo('modicons16');
\$modPathIcon32 = \$xoopsModule->getInfo('modicons32');\n
EOT;
- foreach (array_keys($this->table) as $i)
+ foreach (array_keys($table) as $i)
{
- $table_name = $this->table[$i]->getVar('table_name');
+ $table_name = $table[$i]->getVar('table_name');
$content .= '$'.$table_name.'Handler =& xoops_getModuleHandler(\''.$table_name. '\', $thisModule);'.PHP_EOL;
}
$content .=<<<EOT
@@ -105,7 +116,7 @@
xoops_cp_header();
\$adminMenu = new ModuleAdmin();
EOT;
- $this->tdmcfile->create($path, $filename, $content, _AM_TDMCREATE_FILE_CREATED, _AM_TDMCREATE_FILE_NOTCREATED);
+ $this->tdmcfile->create($module_name, 'admin', $filename, $content, _AM_TDMCREATE_FILE_CREATED, _AM_TDMCREATE_FILE_NOTCREATED);
return $this->tdmcfile->renderFile();
}
}
\ No newline at end of file
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-05-14 20:51:54 UTC (rev 12533)
+++ XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/class/files/admin_index.php 2014-05-16 14:20:30 UTC (rev 12534)
@@ -39,6 +39,18 @@
$this->setFileName($file_name);
}
/*
+ * @static function &getInstance
+ * @param null
+ */
+ public static function &getInstance($module, $table, $file_name)
+ {
+ static $instance = false;
+ if (!$instance) {
+ $instance = new self($module, $table, $file_name);
+ }
+ return $instance;
+ }
+ /*
* @public function render
* @param null
*/
Modified: XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/class/files/architecture.php
===================================================================
--- XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/class/files/architecture.php 2014-05-14 20:51:54 UTC (rev 12533)
+++ XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/class/files/architecture.php 2014-05-16 14:20:30 UTC (rev 12534)
@@ -20,11 +20,23 @@
*/
defined('XOOPS_ROOT_PATH') or die('Restricted access');
require_once 'structure.php';
+require_once 'file.php';
+require_once 'admin_about.php';
+require_once 'admin_footer.php';
+require_once 'admin_header.php';
+require_once 'admin_index.php';
+require_once 'admin_menu.php';
+require_once 'css_styles.php';
+require_once 'include_functions.php';/**/
class TDMCreateArchitecture
{
/*
* @var mixed
*/
+ private $tdmcreate = null;
+ /*
+ * @var mixed
+ */
private $structure = null;
/*
* @var mixed
@@ -39,20 +51,21 @@
* @param null
*/
public function __construct() {
+ $this->tdmcreate = TDMCreate::getInstance();
$this->structure = TDMCreateStructure::getInstance();
}
/*
* @private 'magic method' function __autoload classes
* @param string $class_name
*/
- private function __autoload($class_name) {
- $filename = './'. $class_name . '.php';
- if (file_exists($filename)) {
+ protected function __autoload($class_name) {
+ $filename = $class_name . '.php';
+ if (is_readable($filename)) {
include_once $filename;
return true;
}
return false;
- }
+ }
/*
* @static function &getInstance
* @param null
@@ -80,10 +93,10 @@
$this->upload_path = $path;
}
/*
- * @public function getArchitectureFiles
+ * @public function createBaseFoldersFiles
* @param string $module
*/
- public function getArchitectureFiles( $module )
+ public function createBaseFoldersFiles( $module )
{
$indexFile = $this->path.'/index.html';
$docs_folder = $this->path.'/docs';
@@ -158,11 +171,48 @@
}
/*
- * @public function getBuildingFiles
- * @param string $module
+ * @public function createBuildingFiles
+ * @param string $module
+ * @param string $table
*/
- public function getBuildingFiles( $module, $table )
+ public function createBuildingFiles( $module, $table )
{
- //spl_autoload_register('__autoload');
+ $ret = '';
+ // Admin Aboutr File
+ $adminAbout = AdminAbout::getInstance($module, 'about.php');
+ $admin_about = $adminAbout->render();
+ // Admin Footer File
+ $adminFooter = AdminFooter::getInstance($module, 'footer.php');
+ $admin_footer = $adminFooter->render();
+ // Admin Header File
+ //$adminHeader = AdminHeader::getInstance($module, $table, 'header.php');
+ // Admin Index File
+ //$adminIndex = AdminIndex::getInstance($module, $table, 'index.php');
+ // Admin Menu File
+ //$adminMenu = AdminMenu::getInstance($module, $table, 'menu.php');
+ // Admin Styles File
+ $cssStyles = CssStyles::getInstance($module, 'style.css');
+ // Admin Functions File
+ $includeFunctions = IncludeFunctions::getInstance($module, 'functions.php');
+
+ /*foreach (array_keys($tables_arr) as $i)
+ {
+
+ }*/
+ return array('admin_about' => $admin_about, 'admin_footer' => $admin_footer,//return $ret;
+ //'admin_header' => $adminHeader->render(), 'admin_index' => $adminIndex->render(),
+ //'admin_menu' => $adminMenu->render(), 'admin_footer' => $adminFooter->render(),
+ //'admin_footer' => $adminFooter->render(), 'admin_footer' => $adminFooter->render(),
+ //'admin_footer' => $adminFooter->render(), 'admin_footer' => $adminFooter->render(),
+ //'admin_footer' => $adminFooter->render(), 'admin_footer' => $adminFooter->render(),
+ //'admin_footer' => $adminFooter->render(), 'admin_footer' => $adminFooter->render(),
+ //'admin_footer' => $adminFooter->render(), 'admin_footer' => $adminFooter->render(),
+ //'admin_footer' => $adminFooter->render(), 'admin_footer' => $adminFooter->render(),
+ //'admin_footer' => $adminFooter->render(), 'admin_footer' => $adminFooter->render(),
+ //'admin_footer' => $adminFooter->render(), 'admin_footer' => $adminFooter->render(),
+ //'admin_footer' => $adminFooter->render(), 'admin_footer' => $adminFooter->render(),
+ //'admin_footer' => $adminFooter->render(), 'admin_footer' => $adminFooter->render(),
+ //'admin_footer' => $adminFooter->render(), 'admin_footer' => $adminFooter->render(),
+ 'css_style' => $cssStyles->render()/* , 'include_functions' => $includeFunctions->render()*/);
}
}
\ No newline at end of file
Modified: XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/class/files/css_styles.php
===================================================================
--- XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/class/files/css_styles.php 2014-05-14 20:51:54 UTC (rev 12533)
+++ XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/class/files/css_styles.php 2014-05-16 14:20:30 UTC (rev 12534)
@@ -16,7 +16,7 @@
* @package tdmcreate
* @since 2.5.0
* @author Txmod Xoops http://www.txmodxoops.org
- * @version $Id: css_styles.php 12258 2014-01-02 09:33:29Z timgno $
+ * @version $Id: 1.91 css_styles.php 12258 2014-01-02 09:33:29Z timgno $
*/
defined('XOOPS_ROOT_PATH') or die('Restricted access');
@@ -29,23 +29,37 @@
/*
* @public function constructor
* @param string $module
- * @param string $file_name
+ * @param string $filename
*/
- public function __construct($module, $file_name) {
+ public function __construct($module, $filename) {
$this->tdmcfile = TDMCreateFile::getInstance();
$this->setModule($module);
- $this->setFileName($file_name);
- }
+ $this->setFileName($filename);
+ }
+
/*
+ * @static function &getInstance
+ * @param null
+ */
+ public static function &getInstance($module, $filename)
+ {
+ static $instance = false;
+ if (!$instance) {
+ $instance = new self($module, $filename);
+ }
+ return $instance;
+ }
+
+ /*
* @public function render
* @param null
*/
public function render() {
- $path = $this->getLocalPath('css');
$module = $this->getModule();
$filename = $this->getFileName();
- $module_name = $module->getVar('mod_name');
- $content <<<EOT
+ $module_name = strtolower($module->getVar('mod_name'));
+ $content = $this->getHeaderFilesComments($module, $filename);
+ $content .= <<<EOT
table {
margin: 0;
}
@@ -73,9 +87,8 @@
list-style-type: none;
list-style-image: none;
}
-
EOT;
- $this->tdmcfile->create($path, $filename, $content, _AM_TDMCREATE_FILE_CREATED, _AM_TDMCREATE_FILE_NOTCREATED);
+ $this->tdmcfile->create($module_name, $filename, $content, 'css', _AM_TDMCREATE_FILE_CREATED, _AM_TDMCREATE_FILE_NOTCREATED);
return $this->tdmcfile->renderFile();
}
}
\ No newline at end of file
Modified: XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/class/files/file.php
===================================================================
--- XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/class/files/file.php 2014-05-14 20:51:54 UTC (rev 12533)
+++ XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/class/files/file.php 2014-05-16 14:20:30 UTC (rev 12534)
@@ -20,13 +20,49 @@
*/
defined('XOOPS_ROOT_PATH') or die('Restricted access');
-class TDMCreateFile extends TDMCreateAbstractFiles
-{
+require_once 'abstractfiles.php';
+xoops_load('XoopsFile');
+class TDMCreateFile extends TDMCreateAbstractFiles {
/*
* @var string
*/
- private $xoopsfile = null;
+ private $xoopsfile = null;
+
+ /**
+ * "module" attribute of the files
+ *
+ * @var mixed
+ */
+ private $module = null;
+
+ /**
+ * "filename" attribute of the files
+ *
+ * @var mixed
+ */
+ private $filename = null;
+
+ /**
+ * "path" attribute of the files
+ *
+ * @var string
+ */
+ private $path = null;
+ /**
+ * "upload_path" attribute of the files
+ *
+ * @var string
+ */
+ private $upload_path = null;
+
+ /**
+ * "subdir" attribute of the files
+ *
+ * @var string
+ */
+ private $subdir = null;
+
/*
* @var string
*/
@@ -68,23 +104,170 @@
}
/*
- * @public function constructor
+ * @public function create
+ * @param string $module_name
+ * @param string $filename
* @param string $content
+ * @param mixed $created
+ * @param mixed $notcreated
+ * @param string $mode
*/
- public function create($path, $file_name, $content = '', $created = false, $notcreated = false, $mode = 'w+') {
- $this->setFileName($file_name);
+ public function create($module_name, $subdir = null, $filename, $content = '', $created = false, $notcreated = false, $mode = 'w+') {
+ $this->setFileName($filename);
$this->created = $created;
$this->notcreated = $notcreated;
$this->setMode($mode);
- if(isset($path)){
- $this->setUploadPath($path);
- }
- if(!empty($content) && is_string($content)){
+ $this->setModulePath($module_name);
+ if(!empty($content) && is_string($content)) {
$this->setContent($content);
+ }
+ if((!empty($subdir) || $subdir != null) && is_string($subdir)) {
+ $this->setSubDir($subdir);
}
- }
+ }
/*
+ * @private function setPath
+ * @param string $folder_name
+ */
+ private function setPath($folder_name) {
+ $this->path = TDMC_PATH . DIRECTORY_SEPARATOR . $folder_name;
+ }
+
+ /*
+ * @private function getPath
+ * @param null
+ */
+ private function getPath() {
+ return $this->path;
+ }
+
+ /*
+ * @private function setModulePath
+ * @param string $folder_name
+ */
+ private function setModulePath($folder_name) {
+ $this->upload_path = TDMC_UPLOAD_MODULES_PATH . DIRECTORY_SEPARATOR . $folder_name;
+ }
+
+ /*
+ * @private function getModulePath
+ * @param null
+ */
+ private function getModulePath() {
+ return $this->upload_path;
+ }
+
+ /*
+ * @private function setSubDir
+ * @param string $subdir
+ */
+ private function setSubDir($subdir) {
+ $this->subdir = $subdir;
+ }
+
+ /*
+ * @private function getSubDir
+ * @param null
+ */
+ private function getSubDir() {
+ return $this->subdir;
+ }
+
+ /**
+ * public function setFileName
+ * @param mixed $module
+ */
+ public function setModule($module) {
+ $this->module = $module;
+ }
+
+ /*
+ * @public function getModule
+ * @param null
+ */
+ public function getModule()
+ {
+ return $this->module;
+ }
+
+ /**
+ * public function setTable
+ * @param mixed $table
+ */
+ public function setTable($table) {
+ if (is_array($table)) {
+ foreach($table as $t) {
+ $this->table[] = $t;
+ }
+ } elseif (is_array($this->table)) {
+ $this->table[] = $table;
+ } else {
+ $this->table = $table;
+ }
+ }
+
+ /*
+ * @public function getTable
+ * @param null
+ */
+ public function getTable() {
+ if (is_array($this->table)) {
+ $ret = array();
+ foreach ($this->table as $table) {
+ $ret[] = $table;
+ }
+ return $ret;
+ }
+ }
+
+ /**
+ * @public function setFields
+ * @param mixed $fields
+ */
+ public function setFields($fields) {
+ if (is_array($fields)) {
+ foreach($fields as $f) {
+ $this->fields[] = $f;
+ }
+ } elseif (is_array($this->fields)) {
+ $this->fields[] = $fields;
+ } else {
+ $this->fields = $fields;
+ }
+ }
+
+ /*
+ * @public function getFields
+ * @param null
+ */
+ public function getFields() {
+ if (is_array($this->fields)) {
+ $ret = array();
+ foreach ($this->fields as $fields) {
+ $ret[] = $fields;
+ }
+ return $ret;
+ }
+ }
+
+ /**
+ * public function setFileName
+ * @param mixed $file_name
+ */
+ public function setFileName($filename) {
+ $this->filename = $filename;
+ }
+
+ /*
+ * @public function getFileName
+ * @param null
+ */
+ public function getFileName() {
+ return $this->filename;
+ }
+
+ /*
* @private function setContent
* @param string $content
*/
@@ -105,7 +288,7 @@
* @param null
*/
private function getFolderName() {
- $path = $this->path();
+ $path = $this->getUploadPath();
if(strrpos($path, '/'))
{
$str = strrpos($path, '/');
@@ -113,6 +296,19 @@
return substr($path, $str + 1, strlen($path));
}
}
+ }
+
+ /*
+ * @public function getUploadPath
+ * @param mixed $subdir
+ */
+ private function getUploadPath() {
+ if ($this->getSubDir() != null) {
+ $ret = $this->getModulePath() . DIRECTORY_SEPARATOR . $this->getSubDir();
+ } else {
+ $ret = $this->getModulePath();
+ }
+ return $ret;
}
/*
@@ -148,31 +344,96 @@
}
/*
+ * @public function getLanguage
+ * @param string $prefix
+ * @param string $postfix
+ */
+ public function getLanguage($module_name, $prefix = '', $postfix = '') {
+ $lang = '_' . $prefix . '_' . $module_name;
+ if(!empty($postfix) || $postfix != '_') {
+ $ret = $lang . '_' . $postfix;
+ } elseif($postfix == '_') {
+ $ret = $lang . '_';
+ } else {
+ $ret = $lang;
+ }
+ return $ret;
+ }
+
+ /*
+ * @public function getHeaderFilesComments
+ * @param string $module
+ * @param string $file_name
+ */
+ public function getHeaderFilesComments($module, $filename) {
+
+ $mod_name = $module->getVar('mod_name');
+ $mod_version = $module->getVar('mod_version');
+ $mod_since = $module->getVar('mod_since');
+ $mod_min_xoops = $module->getVar('mod_min_xoops');
+ $mod_author = $module->getVar('mod_author');
+ $mod_credits = $module->getVar('mod_credits');
+ $mod_author_mail = $module->getVar('mod_author_mail');
+ $mod_author_website_url = $module->getVar('mod_author_website_url');
+ $mod_license = $module->getVar('mod_license');
+ $mod_subversion = $module->getVar('mod_subversion');
+ $date = date('D Y/m/d G:i:s');
+ $package = strtolower($mod_name);
+
+ $ret = <<<EOT
+<?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.
+*/
+/**
+ * {$mod_name} module for xoops
+ *
+ * @copyright The XOOPS Project http://sourceforge.net/projects/xoops/
+ * @license {$mod_license}
+ * @package {$package}
+ * @since {$mod_since}
+ * @min_xoops {$mod_min_xoops}
+ * @author {$mod_author} <{$mod_author_mail}> - <{$mod_author_website_url}>
+ * @version \$Id: {$mod_version} {$filename} {$mod_subversion} {$date}Z {$mod_credits} \$
+ */\n
+EOT;
+ return $ret;
+ }
+
+ /*
* @public function renderFile
* @param null
*/
- public function renderFile() {
- $path = $this->getPath();
+ public function renderFile() {
+ $filename = $this->getFileName();
+ $path = $this->getUploadPath() . DIRECTORY_SEPARATOR . $filename;
+ $created = $this->getCreated();
+ $notcreated = $this->getNotCreated();
$folder_name = $this->getFolderName();
- $file_name = $this->getFileName();
- $created = $this->getCreated();
- $notcreated = $this->getNotCreated();
- $this->xoopsfile->__construct($path, true);
- // Integration of the content of file
- if($this->xoopsfile->open($this->getMode()) == false) {
- $GLOBALS['xoopsTpl']->assign('notcreated', sprintf($notcreated, $file_name, $folder_name));
- return false;
- }
- if($this->xoopsfile->is_writable($path)) {
- if ($this->xoopsfile->write($this->getContent()) == false) {
- $GLOBALS['xoopsTpl']->assign('notcreated', sprintf($notcreated, $file_name, $folder_name));
- exit;
+ // Force to create file if not exist
+ if(!$this->xoopsfile->exists()) {
+ if(!$this->xoopsfile->__construct($path, true)) {
+ // Which mode to open the file
+ if($this->xoopsfile->open($this->getMode()) == false) {
+ $GLOBALS['xoopsTpl']->assign('notcreated', sprintf($notcreated, $filename, $folder_name));
+ }
+ // Integration of the content in the file
+ if ($this->xoopsfile->write($this->getContent()) == false) {
+ $GLOBALS['xoopsTpl']->assign('notcreated', sprintf($notcreated, $filename, $folder_name));
+ exit();
+ }
+ } else {
+ // Created
+ $GLOBALS['xoopsTpl']->assign('created', sprintf($created, $filename, $folder_name));
}
- $GLOBALS['xoopsTpl']->assign('created', sprintf($created, $file_name, $folder_name));
- $this->xoopsfile->close();
- } else {
- $GLOBALS['xoopsTpl']->assign('notcreated', sprintf($notcreated, $file_name, $folder_name));
}
- return $GLOBALS['xoopsTpl']->fetch("db:tdmcreate_building.html");
+ $this->xoopsfile->close();
+ return $GLOBALS['xoopsTpl']->fetch('db:building.tpl');
}
}
\ No newline at end of file
Modified: XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/class/files/include_functions.php
===================================================================
--- XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/class/files/include_functions.php 2014-05-14 20:51:54 UTC (rev 12533)
+++ XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/class/files/include_functions.php 2014-05-16 14:20:30 UTC (rev 12534)
@@ -16,7 +16,7 @@
* @package tdmcreate
* @since 2.5.0
* @author Txmod Xoops http://www.txmodxoops.org
- * @version $Id: include_functions.php 12258 2014-01-02 09:33:29Z timgno $
+ * @version $Id: 1.91 include_functions.php 12258 2014-01-02 09:33:29Z timgno $
*/
defined('XOOPS_ROOT_PATH') or die('Restricted access');
@@ -29,13 +29,26 @@
/*
* @public function constructor
* @param string $module
- * @param string $file_name
+ * @param string $filename
*/
- public function __construct($module, $file_name) {
+ public function __construct($module, $filename) {
$this->tdmcfile = TDMCreateFile::getInstance();
$this->setModule($module);
- $this->setFileName($file_name);
+ $this->setFileName($filename);
}
+
+ /*
+ * @static function &getInstance
+ * @param null
+ */
+ public static function &getInstance($module, $filename)
+ {
+ static $instance = false;
+ if (!$instance) {
+ $instance = new self($module, $filename);
+ }
+ return $instance;
+ }
/*
* @public function getFunctionBlock
@@ -133,16 +146,16 @@
* @param null
*/
public function render() {
- $path = $this->getLocalPath('include');
$module = $this->getModule();
$filename = $this->getFileName();
+ $module_name = strtolower($module->getVar('mod_name'));
$content = $this->getHeaderFilesComments($module, $filename);
$content .= $this->getFunctionBlock($module_name);
$content .= $this->getFunctionCleanVars($module_name);
$content .= $this->getFunctionMetaKeywords($module_name);
$content .= $this->getFunctionMetaDescription($module_name);
- $this->tdmcfile->create($path, $filename, $content, _AM_TDMCREATE_FILE_CREATED, _AM_TDMCREATE_FILE_NOTCREATED);
+ $this->tdmcfile->create($module_name, $filename, $content, 'include', _AM_TDMCREATE_FILE_CREATED, _AM_TDMCREATE_FILE_NOTCREATED);
return $this->tdmcfile->renderFile();
}
}
\ No newline at end of file
Modified: XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/class/modules.php
===================================================================
--- XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/class/modules.php 2014-05-14 20:51:54 UTC (rev 12533)
+++ XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/class/modules.php 2014-05-16 14:20:30 UTC (rev 12534)
@@ -111,7 +111,7 @@
*/
public function getForm($action = false)
{
- global $pathIcon32;
+ global $sysPathIcon32;
if ($action === false) {
$action = $_SERVER['REQUEST_URI'];
@@ -186,9 +186,9 @@
//---------- START LOGO GENERATOR -----------------
$tables_img = $this->getVar('table_image') ? $this->getVar('table_image') : 'about.png';
- if(is_dir($pathIcon32)){
- $uploadirectory = $pathIcon32;
- $imgpath = sprintf(_AM_TDMCREATE_FORMIMAGE_PATH, "./{$pathIcon32}");
+ if(is_dir($sysPathIcon32)){
+ $uploadirectory = $sysPathIcon32;
+ $imgpath = sprintf(_AM_TDMCREATE_FORMIMAGE_PATH, "./{$sysPathIcon32}");
} else {
$uploadirectory = "/uploads/".$GLOBALS['xoopsModule']->dirname()."/images/tables";
$imgpath = sprintf(_AM_TDMCREATE_FORMIMAGE_PATH, "./uploads/".$GLOBALS['xoopsModule']->dirname()."/images/tables");
Modified: XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/include/functions.php
===================================================================
--- XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/include/functions.php 2014-05-14 20:51:54 UTC (rev 12533)
+++ XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/include/functions.php 2014-05-16 14:20:30 UTC (rev 12534)
@@ -36,27 +36,26 @@
}
function TDMCreate_clearDir($folder) {
- $opening=@opendir($folder);
+ $opening = @opendir($folder);
if (!$opening) return;
- while($fields=readdir($opening)) {
- if ($fields == '.' || $fields == '..') continue;
- if (is_dir($folder."/".$fields)) {
- $r=TDMCreate_clearDir($folder."/".$fields);
+ while($file = readdir($opening)) {
+ if ($file == '.' || $file == '..') continue;
+ if (is_dir($folder."/".$file)) {
+ $r = TDMCreate_clearDir($folder."/".$file);
if (!$r) return false;
- }
- else {
- $r=@unlink($folder."/".$fields);
+ } else {
+ $r = @unlink($folder."/".$file);
if (!$r) return false;
}
}
closedir($opening);
- $r=@rmdir($folder);
+ $r = @rmdir($folder);
if (!$r) return false;
return true;
}
/**
- * Copy a fields, or a folder and its contents
+ * Copy a file, or a folder and its contents
*
* @author Aidan Li...
[truncated message content] |