Skip to content

Commit 96bb0a1

Browse files
committed
fixes for Migrate
1 parent 139c453 commit 96bb0a1

8 files changed

Lines changed: 644 additions & 17 deletions

File tree

admin/header.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,11 @@
5050
// Local Icons
5151
$GLOBALS['xoopsTpl']->assign('modPathIcon16', $modPathIcon16);
5252
$GLOBALS['xoopsTpl']->assign('modPathIcon32', $modPathIcon32);
53-
// Load languages
54-
xoops_loadLanguage('admin', $thisDirname);
55-
xoops_loadLanguage('modinfo', $thisDirname);
53+
54+
// Load language files
55+
$helper->loadLanguage('admin');
56+
$helper->loadLanguage('modinfo');
57+
$helper->loadLanguage('common');
5658

5759
xoops_cp_header();
5860
/** @var \Xmf\Module\Admin $adminObject */

admin/migrate.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@
3232
use Xmf\Request;
3333
use XoopsModules\Tdmcreate;
3434

35-
require_once __DIR__ . '/admin_header.php';
36-
xoops_cp_header();
35+
require_once __DIR__ . '/header.php';
36+
//xoops_cp_header();
3737

3838
$adminObject->displayNavigation(basename(__FILE__));
3939

@@ -97,4 +97,4 @@
9797

9898
echo "<div>$message</div>";
9999

100-
require_once __DIR__ . '/admin_footer.php';
100+
require_once __DIR__ . '/footer.php';

class/Common/Configurator.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,20 @@ class Configurator
3737
public $oldFiles = [];
3838
public $oldFolders = [];
3939
public $renameTables = [];
40+
public $moduleStats = [];
4041
public $modCopyright;
4142

