|
From: <txm...@us...> - 2014-05-21 22:01:53
|
Revision: 12543
http://sourceforge.net/p/xoops/svn/12543
Author: txmodxoops
Date: 2014-05-21 22:01:47 +0000 (Wed, 21 May 2014)
Log Message:
-----------
Merged name of files and folders modules to repository
for serius vulnerability of root/modules folder
Fixed bugs
Work in progress
Modified Paths:
--------------
XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/admin/building.php
XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/admin/header.php
XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/admin/menu.php
XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/admin/tables.php
XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/class/building.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/architecture.php
XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/class/files/file.php
XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/css/admin/style.css
XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/include/common.php
XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/include/functions.php
XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/include/install.php
XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/language/english/admin.php
XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/sql/mysql.sql
XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/templates/admin/tables.tpl
XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/xoops_version.php
Added Paths:
-----------
XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/admin/repository.php
XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/class/repository.php
Removed Paths:
-------------
XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/class/htmlform.php
XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/class/htmltable.php
XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/class/tdmcreate.php
Modified: XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/admin/building.php
===================================================================
--- XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/admin/building.php 2014-05-20 18:39:28 UTC (rev 12542)
+++ XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/admin/building.php 2014-05-21 22:01:47 UTC (rev 12543)
@@ -19,42 +19,30 @@
* @version $Id: building.php 12258 2014-01-02 09:33:29Z timgno $
*/
include 'header.php';
-$op = TDMCreate_CleanVars( $_REQUEST, 'op', 'default', 'string' );
-$mname = TDMCreate_CleanVars( $_REQUEST, 'mod_name', '', 'string' );
-if ( $mname ) {
- $modules =& $modulesHandler->get( $mname );
-} else {
- $modules =& $modulesHandler;
-}
-$tname = TDMCreate_CleanVars( $_REQUEST, 'table_name', '', 'string' );
-if ( $tname ) {
- $tables =& $tablesHandler->get( $tname );
-} else {
- $tables =& $tablesHandler;
-}
+$op = TDMCreateRequest::getString('op', 'default');
+$mid = TDMCreateRequest::getInt('mod_id');
+$moduleObj = $tdmcreate->getHandler('repository')->get( $mid );
//
-$mod_id = $modules->getVar('mod_id');
-$mod_name = $modules->getVar('mod_name');
-//Name of tables
-$criteria = new CriteriaCompo();
-if (isset($mod_id)) {
- $criteria->add(new Criteria('table_mid', $mod_id));
-} else {
- $criteria->add(new Criteria('table_mid', $mod_name));
-}
-$tables_arr = $tablesHandler->getAll($criteria);
-
-$table_id = $tables->getVar('table_id');
-$table_name = $tables->getVar('table_name');
+$tid = TDMCreateRequest::getInt('table_id');
+$table = $tdmcreate->getHandler('tables')->get( $tid );
+//
+$mod_id = $moduleObj->getVar('mod_id');
+$mod_name = $moduleObj->getVar('mod_name');
+// Id of tables
+$criteria_tables = new CriteriaCompo();
+$criteria_tables->add(new Criteria('table_mid', $mod_id));
+$tables = $tdmcreate->getHandler('tables')->getAll($criteria_tables);
+unset($criteria_tables);
+//
+$table_id = $table->getVar('table_id');
+$table_name = $table->getVar('table_name');
+//
$criteria_fields = new CriteriaCompo();
-if (isset($table_id)) {
- $criteria_fields->add(new Criteria('field_tid', $table_id));
-} else {
- $criteria_fields->add(new Criteria('field_tid', $table_name));
-}
-$fields = $fieldsHandler->getAll($criteria_fields);
+$criteria_fields->add(new Criteria('field_tid', $table_id));
+$fields = $tdmcreate->getHandler('fields')->getAll($criteria_fields);
+unset($criteria_fields);
//
-$from_dir = TDMC_UPLOAD_MODULES_PATH.'/'.strtolower($mod_name);
+$from_dir = TDMC_UPLOAD_REPOSITORY_PATH.'/'.strtolower($mod_name);
$to_dir = XOOPS_ROOT_PATH.'/modules/'.strtolower($mod_name);
switch ($op) {
case 'build':
@@ -70,7 +58,7 @@
$handler->getPath( TDMC_PATH );
$handler->getUploadPath( TDMC_UPLOAD_PATH );
// Creation of the structure of folders and files
- $base_architecture = $handler->createBaseFoldersFiles( $modules );
+ $base_architecture = $handler->createBaseFoldersFiles( $moduleObj );
if($base_architecture !== false) {
$GLOBALS['xoopsTpl']->assign('base_architecture', true);
} else {
@@ -78,7 +66,7 @@
}
// Get files
$builds = array();
- $files = $handler->createBuildingFiles( $modules, $tables, $tables_arr, $fields );
+ $files = $handler->createBuildingFiles( $moduleObj, $table, $tables, $fields );
foreach($files as $file) {
if($file) {
$builds['created'] = $file;
@@ -90,7 +78,7 @@
// Directory to saved all files
$GLOBALS['xoopsTpl']->assign('building_directory', sprintf(_AM_TDMCREATE_BUILDING_DIRECTORY, str_replace(' ', '', strtolower($mod_name))));
// Copy this module in root modules
- if ( $modules->getVar('mod_inroot_copy') == 1 ) {
+ if ( $moduleObj->getVar('mod_inroot_copy') == 1 ) {
TDMCreate_copyr($from_dir, $to_dir);
}
break;
Modified: XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/admin/header.php
===================================================================
--- XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/admin/header.php 2014-05-20 18:39:28 UTC (rev 12542)
+++ XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/admin/header.php 2014-05-21 22:01:47 UTC (rev 12543)
@@ -34,7 +34,7 @@
// TDMCreate Instance
$tdmcreate = TDMCreate::getInstance();
// Get class handler
-$modulesHandler =& $tdmcreate->getHandler('modules');
+$modulesHandler =& $tdmcreate->getHandler('repository');
$tablesHandler =& $tdmcreate->getHandler('tables');
$fieldsHandler =& $tdmcreate->getHandler('fields');
$fieldtypeHandler =& $tdmcreate->getHandler('fieldtype');
Modified: XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/admin/menu.php
===================================================================
--- XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/admin/menu.php 2014-05-20 18:39:28 UTC (rev 12542)
+++ XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/admin/menu.php 2014-05-21 22:01:47 UTC (rev 12543)
@@ -29,7 +29,7 @@
$adminmenu[$i]['icon'] = $sysPathIcon32.'/home.png';
$i++;
$adminmenu[$i]['title'] = _MI_TDMCREATE_ADMENU2;
-$adminmenu[$i]['link'] = 'admin/modules.php';
+$adminmenu[$i]['link'] = 'admin/repository.php';
$adminmenu[$i]['icon'] = 'images/icons/32/addmodule.png';
$i++;
$adminmenu[$i]['title'] = _MI_TDMCREATE_ADMENU3;
Added: XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/admin/repository.php
===================================================================
--- XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/admin/repository.php (rev 0)
+++ XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/admin/repository.php 2014-05-21 22:01:47 UTC (rev 12543)
@@ -0,0 +1,231 @@
+<?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.5
+ * @author Txmod Xoops <su...@tx...>
+ * @version $Id: 1.59 repository.php 11297 2013-03-24 10:58:10Z timgno $
+ */
+include 'header.php';
+// Recovered value of argument op in the URL $
+$op = TDMCreateRequest::getString('op', 'list');
+//
+$mod_id = TDMCreateRequest::getInt('mod_id');
+//
+switch ($op)
+{
+ case 'list':
+ default:
+ $start = TDMCreateRequest::getInt('start', 0);
+ $limit = TDMCreateRequest::getInt('limit', $tdmcreate->getConfig('repository_adminpager'));
+ // Define main template
+ $template_main = 'repository.tpl';
+ $GLOBALS['xoTheme']->addScript('modules/TDMCreate/js/functions.js');
+ $GLOBALS['xoTheme']->addStylesheet( 'modules/TDMCreate/css/admin/style.css' );
+ $GLOBALS['xoopsTpl']->assign('navigation', $adminMenu->addNavigation('repository.php'));
+ $adminMenu->addItemButton(_AM_TDMCREATE_ADD_MODULE, 'repository.php?op=new', 'add');
+ $GLOBALS['xoopsTpl']->assign('buttons', $adminMenu->renderButton());
+ $GLOBALS['xoopsTpl']->assign('tdmc_url', TDMC_URL);
+ $GLOBALS['xoopsTpl']->assign('tdmc_upload_imgrep_url', TDMC_UPLOAD_IMGREP_URL);
+ $GLOBALS['xoopsTpl']->assign('modPathIcon16', $modPathIcon16);
+ $GLOBALS['xoopsTpl']->assign('sysPathIcon32', $sysPathIcon32);
+ $criteria = new CriteriaCompo();
+ $criteria->setSort('mod_id ASC, mod_name');
+ $criteria->setOrder('ASC');
+ $nb_modules = $tdmcreate->getHandler('repository')->getCount( $criteria );
+ $mods_arr = $tdmcreate->getHandler('repository')->getAll( $criteria );
+ unset($criteria);
+ // Redirect if there aren't repository
+ if ( $nb_modules == 0 ) {
+ redirect_header('repository.php?op=new', 2, _AM_TDMCREATE_NOTMODULES );
+ }
+ // Display repository list
+ if ( $nb_modules > 0 ) {
+ foreach (array_keys($mods_arr) as $i) {
+ $mod['id'] = $i;
+ $mod['name'] = $mods_arr[$i]->getVar('mod_name');
+ $mod['version'] = $mods_arr[$i]->getVar('mod_version');
+ $mod['image'] = $mods_arr[$i]->getVar('mod_image');
+ $mod['release'] = $mods_arr[$i]->getVar('mod_release');
+ $mod['status'] = $mods_arr[$i]->getVar('mod_status');
+ $mod['admin'] = $mods_arr[$i]->getVar('mod_admin');
+ $mod['user'] = $mods_arr[$i]->getVar('mod_user');
+ $mod['search'] = $mods_arr[$i]->getVar('mod_search');
+ $mod['comments'] = $mods_arr[$i]->getVar('mod_comments');
+ $mod['notifications'] = $mods_arr[$i]->getVar('mod_notifications');
+ $mod['permissions'] = $mods_arr[$i]->getVar('mod_permissions');
+ $GLOBALS['xoopsTpl']->append('repository_list', $mod);
+ unset($mod);
+ }
+ if ( $nb_modules > $limit ) {
+ include_once XOOPS_ROOT_PATH . '/class/pagenav.php';
+ $pagenav = new XoopsPageNav($nb_modules, $limit, $start, 'start', 'op=list&limit=' . $limit);
+ $GLOBALS['xoopsTpl']->assign('pagenav', $pagenav->renderNav(4));
+ }
+ } else {
+ $GLOBALS['xoopsTpl']->assign('error', _AM_TDMCREATE_THEREARENT_MODULES);
+ }
+ break;
+
+ case 'new':
+ // Define main template
+ $template_main = 'repository.tpl';
+ $GLOBALS['xoTheme']->addScript('modules/TDMCreate/js/functions.js');
+ $GLOBALS['xoopsTpl']->assign('navigation', $adminMenu->addNavigation('repository.php'));
+ $adminMenu->addItemButton(_AM_TDMCREATE_MODULES_LIST, 'repository.php', 'list');
+ $GLOBALS['xoopsTpl']->assign('buttons', $adminMenu->renderButton());
+
+ $obj =& $tdmcreate->getHandler('repository')->create();
+ $form = $obj->getForm();
+ $GLOBALS['xoopsTpl']->assign('form', $form->render());
+ break;
+
+ case 'save':
+ if ( !$GLOBALS['xoopsSecurity']->check() ) {
+ redirect_header('repository.php', 3, implode(',', $GLOBALS['xoopsSecurity']->getErrors()));
+ }
+ if (isset($mod_id)) {
+ $obj =& $tdmcreate->getHandler('repository')->get($mod_id);
+ } else {
+ $obj =& $tdmcreate->getHandler('repository')->create();
+ }
+ //Form module save
+ $obj->setVars(array('mod_name' => $_POST['mod_name'],
+ 'mod_version' => $_POST['mod_version'],
+ 'mod_since' => $_POST['mod_since'],
+ 'mod_min_php' => $_POST['mod_min_php'],
+ 'mod_min_xoops' => $_POST['mod_min_xoops'],
+ 'mod_min_admin' => $_POST['mod_min_admin'],
+ 'mod_min_mysql' => $_POST['mod_min_mysql'],
+ 'mod_description' => $_POST['mod_description'],
+ 'mod_author' => $_POST['mod_author'],
+ 'mod_author_mail' => $_POST['mod_author_mail'],
+ 'mod_author_website_url' => $_POST['mod_author_website_url'],
+ 'mod_author_website_name' => $_POST['mod_author_website_name'],
+ 'mod_credits' => $_POST['mod_credits'],
+ 'mod_license' => $_POST['mod_license'],
+ 'mod_release_info' => $_POST['mod_release_info'],
+ 'mod_release_file' => $_POST['mod_release_file'],
+ 'mod_manual' => $_POST['mod_manual'],
+ 'mod_manual_file' => $_POST['mod_manual_file']));
+ //Form mod_image
+ include_once XOOPS_ROOT_PATH . '/class/uploader.php';
+ $uploader = new XoopsMediaUploader(TDMC_UPLOAD_IMGMOD_PATH, $tdmcreate->getConfig('mimetypes'),
+ $tdmcreate->getConfig('maxsize'), null, null);
+ if ($uploader->fetchMedia($_POST['xoops_upload_file'][0])) {
+ $extension = preg_replace( '/^.+\.([^.]+)$/sU' , '\\1' , $_FILES['attachedfile']['name']);
+ $name_img = strtolower($_POST['mod_name']).'_slogo.'.$extension;
+ $uploader->setPrefix($name_img);
+ $uploader->fetchMedia($_POST['xoops_upload_file'][0]);
+ if (!$uploader->upload()) {
+ $errors = $uploader->getErrors();
+ redirect_header('javascript:history.go(-1)',3, $errors);
+ } else {
+ $obj->setVar('mod_image', $uploader->getSavedFileName());
+ }
+ } else {
+ $obj->setVar('mod_image', $_POST['mod_image']);
+ }
+ //Form module save
+ $obj->setVars(array('mod_demo_site_url' => $_POST['mod_demo_site_url'],
+ 'mod_demo_site_name' => $_POST['mod_demo_site_name'],
+ 'mod_support_url' => $_POST['mod_support_url'],
+ 'mod_support_name' => $_POST['mod_support_name'],
+ 'mod_website_url' => $_POST['mod_website_url'],
+ 'mod_website_name' => $_POST['mod_website_name'],
+ 'mod_release' => $_POST['mod_release'],
+ 'mod_status' => $_POST['mod_status'],
+ 'mod_admin' => (($_REQUEST['mod_admin'] == 1) ? '1' : '0'),
+ 'mod_user' => (($_REQUEST['mod_user'] == 1) ? '1' : '0'),
+ 'mod_search' => (($_REQUEST['mod_search'] == 1) ? '1' : '0'),
+ 'mod_comments' => (($_REQUEST['mod_comments'] == 1) ? '1' : '0'),
+ 'mod_notifications' => (($_REQUEST['mod_notifications'] == 1) ? '1' : '0'),
+ 'mod_permissions' => (($_REQUEST['mod_permissions'] == 1) ? '1' : '0'),
+ 'mod_inroot_copy' => (($_REQUEST['mod_inroot_copy'] == 1) ? '1' : '0'),
+ 'mod_donations' => $_POST['mod_donations'],
+ 'mod_subversion' => $_POST['mod_subversion'])
+ );
+
+ if ($tdmcreate->getHandler('repository')->insert($obj)) {
+ redirect_header('repository.php', 2, _AM_TDMCREATE_FORMOK);
+ }
+
+ $GLOBALS['xoopsTpl']->assign('error', $obj->getHtmlErrors());
+ $form =& $obj->getForm();
+ $GLOBALS['xoopsTpl']->assign('form', $form->render());
+ break;
+
+ case 'edit':
+ // Define main template
+ $template_main = 'repository.tpl';
+ $GLOBALS['xoTheme']->addScript('modules/TDMCreate/js/functions.js');
+ $GLOBALS['xoopsTpl']->assign('navigation', $adminMenu->addNavigation('repository.php'));
+ $adminMenu->addItemButton(_AM_TDMCREATE_ADD_MODULE, 'repository.php?op=new', 'add');
+ $adminMenu->addItemButton(_AM_TDMCREATE_MODULES_LIST, 'repository.php', 'list');
+ $GLOBALS['xoopsTpl']->assign('buttons', $adminMenu->renderButton());
+
+ $obj = $tdmcreate->getHandler('repository')->get($mod_id);
+ $form = $obj->getForm();
+ $GLOBALS['xoopsTpl']->assign('form', $form->render());
+ break;
+
+ case 'delete':
+ $obj =& $tdmcreate->getHandler('repository')->get($mod_id);
+ if (isset($_REQUEST['ok']) && $_REQUEST['ok'] == 1) {
+ if ( !$GLOBALS['xoopsSecurity']->check() ) {
+ redirect_header('repository.php', 3, implode(',', $GLOBALS['xoopsSecurity']->getErrors()));
+ }
+ if ($tdmcreate->getHandler('repository')->delete($obj)) {
+ redirect_header('repository.php', 3, _AM_TDMCREATE_FORMDELOK);
+ } else {
+ $GLOBALS['xoopsTpl']->assign('error', $obj->getHtmlErrors());
+ }
+ } else {
+ xoops_confirm(array('ok' => 1, 'mod_id' => $mod_id, 'op' => 'delete'), $_SERVER['REQUEST_URI'], sprintf(_AM_TDMCREATE_FORMSUREDEL, $obj->getVar('mod_name')));
+ }
+ break;
+
+ case 'display':
+ $mod_admin = TDMCreateRequest::getInt('mod_admin');
+ $mod_user = TDMCreateRequest::getInt('mod_user');
+ $mod_search = TDMCreateRequest::getInt('mod_search');
+ $mod_comments = TDMCreateRequest::getInt('mod_comments');
+ $mod_notifications = TDMCreateRequest::getInt('mod_notifications');
+ $mod_permissions = TDMCreateRequest::getInt('mod_permissions');
+
+ if ( $mod_id > 0 ) {
+ $obj =& $tdmcreate->getHandler('repository')->get($mod_id);
+ if(isset($mod_adminm)) {
+ $obj->setVar('mod_admin', $mod_admin);
+ } elseif(isset($mod_user)) {
+ $obj->setVar('mod_user', $mod_user);
+ } elseif(isset($mod_search)) {
+ $obj->setVar('mod_search', $mod_search);
+ } elseif(isset($mod_comments)) {
+ $obj->setVar('mod_comments', $mod_comments);
+ } elseif(isset($mod_notifications)) {
+ $obj->setVar('mod_notifications', $mod_notifications);
+ } elseif(isset($mod_permissions)) {
+ $obj->setVar('mod_permissions', $mod_permissions);
+ }
+ if ($tdmcreate->getHandler('repository')->insert($obj, true)) {
+ redirect_header('repository.php', 1, _AM_TDMCREATE_TOGGLE_SUCCESS);
+ } else {
+ redirect_header('repository.php', 1, _AM_TDMCREATE_TOGGLE_FAILED);
+ }
+ }
+ break;
+}
+include 'footer.php';
\ No newline at end of file
Modified: XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/admin/tables.php
===================================================================
--- XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/admin/tables.php 2014-05-20 18:39:28 UTC (rev 12542)
+++ XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/admin/tables.php 2014-05-21 22:01:47 UTC (rev 12543)
@@ -34,7 +34,7 @@
case 'list':
default:
$start = TDMCreateRequest::getInt('start', 0);
- $limit = TDMCreateRequest::getInt('limit', $tdmcreate->getConfig('modules_adminpager'));
+ $limit = TDMCreateRequest::getInt('limit', $tdmcreate->getConfig('repository_adminpager'));
//$limit = TDMCreateRequest::getInt('limit', $tdmcreate->getConfig('tables_adminpager'));
// Define main template
$template_main = 'tables.tpl';
@@ -45,7 +45,7 @@
$GLOBALS['xoopsTpl']->assign('buttons', $adminMenu->renderButton());
$GLOBALS['xoopsTpl']->assign('tdmc_url', TDMC_URL);
$GLOBALS['xoopsTpl']->assign('tdmc_icons_url', TDMC_ICONS_URL);
- $GLOBALS['xoopsTpl']->assign('tdmc_upload_imgmod_url', TDMC_UPLOAD_IMGMOD_URL);
+ $GLOBALS['xoopsTpl']->assign('tdmc_upload_imgrep_url', TDMC_UPLOAD_IMGREP_URL);
//$GLOBALS['xoopsTpl']->assign('tdmc_upload_imgtab_url', TDMC_UPLOAD_IMGTAB_URL);
$GLOBALS['xoopsTpl']->assign('modPathIcon16', $modPathIcon16);
$GLOBALS['xoopsTpl']->assign('sysPathIcon32', $sysPathIcon32);
@@ -53,20 +53,20 @@
$criteria = new CriteriaCompo();
$criteria->setSort('mod_id ASC, mod_name');
$criteria->setOrder('ASC');
- $nb_modules = $modulesHandler->getCount($criteria);
+ $nb_modules = $tdmcreate->getHandler('repository')->getCount($criteria);
// Redirect if there aren't modules
if ( $nb_modules == 0 ) {
- redirect_header('modules.php?op=new', 2, _AM_TDMCREATE_NOTMODULES );
+ redirect_header('repository.php?op=new', 2, _AM_TDMCREATE_NOTMODULES );
}
- $mods_arr = $modulesHandler->getAll($criteria);
+ $mods_arr = $tdmcreate->getHandler('repository')->getAll($criteria);
unset($criteria);
- $nb_tables = $tablesHandler->getObjects(null);
+ $nb_tables = $tdmcreate->getHandler('tables')->getObjects(null);
// Redirect if there aren't tables
if ($nb_tables == 0) {
redirect_header('tables.php?op=new', 2, _AM_TDMCREATE_NOTTABLES );
}
unset($nb_tables);
- // Display modules list
+ // Display repository list
if ( $nb_modules > 0 )
{
foreach (array_keys($mods_arr) as $i)
@@ -85,8 +85,8 @@
$criteria->add(new Criteria('table_mid', $i));
$criteria->setSort('table_id ASC, table_name');
$criteria->setOrder('ASC');
- $nb_tables = $tablesHandler->getCount($criteria);
- $tables_arr = $tablesHandler->getAll($criteria);
+ $nb_tables = $tdmcreate->getHandler('tables')->getCount($criteria);
+ $tables_arr = $tdmcreate->getHandler('tables')->getAll($criteria);
unset($criteria);
// Display tables list
$tables = array();
@@ -116,7 +116,7 @@
}
unset($lid);
$mod['tables'] = $tables;
- $GLOBALS['xoopsTpl']->append('modules_list', $mod);
+ $GLOBALS['xoopsTpl']->append('repository_list', $mod);
unset($mod);
}
if ( $nb_modules > $limit ) {
@@ -136,7 +136,7 @@
$adminMenu->addItemButton(_AM_TDMCREATE_TABLES_LIST, 'tables.php', 'list');
$GLOBALS['xoopsTpl']->assign('buttons', $adminMenu->renderButton());
- $obj =& $tablesHandler->create();
+ $obj =& $tdmcreate->getHandler('tables')->create();
$form = $obj->getForm();
$GLOBALS['xoopsTpl']->assign('form', $form->render());
break;
@@ -146,12 +146,12 @@
redirect_header('tables.php', 3, implode(',', $GLOBALS['xoopsSecurity']->getErrors()));
}
if (isset($table_id)) {
- $obj =& $tablesHandler->get($table_id);
+ $obj =& $tdmcreate->getHandler('tables')->get($table_id);
} else {
- $obj =& $tablesHandler->create();
+ $obj =& $tdmcreate->getHandler('tables')->create();
}
// Checking if table name exist
- $table_name_search = $tablesHandler->getObjects(null);
+ $table_name_search = $tdmcreate->getHandler('tables')->getObjects(null);
foreach (array_keys($table_name_search) as $t)
{
if( ($table_name_search[$t]->getVar('table_name') === $_POST['table_name']) &&
@@ -193,7 +193,7 @@
'table_notifications' => (($_REQUEST['table_notifications'] == 1) ? '1' : '0'),
'table_permissions' => (($_REQUEST['table_permissions'] == 1) ? '1' : '0')));
- if( $tablesHandler->insert($obj) ) {
+ if( $tdmcreate->getHandler('tables')->insert($obj) ) {
if( $obj->isNew() ) {
$table_iid = $GLOBALS['xoopsDB']->getInsertId();
$table_action = '&field_mid='.$table_mid.'&field_tid='.$table_iid.'&field_numb='.$table_nbfields.'&field_name='.$table_fieldname;
@@ -216,18 +216,18 @@
$adminMenu->addItemButton(_AM_TDMCREATE_TABLES_LIST, 'tables.php?op=list', 'list');
$GLOBALS['xoopsTpl']->assign('buttons', $adminMenu->renderButton());
- $obj = $tablesHandler->get($table_id);
+ $obj = $tdmcreate->getHandler('tables')->get($table_id);
$form = $obj->getForm();
$GLOBALS['xoopsTpl']->assign('form', $form->render());
break;
case 'delete':
- $obj =& $tablesHandler->get($table_id);
+ $obj =& $tdmcreate->getHandler('tables')->get($table_id);
if (isset($_REQUEST['ok']) && $_REQUEST['ok'] == 1) {
if ( !$GLOBALS['xoopsSecurity']->check() ) {
redirect_header('tables.php', 3, implode(',', $GLOBALS['xoopsSecurity']->getErrors()));
}
- if ($tablesHandler->delete($obj)) {
+ if ($tdmcreate->getHandler('tables')->delete($obj)) {
redirect_header('tables.php', 3, _AM_TDMCREATE_FORMDELOK);
} else {
echo $obj->getHtmlErrors();
@@ -248,7 +248,7 @@
$table_permissions = TDMCreateRequest::getInt('table_permissions');
if ( $table_id > 0 ) {
- $obj =& $tablesHandler->get($table_id);
+ $obj =& $tdmcreate->getHandler('tables')->get($table_id);
if(isset($table_blocks)) {
$obj->setVar('table_blocks', $table_blocks);
} elseif(isset($table_adminm)) {
@@ -266,7 +266,7 @@
} elseif(isset($table_permissions)) {
$obj->setVar('table_permissions', $table_permissions);
}
- if ($tablesHandler->insert($obj, true)) {
+ if ($tdmcreate->getHandler('tables')->insert($obj, true)) {
redirect_header('modules.php', 1, _AM_TDMCREATE_TOGGLE_SUCCESS);
} else {
redirect_header('modules.php', 1, _AM_TDMCREATE_TOGGLE_FAILED);
Modified: XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/class/building.php
===================================================================
--- XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/class/building.php 2014-05-20 18:39:28 UTC (rev 12542)
+++ XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/class/building.php 2014-05-21 22:01:47 UTC (rev 12543)
@@ -17,7 +17,7 @@
* @package tdmcreate
* @since 2.5.x
* @author TDM TEAM DEV MODULE
- * @version $Id: modules.php 12425 2014-02-23 22:40:09Z timgno $
+ * @version $Id: building.php 12425 2014-02-23 22:40:09Z timgno $
*/
defined('XOOPS_ROOT_PATH') or die('Restricted access');
@@ -27,7 +27,7 @@
/**
* @var mixed
*/
- private $tdmc = null;
+ private $tdmcreate = null;
/*
* @public function constructor class
@@ -36,7 +36,7 @@
public function __construct()
{
$this->XoopsObject();
- $this->tdmc = TDMCreate::getInstance();
+ $this->tdmcreate = TDMCreate::getInstance();
}
/*
@@ -59,9 +59,12 @@
}
xoops_load('XoopsFormLoader');
$form = new XoopsThemeForm(_AM_TDMCREATE_ADMIN_CONST, 'buildform', $action, 'post', true);
- $modulesHandler =& $this->tdmc->getHandler('modules');
- $mod_select = new XoopsFormSelect(_AM_TDMCREATE_CONST_MODULES, 'mod_name', 'mod_name');
- $mod_select->addOptionArray($modulesHandler->getList());
+ $moduleObj =& $this->tdmcreate->getHandler('repository')->getObjects(null);
+ $mod_select = new XoopsFormSelect(_AM_TDMCREATE_CONST_MODULES, 'mod_id', 'mod_id');
+ $mod_select->addOption($action, _AM_TDMCREATE_BUILD_MODSELOPT);
+ foreach ($moduleObj as $mod) {
+ $mod_select->addOption($mod->getVar('mod_id'), $mod->getVar('mod_name'));
+ }
$form->addElement($mod_select, true);
$form->addElement(new XoopsFormHidden('op', 'build'));
Modified: XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/class/fields.php
===================================================================
--- XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/class/fields.php 2014-05-20 18:39:28 UTC (rev 12542)
+++ XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/class/fields.php 2014-05-21 22:01:47 UTC (rev 12543)
@@ -318,6 +318,31 @@
{
return parent::get($id, $fields);
}
+
+ /**
+ * Retrieve a {@link TDMCreateFields}
+ *
+ * @param int $id ID
+ *
+ * @return object {@link TDMCreateFields}, FALSE on fail
+ */
+ /*public function &get($id)
+ {
+ $fieldtable = false;
+ $id = intval($id);
+ if ($id > 0) {
+ $sql = 'SELECT * FROM ' . $this->db->prefix('mod_tdmcreate_fields') . ' WHERE field_tid=' . $id;
+ if (!$result = $this->db->query($sql)) {
+ return $fieldtable;
+ }
+ $numrows = $this->db->getRowsNum($result);
+ if ($numrows == 1) {
+ $fieldtable = TDMCreateFields::getInstance();
+ $fieldtable->assignVars($this->db->fetchArray($result), false);
+ }
+ }
+ return $fieldtable;
+ }*/
/**
* get IDs of objects matching a condition
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-20 18:39:28 UTC (rev 12542)
+++ XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/class/files/abstractfiles.php 2014-05-21 22:01:47 UTC (rev 12543)
@@ -38,7 +38,7 @@
*
* @var string
*/
- private $upload_path = TDMC_UPLOAD_MODULES_PATH;
+ private $upload_path = TDMC_UPLOAD_REPOSITORY_PATH;
/**
* "module" attribute of the files
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-20 18:39:28 UTC (rev 12542)
+++ XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/class/files/architecture.php 2014-05-21 22:01:47 UTC (rev 12543)
@@ -20,8 +20,8 @@
*/
defined('XOOPS_ROOT_PATH') or die('Restricted access');
require_once 'structure.php';
-include_once TDMC_PATH . '/include/functions.php';
-spl_autoload_register('TDMCreate_autoload');
+/*include_once TDMC_PATH . '/include/functions.php';
+spl_autoload_register('TDMCreate_autoload');*/
class TDMCreateArchitecture extends TDMCreateStructure
{
@@ -83,9 +83,9 @@
{
$indexFile = $this->path.'/index.html';
$docs_folder = $this->path.'/docs';
- //Creation of the Directory of modules
- $targetDirectory = $this->upload_path.'/modules/'. str_replace(' ', '', strtolower($module->getVar('mod_name')));
- $upload_images_folder = $this->upload_path.'/images/modules';
+ // Creation of the Directory in repository
+ $targetDirectory = $this->upload_path.'/repository/'. str_replace(' ', '', strtolower($module->getVar('mod_name')));
+ $upload_images_folder = $this->upload_path.'/images/repository';
// Creation of "module" folder
$this->structure->getPath($targetDirectory);
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-20 18:39:28 UTC (rev 12542)
+++ XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/class/files/file.php 2014-05-21 22:01:47 UTC (rev 12543)
@@ -162,7 +162,7 @@
* @param string $module_name
*/
private function setModulePath($module_name) {
- $this->upload_path = TDMC_UPLOAD_MODULES_PATH . DIRECTORY_SEPARATOR . strtolower($module_name);
+ $this->upload_path = TDMC_UPLOAD_REPOSITORY_PATH . DIRECTORY_SEPARATOR . strtolower($module_name);
}
/*
Deleted: XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/class/htmlform.php
===================================================================
--- XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/class/htmlform.php 2014-05-20 18:39:28 UTC (rev 12542)
+++ XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/class/htmlform.php 2014-05-21 22:01:47 UTC (rev 12543)
@@ -1,140 +0,0 @@
-<?php
-/*
- You may not change or alter any portion of this comment or credits
- of supporting developers from this source code or any supporting source code
- which is considered copyrighted (c) material of the original comment or credit authors.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- */
-/**
- * tdmcreate module
- *
- * @copyright The XOOPS Project http://sourceforge.net/projects/xoops/
- * @license GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html)
- * @package tdmcreate
- * @since 2.5.5
- * @author Txmod Xoops <su...@tx...>
- * @version $Id: 1.91 htmlform.php 11297 2014-03-22 10:19:18Z timgno $
- */
-
-defined('XOOPS_ROOT_PATH') or die('Restricted access');
-
-require_once 'htmltable.php';
-
-/**
- * Form HTML
- *
- */
-class TDMCreateHtmlForm
-{
- /**
- * name attribute
- *
- * @var string
- */
- private $name = null;
-
- /**
- * action attribute
- *
- * @var mixed
- */
- private $action = null;
-
- /**
- * method attribute
- *
- * @var string
- */
- private $method = null;
-
- /**
- * extra attribute
- *
- * @var mixed
- */
- private $extra = null;
-
- /**
- * constructor
- *
- */
- public function __construct()
- {
- }
-
- /*
- * @static function &getInstance
- * @param null
- */
- public static function &getInstance()
- {
- static $instance = false;
- if (!$instance) {
- $instance = new self();
- }
- return $instance;
- }
-
- /**
- * Function getHtmlForm
- *
- * @param string $name "name" attribute for the <form> tag
- * @param string $action "action" attribute for the <form> tag
- * @param string $method "method" attribute for the <form> tag
- * @param bool $extra whether to add a javascript to the form
- */
- public function getInitForm($name = null, $action = false, $method = 'post', $extra = false)
- {
- $this->name = $name;
- $this->action = $action;
- $this->method = $method;
- $this->extra = $extra;
- }
-
- /**
- * Function getHeaderForm
- *
- * @param string $title
- */
- public function getHeaderForm($title)
- {
- $ret = ($title ? '<div class=" center head ">' . $title . '</div>' . NWLINE : '');
- return $ret;
- }
-
- /**
- * Function getOpenForm
- *
- * @param null
- */
- public function getOpenForm()
- {
- $ret = '<form name="' . $this->name . '" id="' . $this->name . '" action="' . $this->action . '" method="' . $this->method . '" onsubmit="return xoopsFormValidate_' . $this->name . '();"' . $this->extra . '>' . NWLINE;
- return $ret;
- }
-
- /**
- * Function getContentForm
- *
- * @param null
- */
- public function getContentForm($class, $caption, $content)
- {
- $ret = '<div class="' . $class . '"><strong>' . $caption . '</strong>' . $content . '</div>' . NWLINE;
- return $ret;
- }
-
- /**
- * Function CloseForm
- *
- * @param null
- */
- public function getCloseForm()
- {
- $ret = '</form>' . NWLINE;
- return $ret;
- }
-}
\ No newline at end of file
Deleted: XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/class/htmltable.php
===================================================================
--- XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/class/htmltable.php 2014-05-20 18:39:28 UTC (rev 12542)
+++ XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/class/htmltable.php 2014-05-21 22:01:47 UTC (rev 12543)
@@ -1,302 +0,0 @@
-<?php
-/*
- You may not change or alter any portion of this comment or credits
- of supporting developers from this source code or any supporting source code
- which is considered copyrighted (c) material of the original comment or credit authors.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- */
-/**
- * tdmcreate module
- *
- * @copyright The XOOPS Project http://sourceforge.net/projects/xoops/
- * @license GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html)
- * @package tdmcreate
- * @since 2.5.0
- * @author Txmod Xoops http://www.txmodxoops.org
- * @version $Id: htmltable.php 12258 2014-01-02 09:33:29Z timgno $
-*/
-defined('XOOPS_ROOT_PATH') or die('Restricted access');
-
-/**
- * Base class for html tables
- *
- * @author TXMod Xoops <in...@tx...>
- * @package tdmcreate
- * @access public
- */
-class TDMCreateHtmlTable
-{
- /**
- * array of {@TDMCreateHtmlTable} objects
- *
- * @var array
- */
- private $rows = array();
-
- /**
- * array of {@link TDMCreateHtmlTable} objects
- *
- * @var array
- */
- private $cells = array();
-
- /**
- * string of {@link TDMCreateHtmlTable} objects
- *
- * @var string
- */
- private $data = '';
-
- /**
- * string of {@link TDMCreateHtmlTable} objects
- *
- * @var string
- */
- private $_id = '';
-
- /**
- * string of {@link TDMCreateHtmlTable} objects
- *
- * @var string
- */
- private $_class = '';
-
- /**
- * string of {@link TDMCreateHtmlTable} objects
- *
- * @var string
- */
- private $type = '';
-
- /**
- * array of {@link TDMCreateHtmlTable} objects
- *
- * @var array
- */
- private $attributes = array();
-
- /**
- * constructor
- *
- * @param null
- */
- public function __construct()
- {
- }
-
- /*
- * @public static function &getInstance
- * @param null
- */
- public static function &getInstance()
- {
- static $instance = false;
- if (!$instance) {
- $instance = new self();
- }
- return $instance;
- }
-
- /**
- * @public Function initTable
- *
- * @param string $id attribute of the table
- * @param string $_class "css class" attribute for the <table> tag
- * @param mixed $attributes attributes for the <table> tag
- */
- public function initTable($_class = null, $id = null, $attributes = false )
- {
- $ret = '<table' . ( !empty($id) ? ' id="' . $id . '"' : '' );
- $ret .= ( !empty($_class) ? ' class="' . $_class . '"' : '' );
- if($attributes && is_array($attributes)) {
- $ret .= $this->addAttributes( $attributes );
- }
- $ret .= '>';
- return $ret;
- }
-
- /**
- * return key & value of attributes
- *
- * @param array $attributes
- * @return string
- */
- public function addAttributes( $attributes = array() )
- {
- $str = '';
- if(is_array( $attributes )) {
- foreach( $attributes as $k => $v ) {
- $str .= " {$k}=\"{$v}\"";
- }
- }
- return $str;
- }
-
- /**
- * Add an element row to the table
- *
- * @param string $_class
- * @param mixed $attributes
- */
- public function addRow( $class = '', $attributes = null )
- {
- $row = self::getInstance();
- $row->addTableRow( $class, $attributes );
- if(is_array( $attributes )) {
- array_push( $this->rows, $row );
- }
- }
-
- /**
- * Add an element cell to the table
- *
- * @param object $data reference to a {@link XoopsFormElement}
- * @param string $class css element
- * @param string $type reference to a header or data
- * @param mixed $attributes attributes for a cell
- */
- public function addCell( $data, $class = '', $type = 'data', $attributes = null )
- {
- $cell = self::getInstance();
- $cell->addTableCell( $data, $class, $type, $attributes );
- // add new cell to current row's list of cells
- $curRow =& $this->rows[ count( $this->rows ) - 1 ]; // copy by reference
- if(is_array( $attributes )) {
- if(isset($curRow->cells) && isset($cell)) {
- array_push( $curRow->cells, $cell );
- }
- }
- }
-
- /**
- * Add an array of cells
- *
- * @param object $data content text
- * @param string $_class css element
- * @param string $type reference to a header or data
- * @param array $attributes attributes for a cell
- */
- public function addCells( $data, $class = '', $type = 'data', $attributes = array() )
- {
- if (is_array($data)) {
- foreach( $data as $data_cell ) {
- $this->addCell($data_cell, $class, $type, $attributes );
- }
- }
- }
-
- /**
- * Add Cell for tables
- *
- * return end of html table
- */
- public function getRows($rows)
- {
- $ret = '';
- $this->rows = $rows;
- if (is_array( $this->rows )) {
- foreach( $this->rows as $row )
- {
- $ret .= !empty($row->_class) ? '<tr class="' . $row->_class . '"' : '<tr';
- $ret .= $this->addAttributes( $row->attributes ) . '>';
- $ret .= $this->getRowCells( $row->cells );
- $ret .= '</tr>';
- }
- }
- return $ret;
- }
-
- /**
- * get an array of row & cells
- *
- * @param cells $cells elements
- * @return array - array of RowCells
- */
- public function getRowCells($cells)
- {
- $str = '';
- $this->cells = $cells;
- if (is_array( $this->cells )) {
- foreach( $this->cells as $cell )
- {
- $tag = ($cell->type == 'data')? 'td': 'th';
- $str .= !empty($cell->_class) ? '<' . $tag . ' class="' . $cell->_class . '"' : '<' . $tag;
- $str .= $this->addAttributes( $cell->attributes ) . '>';
- $str .= $cell->data;
- $str .= '</' . $tag . '>';
- }
- }
- return $str;
- }
-
- /**
- * Add Row for tables
- *
- * @param string $class css element
- * @param mixed $attributes attributes for a cell
- */
- public function addTableRow( $class = '', $attributes = null )
- {
- if(empty($class)){
- $this->_class = $class;
- }
- if(!is_array($attributes)){
- $this->attributes[] = $attributes;
- } else {
- $this->attributes = $attributes;
- }
- }
-
- /**
- * Add Cell for tables
- *
- * @param string $data content text
- * @param string $class css style
- * @param string $type reference to a header or data
- * @param array $attributes attributes for a cell
- */
- public function addTableCell( $data, $class = '', $type = '', $attributes = null )
- {
- $this->data = $data;
- if(empty($class)){
- $this->_class = $class;
- }
- $this->type = $type;
- if(!is_array($attributes)){
- $this->attributes[] = $attributes;
- } else {
- $this->attributes = $attributes;
- }
- }
-
- /**
- * Add Cell for tables
- *
- * return end of html table
- */
- public function endTable()
- {
- $ret = '';
- $class = $this->_class;
- $attributes = $this->attributes;
- $rows = $this->addRow( $class, $attributes );
- $ret .= $this->getRows($rows);
- $ret .= '</table>';
- return $ret;
- }
-
- /**
- * Render Function
- *
- * return html table
- */
- public function render()
- {
- //$ret = $this->initTable($id = '', $_class = '', $border = 0, $cellspacing = 2, $cellpadding = 0, $attributes = array() );
- $ret = $this->endTable();
- return $ret;
- }
-}
\ No newline at end of file
Added: XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/class/repository.php
===================================================================
--- XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/class/repository.php (rev 0)
+++ XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/class/repository.php 2014-05-21 22:01:47 UTC (rev 12543)
@@ -0,0 +1,302 @@
+<?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.
+ */
+
+/**
+ * Repository class
+ *
+ * @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.x
+ * @author TDM TEAM DEV MODULE
+ * @version $Id: modules.php 12209 2013-10-23 02:49:09Z beckmi $
+ * @version $Id: repository.php 12400 2014-02-13 10:22:12Z timgno $
+ */
+defined('XOOPS_ROOT_PATH') or die('Restricted access');
+
+/*
+* @Class TDMCreateModules
+* @extends XoopsObject
+*/
+class TDMCreateRepository extends XoopsObject
+{
+ /**
+ * Instance of TDMCreate class
+ *
+ * @var mixed
+ */
+ private $tdmcreate = null;
+ /*
+ * @public function constructor class
+ * @param null
+ */
+ public function __construct()
+ {
+ $this->tdmcreate = TDMCreate::getInstance();
+ $this->initVar('mod_id',XOBJ_DTYPE_INT);
+ $this->initVar('mod_name',XOBJ_DTYPE_TXTBOX, $this->tdmcreate->getConfig('name'));
+ $this->initVar('mod_version',XOBJ_DTYPE_TXTBOX, $this->tdmcreate->getConfig('version'));
+ $this->initVar('mod_since',XOBJ_DTYPE_TXTBOX, $this->tdmcreate->getConfig('since'));
+ $this->initVar('mod_min_php',XOBJ_DTYPE_TXTBOX, $this->tdmcreate->getConfig('min_php'));
+ $this->initVar('mod_min_xoops',XOBJ_DTYPE_TXTBOX, $this->tdmcreate->getConfig('min_xoops'));
+ $this->initVar('mod_min_admin',XOBJ_DTYPE_TXTBOX, $this->tdmcreate->getConfig('min_admin'));
+ $this->initVar('mod_min_mysql',XOBJ_DTYPE_TXTBOX, $this->tdmcreate->getConfig('min_mysql'));
+ $this->initVar('mod_description',XOBJ_DTYPE_TXTAREA, $this->tdmcreate->getConfig('description'));
+ $this->initVar('mod_author',XOBJ_DTYPE_TXTBOX, $this->tdmcreate->getConfig('author'));
+ $this->initVar('mod_author_mail',XOBJ_DTYPE_TXTBOX, $this->tdmcreate->getConfig('author_email'));
+ $this->initVar('mod_author_website_url',XOBJ_DTYPE_TXTBOX, $this->tdmcreate->getConfig('author_website_url'));
+ $this->initVar('mod_author_website_name',XOBJ_DTYPE_TXTBOX, $this->tdmcreate->getConfig('author_website_name'));
+ $this->initVar('mod_credits',XOBJ_DTYPE_TXTBOX, $this->tdmcreate->getConfig('credits'));
+ $this->initVar('mod_license',XOBJ_DTYPE_TXTBOX, $this->tdmcreate->getConfig('license'));
+ $this->initVar('mod_release_info',XOBJ_DTYPE_TXTBOX, $this->tdmcreate->getConfig('release_info'));
+ $this->initVar('mod_release_file',XOBJ_DTYPE_TXTBOX, $this->tdmcreate->getConfig('release_file'));
+ $this->initVar('mod_manual',XOBJ_DTYPE_TXTBOX, $this->tdmcreate->getConfig('manual'));
+ $this->initVar('mod_manual_file',XOBJ_DTYPE_TXTBOX, $this->tdmcreate->getConfig('manual_file'));
+ $this->initVar('mod_image',XOBJ_DTYPE_TXTBOX, null);
+ $this->initVar('mod_demo_site_url',XOBJ_DTYPE_TXTBOX, $this->tdmcreate->getConfig('demo_site_url'));
+ $this->initVar('mod_demo_site_name',XOBJ_DTYPE_TXTBOX, $this->tdmcreate->getConfig('demo_site_name'));
+ $this->initVar('mod_support_url',XOBJ_DTYPE_TXTBOX, $this->tdmcreate->getConfig('support_url'));
+ $this->initVar('mod_support_name',XOBJ_DTYPE_TXTBOX, $this->tdmcreate->getConfig('support_name'));
+ $this->initVar('mod_website_url',XOBJ_DTYPE_TXTBOX, $this->tdmcreate->getConfig('website_url'));
+ $this->initVar('mod_website_name',XOBJ_DTYPE_TXTBOX, $this->tdmcreate->getConfig('website_name'));
+ $this->initVar('mod_release',XOBJ_DTYPE_TXTBOX, $this->tdmcreate->getConfig('release_date'));
+ $this->initVar('mod_status',XOBJ_DTYPE_TXTBOX, $this->tdmcreate->getConfig('status'));
+ $this->initVar('mod_admin',XOBJ_DTYPE_INT, $this->tdmcreate->getConfig('display_admin'));
+ $this->initVar('mod_user',XOBJ_DTYPE_INT, $this->tdmcreate->getConfig('display_user'));
+ $this->initVar('mod_search',XOBJ_DTYPE_INT, $this->tdmcreate->getConfig('active_search'));
+ $this->initVar('mod_comments',XOBJ_DTYPE_INT, $this->tdmcreate->getConfig('active_comments'));
+ $this->initVar('mod_notifications', XOBJ_DTYPE_INT, $this->tdmcreate->getConfig('active_notifications'));
+ $this->initVar('mod_permissions', XOBJ_DTYPE_INT, $this->tdmcreate->getConfig('active_permissions'));
+ $this->initVar('mod_inroot_copy', XOBJ_DTYPE_INT, $this->tdmcreate->getConfig('inroot_copy'));
+ $this->initVar('mod_donations', XOBJ_DTYPE_TXTBOX, $this->tdmcreate->getConfig('donations'));
+ $this->initVar('mod_subversion', XOBJ_DTYPE_TXTBOX, $this->tdmcreate->getConfig('subversion'));
+ }
+
+ /**
+ * @param string $method
+ * @param array $args
+ *
+ * @return mixed
+ */
+ public function __call($method, $args)
+ {
+ $arg = isset($args[0]) ? $args[0] : null;
+ return $this->getVar($method, $arg);
+ }
+
+ /*
+ * @static function &getInstance
+ * @param null
+ */
+ public static function &getInstance()
+ {
+ static $instance = false;
+ if (!$instance) {
+ $instance = new self();
+ }
+ return $instance;
+ }
+
+ /*
+ * @public function getForm
+ * @param mixed $action
+ */
+ public function getForm($action = false)
+ {
+ global $sysPathIcon32;
+
+ if ($action === false) {
+ $action = $_SERVER['REQUEST_URI'];
+ }
+ $isNew = $this->isNew();
+ $title = $isNew ? sprintf(_AM_TDMCREATE_MODULE_ADD) : sprintf(_AM_TDMCREATE_MODULE_EDIT);
+
+ xoops_load('XoopsFormLoader');
+ $form = new XoopsThemeForm($title, 'repositoryform', $action, 'post', true);
+ $form->setExtra('enctype="multipart/form-data"');
+
+ $form->insertBreak('<div class="center"><b>'._AM_TDMCREATE_MODULE_IMPORTANT.'</b></div>','head');
+ $form->addElement(new XoopsFormText(_AM_TDMCREATE_MODULE_NAME, 'mod_name', 50, 255, $this->getVar('mod_name')), true);
+ $form->addElement(new XoopsFormText(_AM_TDMCREATE_MODULE_VERSION, 'mod_version', 10, 25, $this->getVar('mod_version')), true);
+ $form->addElement(new XoopsFormText(_AM_TDMCREATE_MODULE_SINCE, 'mod_since', 10, 25, $this->getVar('mod_since')), true);
+ $form->addElement(new XoopsFormText(_AM_TDMCREATE_MODULE_MIN_PHP, 'mod_min_php', 10, 25, $this->getVar('mod_min_php')), true);
+ $form->addElement(new XoopsFormText(_AM_TDMCREATE_MODULE_MIN_XOOPS, 'mod_min_xoops', 10, 25, $this->getVar('mod_min_xoops')), true);
+ $form->addElement(new XoopsFormText(_AM_TDMCREATE_MODULE_MIN_ADMIN, 'mod_min_admin', 10, 25, $this->getVar('mod_min_admin')), true);
+ $form->addElement(new XoopsFormText(_AM_TDMCREATE_MODULE_MIN_MYSQL, 'mod_min_mysql', 10, 25, $this->getVar('mod_min_mysql')), true);
+ // Name description
+ $editor_configs=array();
+ $editor_configs['name'] = 'mod_description';
+ $editor_configs['value'] = $this->getVar('mod_description', 'e');
+ $editor_configs['rows'] = 5;
+ $editor_configs['cols'] = 100;
+ $editor_configs['width'] = '50%';
+ $editor_configs['height'] = '100px';
+ $editor_configs['editor'] = $this->tdmcreate->getConfig('tdmcreate_editor');
+ $form->addElement( new XoopsFormEditor(_AM_TDMCREATE_MODULE_DESCRIPTION, 'mod_description', $editor_configs), true);
+ // Author
+ $form->addElement(new XoopsFormText(_AM_TDMCREATE_MODULE_AUTHOR, 'mod_author', 50, 255, $this->getVar('mod_author')), true);
+ $form->addElement(new XoopsFormText(_AM_TDMCREATE_MODULE_LICENSE, 'mod_license', 50, 255, $this->getVar('mod_license')), true);
+ $mod_admin = $isNew ? $this->tdmcreate->getConfig('display_admin') : $this->getVar('mod_admin');
+ $form->addElement(new XoopsFormRadioYN(_AM_TDMCREATE_MODULE_ADMIN, 'mod_admin', $mod_admin, _YES, _NO));
+ $mod_user = $isNew ? $this->tdmcreate->getConfig('display_user') : $this->getVar('mod_user');
+ $form->addElement(new XoopsFormRadioYN(_AM_TDMCREATE_MODULE_USER, 'mod_user', $mod_user, _YES, _NO));
+ $mod_search = $isNew ? $this->tdmcreate->getConfig('active_search') : $this->getVar('mod_search');
+ $form->addElement(new XoopsFormRadioYN(_AM_TDMCREATE_MODULE_SEARCH, 'mod_search', $mod_search, _YES, _NO));
+ $mod_comments = $isNew ? $this->tdmcreate->getConfig('active_comments') : $this->getVar('mod_comments');
+ $form->addElement(new XoopsFormRadioYN(_AM_TDMCREATE_MODULE_COMMENTS, 'mod_comments', $mod_comments, _YES, _NO));
+
+ $mod_notifications = $isNew ? $this->tdmcreate->getConfig('active_notifications') : $this->getVar('mod_notifications');
+ $form->addElement(new XoopsFormRadioYN(_AM_TDMCREATE_MODULE_NOTIFICATIONS, 'mod_notifications', $mod_notifications, _YES, _NO));
+
+ $mod_permissions = $isNew ? $this->tdmcreate->getConfig('active_permissions') : $this->getVar('mod_permissions');
+ $form->addElement(new XoopsFormRadioYN(_AM_TDMCREATE_MODULE_PERMISSIONS, 'mod_permissions', $mod_permissions, _YES, _NO));
+
+ $mod_inroot_copy = $isNew ? $this->tdmcreate->getConfig('inroot_copy') : $this->getVar('mod_inroot_copy');
+ $form->addElement(new XoopsFormRadioYN(_AM_TDMCREATE_MODULE_INROOT_MODULES_COPY, 'mod_inroot_copy', $mod_inroot_copy, _YES, _NO));
+
+ $this_image = $this->getVar('mod_image');
+ $mod_image = $this_image ? $this_image : 'empty.png';
+
+ $uploadirectory = 'uploads/'.$GLOBALS['xoopsModule']->dirname().'/images/repository';
+ $imgtray = new XoopsFormElementTray(_AM_TDMCREATE_MODULE_IMAGE, '<br />');
+ $imgpath = sprintf(_AM_TDMCREATE_FORMIMAGE_PATH, './' . strtolower($uploadirectory) . '/');
+ $imageselect= new XoopsFormSelect($imgpath, 'mod_image', $mod_image);
+ $mod_image_array = XoopsLists::getImgListAsArray( TDMC_UPLOAD_IMGREP_PATH );
+ foreach( $mod_image_array as $image ) {
+ $imageselect->addOption("{$image}", $image);
+ }
+ $imageselect->setExtra( "onchange='showImgSelected(\"image3\", \"mod_image\", \"" . $uploadirectory . "\", \"\", \"" . XOOPS_URL . "\")'" );
+ $imgtray->addElement($imageselect);
+ $imgtray->addElement( new XoopsFormLabel( '', "<br /><img src='" . TDMC_UPLOAD_IMGREP_URL . "/" . $mod_image . "' name='image3' id='image3' alt='' /><br />" ) );
+
+ $fileseltray = new XoopsFormElementTray('', '<br />');
+ $fileseltray->addElement(new XoopsFormFile(_AM_TDMCREATE_FORMUPLOAD, 'attachedfile', $this->tdmcreate->getConfig('maxsize')));
+ $fileseltray->addElement(new XoopsFormLabel(''));
+ $imgtray->addElement($fileseltray);
+ $form->addElement($imgtray);
+
+ //---------- START LOGO GENERATOR -----------------
+ $tables_img = $this->getVar('table_image') ? $this->getVar('table_image') : 'about.png';
+ 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");
+ }
+ $createLogoTray = new XoopsFormElementTray(_AM_TDMCREATE_MODULE_BUTTON_NEW_LOGO, '<br />');
+ $iconSelect= new XoopsFormSelect($imgpath, 'tables_img', $tables_img, 8);
+ $tables_img_array = XoopsLists::getImgListAsArray( $uploadirectory );
+ foreach( $tables_img_array as $image ) {
+ $iconSelect->addOption("{$image}", $image);
+ }
+ $iconSelect->setExtra( "onchange='showImgSelected2(\"image4\", \"tables_img\", \"" . $uploadirectory . "\", \"\", \"" . '' . "\")'" );
+ $createLogoTray->addElement($iconSelect);
+ $createLogoTray -> addElement( new XoopsFormLabel( '', "<br /><img src='" . $uploadirectory . "/" . $tables_img . "' name='image4' id='image4' alt='' />" ) );
+
+ // Create preview and submit buttons
+ $buttonLogoGenerator4= new XoopsFormButton('', 'button4', "Create New Logo", 'button');
+ $buttonLogoGenerator4->setExtra("onclick='createNewModuleLogo(\"" . XOOPS_URL . "\")'");
+ $createLogoTray->addElement($buttonLogoGenerator4);
+
+ $form->addElement($createLogoTray);
+ //------------ END LOGO GENERATOR --------------------
+
+ $form->insertBreak('<div class="center"><b>'._AM_TDMCREATE_MODULE_NOTIMPORTANT.'</b></div>','head');
+ $form->addElement(new XoopsFormText(_AM_TDMCREATE_MODULE_AUTHOR_MAIL, 'mod_author_mail', 50, 255, $this->getVar('mod_author_mail')));
+ $form->addElement(new XoopsFormText(_AM_TDMCREATE_MODULE_AUTHOR_WEBSITE_URL, 'mod_author_website_url', 50, 255, $this->getVar('mod_author_website_url')));
+ $form->addElement(new XoopsFormText(_AM_TDMCREATE_MODULE_AUTHOR_WEBSITE_NAME, 'mod_author_website_name', 50, 255, $this->getVar('mod_author_website_name')));
+ $form->addElement(new XoopsFormText(_AM_TDMCREATE_MODULE_CREDITS, 'mod_credits', 50, 255, $this->getVar('mod_credits')));
+ $form->addElement(new XoopsFormText(_AM_TDMCREATE_MODULE_RELEASE_INFO, 'mod_release_info', 50, 255, $this->getVar('mod_release_info')));
+ $form->addElement(new XoopsFormText(_AM_TDMCREATE_MODULE_RELEASE_FILE, 'mod_release_file', 50, 255, $this->getVar('mod_release_file')));
+ $form->addElement(new XoopsFormText(_AM_TDMCREATE_MODULE_MANUAL, 'mod_manual', 50, 255, $this->getVar('mod_manual')));
+ $form->addElement(new XoopsFormText(_AM_TDMCREATE_MODULE_MANUAL_FILE, 'mod_manual_file', 50, 255, $this->getVar('mod_manual_file')));
+ $form->addElement(new XoopsFormText(_AM_TDMCREATE_MODULE_DEMO_SITE_URL, 'mod_demo_site_url', 50, 255, $this->getVar('mod_demo_site_url')));
+ $form->addElement(new XoopsFormText(_AM_TDMCREATE_MODULE_DEMO_SITE_NAME, 'mod_demo_site_name', 50, 255, $this->getVar('mod_demo_site_name')));
+ $form->addElement(new XoopsFormText(_AM_TDMCREATE_MODULE_SUPPORT_URL, 'mod_support_url', 50, 255, $this->getVar('mod_support_url')));
+ $form->addElement(new XoopsFormText(_AM_TDMCREATE_MODULE_SUPPORT_NAME, 'mod_support_name', 50, 255, $this->getVar('mod_support_name')));
+ $form->addElement(new XoopsFormText(_AM_TDMCREATE_MODULE_WEBSITE_URL, 'mod_website_url', 50, 255, $this->getVar('mod_website_url')));
+ $form->addElement(new XoopsFormText(_AM_TDMCREATE_MODULE_WEBSITE_NAME, 'mod_website_name', 50, 255, $this->getVar('mod_website_name')));
+ $form->addElement(new XoopsFormText(_AM_TDMCREATE_MODULE_RELEASE, 'mod_release', 50, 255, $this->getVar('mod_release')));
+ $form->addElement(new XoopsFormText(_AM_TDMCREATE_MODULE_STATUS, 'mod_status', 50, 255, $this->getVar('mod_status')));
+ $form->addElement(new XoopsFormText(_AM_TDMCREATE_MODULE_PAYPAL_BUTTON, 'mod_donations', 50, 255, $this->getVar('mod_donations')));
+ $form->addElement(new XoopsFormText(_AM_TDMCREATE_MODULE_SUBVERSION, 'mod_subversion', 50, 255, $this->getVar('mod_subversion')));
+
+ $form->addElement(new XoopsFormHidden('op', 'save'));
+ $form->addElement(new XoopsFormButton(_REQUIRED.' <span class="red bold">*</span>', 'submit', _SUBMIT, 'submit'));
+ return $form;
+ }
+
+ /*
+ * @private static function createLogo
+ * @param mixed $logoIcon
+ * @param string $moduleName
+ */
+ private static function createLogo($logoIcon, $moduleName)
+ {
+ global $pathIcon32;
+
+ if (!extension_loaded("gd")) {
+ return false;
+ } else {
+ $required_functions = array("imagecreatefrompng", "imagefttext", "imagecopy", "imagepng", "imagedestroy", "imagecolorallocate");
+ foreach ($required_functions as $func) {
+ if (!function_exists($func)) {
+ return false;
+ }
+ }
+ }
+
+ // $dirname = $GLOBALS['xoopsModule']->dirname();
+ $iconFileName = $pathIcon32 . '/' . basename($logoIcon);
+
+ $dirlogos = TDMC_PATH . "/images/logos";
+ if (!file_exists($imageBase = $dirlogos . "/empty.png") ||
+ !file_exists($font = $dirlogos . "/VeraBd.ttf") ||
+ !file_exists($iconFile = $iconFileName)) {
+ return false;
+ }
+
+ $imageModule = imagecreatefrompng($imageBase);
+ $imageIcon = imagecreatefrompng($iconFile);
+
+ // Write text
+ $text_color = imagecolorallocate($imageModule, 0, 0, 0);
+ $space_to_border = (92 - strlen($moduleName) * 7.5) / 2;
+ imagefttext($imageModule, 8.5, 0, $space_to_border, 45, $text_color, $font, ucfirst($moduleName), array());
+
+ imagecopy($imageModule, $imageIcon, 29, 2, 0, 0, 32, 32);
+
+ $targetImage = TDMC_UPLOAD_IMGMOD_URL . "/" . $moduleName . "_logo.png";
+
+ imagepng($imageModule, $targetImage );
+
+ imagedestroy($imageModule);
+ imagedestroy($imageIcon);
+
+ return XOOPS_URL . $targetImage;
+ }
+}
+/*
+* @Class TDMCreateModulesHandler
+* @extends XoopsPersistableObjectHandler
+*/
+class TDMCreateRepositoryHandler extends XoopsPersistableObjectHandler
+{
+ /*
+ * @public function constructor class
+ * @param mixed $db
+ */
+ public function __construct(&$db)
+ {
+ parent::__construct($db, 'mod_tdmcreate_repository', 'tdmcreaterepository', 'mod_id', 'mod_name');
+ }
+}
\ No newline at end of file
Deleted: XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/class/t...
[truncated message content] |