Skip to content

Commit 139c453

Browse files
committed
testdata
1 parent 0182640 commit 139c453

36 files changed

Lines changed: 1645 additions & 3 deletions

admin/header.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636

3737
/** @var \XoopsModules\Tdmcreate\Helper $helper */
3838
$helper = \XoopsModules\Tdmcreate\Helper::getInstance();
39+
$utility = new \XoopsModules\Tdmcreate\Utility();
3940

4041
// MyTextSanitizer
4142
$myts = MyTextSanitizer::getInstance();

admin/index.php

Lines changed: 78 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,83 @@
5252
$adminObject->addConfigBoxLine([$folder[$i], '777'], 'chmod');
5353
}
5454

55-
$GLOBALS['xoopsTpl']->assign('navigation', $adminObject->displayNavigation('index.php'));
56-
$GLOBALS['xoopsTpl']->assign('index', $adminObject->displayIndex());
55+
56+
$adminObject->displayNavigation(basename(__FILE__));
57+
58+
//------------- Test Data ----------------------------
59+
60+
if ($helper->getConfig('displaySampleButton')) {
61+
$yamlFile = dirname(__DIR__) . '/config/admin.yml';
62+
$config = loadAdminConfig($yamlFile);
63+
$displaySampleButton = $config['displaySampleButton'];
64+
65+
if (1 == $displaySampleButton) {
66+
xoops_loadLanguage('admin/modulesadmin', 'system');
67+
require __DIR__ . '/../testdata/index.php';
68+
69+
$adminObject->addItemButton(constant('CO_' . $moduleDirNameUpper . '_' . 'ADD_SAMPLEDATA'), '__DIR__ . /../../testdata/index.php?op=load', 'add');
70+
$adminObject->addItemButton(constant('CO_' . $moduleDirNameUpper . '_' . 'SAVE_SAMPLEDATA'), '__DIR__ . /../../testdata/index.php?op=save', 'add');
71+
// $adminObject->addItemButton(constant('CO_' . $moduleDirNameUpper . '_' . 'EXPORT_SCHEMA'), '__DIR__ . /../../testdata/index.php?op=exportschema', 'add');
72+
$adminObject->addItemButton(constant('CO_' . $moduleDirNameUpper . '_' . 'HIDE_SAMPLEDATA_BUTTONS'), '?op=hide_buttons', 'delete');
73+
} else {
74+
$adminObject->addItemButton(constant('CO_' . $moduleDirNameUpper . '_' . 'SHOW_SAMPLEDATA_BUTTONS'), '?op=show_buttons', 'add');
75+
$displaySampleButton = $config['displaySampleButton'];
76+
}
77+
$adminObject->displayButton('left', '');
78+
}
79+
80+
//------------- End Test Data ----------------------------
81+
82+
$adminObject->displayIndex();
83+
84+
/**
85+
* @param $yamlFile
86+
* @return array|bool
87+
*/
88+
function loadAdminConfig($yamlFile)
89+
{
90+
$config = \Xmf\Yaml::readWrapped($yamlFile); // work with phpmyadmin YAML dumps
91+
return $config;
92+
}
93+
94+
/**
95+
* @param $yamlFile
96+
*/
97+
function hideButtons($yamlFile)
98+
{
99+
$app['displaySampleButton'] = 0;
100+
\Xmf\Yaml::save($app, $yamlFile);
101+
redirect_header('index.php', 0, '');
102+
}
103+
104+
/**
105+
* @param $yamlFile
106+
*/
107+
function showButtons($yamlFile)
108+
{
109+
$app['displaySampleButton'] = 1;
110+
\Xmf\Yaml::save($app, $yamlFile);
111+
redirect_header('index.php', 0, '');
112+
}
113+
114+
$op = \Xmf\Request::getString('op', 0, 'GET');
115+
116+
switch ($op) {
117+
case 'hide_buttons':
118+
hideButtons($yamlFile);
119+
break;
120+
case 'show_buttons':
121+
showButtons($yamlFile);
122+
break;
123+
}
124+
125+
echo $utility::getServerStats();
126+
127+
128+
129+
130+
131+
//$GLOBALS['xoopsTpl']->assign('navigation', $adminObject->displayNavigation('index.php'));
132+
//$GLOBALS['xoopsTpl']->assign('index', $adminObject->displayIndex());
57133

58134
include __DIR__ . '/footer.php';