4243
/**
4344
* Configurator constructor.
4445
*/
4546
public function __construct()
4647
{
48+
// $moduleDirName = basename(dirname(dirname(__DIR__)));
49+
// $moduleDirNameUpper = mb_strtoupper($moduleDirName);
50+
51+
// require dirname(dirname(__DIR__)) . '/config/config.php';
52+
// $config = getConfig();
53+
4754
$config = include dirname(dirname(__DIR__)) . '/config/config.php';
4855

4956
$this->name = $config->name;

class/Common/Migrate.php

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
1313
*/
1414

15+
use \XoopsModules\Tdmcreate\Common;
16+
1517
/**
1618
* Class Migrate synchronize existing tables with target schema
1719
*
@@ -21,23 +23,25 @@
2123
* @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html)
2224
* @link https://xoops.org
2325
*/
26+
2427
class Migrate extends \Xmf\Database\Migrate
2528
{
2629
private $renameTables;
2730

2831
/**
2932
* Migrate constructor.
33+
* @param Common\Configurator $configurator
3034
* @throws \RuntimeException
3135
* @throws \InvalidArgumentException
3236
*/
33-
public function __construct()
37+
public function __construct(Common\Configurator $configurator = null)
3438
{
35-
require_once dirname(dirname(__DIR__)) . '/include/config.php';
36-
$config = getConfig();
37-
$this->renameTables = $config->renameTables;
39+
if (null !== $configurator) {
40+
$this->renameTables = $configurator->renameTables;
3841

39-
$moduleDirName = basename(dirname(dirname(__DIR__)));
40-
parent::__construct($moduleDirName);
42+
$moduleDirName = basename(dirname(dirname(__DIR__)));
43+
parent::__construct($moduleDirName);
44+
}
4145
}
4246

4347
/**
@@ -80,8 +84,8 @@ private function moveDoColumns()
8084
{
8185
$tableName = 'newbb_posts_text';
8286
$srcTableName = 'newbb_posts';
83-
if (false !== $this->tableHandler->useTable($tableName)
84-
&& false !== $this->tableHandler->useTable($srcTableName)) {
87+
if ($this->tableHandler->useTable($tableName)
88+
&& $this->tableHandler->useTable($srcTableName)) {
8589
$attributes = $this->tableHandler->getColumnAttributes($tableName, 'dohtml');
8690
if (false === $attributes) {
8791
$this->synchronizeTable($tableName);
@@ -102,12 +106,14 @@ private function moveDoColumns()
102106
*/
103107
protected function preSyncActions()
104108
{
109+
/*
105110
// change 'bb' table prefix to 'newbb'
106111
$this->changePrefix();
107112
// columns dohtml, dosmiley, doxcode, doimage and dobr moved between tables as some point
108113
$this->moveDoColumns();
109114
// Convert IP address columns from int to readable varchar(45) for IPv6
110115
$this->convertIPAddresses('newbb_posts', 'poster_ip');
111116
$this->convertIPAddresses('newbb_report', 'reporter_ip');
117+
*/
112118
}
113119
}

config/config.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
*/
1919
$moduleDirName = basename(dirname(__DIR__));
2020
$moduleDirNameUpper = mb_strtoupper($moduleDirName);
21+
xoops_loadLanguage('common', $moduleDirName);
2122

2223
return (object)[
2324
'name' => mb_strtoupper($moduleDirName) . ' ModuleConfigurator',

include/common.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,13 @@
2020
* @author Txmod Xoops http://www.txmodxoops.org
2121
*
2222
*/
23+
24+
use XoopsModules\Tdmcreate;
25+
include dirname(__DIR__) . '/preloads/autoloader.php';
26+
27+
$moduleDirName = basename(dirname(__DIR__));
28+
$moduleDirNameUpper = mb_strtoupper($moduleDirName); //$capsDirName
29+
2330
defined('XOOPS_ROOT_PATH') || exit('Restricted access');
2431
$dirname = $GLOBALS['xoopsModule']->getVar('dirname');
2532
// Root Frameworks icons 32x32 directory
@@ -44,6 +51,7 @@
4451
define('TDMC_IMAGES_LOGOS_URL', TDMC_URL . '/assets/images/logos');
4552
define('TDMC_ICONS_PATH', TDMC_PATH . '/assets/icons');
4653
define('TDMC_ICONS_URL', TDMC_URL . '/assets/icons');
54+
define($moduleDirNameUpper . '_AUTHOR_LOGOIMG', TDMC_URL . '/assets/images/logoModule.png');
4755
// Uploads Directories
4856
define('TDMC_UPLOAD_PATH', XOOPS_UPLOAD_PATH . '/' . $dirname);
4957
define('TDMC_UPLOAD_URL', XOOPS_UPLOAD_URL . '/' . $dirname);

language/english/common.php

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -159,9 +159,6 @@
159159
//define('CO_' . $moduleDirNameUpper . '_' . 'PERMSET', 'The permission has been set');
160160
//define('CO_' . $moduleDirNameUpper . '_' . 'PERMNOTSET', 'The permission cannot be set');
161161

162-
define('CO_' . $moduleDirNameUpper . '_' . 'TRUNCATE_LENGTH', 'Number of Characters to truncate to the long text field');
163-
define('CO_' . $moduleDirNameUpper . '_' . 'TRUNCATE_LENGTH_DESC', 'Set the maximum number of characters to truncate the long text fields');
164-
165162
//image config
166163
define('CO_' . $moduleDirNameUpper . '_' . 'IMAGE_WIDTH', 'Image Display Width');
167164
define('CO_' . $moduleDirNameUpper . '_' . 'IMAGE_WIDTH_DSC', 'Display width for image');
@@ -171,3 +168,16 @@
171168
define('CO_' . $moduleDirNameUpper . '_' . 'IMAGE_CONFIG_DSC', '');
172169
define('CO_' . $moduleDirNameUpper . '_' . 'IMAGE_UPLOAD_PATH', 'Image Upload path');
173170
define('CO_' . $moduleDirNameUpper . '_' . 'IMAGE_UPLOAD_PATH_DSC', 'Path for uploading images');
171+
172+
//Preferences
173+
define('CO_' . $moduleDirNameUpper . '_' . 'TRUNCATE_LENGTH', 'Number of Characters to truncate to the long text field');
174+
define('CO_' . $moduleDirNameUpper . '_' . 'TRUNCATE_LENGTH_DESC', 'Set the maximum number of characters to truncate the long text fields');
175+
176+
//Module Stats
177+
define('CO_' . $moduleDirNameUpper . '_' . 'STATS_SUMMARY', 'Module Statistics');
178+
define('CO_' . $moduleDirNameUpper . '_' . 'TOTAL_CATEGORIES', 'Categories:');
179+
define('CO_' . $moduleDirNameUpper . '_' . 'TOTAL_ITEMS', 'Items');
180+
define('CO_' . $moduleDirNameUpper . '_' . 'TOTAL_OFFLINE', 'Offline');
181+
define('CO_' . $moduleDirNameUpper . '_' . 'TOTAL_PUBLISHED', 'Published');
182+
define('CO_' . $moduleDirNameUpper . '_' . 'TOTAL_REJECTED', 'Rejected');
183+
define('CO_' . $moduleDirNameUpper . '_' . 'TOTAL_SUBMITTED', 'Submitted');

0 commit comments

Comments
 (0)