Use designer without configuring tables
Signed-off-by: Bimal Yashodha <kb.yashodha@gmail.com>
This commit is contained in:
parent
adf0d2e4b7
commit
7ec0f098db
@ -375,6 +375,7 @@ $js_messages['strPageName'] = __('Page name');
|
||||
$js_messages['strSavePage'] = __('Save page');
|
||||
$js_messages['strOpenPage'] = __('Open page');
|
||||
$js_messages['strDeletePage'] = __('Delete page');
|
||||
$js_messages['strUntitled'] = __('*Untitled');
|
||||
$js_messages['strSelectPage'] = __('Please select a page to continue');
|
||||
$js_messages['strEnterValidPageName'] = __('Please enter a valid page name');
|
||||
$js_messages['strLeavingPage'] = __('Do you want to save the changes to the current page?');
|
||||
|
||||
143
js/pmd/designer_db.js
Normal file
143
js/pmd/designer_db.js
Normal file
@ -0,0 +1,143 @@
|
||||
var designer_tables = [{name: "pdf_pages", key: "pg_nr", auto_inc: true},
|
||||
{name: "relation", key: "rel_nr", auto_inc: true},
|
||||
{name: "table_coords", key: "id", auto_inc: true}];
|
||||
|
||||
var DesignerOfflineDB = (function () {
|
||||
var designerDB = {};
|
||||
var datastore = null;
|
||||
|
||||
designerDB.open = function (callback)
|
||||
{
|
||||
var version = 2;
|
||||
var request = window.indexedDB.open("pmd_designer", version);
|
||||
|
||||
request.onupgradeneeded = function (e) {
|
||||
var db = e.target.result;
|
||||
e.target.transaction.onerror = designerDB.onerror;
|
||||
|
||||
for (var t in designer_tables) {
|
||||
if (db.objectStoreNames.contains(designer_tables[t].name)) {
|
||||
db.deleteObjectStore(designer_tables[t].name);
|
||||
}
|
||||
}
|
||||
|
||||
for (var t in designer_tables) {
|
||||
db.createObjectStore(designer_tables[t].name, {
|
||||
keyPath: designer_tables[t].key, autoIncrement: designer_tables[t].auto_inc
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
request.onsuccess = function (e) {
|
||||
datastore = e.target.result;
|
||||
if (callback != null) {
|
||||
callback(true);
|
||||
}
|
||||
};
|
||||
|
||||
request.onerror = designerDB.onerror;
|
||||
};
|
||||
|
||||
designerDB.loadObject = function (table, id, callback)
|
||||
{
|
||||
var db = datastore;
|
||||
var transaction = db.transaction([table], 'readwrite');
|
||||
var objStore = transaction.objectStore(table);
|
||||
var cursorRequest = objStore.get(parseInt(id));
|
||||
|
||||
cursorRequest.onsuccess = function (e) {
|
||||
var result = e.target.result;
|
||||
callback(result);
|
||||
};
|
||||
|
||||
cursorRequest.onerror = designerDB.onerror;
|
||||
};
|
||||
|
||||
designerDB.loadAllObjects = function (table, callback)
|
||||
{
|
||||
var db = datastore;
|
||||
var transaction = db.transaction([table], 'readwrite');
|
||||
var objStore = transaction.objectStore(table);
|
||||
var keyRange = IDBKeyRange.lowerBound(0);
|
||||
var cursorRequest = objStore.openCursor(keyRange);
|
||||
|
||||
var results = [];
|
||||
|
||||
transaction.oncomplete = function (e) {
|
||||
callback(results);
|
||||
};
|
||||
|
||||
cursorRequest.onsuccess = function (e) {
|
||||
var result = e.target.result;
|
||||
|
||||
if (!!result == false) {
|
||||
return;
|
||||
}
|
||||
results.push(result.value);
|
||||
result.continue();
|
||||
};
|
||||
|
||||
cursorRequest.onerror = designerDB.onerror;
|
||||
};
|
||||
|
||||
designerDB.loadFirstObject = function(table, callback)
|
||||
{
|
||||
var db = datastore;
|
||||
var transaction = db.transaction([table], 'readwrite');
|
||||
var objStore = transaction.objectStore(table);
|
||||
var keyRange = IDBKeyRange.lowerBound(0);
|
||||
var cursorRequest = objStore.openCursor(keyRange);
|
||||
|
||||
var firstResult = null;
|
||||
|
||||
transaction.oncomplete = function(e) {
|
||||
callback(firstResult);
|
||||
};
|
||||
|
||||
cursorRequest.onsuccess = function(e) {
|
||||
var result = e.target.result;
|
||||
|
||||
if (!!result == false) {
|
||||
return;
|
||||
}
|
||||
firstResult = result.value;
|
||||
};
|
||||
|
||||
cursorRequest.onerror = designerDB.onerror;
|
||||
};
|
||||
|
||||
designerDB.addObject = function(table, obj, callback)
|
||||
{
|
||||
var db = datastore;
|
||||
var transaction = db.transaction([table], 'readwrite');
|
||||
var objStore = transaction.objectStore(table);
|
||||
|
||||
var request = objStore.put(obj);
|
||||
|
||||
request.onsuccess = function(e) {
|
||||
callback(e.currentTarget.result);
|
||||
};
|
||||
|
||||
request.onerror = designerDB.onerror;
|
||||
};
|
||||
|
||||
designerDB.deleteObject = function(table, id, callback)
|
||||
{
|
||||
var db = datastore;
|
||||
var transaction = db.transaction([table], 'readwrite');
|
||||
var objStore = transaction.objectStore(table);
|
||||
|
||||
var request = objStore.delete(parseInt(id));
|
||||
|
||||
request.onsuccess = function(e) {
|
||||
callback(true);
|
||||
}
|
||||
|
||||
request.onerror = function(e) {
|
||||
console.log(e);
|
||||
};
|
||||
};
|
||||
|
||||
// Export the designerDB object.
|
||||
return designerDB;
|
||||
}());
|
||||
34
js/pmd/designer_objects.js
Normal file
34
js/pmd/designer_objects.js
Normal file
@ -0,0 +1,34 @@
|
||||
function PDFPage(db_name, page_descr, tbl_cords)
|
||||
{
|
||||
if (page_descr == null) {
|
||||
this.pg_nr = db_name.pg_nr;
|
||||
this.db_name = db_name.db_name;
|
||||
this.page_descr = db_name.page_descr;
|
||||
this.tbl_cords = db_name.tbl_cords;
|
||||
} else {
|
||||
this.pg_nr;
|
||||
this.db_name = db_name;
|
||||
this.page_descr = page_descr;
|
||||
this.tbl_cords = tbl_cords;
|
||||
}
|
||||
}
|
||||
|
||||
function TableCoordinate(obj)
|
||||
{
|
||||
this.id = obj.id;
|
||||
this.db_name = obj.db_name;
|
||||
this.table_name = obj.table_name;
|
||||
this.pdf_pg_nr = obj.pdf_pg_nr;
|
||||
this.x = obj.x;
|
||||
this.y = obj.y;
|
||||
}
|
||||
|
||||
function TableCoordinate(db_name, table_name, pdf_pg_nr, x, y)
|
||||
{
|
||||
this.id;
|
||||
this.db_name = db_name;
|
||||
this.table_name = table_name;
|
||||
this.pdf_pg_nr = pdf_pg_nr;
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
}
|
||||
146
js/pmd/designer_page.js
Normal file
146
js/pmd/designer_page.js
Normal file
@ -0,0 +1,146 @@
|
||||
function Show_tables_in_landing_page()
|
||||
{
|
||||
Load_first_page(function (page) {
|
||||
if (page) {
|
||||
Load_HTML_for_page(page.pg_nr);
|
||||
selected_page = page.pg_nr;
|
||||
} else {
|
||||
Show_new_page_tables(true);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function Save_to_new_page(db, page_name, table_positions, callbcak)
|
||||
{
|
||||
Create_new_page(db, page_name, function (page) {
|
||||
if (page) {
|
||||
var tbl_cords = [];
|
||||
for (pos in table_positions) {
|
||||
table_positions[pos].pdf_pg_nr = page.pg_nr;
|
||||
Save_table_positions(table_positions[pos], function (id) {
|
||||
tbl_cords.push(id);
|
||||
if (table_positions.length === tbl_cords.length) {
|
||||
page.tbl_cords = tbl_cords;
|
||||
DesignerOfflineDB.addObject('pdf_pages', page, function() {});
|
||||
callbcak(page);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function Save_to_selected_page(db, page_id, page_name, table_positions, callbcak)
|
||||
{
|
||||
Delete_page(page_id, function() {});
|
||||
Save_to_new_page(db, page_name, table_positions, function (page) {
|
||||
callbcak(page);
|
||||
selected_page = page.pg_nr;
|
||||
});
|
||||
}
|
||||
|
||||
function Create_new_page(db, page_name, callback)
|
||||
{
|
||||
var newPage = new PDFPage(db, page_name);
|
||||
DesignerOfflineDB.addObject('pdf_pages', newPage, function (pg_nr) {
|
||||
newPage.pg_nr = pg_nr;
|
||||
callback(newPage);
|
||||
});
|
||||
}
|
||||
|
||||
function Save_table_positions(positions, callback)
|
||||
{
|
||||
DesignerOfflineDB.addObject('table_coords', positions, function (id) {
|
||||
callback(id);
|
||||
});
|
||||
}
|
||||
|
||||
function Create_page_list(callback)
|
||||
{
|
||||
DesignerOfflineDB.loadAllObjects('pdf_pages', function (pages) {
|
||||
var html = "";
|
||||
for( var p in pages) {
|
||||
html += '<option value="' + pages[p].pg_nr + '">';
|
||||
html += (pages[p].page_descr) + '</option>';
|
||||
}
|
||||
callback(html);
|
||||
});
|
||||
}
|
||||
|
||||
function Delete_page(page_id, callback)
|
||||
{
|
||||
DesignerOfflineDB.loadObject('pdf_pages', page_id, function (page) {
|
||||
if (page) {
|
||||
for (i in page.tbl_cords) {
|
||||
DesignerOfflineDB.deleteObject('table_coords', page.tbl_cords[i], function() {});
|
||||
}
|
||||
DesignerOfflineDB.deleteObject('pdf_pages', page_id, function (state) {
|
||||
callback(state);
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function Load_first_page(callback)
|
||||
{
|
||||
DesignerOfflineDB.loadFirstObject('pdf_pages', function (page) {
|
||||
callback(page);
|
||||
});
|
||||
}
|
||||
|
||||
function Show_new_page_tables(check)
|
||||
{
|
||||
var all_tables = $("#id_scroll_tab td input:checkbox");
|
||||
all_tables.prop('checked', check);
|
||||
for (var tab in all_tables) {
|
||||
var input = all_tables[tab];
|
||||
if (input.value) {
|
||||
VisibleTab(input, input.value);
|
||||
var element = document.getElementById(input.value);
|
||||
element.style.top = Get_random(550, 20) + 'px';
|
||||
element.style.left = Get_random(700, 20) + 'px';
|
||||
}
|
||||
}
|
||||
selected_page = -1;
|
||||
$("#top_menu #page_name").html(PMA_messages.strUntitled);
|
||||
}
|
||||
|
||||
function Load_HTML_for_page(page_id)
|
||||
{
|
||||
Show_new_page_tables(false);
|
||||
Load_page_objects(page_id, function (page, tbl_cords) {
|
||||
$("#top_menu #page_name").html(page.page_descr);
|
||||
for (var t in tbl_cords) {
|
||||
var tb_id = db + '.' + tbl_cords[t].table_name;
|
||||
var table = document.getElementById(tb_id);
|
||||
table.style.top = tbl_cords[t].y + 'px';
|
||||
table.style.left = tbl_cords[t].x + 'px';
|
||||
|
||||
var checkbox = document.getElementById("check_vis_" + tb_id);
|
||||
checkbox.checked = true;
|
||||
VisibleTab(checkbox, checkbox.value);
|
||||
}
|
||||
selected_page = page.pg_nr;
|
||||
});
|
||||
}
|
||||
|
||||
function Load_page_objects(page_id, callback)
|
||||
{
|
||||
DesignerOfflineDB.loadObject('pdf_pages', page_id, function (page) {
|
||||
var tbl_cords = [];
|
||||
for (i in page.tbl_cords) {
|
||||
DesignerOfflineDB.loadObject('table_coords', page.tbl_cords[i], function (tbl_cord) {
|
||||
tbl_cords.push(tbl_cord);
|
||||
if (tbl_cords.length === page.tbl_cords.length) {
|
||||
callback(page,tbl_cords);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function Get_random(max, min)
|
||||
{
|
||||
var val = Math.random() * (max - min) + min;
|
||||
return Math.floor(val);
|
||||
}
|
||||
@ -3,7 +3,7 @@
|
||||
* Initialises the data required to run PMD, then fires it up.
|
||||
*/
|
||||
|
||||
var j_tabs, h_tabs, contr, server, db, token, selected_page;
|
||||
var j_tabs, h_tabs, contr, server, db, token, selected_page, pmd_tables_enabled;
|
||||
|
||||
AJAX.registerTeardown('pmd/init.js', function () {
|
||||
$(".trigger").unbind('click');
|
||||
@ -15,18 +15,26 @@ AJAX.registerOnload('pmd/init.js', function () {
|
||||
$(this).toggleClass("active");
|
||||
return false;
|
||||
});
|
||||
|
||||
var tables_data = $.parseJSON($("#script_tables").html());
|
||||
|
||||
j_tabs = tables_data.j_tabs;
|
||||
h_tabs = tables_data.h_tabs;
|
||||
contr = $.parseJSON($("#script_contr").html());
|
||||
display_field = $.parseJSON($("#script_display_field").html());
|
||||
j_tabs = tables_data.j_tabs;
|
||||
h_tabs = tables_data.h_tabs;
|
||||
contr = $.parseJSON($("#script_contr").html());
|
||||
display_field = $.parseJSON($("#script_display_field").html());
|
||||
|
||||
server = $("#script_server").html();
|
||||
db = $("#script_db").html();
|
||||
token = $("#script_token").html();
|
||||
selected_page = $("#script_display_page").html();
|
||||
server = $("#script_server").html();
|
||||
db = $("#script_db").html();
|
||||
token = $("#script_token").html();
|
||||
selected_page = $("#script_display_page").html() === "" ? "-1" : $("#script_display_page").html();
|
||||
pmd_tables_enabled = $("#pmd_tables_enabled").html() === "1";
|
||||
|
||||
Main();
|
||||
|
||||
if (! pmd_tables_enabled) {
|
||||
DesignerOfflineDB.open(function(success) {
|
||||
if (success) {
|
||||
Show_tables_in_landing_page();
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
223
js/pmd/move.js
223
js/pmd/move.js
@ -541,30 +541,52 @@ function Save(url) // (del?) no for pdf
|
||||
|
||||
function Get_url_pos()
|
||||
{
|
||||
var poststr = '';
|
||||
for (var key in j_tabs) {
|
||||
poststr += '&t_x[' + key + ']=' + parseInt(document.getElementById(key).style.left, 10);
|
||||
poststr += '&t_y[' + key + ']=' + parseInt(document.getElementById(key).style.top, 10);
|
||||
poststr += '&t_v[' + key + ']=' + (document.getElementById('id_tbody_' + key).style.display == 'none' ? 0 : 1);
|
||||
poststr += '&t_h[' + key + ']=' + (document.getElementById('check_vis_' + key).checked ? 1 : 0);
|
||||
if (pmd_tables_enabled) {
|
||||
var poststr = '';
|
||||
for (var key in j_tabs) {
|
||||
poststr += '&t_x[' + key + ']=' + parseInt(document.getElementById(key).style.left, 10);
|
||||
poststr += '&t_y[' + key + ']=' + parseInt(document.getElementById(key).style.top, 10);
|
||||
poststr += '&t_v[' + key + ']=' + (document.getElementById('id_tbody_' + key).style.display == 'none' ? 0 : 1);
|
||||
poststr += '&t_h[' + key + ']=' + (document.getElementById('check_vis_' + key).checked ? 1 : 0);
|
||||
}
|
||||
return poststr;
|
||||
} else {
|
||||
var coords = [];
|
||||
for (var key in j_tabs) {
|
||||
if (document.getElementById('check_vis_' + key).checked) {
|
||||
var x = parseInt(document.getElementById(key).style.left, 10);
|
||||
var y = parseInt(document.getElementById(key).style.top, 10);
|
||||
var tbCoords = new TableCoordinate(db, key.split(".")[1], -1, x, y);
|
||||
coords.push(tbCoords);
|
||||
}
|
||||
}
|
||||
return coords;
|
||||
}
|
||||
return poststr;
|
||||
}
|
||||
|
||||
function Save2(callback)
|
||||
{
|
||||
_change = 0;
|
||||
var poststr = 'IS_AJAX=1&server=' + server + '&db=' + db + '&token=' + token + '&die_save_pos=1&selected_page=' + selected_page;
|
||||
poststr += Get_url_pos();
|
||||
makeRequest('pmd_save_pos.php', poststr);
|
||||
if (callback != null) {
|
||||
callback();
|
||||
if (pmd_tables_enabled) {
|
||||
var poststr = 'IS_AJAX=1&server=' + server + '&db=' + db + '&token=' + token + '&die_save_pos=1&selected_page=' + selected_page;
|
||||
poststr += Get_url_pos();
|
||||
makeRequest('pmd_save_pos.php', poststr);
|
||||
if (callback != null) {
|
||||
callback();
|
||||
}
|
||||
} else {
|
||||
var name = $("#page_name").html().trim();
|
||||
Save_to_selected_page(db, selected_page, name, Get_url_pos(), function (page){
|
||||
if (callback != null) {
|
||||
callback();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function Save3(callback)
|
||||
{
|
||||
if (selected_page !== '-1') {
|
||||
if (parseInt(selected_page) !== -1) {
|
||||
Save2(callback);
|
||||
} else {
|
||||
var button_options = {};
|
||||
@ -577,23 +599,37 @@ function Save3(callback)
|
||||
}
|
||||
$(this).dialog('close');
|
||||
|
||||
var $msgbox = PMA_ajaxShowMessage(PMA_messages.strProcessingRequest);
|
||||
PMA_prepareForAjaxRequest($form);
|
||||
$.post($form.attr('action'), $form.serialize() + Get_url_pos(), function (data) {
|
||||
if (data.success === false) {
|
||||
PMA_ajaxShowMessage(data.error, false);
|
||||
} else {
|
||||
PMA_ajaxRemoveMessage($msgbox);
|
||||
_change = 0;
|
||||
if (data.id) {
|
||||
selected_page = data.id;
|
||||
if (pmd_tables_enabled) {
|
||||
var $msgbox = PMA_ajaxShowMessage(PMA_messages.strProcessingRequest);
|
||||
PMA_prepareForAjaxRequest($form);
|
||||
$.post($form.attr('action'), $form.serialize() + Get_url_pos(), function (data) {
|
||||
if (data.success === false) {
|
||||
PMA_ajaxShowMessage(data.error, false);
|
||||
} else {
|
||||
PMA_ajaxRemoveMessage($msgbox);
|
||||
_change = 0;
|
||||
if (data.id) {
|
||||
selected_page = data.id;
|
||||
}
|
||||
$('#page_name').text(name);
|
||||
if (callback != null) {
|
||||
callback();
|
||||
}
|
||||
}
|
||||
$('#page_name').text(name);
|
||||
});
|
||||
} else {
|
||||
Save_to_new_page(db, name, Get_url_pos(), function (page) {
|
||||
_change = 0;
|
||||
debugger;
|
||||
if (page.pg_nr) {
|
||||
selected_page = page.pg_nr;
|
||||
}
|
||||
$('#page_name').text(page.page_descr);
|
||||
if (callback != null) {
|
||||
callback();
|
||||
}
|
||||
}
|
||||
}); // end $.post()
|
||||
});
|
||||
}
|
||||
};
|
||||
button_options[PMA_messages.strCancel] = function () {
|
||||
$(this).dialog('close');
|
||||
@ -647,6 +683,12 @@ function Edit_pages()
|
||||
PMA_ajaxShowMessage(data.error, false);
|
||||
} else {
|
||||
PMA_ajaxRemoveMessage($msgbox);
|
||||
|
||||
if (! pmd_tables_enabled) {
|
||||
Create_page_list(function (options) {
|
||||
$("#page_edit_dialog #selected_page").append(options);
|
||||
});
|
||||
}
|
||||
$('<div id="page_edit_dialog"></div>')
|
||||
.append(data.message)
|
||||
.dialog({
|
||||
@ -675,20 +717,36 @@ function Delete_pages()
|
||||
}
|
||||
|
||||
var $msgbox = PMA_ajaxShowMessage(PMA_messages.strProcessingRequest);
|
||||
var deleting_current_page = selected === selected_page;
|
||||
var deleting_current_page = selected == selected_page;
|
||||
PMA_prepareForAjaxRequest($form);
|
||||
$.post($form.attr('action'), $form.serialize(), function (data) {
|
||||
if (data.success === false) {
|
||||
PMA_ajaxShowMessage(data.error, false);
|
||||
} else {
|
||||
PMA_ajaxRemoveMessage($msgbox);
|
||||
if (deleting_current_page) {
|
||||
Load_page(null);
|
||||
|
||||
if (pmd_tables_enabled) {
|
||||
$.post($form.attr('action'), $form.serialize(), function (data) {
|
||||
if (data.success === false) {
|
||||
PMA_ajaxShowMessage(data.error, false);
|
||||
} else {
|
||||
PMA_ajaxShowMessage(PMA_messages.strSuccessfulPageDelete);
|
||||
PMA_ajaxRemoveMessage($msgbox);
|
||||
if (deleting_current_page) {
|
||||
Load_page(null);
|
||||
} else {
|
||||
PMA_ajaxShowMessage(PMA_messages.strSuccessfulPageDelete);
|
||||
}
|
||||
}
|
||||
}
|
||||
}); // end $.post()
|
||||
}); // end $.post()
|
||||
} else {
|
||||
Delete_page(selected, function (success) {
|
||||
if (! success) {
|
||||
PMA_ajaxShowMessage("Error", false);
|
||||
} else {
|
||||
PMA_ajaxRemoveMessage($msgbox);
|
||||
if (deleting_current_page) {
|
||||
Load_page(null);
|
||||
} else {
|
||||
PMA_ajaxShowMessage(PMA_messages.strSuccessfulPageDelete);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
$(this).dialog('close');
|
||||
};
|
||||
@ -703,6 +761,13 @@ function Delete_pages()
|
||||
PMA_ajaxShowMessage(data.error, false);
|
||||
} else {
|
||||
PMA_ajaxRemoveMessage($msgbox);
|
||||
|
||||
if (! pmd_tables_enabled) {
|
||||
Create_page_list(function (options) {
|
||||
$("#page_delete_dialog #selected_page").append(options);
|
||||
});
|
||||
}
|
||||
|
||||
$('<div id="page_delete_dialog"></div>')
|
||||
.append(data.message)
|
||||
.dialog({
|
||||
@ -744,19 +809,42 @@ function Save_as()
|
||||
}
|
||||
|
||||
var $msgbox = PMA_ajaxShowMessage(PMA_messages.strProcessingRequest);
|
||||
PMA_prepareForAjaxRequest($form);
|
||||
$.post($form.attr('action'), $form.serialize() + Get_url_pos(), function (data) {
|
||||
if (data.success === false) {
|
||||
PMA_ajaxShowMessage(data.error, false);
|
||||
} else {
|
||||
PMA_ajaxRemoveMessage($msgbox);
|
||||
_change = 0;
|
||||
if (data.id) {
|
||||
selected_page = data.id;
|
||||
if (pmd_tables_enabled) {
|
||||
PMA_prepareForAjaxRequest($form);
|
||||
$.post($form.attr('action'), $form.serialize() + Get_url_pos(), function (data) {
|
||||
if (data.success === false) {
|
||||
PMA_ajaxShowMessage(data.error, false);
|
||||
} else {
|
||||
PMA_ajaxRemoveMessage($msgbox);
|
||||
_change = 0;
|
||||
if (data.id) {
|
||||
selected_page = data.id;
|
||||
}
|
||||
$('#page_name').text(name);
|
||||
}
|
||||
$('#page_name').text(name);
|
||||
}); // end $.post()
|
||||
} else {
|
||||
if (choice === 'same') {
|
||||
var selected_page_id = $selected_page.find('option:selected').val();
|
||||
Save_to_selected_page(db, selected_page_id, name, Get_url_pos(), function (page) {
|
||||
PMA_ajaxRemoveMessage($msgbox);
|
||||
_change = 0;
|
||||
if (page.pg_nr) {
|
||||
selected_page = page.pg_nr;
|
||||
}
|
||||
$('#page_name').text(page.page_descr);
|
||||
});
|
||||
} else if (choice === 'new') {
|
||||
Save_to_new_page(db, name, Get_url_pos(), function (page) {
|
||||
PMA_ajaxRemoveMessage($msgbox);
|
||||
_change = 0;
|
||||
if (page.pg_nr) {
|
||||
selected_page = page.pg_nr;
|
||||
}
|
||||
$('#page_name').text(page.page_descr);
|
||||
});
|
||||
}
|
||||
}); // end $.post()
|
||||
}
|
||||
|
||||
$(this).dialog('close');
|
||||
};
|
||||
@ -771,6 +859,13 @@ function Save_as()
|
||||
PMA_ajaxShowMessage(data.error, false);
|
||||
} else {
|
||||
PMA_ajaxRemoveMessage($msgbox);
|
||||
|
||||
if (! pmd_tables_enabled) {
|
||||
Create_page_list(function (options) {
|
||||
$("#page_save_as_dialog #selected_page").append(options);
|
||||
});
|
||||
}
|
||||
|
||||
$('<div id="page_save_as_dialog"></div>')
|
||||
.append(data.message)
|
||||
.dialog({
|
||||
@ -828,7 +923,7 @@ function Export_pages()
|
||||
button_options[PMA_messages.strGo] = function () {
|
||||
var $form = $("#id_export_pages");
|
||||
var $msgbox = PMA_ajaxShowMessage(PMA_messages.strProcessingRequest);
|
||||
location.href = $form.attr('action') + '?' + getParamsForExport($form) + Get_url_pos();
|
||||
location.href = $form.attr('action') + '?' + getParamsForExport($form);
|
||||
$msgbox.remove();
|
||||
$(this).dialog('close');
|
||||
};
|
||||
@ -873,19 +968,35 @@ function getParamsForExport($from)
|
||||
url += "&show_grid=" + ($from.find('input[name="show_grid"]').is(":checked") ? "on" : "off");
|
||||
url += "&show_keys=" + ($from.find('input[name="show_keys"]').is(":checked") ? "on" : "off");
|
||||
url += "&show_table_dimension=" + ($from.find('input[name="show_table_dimension"]').is(":checked") ? "on" : "off");
|
||||
url += "&offline_export=" + (pmd_tables_enabled ? "off" : "on");
|
||||
if (pmd_tables_enabled) {
|
||||
url += Get_url_pos();
|
||||
} else {
|
||||
url += "&tbl_coords=" + JSON.stringify(Get_url_pos());
|
||||
}
|
||||
|
||||
return url;
|
||||
}
|
||||
|
||||
|
||||
function Load_page(page) {
|
||||
var param_page = '';
|
||||
if (page != null) {
|
||||
param_page = '&page=' + page;
|
||||
if (pmd_tables_enabled) {
|
||||
var param_page = '';
|
||||
if (page != null) {
|
||||
param_page = '&page=' + page;
|
||||
}
|
||||
$('<a href="pmd_general.php?db=' + db + '&token=' + token + param_page + '"></a>')
|
||||
.appendTo($('#page_content'))
|
||||
.click();
|
||||
} else {
|
||||
if (page == null) {
|
||||
Show_tables_in_landing_page();
|
||||
} else if (page > -1) {
|
||||
Load_HTML_for_page(page);
|
||||
} else if (page === -1) {
|
||||
Show_new_page_tables(true);
|
||||
}
|
||||
}
|
||||
$('<a href="pmd_general.php?db=' + db + '&token=' + token + param_page + '"></a>')
|
||||
.appendTo($('#page_content'))
|
||||
.click();
|
||||
_change = 0;
|
||||
}
|
||||
|
||||
@ -1608,4 +1719,4 @@ function add_object()
|
||||
existingDiv.innerHTML = display(init, history_array.length);
|
||||
Close_option();
|
||||
panel(0);
|
||||
}
|
||||
}
|
||||
@ -471,11 +471,11 @@ class PMA_Menu
|
||||
$tabs['tracking']['link'] = 'db_tracking.php';
|
||||
}
|
||||
|
||||
if (! $db_is_system_schema && $cfgRelation['pdfwork']) {
|
||||
$tabs['designer']['text'] = __('Designer');
|
||||
$tabs['designer']['icon'] = 'b_relations.png';
|
||||
$tabs['designer']['link'] = 'pmd_general.php';
|
||||
}
|
||||
$tabs['designer']['text'] = __('Designer');
|
||||
$tabs['designer']['icon'] = 'b_relations.png';
|
||||
$tabs['designer']['link'] = 'pmd_general.php';
|
||||
$tabs['designer']['id'] = 'designer_tab';
|
||||
|
||||
if (! $db_is_system_schema && $cfgRelation['central_columnswork']) {
|
||||
$tabs['central_columns']['text'] = __('Central columns');
|
||||
$tabs['central_columns']['icon'] = 'centralColumns.png';
|
||||
|
||||
@ -21,6 +21,7 @@ require_once 'libraries/relation.lib.php';
|
||||
*/
|
||||
function PMA_getHtmlForEditOrDeletePages($db, $operation)
|
||||
{
|
||||
$cfgRelation = PMA_getRelationsParam();
|
||||
$html = '<form action="pmd_general.php" method="post"'
|
||||
. ' name="edit_delete_pages" id="edit_delete_pages" class="ajax">';
|
||||
$html .= PMA_URL_getHiddenInputs($db);
|
||||
@ -35,10 +36,12 @@ function PMA_getHtmlForEditOrDeletePages($db, $operation)
|
||||
$html .= ': </label>';
|
||||
$html .= '<select name="selected_page" id="selected_page">';
|
||||
$html .= '<option value="0">-- ' . __('Select page').' --</option>';
|
||||
$pages = PMA_getPageIdsAndNames($db);
|
||||
foreach ($pages as $nr => $desc) {
|
||||
$html .= '<option value="' . $nr . '">';
|
||||
$html .= htmlspecialchars($desc) . '</option>';
|
||||
if ($cfgRelation['pdfwork']) {
|
||||
$pages = PMA_getPageIdsAndNames($db);
|
||||
foreach ($pages as $nr => $desc) {
|
||||
$html .= '<option value="' . $nr . '">';
|
||||
$html .= htmlspecialchars($desc) . '</option>';
|
||||
}
|
||||
}
|
||||
$html .= '</select>';
|
||||
$html .= '</fieldset>';
|
||||
@ -55,6 +58,7 @@ function PMA_getHtmlForEditOrDeletePages($db, $operation)
|
||||
*/
|
||||
function PMA_getHtmlForPageSaveAs($db)
|
||||
{
|
||||
$cfgRelation = PMA_getRelationsParam();
|
||||
$choices = array(
|
||||
'same' => __('Save to selected page'),
|
||||
'new' => __('Create a page and save to it')
|
||||
@ -72,10 +76,12 @@ function PMA_getHtmlForPageSaveAs($db)
|
||||
$html .= '<select name="selected_page" id="selected_page">';
|
||||
$html .= '<option value="0">-- ' . __('Select page') . ' --</option>';
|
||||
|
||||
$pages = PMA_getPageIdsAndNames($db);
|
||||
foreach ($pages as $nr => $desc) {
|
||||
$html .= '<option value="' . $nr . '">';
|
||||
$html .= htmlspecialchars($desc) . '</option>';
|
||||
if ($cfgRelation['pdfwork']) {
|
||||
$pages = PMA_getPageIdsAndNames($db);
|
||||
foreach ($pages as $nr => $desc) {
|
||||
$html .= '<option value="' . $nr . '">';
|
||||
$html .= htmlspecialchars($desc) . '</option>';
|
||||
}
|
||||
}
|
||||
$html .= '</select>';
|
||||
$html .= '</td>';
|
||||
|
||||
@ -221,10 +221,10 @@ class Table_Stats_Dia extends TableStats
|
||||
*
|
||||
* @see PMA_DIA
|
||||
*/
|
||||
function __construct($tableName, $pageNumber, $showKeys = false)
|
||||
function __construct($tableName, $pageNumber, $showKeys = false, $offline = false)
|
||||
{
|
||||
global $dia, $cfgRelation, $db;
|
||||
parent::__construct($dia, $db, $pageNumber, $tableName, $showKeys, false);
|
||||
parent::__construct($dia, $db, $pageNumber, $tableName, $showKeys, false, $offline);
|
||||
|
||||
/**
|
||||
* Every object in Dia document needs an ID to identify
|
||||
@ -674,17 +674,28 @@ class PMA_Dia_Relation_Schema extends PMA_Export_Relation_Schema
|
||||
$this->setOrientation(isset($_POST['orientation']));
|
||||
$this->setPaper($_POST['paper']);
|
||||
$this->setExportType($_POST['export_type']);
|
||||
$this->setOffline($_POST['offline_export']);
|
||||
|
||||
$dia = new PMA_DIA();
|
||||
$dia->startDiaDoc(
|
||||
$this->paper, $this->_topMargin, $this->_bottomMargin,
|
||||
$this->_leftMargin, $this->_rightMargin, $this->orientation
|
||||
);
|
||||
$alltables = $this->getAllTables($db, $this->pageNumber);
|
||||
|
||||
if ($this->isOffline()) {
|
||||
$alltables = array();
|
||||
$tbl_coords = json_decode($GLOBALS['tbl_coords']);
|
||||
foreach ($tbl_coords as $tbl) {
|
||||
$alltables[] = $tbl->table_name;
|
||||
}
|
||||
} else {
|
||||
$alltables = $this->getAllTables($db, $this->pageNumber);
|
||||
}
|
||||
|
||||
foreach ($alltables as $table) {
|
||||
if (! isset($this->tables[$table])) {
|
||||
$this->_tables[$table] = new Table_Stats_Dia(
|
||||
$table, $this->pageNumber, $this->showKeys
|
||||
$table, $this->pageNumber, $this->showKeys, $this->isOffline()
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -726,7 +737,11 @@ class PMA_Dia_Relation_Schema extends PMA_Export_Relation_Schema
|
||||
function showOutput()
|
||||
{
|
||||
global $dia, $db;
|
||||
$dia->showOutput($db . '-' . $this->pageNumber);
|
||||
$filename = $db . '-' . $this->pageNumber;
|
||||
if ($this->isOffline()) {
|
||||
$filename = __("dia export page");
|
||||
}
|
||||
$dia->showOutput($filename);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -340,11 +340,11 @@ class Table_Stats_Eps extends TableStats
|
||||
*/
|
||||
function __construct(
|
||||
$tableName, $font, $fontSize, $pageNumber, &$same_wide_width,
|
||||
$showKeys = false, $showInfo = false
|
||||
$showKeys = false, $showInfo = false, $offline = false
|
||||
) {
|
||||
global $eps, $cfgRelation, $db;
|
||||
parent::__construct(
|
||||
$eps, $db, $pageNumber, $tableName, $showKeys, $showInfo
|
||||
$eps, $db, $pageNumber, $tableName, $showKeys, $showInfo, $offline
|
||||
);
|
||||
|
||||
// height and width
|
||||
@ -701,6 +701,7 @@ class PMA_Eps_Relation_Schema extends PMA_Export_Relation_Schema
|
||||
$this->setAllTablesSameWidth($_POST['all_tables_same_width']);
|
||||
$this->setOrientation($_POST['orientation']);
|
||||
$this->setExportType($_POST['export_type']);
|
||||
$this->setOffline($_POST['offline_export']);
|
||||
|
||||
$eps = new PMA_EPS();
|
||||
$eps->setTitle(
|
||||
@ -715,13 +716,21 @@ class PMA_Eps_Relation_Schema extends PMA_Export_Relation_Schema
|
||||
$eps->setOrientation($this->orientation);
|
||||
$eps->setFont('Verdana', '10');
|
||||
|
||||
$alltables = $this->getAllTables($db, $this->pageNumber);
|
||||
if ($this->isOffline()) {
|
||||
$alltables = array();
|
||||
$tbl_coords = json_decode($GLOBALS['tbl_coords']);
|
||||
foreach ($tbl_coords as $tbl) {
|
||||
$alltables[] = $tbl->table_name;
|
||||
}
|
||||
} else {
|
||||
$alltables = $this->getAllTables($db, $this->pageNumber);
|
||||
}
|
||||
|
||||
foreach ($alltables as $table) {
|
||||
if (! isset($this->_tables[$table])) {
|
||||
$this->_tables[$table] = new Table_Stats_Eps(
|
||||
$table, $eps->getFont(), $eps->getFontSize(), $this->pageNumber,
|
||||
$this->_tablewidth, $this->showKeys, $this->tableDimension
|
||||
$this->_tablewidth, $this->showKeys, $this->tableDimension, $this->isOffline()
|
||||
);
|
||||
}
|
||||
|
||||
@ -768,7 +777,11 @@ class PMA_Eps_Relation_Schema extends PMA_Export_Relation_Schema
|
||||
function showOutput()
|
||||
{
|
||||
global $eps,$db;
|
||||
$eps->showOutput($db . '-' . $this->pageNumber);
|
||||
$filename = $db . '-' . $this->pageNumber;
|
||||
if ($this->isOffline()) {
|
||||
$filename = __("eps export page");
|
||||
}
|
||||
$eps->showOutput($filename);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -30,6 +30,7 @@ class PMA_Export_Relation_Schema
|
||||
public $paper;
|
||||
public $pageNumber;
|
||||
public $exportType;
|
||||
public $offline;
|
||||
|
||||
/**
|
||||
* Set Page Number
|
||||
@ -183,6 +184,32 @@ class PMA_Export_Relation_Schema
|
||||
$this->exportType=$value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set whether the document is generated from client side DB
|
||||
*
|
||||
* @param string $value 'on' if offline
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @access public
|
||||
*/
|
||||
public function setOffline($value)
|
||||
{
|
||||
$this->offline = (isset($value) && $value == 'on');
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether the client side database is used
|
||||
*
|
||||
* @return boolean
|
||||
*
|
||||
* @access public
|
||||
*/
|
||||
public function isOffline()
|
||||
{
|
||||
return $this->offline;
|
||||
}
|
||||
|
||||
/**
|
||||
* get all tables involved or included in page
|
||||
*
|
||||
|
||||
@ -50,6 +50,7 @@ class PMA_Schema_PDF extends PMA_PDF
|
||||
var $def_outlines;
|
||||
var $widths;
|
||||
private $_ff = PMA_PDF_FONT;
|
||||
private $offline;
|
||||
|
||||
/**
|
||||
* Sets the value for margins
|
||||
@ -224,15 +225,21 @@ class PMA_Schema_PDF extends PMA_PDF
|
||||
// This function must be named "Header" to work with the TCPDF library
|
||||
global $cfgRelation, $db, $pdf_page_number, $with_doc;
|
||||
if ($with_doc) {
|
||||
$test_query = 'SELECT * FROM '
|
||||
. PMA_Util::backquote($GLOBALS['cfgRelation']['db']) . '.'
|
||||
. PMA_Util::backquote($cfgRelation['pdf_pages'])
|
||||
. ' WHERE db_name = \'' . PMA_Util::sqlAddSlashes($db) . '\''
|
||||
. ' AND page_nr = \'' . $pdf_page_number . '\'';
|
||||
$test_rs = PMA_queryAsControlUser($test_query);
|
||||
$pages = @$GLOBALS['dbi']->fetchAssoc($test_rs);
|
||||
if ($this->offline) {
|
||||
$pg_name = __("pdf export page");
|
||||
} else {
|
||||
$test_query = 'SELECT * FROM '
|
||||
. PMA_Util::backquote($GLOBALS['cfgRelation']['db']) . '.'
|
||||
. PMA_Util::backquote($cfgRelation['pdf_pages'])
|
||||
. ' WHERE db_name = \'' . PMA_Util::sqlAddSlashes($db) . '\''
|
||||
. ' AND page_nr = \'' . $pdf_page_number . '\'';
|
||||
$test_rs = PMA_queryAsControlUser($test_query);
|
||||
$pages = @$GLOBALS['dbi']->fetchAssoc($test_rs);
|
||||
$pg_name = ucfirst($pages['page_descr']);
|
||||
}
|
||||
|
||||
$this->SetFont($this->_ff, 'B', 14);
|
||||
$this->Cell(0, 6, ucfirst($pages['page_descr']), 'B', 1, 'C');
|
||||
$this->Cell(0, 6, $pg_name, 'B', 1, 'C');
|
||||
$this->SetFont($this->_ff, '');
|
||||
$this->Ln();
|
||||
}
|
||||
@ -364,6 +371,20 @@ class PMA_Schema_PDF extends PMA_PDF
|
||||
}
|
||||
return $nl;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set whether the document is generated from client side DB
|
||||
*
|
||||
* @param string $value 'on' if offline
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @access private
|
||||
*/
|
||||
public function setOffline($value)
|
||||
{
|
||||
$this->offline = (isset($value) && $value == 'on');
|
||||
}
|
||||
}
|
||||
|
||||
require_once './libraries/schema/TableStats.class.php';
|
||||
@ -406,11 +427,11 @@ class Table_Stats_Pdf extends TableStats
|
||||
* Table_Stats_Pdf::Table_Stats_setHeight
|
||||
*/
|
||||
function __construct($tableName, $fontSize, $pageNumber, &$sameWideWidth,
|
||||
$showKeys = false, $showInfo = false
|
||||
$showKeys = false, $showInfo = false, $offline = false
|
||||
) {
|
||||
global $pdf, $cfgRelation, $db;
|
||||
parent::__construct(
|
||||
$pdf, $db, $pageNumber, $tableName, $showKeys, $showInfo
|
||||
$pdf, $db, $pageNumber, $tableName, $showKeys, $showInfo, $offline
|
||||
);
|
||||
|
||||
$this->heightCell = 6;
|
||||
@ -837,6 +858,7 @@ class PMA_Pdf_Relation_Schema extends PMA_Export_Relation_Schema
|
||||
$this->setOrientation($_POST['orientation']);
|
||||
$this->setPaper($_POST['paper']);
|
||||
$this->setExportType($_POST['export_type']);
|
||||
$this->setOffline($_POST['offline_export']);
|
||||
|
||||
// Initializes a new document
|
||||
$pdf = new PMA_Schema_PDF($this->orientation, 'mm', $this->paper);
|
||||
@ -850,7 +872,16 @@ class PMA_Pdf_Relation_Schema extends PMA_Export_Relation_Schema
|
||||
$pdf->setCMargin(0);
|
||||
$pdf->Open();
|
||||
$pdf->SetAutoPageBreak('auto');
|
||||
$alltables = $this->getAllTables($db, $this->pageNumber);
|
||||
$pdf->setOffline($this->isOffline());
|
||||
if ($this->isOffline()){
|
||||
$alltables = array();
|
||||
$tbl_coords = json_decode($GLOBALS['tbl_coords']);
|
||||
foreach ($tbl_coords as $tbl) {
|
||||
$alltables[] = $tbl->table_name;
|
||||
}
|
||||
} else {
|
||||
$alltables = $this->getAllTables($db, $this->pageNumber);
|
||||
}
|
||||
|
||||
if ($this->withDoc) {
|
||||
$pdf->SetAutoPageBreak('auto', 15);
|
||||
@ -879,7 +910,8 @@ class PMA_Pdf_Relation_Schema extends PMA_Export_Relation_Schema
|
||||
$this->pageNumber,
|
||||
$this->_tablewidth,
|
||||
$this->showKeys,
|
||||
$this->tableDimension
|
||||
$this->tableDimension,
|
||||
$this->isOffline()
|
||||
);
|
||||
}
|
||||
if ($this->sameWide) {
|
||||
@ -1146,19 +1178,24 @@ class PMA_Pdf_Relation_Schema extends PMA_Export_Relation_Schema
|
||||
global $pdf, $cfgRelation;
|
||||
|
||||
// Get the name of this pdfpage to use as filename
|
||||
$editingPage = $_POST['chpage'] != '-1' ? $_POST['chpage'] : $pageNumber;
|
||||
$_name_sql = 'SELECT page_descr FROM '
|
||||
. PMA_Util::backquote($GLOBALS['cfgRelation']['db']) . '.'
|
||||
. PMA_Util::backquote($cfgRelation['pdf_pages'])
|
||||
. ' WHERE page_nr = ' . $editingPage;
|
||||
$_name_rs = PMA_queryAsControlUser($_name_sql);
|
||||
if ($_name_rs) {
|
||||
$_name_row = $GLOBALS['dbi']->fetchRow($_name_rs);
|
||||
$filename = $_name_row[0] . '.pdf';
|
||||
}
|
||||
if (empty($filename)) {
|
||||
$filename = $editingPage . '.pdf';
|
||||
if ($this->isOffline()) {
|
||||
$filename = __("pdf export page") . '.pdf';
|
||||
} else {
|
||||
$editingPage = $_POST['chpage'] != '-1' ? $_POST['chpage'] : $pageNumber;
|
||||
$_name_sql = 'SELECT page_descr FROM '
|
||||
. PMA_Util::backquote($GLOBALS['cfgRelation']['db']) . '.'
|
||||
. PMA_Util::backquote($cfgRelation['pdf_pages'])
|
||||
. ' WHERE page_nr = ' . $editingPage;
|
||||
$_name_rs = PMA_queryAsControlUser($_name_sql);
|
||||
if ($_name_rs) {
|
||||
$_name_row = $GLOBALS['dbi']->fetchRow($_name_rs);
|
||||
$filename = $_name_row[0] . '.pdf';
|
||||
}
|
||||
if (empty($filename)) {
|
||||
$filename = $editingPage . '.pdf';
|
||||
}
|
||||
}
|
||||
|
||||
$pdf->Download($filename);
|
||||
}
|
||||
|
||||
|
||||
@ -306,12 +306,12 @@ class Table_Stats_Svg extends TableStats
|
||||
* Table_Stats_Svg::Table_Stats_setHeight
|
||||
*/
|
||||
function __construct(
|
||||
$tableName, $font, $fontSize, $pageNumber,
|
||||
&$same_wide_width, $showKeys = false, $showInfo = false
|
||||
$tableName, $font, $fontSize, $pageNumber, &$same_wide_width,
|
||||
$showKeys = false, $showInfo = false, $offline = false
|
||||
) {
|
||||
global $svg, $cfgRelation, $db;
|
||||
parent::__construct(
|
||||
$svg, $db, $pageNumber, $tableName, $showKeys, $showInfo
|
||||
$svg, $db, $pageNumber, $tableName, $showKeys, $showInfo, $offline
|
||||
);
|
||||
|
||||
// height and width
|
||||
@ -672,6 +672,7 @@ class PMA_Svg_Relation_Schema extends PMA_Export_Relation_Schema
|
||||
$this->setTableDimension($_POST['show_table_dimension']);
|
||||
$this->setAllTablesSameWidth($_POST['all_tables_same_width']);
|
||||
$this->setExportType($_POST['export_type']);
|
||||
$this->setOffline($_POST['offline_export']);
|
||||
|
||||
$svg = new PMA_SVG();
|
||||
$svg->setTitle(
|
||||
@ -685,13 +686,22 @@ class PMA_Svg_Relation_Schema extends PMA_Export_Relation_Schema
|
||||
$svg->setFont('Arial');
|
||||
$svg->setFontSize('16px');
|
||||
$svg->startSvgDoc('1000px', '1000px');
|
||||
$alltables = $this->getAllTables($db, $this->pageNumber);
|
||||
|
||||
if ($this->isOffline()) {
|
||||
$alltables = array();
|
||||
$tbl_coords = json_decode($GLOBALS['tbl_coords']);
|
||||
foreach ($tbl_coords as $tbl) {
|
||||
$alltables[] = $tbl->table_name;
|
||||
}
|
||||
} else {
|
||||
$alltables = $this->getAllTables($db, $this->pageNumber);
|
||||
}
|
||||
|
||||
foreach ($alltables as $table) {
|
||||
if (! isset($this->_tables[$table])) {
|
||||
$this->_tables[$table] = new Table_Stats_Svg(
|
||||
$table, $svg->getFont(), $svg->getFontSize(), $this->pageNumber,
|
||||
$this->_tablewidth, $this->showKeys, $this->tableDimension
|
||||
$this->_tablewidth, $this->showKeys, $this->tableDimension, $this->isOffline()
|
||||
);
|
||||
}
|
||||
|
||||
@ -738,7 +748,11 @@ class PMA_Svg_Relation_Schema extends PMA_Export_Relation_Schema
|
||||
function showOutput()
|
||||
{
|
||||
global $svg,$db;
|
||||
$svg->showOutput($db . '-' . $this->pageNumber);
|
||||
$filename = $db . '-' . $this->pageNumber;
|
||||
if ($this->isOffline()) {
|
||||
$filename = __("svg export page");
|
||||
}
|
||||
$svg->showOutput($filename);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -36,6 +36,8 @@ abstract class TableStats
|
||||
public $width = 0;
|
||||
public $heightCell = 0;
|
||||
|
||||
protected $offline;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
@ -48,7 +50,7 @@ abstract class TableStats
|
||||
* @param boolean $showInfo whether to display table position or not
|
||||
*/
|
||||
public function __construct(
|
||||
$diagram, $db, $pageNumber, $tableName, $showKeys, $showInfo
|
||||
$diagram, $db, $pageNumber, $tableName, $showKeys, $showInfo, $offline
|
||||
) {
|
||||
$this->diagram = $diagram;
|
||||
$this->db = $db;
|
||||
@ -58,6 +60,8 @@ abstract class TableStats
|
||||
$this->showKeys = $showKeys;
|
||||
$this->showInfo = $showInfo;
|
||||
|
||||
$this->offline = $offline;
|
||||
|
||||
// checks whether the table exists
|
||||
// and loads fields
|
||||
$this->validateTableAndLoadFields();
|
||||
@ -118,21 +122,32 @@ abstract class TableStats
|
||||
{
|
||||
global $cfgRelation;
|
||||
|
||||
$sql = "SELECT x, y FROM "
|
||||
. PMA_Util::backquote($GLOBALS['cfgRelation']['db']) . "."
|
||||
if ($this->offline){
|
||||
$tbl_coords = json_decode($GLOBALS['tbl_coords']);
|
||||
foreach ($tbl_coords as $tbl) {
|
||||
if( $this->tableName === $tbl->table_name){
|
||||
$this->x = (double) $tbl->x;
|
||||
$this->y = (double) $tbl->y;
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$sql = "SELECT x, y FROM "
|
||||
. PMA_Util::backquote($GLOBALS['cfgRelation']['db']) . "."
|
||||
. PMA_Util::backquote($cfgRelation['table_coords'])
|
||||
. " WHERE db_name = '" . PMA_Util::sqlAddSlashes($this->db) . "'"
|
||||
. " AND table_name = '" . PMA_Util::sqlAddSlashes($this->tableName) . "'"
|
||||
. " AND pdf_page_number = " . $this->pageNumber;
|
||||
$result = PMA_queryAsControlUser(
|
||||
$sql, false, PMA_DatabaseInterface::QUERY_STORE
|
||||
);
|
||||
if (! $result || ! $GLOBALS['dbi']->numRows($result)) {
|
||||
$this->showMissingCoordinatesError();
|
||||
$result = PMA_queryAsControlUser(
|
||||
$sql, false, PMA_DatabaseInterface::QUERY_STORE
|
||||
);
|
||||
if (! $result || ! $GLOBALS['dbi']->numRows($result)) {
|
||||
$this->showMissingCoordinatesError();
|
||||
}
|
||||
list($this->x, $this->y) = $GLOBALS['dbi']->fetchRow($result);
|
||||
$this->x = (double) $this->x;
|
||||
$this->y = (double) $this->y;
|
||||
}
|
||||
list($this->x, $this->y) = $GLOBALS['dbi']->fetchRow($result);
|
||||
$this->x = (double) $this->x;
|
||||
$this->y = (double) $this->y;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -84,6 +84,9 @@ $header = $response->getHeader();
|
||||
$header->setBodyId('pmd_body');
|
||||
$scripts = $header->getScripts();
|
||||
$scripts->addFile('jquery/jquery.fullscreen.js');
|
||||
$scripts->addFile('pmd/designer_db.js');
|
||||
$scripts->addFile('pmd/designer_objects.js');
|
||||
$scripts->addFile('pmd/designer_page.js');
|
||||
$scripts->addFile('pmd/ajax.js');
|
||||
$scripts->addFile('pmd/history.js');
|
||||
$scripts->addFile('pmd/move.js');
|
||||
@ -116,7 +119,9 @@ echo '</div>';
|
||||
echo '<div id="script_display_page" class="hide">';
|
||||
echo htmlspecialchars($display_page);
|
||||
echo '</div>';
|
||||
|
||||
echo '<div id="pmd_tables_enabled" class="hide">';
|
||||
echo htmlspecialchars($cfgRelation['pdfwork']);
|
||||
echo '</div>';
|
||||
?>
|
||||
<div class="pmd_header" id="top_menu">
|
||||
<a href="#" onclick="Show_left_menu(document.getElementById('key_Show_left_menu')); return false"
|
||||
|
||||
@ -31,7 +31,9 @@ foreach ($post_params as $one_post_param) {
|
||||
}
|
||||
}
|
||||
|
||||
PMA_saveTablePositions($_REQUEST['selected_page']);
|
||||
if (isset($_REQUEST['selected_page']) {
|
||||
PMA_saveTablePositions($_REQUEST['selected_page']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Error handler
|
||||
|
||||
@ -41,7 +41,9 @@ $post_params = array(
|
||||
'show_grid',
|
||||
'show_keys',
|
||||
'show_table_dimension',
|
||||
'with_doc'
|
||||
'with_doc',
|
||||
'offline_export',
|
||||
'tbl_coords'
|
||||
);
|
||||
foreach ($post_params as $one_post_param) {
|
||||
if (isset($_REQUEST[$one_post_param])) {
|
||||
@ -50,15 +52,20 @@ foreach ($post_params as $one_post_param) {
|
||||
}
|
||||
}
|
||||
|
||||
$temp_page = PMA_createNewPage("_temp" . rand(), $GLOBALS['db']);
|
||||
try {
|
||||
PMA_saveTablePositions($temp_page);
|
||||
$_POST['pdf_page_number'] = $temp_page;
|
||||
if ($_POST['offline_export'] === "on") {
|
||||
$_POST['pdf_page_number'] = -1;
|
||||
PMA_processExportSchema();
|
||||
PMA_deletePage($temp_page);
|
||||
} catch (Exception $e) {
|
||||
PMA_deletePage($temp_page); // delete temp page even if an exception occured
|
||||
throw $e;
|
||||
} else {
|
||||
$temp_page = PMA_createNewPage("_temp" . rand(), $GLOBALS['db']);
|
||||
try {
|
||||
PMA_saveTablePositions($temp_page);
|
||||
$_POST['pdf_page_number'] = $temp_page;
|
||||
PMA_processExportSchema();
|
||||
PMA_deletePage($temp_page);
|
||||
} catch (Exception $e) {
|
||||
PMA_deletePage($temp_page); // delete temp page even if an exception occured
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Loading…
Reference in New Issue
Block a user