admin/migrate.php

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
<?php
2+
//
3+
// ------------------------------------------------------------------------ //
4+
// XOOPS - PHP Content Management System //
5+
// Copyright (c) 2000-2016 XOOPS.org //
6+
// <https://xoops.org/> //
7+
// ------------------------------------------------------------------------ //
8+
// This program is free software; you can redistribute it and/or modify //
9+
// it under the terms of the GNU General Public License as published by //
10+
// the Free Software Foundation; either version 2 of the License, or //
11+
// (at your option) any later version. //
12+
// //
13+
// You may not change or alter any portion of this comment or credits //
14+
// of supporting developers from this source code or any supporting //
15+
// source code which is considered copyrighted (c) material of the //
16+
// original comment or credit authors. //
17+
// //
18+
// This program is distributed in the hope that it will be useful, //
19+
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
20+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
21+
// GNU General Public License for more details. //
22+
// //
23+
// You should have received a copy of the GNU General Public License //
24+
// along with this program; if not, write to the Free Software //
25+
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA //
26+
// ------------------------------------------------------------------------ //
27+
// Author: Kazumi Ono (AKA onokazu) //
28+
// URL: http://www.myweb.ne.jp/, https://xoops.org/, http://jp.xoops.org/ //
29+
// Project: XOOPS Project //
30+
// ------------------------------------------------------------------------- //
31+
32+
use Xmf\Request;
33+
use XoopsModules\Tdmcreate;
34+
35+
require_once __DIR__ . '/admin_header.php';
36+
xoops_cp_header();
37+
38+
$adminObject->displayNavigation(basename(__FILE__));
39+
40+
echo <<<EOF
41+
<form method="post" class="form-inline">
42+
<div class="form-group">
43+
<input name="show" class="btn btn-default" type="submit" value="Show SQL">
44+
</div>
45+
<div class="form-group">
46+
<input name="migrate" class="btn btn-default" type="submit" value="Do Migration">
47+
</div>
48+
<div class="form-group">
49+
<input name="schema" class="btn btn-default" type="submit" value="Write Schema">
50+
</div>
51+
</form>
52+
EOF;
53+
54+
//XoopsLoad::load('migrate', 'newbb');
55+
56+
/** @var Tdmcreate\Common\Configurator $configurator */
57+
$configurator = new Tdmcreate\Common\Configurator();
58+
59+
/** @var \XoopsModules\Tdmcreate\Common\Migrate $migrator */
60+
$migrator = new \XoopsModules\Tdmcreate\Common\Migrate($configurator);
61+
62+
$op = Request::getCmd('op', 'default');
63+
$opShow = Request::getCmd('show', null, 'POST');
64+
$opMigrate = Request::getCmd('migrate', null, 'POST');
65+
$opSchema = Request::getCmd('schema', null, 'POST');
66+
$op = !empty($opShow) ? 'show' : $op;
67+
$op = !empty($opMigrate) ? 'migrate' : $op;
68+
$op = !empty($opSchema) ? 'schema' : $op;
69+
70+
$message = '';
71+
72+
switch ($op) {
73+
case 'show':
74+
$queue = $migrator->getSynchronizeDDL();
75+
if (!empty($queue)) {
76+
echo "<pre>\n";
77+
foreach ($queue as $line) {
78+
echo $line . ";\n";
79+
}
80+
echo "</pre>\n";
81+
}
82+
break;
83+
case 'migrate':
84+
$migrator->synchronizeSchema();
85+
$message = 'Database migrated to current schema.';
86+
break;
87+
case 'schema':
88+
xoops_confirm(['op' => 'confirmwrite'], 'migrate.php', 'Warning! This is intended for developers only. Confirm write schema file from current database.', 'Confirm');
89+
break;
90+
case 'confirmwrite':
91+
if ($GLOBALS['xoopsSecurity']->check()) {
92+
$migrator->saveCurrentSchema();
93+
$message = 'Current schema file written';
94+
}
95+
break;
96+
}
97+
98+
echo "<div>$message</div>";
99+
100+
require_once __DIR__ . '/admin_footer.php';

config/admin.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
displaySampleButton: 1
1+
displaySampleButton: 1

testdata/.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# no backup files, editor temp
2+
*~
3+
\#*
4+
*.bak
5+
.idea/

