18 require __DIR__ .
'/admin_header.php';
35 array(
'op',
'string',
'selectmodule',
true),
36 array(
'mod_dirname',
'string',
'',
true),
50 if (
$op ==
'showschema') {
52 $mod_to_use =
$helper->getModule();
54 $mod_ver = $mod_to_use->modinfo;
55 $table_list = array();
56 if (isset($mod_ver[
'tables'])) {
57 $table_list = $mod_ver[
'tables'];
60 if (empty($table_list)) {
69 $schemaManager =
$xoops->db()->getSchemaManager();
72 $schema = $schemaManager->createSchema();
77 $schema->visit($visitor);
81 $newSchema = $visitor->getNewSchema();
86 $newSchema->visit($export);
89 $yamldump = Yaml::dump($export->getSchemaArray(), 5);
94 <div contenteditable><pre>{$yamldump}</pre></div>
95 <input type=
"text" value=
"schema.yml" placeholder=
"schema.yml">
96 <button onclick=
"downloadFile()">Create file</button> <output></output>
103 var container = document.querySelector(
'#container');
104 var typer = container.querySelector(
'[contenteditable]');
105 var output = container.querySelector(
'output');
107 const MIME_TYPE =
'text/plain';
110 document.body.addEventListener(
'dragstart',
function(e) {
112 if (a.classList.contains(
'dragout')) {
113 e.dataTransfer.setData(
'DownloadURL', a.dataset.downloadurl);
117 document.body.addEventListener(
'dragend',
function(e) {
119 if (a.classList.contains(
'dragout')) {
124 document.addEventListener(
'keydown',
function(e) {
125 if (e.keyCode == 27) {
126 document.querySelector(
'details').open = false;
127 }
else if (e.shiftKey && e.keyCode == 191) {
128 document.querySelector(
'details').open = true;
132 var cleanUp =
function(a) {
133 a.textContent =
'Downloaded';
134 a.dataset.disabled =
true;
137 setTimeout(
function() {
138 window.URL.revokeObjectURL(a.href);
142 var downloadFile =
function() {
143 window.URL = window.webkitURL || window.URL;
145 var prevLink = output.querySelector(
'a');
147 window.URL.revokeObjectURL(prevLink.href);
148 output.innerHTML =
'';
151 var bb =
new Blob([typer.textContent], {type: MIME_TYPE});
153 var a = document.createElement(
'a');
154 a.download = container.querySelector(
'input[type="text"]').value;
155 a.href = window.URL.createObjectURL(bb);
156 a.textContent =
'Download ready';
158 a.dataset.downloadurl = [MIME_TYPE, a.download, a.href].join(
':');
162 output.appendChild(a);
164 a.onclick =
function(e) {
165 if (
'disabled' in this.dataset) {
178 $op =
'selectmodule';
181 if (
$op ==
'selectmodule') {
182 $activeModules =
$xoops->getActiveModules();
183 natcasesort($activeModules);
188 foreach ($activeModules as
$dirname) {
189 $mHelper =
$xoops->getModuleHelper($dirname);
190 if (is_object($mHelper)) {
191 $ele->addOption($dirname, $mHelper->getModule()->getVar(
'name'));
194 $form->addElement($ele);
195 $form->addElement(
new Xoops\Form\Hidden(
'op',
'showschema'));
197 echo
$form->render();
setTableFilter(array $tableList)