testdata/category.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
---
2+
# category
3+
-
4+
id: 1
5+
pid: 0
6+
title: 'Science'
7+
description: ''
8+
image:
9+
weight: 1
10+
color:
11+
online: 1
12+
-
13+
id: 2
14+
pid: 1
15+
title: 'Politics'
16+
description:
17+
image:
18+
weight: 1
19+
color:
20+
online: 1
21+
-
22+
id: 3
23+
pid: 0
24+
title: 'Arts'
25+
description:
26+
image:
27+
weight: 1
28+
color:
29+
online: 1
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<script>history.go(-1);</script>
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
-
2+
fieldattribute_id: '1'
3+
fieldattribute_name: ...
4+
fieldattribute_value: ''
5+
-
6+
fieldattribute_id: '2'
7+
fieldattribute_name: BINARY
8+
fieldattribute_value: BINARY
9+
-
10+
fieldattribute_id: '3'
11+
fieldattribute_name: UNSIGNED
12+
fieldattribute_value: UNSIGNED
13+
-
14+
fieldattribute_id: '4'
15+
fieldattribute_name: UNSIGNED_ZEROFILL
16+
fieldattribute_value: UNSIGNED_ZEROFILL
17+
-
18+
fieldattribute_id: '5'
19+
fieldattribute_name: CURRENT_TIMESTAMP
20+
fieldattribute_value: CURRENT_TIMESTAMP
Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
-
2+
fieldelement_id: '1'
3+
fieldelement_mid: '0'
4+
fieldelement_tid: '0'
5+
fieldelement_name: ...
6+
fieldelement_value: ''
7+
-
8+
fieldelement_id: '2'
9+
fieldelement_mid: '0'
10+
fieldelement_tid: '0'
11+
fieldelement_name: Text
12+
fieldelement_value: XoopsFormText
13+
-
14+
fieldelement_id: '3'
15+
fieldelement_mid: '0'
16+
fieldelement_tid: '0'
17+
fieldelement_name: TextArea
18+
fieldelement_value: XoopsFormTextArea
19+
-
20+
fieldelement_id: '4'
21+
fieldelement_mid: '0'
22+
fieldelement_tid: '0'
23+
fieldelement_name: DhtmlTextArea
24+
fieldelement_value: XoopsFormDhtmlTextArea
25+
-
26+
fieldelement_id: '5'
27+
fieldelement_mid: '0'
28+
fieldelement_tid: '0'
29+
fieldelement_name: CheckBox
30+
fieldelement_value: XoopsFormCheckBox
31+
-
32+
fieldelement_id: '6'
33+
fieldelement_mid: '0'
34+
fieldelement_tid: '0'
35+
fieldelement_name: RadioYN
36+
fieldelement_value: XoopsFormRadioYN
37+
-
38+
fieldelement_id: '7'
39+
fieldelement_mid: '0'
40+
fieldelement_tid: '0'
41+
fieldelement_name: SelectBox
42+
fieldelement_value: XoopsFormSelect
43+
-
44+
fieldelement_id: '8'
45+
fieldelement_mid: '0'
46+
fieldelement_tid: '0'
47+
fieldelement_name: SelectUser
48+
fieldelement_value: XoopsFormSelectUser
49+
-
50+
fieldelement_id: '9'
51+
fieldelement_mid: '0'
52+
fieldelement_tid: '0'
53+
fieldelement_name: ColorPicker
54+
fieldelement_value: XoopsFormColorPicker
55+
-
56+
fieldelement_id: '10'
57+
fieldelement_mid: '0'
58+
fieldelement_tid: '0'
59+
fieldelement_name: ImageList
60+
fieldelement_value: XoopsFormImageList
61+
-
62+
fieldelement_id: '11'
63+
fieldelement_mid: '0'
64+
fieldelement_tid: '0'
65+
fieldelement_name: SelectFile
66+
fieldelement_value: XoopsFormSelectFile
67+
-
68+
fieldelement_id: '12'
69+
fieldelement_mid: '0'
70+
fieldelement_tid: '0'
71+
fieldelement_name: UrlFile
72+
fieldelement_value: XoopsFormUrlFile
73+
-
74+
fieldelement_id: '13'
75+
fieldelement_mid: '0'
76+
fieldelement_tid: '0'
77+
fieldelement_name: UploadImage
78+
fieldelement_value: XoopsFormUploadImage
79+
-
80+
fieldelement_id: '14'
81+
fieldelement_mid: '0'
82+
fieldelement_tid: '0'
83+
fieldelement_name: UploadFile
84+
fieldelement_value: XoopsFormUploadFile
85+
-
86+
fieldelement_id: '15'
87+
fieldelement_mid: '0'
88+
fieldelement_tid: '0'
89+
fieldelement_name: TextDateSelect
90+
fieldelement_value: XoopsFormTextDateSelect
91+
-
92+
fieldelement_id: '16'
93+
fieldelement_mid: '1'
94+
fieldelement_tid: '1'
95+
fieldelement_name: 'Table : Categories'
96+
fieldelement_value: XoopsFormTables-Categories
97+
-
98+
fieldelement_id: '17'
99+
fieldelement_mid: '1'
100+
fieldelement_tid: '2'
101+
fieldelement_name: 'Table : Tests2'
102+
fieldelement_value: XoopsFormTables-Tests2
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
-
2+
fieldkey_id: '1'
3+
fieldkey_name: ...
4+
fieldkey_value: ''
5+
-
6+
fieldkey_id: '2'
7+
fieldkey_name: PRIMARY
8+
fieldkey_value: PRIMARY
9+
-
10+
fieldkey_id: '3'
11+
fieldkey_name: UNIQUE
12+
fieldkey_value: UNIQUE
13+
-
14+
fieldkey_id: '4'
15+
fieldkey_name: KEY
16+
fieldkey_value: KEY
17+
-
18+
fieldkey_id: '5'
19+
fieldkey_name: INDEX
20+
fieldkey_value: INDEX
21+
-
22+
fieldkey_id: '6'
23+
fieldkey_name: FULLTEXT
24+
fieldkey_value: FULLTEXT

0 commit comments

Comments
 (0)