BUG 9509 "On ProcessMaker 2.0.42 the WYSISWG editor doesn't..." SOLVED

- OutputDocument the WYSISWG editor doesn't generate the content
  of a GRID correctly
- Solved problem, now generated correctly the source of the OutputDocument,
  was also corrected the problem with the tag <table>
This commit is contained in:
Victor Saisa Lopez
2012-08-03 16:31:21 -04:00
parent 3b78081f18
commit e84c194487
3 changed files with 189 additions and 117 deletions

View File

@@ -1,6 +1,6 @@
PMExtJSCommon = function() {
this.version = '1.8';
this.notify_time_out = 3;
this.confirm = function(title, msg, fnYes, fnNo)
@@ -16,9 +16,9 @@ PMExtJSCommon = function() {
setTimeout(fnYes, 0)
else if( fnNo != undefined )
setTimeout(fnNo, 0)
});
});
}
this.info = function(title, msg, fn) {
Ext.MessageBox.show({
title: title,
@@ -65,12 +65,12 @@ PMExtJSCommon = function() {
icon: Ext.MessageBox.ERROR
});
}
this.notify = function(title, msg, type, time)
{
Ext.msgBoxSlider.msg(title, msg, type, time);
}
this.getBrowser = function()
{
var browsersList = new Array("opera", "msie", "firefox", "chrome", "safari");
@@ -78,12 +78,12 @@ PMExtJSCommon = function() {
var name = 'Unknown';
var version = '';
var screen = {
width : Ext.getBody().getViewSize().width,
width : Ext.getBody().getViewSize().width,
height : Ext.getBody().getViewSize().height
};
var so = Ext.isLinux ? 'Linux' : ( Ext.isWindows ? 'Windows' : (Ext.isMac ? 'Mac OS' : 'Unknown') );
for (var i = 0; i < browsersList.length; i++){
if ((name == "") && (browserMeta.indexOf(browsersList[i]) != -1)){
name = browsersList[i];
@@ -91,7 +91,7 @@ PMExtJSCommon = function() {
break;
}
}
return {name:name, version:version, screen: screen}
}
@@ -100,7 +100,7 @@ PMExtJSCommon = function() {
var labelColumnWidth = 170;
var valueColumnWidth = 350;
params = params || {};
if(typeof columnsSize != 'undefined') {
labelColumnWidth = columnsSize[0] || labelColumnWidth;
valueColumnWidth = columnsSize[1] || valueColumnWidth;
@@ -124,7 +124,7 @@ PMExtJSCommon = function() {
dataIndex : 'label',
renderer: function(v){return '<b><font color="#465070">'+v+'</font></b>'},
align: 'right'
},
},
{
width : valueColumnWidth,
dataIndex : 'value'
@@ -133,7 +133,7 @@ PMExtJSCommon = function() {
dataIndex : 'section'
}],
autoHeight : true,
columnLines: true,
columnLines: true,
trackMouseOver:false,
disableSelection:true,
view: new Ext.grid.GroupingView({
@@ -171,7 +171,7 @@ PMExtJSCommon = function() {
}
}
}
}
var PMExt = new PMExtJSCommon();
@@ -198,7 +198,7 @@ Ext.msgBoxSlider = function(){
}
//msgCt.alignTo(document, 'br-br');
//msgCt.alignTo(document, "br-br", [-20, -20]);
var s = String.format.apply(String, Array.prototype.slice.call(arguments, 1));
var m = Ext.DomHelper.append(msgCt, {html:createBox(title, s)}, true);
m.setWidth(400 );
@@ -207,7 +207,7 @@ Ext.msgBoxSlider = function(){
type = typeof type != 'undefined' ? type : '';
time = typeof time != 'undefined' ? time : PMExt.notify_time_out;
switch(type) {
case 'alert':
case 'warning':
@@ -222,7 +222,7 @@ Ext.msgBoxSlider = function(){
case 'info':
image = '/images/info.png';
break;
case 'success':
case 'success':
case 'ok':
image = '/images/select-icon.png';
break;
@@ -244,7 +244,7 @@ Ext.msgBoxSlider = function(){
},
msgTopCenter : function(type, title, format, time) {
if (typeof remove == 'undefined')
if (typeof remove == 'undefined')
remove : true;
time = typeof time != 'undefined' ? time : PMExt.notify_time_out;
@@ -252,7 +252,7 @@ Ext.msgBoxSlider = function(){
if( ! msgCt ) {
msgCt = Ext.DomHelper.insertFirst(document.body, {id:'msg-div', style:'position:absolute'}, true);
}
var s = String.format.apply(String, Array.prototype.slice.call(arguments, 2));
var m = Ext.DomHelper.append(msgCt, {html:createBox(title, s)}, true);
m.setWidth(400 );
@@ -273,7 +273,7 @@ Ext.msgBoxSlider = function(){
case 'info':
image = '/images/info.png';
break;
case 'success':
case 'success':
case 'ok':
image = '/images/select-icon.png';
break;
@@ -318,7 +318,7 @@ Ext.msgBoxSlider = function(){
};
}();*/
/**
/**
* Translator function for internationalization
*/
function _()
@@ -328,20 +328,20 @@ function _()
if( typeof TRANSLATIONS != 'undefined' && TRANSLATIONS) {
if( typeof TRANSLATIONS[argv[0]] != 'undefined' ) {
if (argc > 1) {
if (argc > 1) {
trn = TRANSLATIONS[argv[0]];
for (i = 1; i < argv.length; i++) {
trn = trn.replace('{'+(i-1)+'}', argv[i]);
}
}
else {
trn = TRANSLATIONS[argv[0]];
trn = TRANSLATIONS[argv[0]];
}
}
}
else {
trn = '**' + argv[0] + '**';
}
}
}
else {
PMExt.error('Processmaker JS Core Error', 'The TRANSLATIONS global object is not loaded!');
trn = '';
@@ -349,18 +349,18 @@ function _()
return trn;
}
/**
/**
* Environment Formats function for full name
*/
function _FNF(USER_NAME, FIRST_NAME, LAST_NAME, FN_FORMAT)
{
{
if (typeof FORMATS != 'undefined') {
FN_FORMAT = FORMATS.format;
}
else {
FN_FORMAT = '(@lastName, @firstName) @userName';
}
var aux = FN_FORMAT;
aux = aux.replace('@userName',USER_NAME);
aux = aux.replace('@firstName',FIRST_NAME);
@@ -368,13 +368,13 @@ function _FNF(USER_NAME, FIRST_NAME, LAST_NAME, FN_FORMAT)
return aux;
}
/**
/**
* Environment Formats function for date
*/
function _DF(DATE_TIME, D_FORMAT)
{
function LZ(x){return(x<0||x>9?"":"0")+x;}
if(typeof D_FORMAT == 'undefined'){
if (typeof FORMATS != 'undefined') {
D_FORMAT = FORMATS.dateFormat;
@@ -388,7 +388,7 @@ function _DF(DATE_TIME, D_FORMAT)
if (DATE_TIME == '')
return '';
else
return '**' + DATE_TIME + '**';
return '**' + DATE_TIME + '**';
}
var arrD = DATE_TIME.split(' ');
@@ -400,8 +400,8 @@ function _DF(DATE_TIME, D_FORMAT)
else {
var arrH = new Array(0,0,0);
}
var MONTH_NAMES=new Array(_('ID_MONTH_1'),_('ID_MONTH_2'),_('ID_MONTH_3'),_('ID_MONTH_4'),_('ID_MONTH_5'),_('ID_MONTH_6'),_('ID_MONTH_7'),
_('ID_MONTH_8'),_('ID_MONTH_9'),_('ID_MONTH_10'),_('ID_MONTH_11'),_('ID_MONTH_12'),_('ID_MONTH_ABB_1'),_('ID_MONTH_ABB_2'),
_('ID_MONTH_ABB_3'),_('ID_MONTH_ABB_4'),_('ID_MONTH_ABB_5'),_('ID_MONTH_ABB_6'),_('ID_MONTH_ABB_7'),_('ID_MONTH_ABB_8'),
@@ -418,7 +418,7 @@ function _DF(DATE_TIME, D_FORMAT)
var H=date.getHours();
var m=date.getMinutes();
var s=date.getSeconds();
var values = new Object();
values['Y'] = y;
values['y'] = y.substring(2, 4);
@@ -442,14 +442,14 @@ function _DF(DATE_TIME, D_FORMAT)
if (H>11) values['A'] = 'PM'; else values['A'] = 'AM';
if (typeof FORMATS == 'undefined') values['T'] = '**';
else values['T'] = FORMATS.TimeZone;
var aDate = D_FORMAT.split('');
var aux = '';
var xParts = new Array('Y','y','F','M','m','n','d','j','D','l','G','H','g','h','i','s','a','A','T');
for (var i=0; i < aDate.length; i++){
if (xParts.indexOf(aDate[i])==-1){
aux = aux + aDate[i];
aux = aux + aDate[i];
}
else{
aux = aux + values[aDate[i]];
@@ -482,3 +482,13 @@ String.prototype.nl2br = function () {
return this.replace(/\n/g,'<br />');
}
/**
* String Replace function, if StrSearch has special characters "(", "[", must be escape "\\(", "\\[".
*/
function stringReplace(strSearch, stringReplace, str)
{
var expression = eval("/" + strSearch + "/g");
return str.replace(expression, stringReplace);
}

View File

@@ -509,8 +509,12 @@ class OutputDocument extends BaseOutputDocument
$aProperties=array()
) {
if (($sUID != '') && is_array($aFields) && ($sPath != '')) {
$sContent = G::unhtmlentities($sContent);
$strContentAux = str_replace(array("\n", "\r", "\t"), array(null, null, null), $sContent);
$nrt = array("\n", "\r", "\t");
$nrthtml = array("(n /)", "(r /)", "(t /)");
$sContent = G::unhtmlentities($sContent);
$strContentAux = str_replace($nrt, $nrthtml, $sContent);
$iOcurrences = preg_match_all('/\@(?:([\>])([a-zA-Z\_]\w*)|([a-zA-Z\_][\w\-\>\:]*)\(((?:[^\\\\\)]*(?:[\\\\][\w\W])?)*)\))((?:\s*\[[\'"]?\w+[\'"]?\])+)?/', $strContentAux, $arrayMatch1, PREG_PATTERN_ORDER | PREG_OFFSET_CAPTURE);
@@ -554,6 +558,8 @@ class OutputDocument extends BaseOutputDocument
}
}
$strContentAux = str_replace($nrthtml, $nrt, $strContentAux);
$sContent = $strContentAux;
foreach ($aFields as $sKey => $vValue) {

View File

@@ -1,14 +1,97 @@
function setGridHtml(outdocHtml, swEdit)
{
var outdocHtmlAux = outdocHtml;
outdocHtmlAux = stringReplace("\\x0A", "(n /)", outdocHtmlAux); //\n 10
outdocHtmlAux = stringReplace("\\x0D", "(r /)", outdocHtmlAux); //\r 13
outdocHtmlAux = stringReplace("\\x09", "(t /)", outdocHtmlAux); //\t 9
var arrayMatch1 = [];
var outdocHtmlAux1 = "";
var strHtml = "";
///////
outdocHtmlAux1 = outdocHtmlAux;
strHtml = "";
//@>
if (swEdit == 1) {
while ((arrayMatch1 = /^(.*)<tr>[\(\)nrt\s\/]*<td>[\(\)nrt\s\/]*(@>[a-zA-Z\_]\w*)[\(\)nrt\s\/]*<\/td>[\(\)nrt\s\/]*<\/tr>(.*)$/ig.exec(outdocHtmlAux1))) {
outdocHtmlAux1 = arrayMatch1[1];
strHtml = arrayMatch1[2] + arrayMatch1[3] + strHtml;
}
} else {
while ((arrayMatch1 = /^(.*<table.*>.*)(@>[a-zA-Z\_]\w*)(.*<\/table>.*)$/ig.exec(outdocHtmlAux1))) {
outdocHtmlAux1 = arrayMatch1[1];
strHtml = "<tr><td>" + arrayMatch1[2] + "</td></tr>" + arrayMatch1[3] + strHtml;
}
}
strHtml = outdocHtmlAux1 + strHtml;
///////
outdocHtmlAux1 = strHtml;
strHtml = "";
//@< //Copy of @>
if (swEdit == 1) {
while ((arrayMatch1 = /^(.*)<tr>[\(\)nrt\s\/]*<td>[\(\)nrt\s\/]*(@<[a-zA-Z\_]\w*)[\(\)nrt\s\/]*<\/td>[\(\)nrt\s\/]*<\/tr>(.*)$/ig.exec(outdocHtmlAux1))) {
outdocHtmlAux1 = arrayMatch1[1];
strHtml = arrayMatch1[2] + arrayMatch1[3] + strHtml;
}
} else {
while ((arrayMatch1 = /^(.*<table.*>.*)(@<[a-zA-Z\_]\w*)(.*<\/table>.*)$/ig.exec(outdocHtmlAux1))) {
outdocHtmlAux1 = arrayMatch1[1];
strHtml = "<tr><td>" + arrayMatch1[2] + "</td></tr>" + arrayMatch1[3] + strHtml;
}
}
strHtml = outdocHtmlAux1 + strHtml;
///////
strHtml = stringReplace("\\(n \\/\\)", "\n", strHtml);
strHtml = stringReplace("\\(r \\/\\)", "\r", strHtml);
strHtml = stringReplace("\\(t \\/\\)", "\t", strHtml);
outdocHtml = strHtml;
return outdocHtml;
}
function setHtml(outdocHtml, swEdit)
{
if (outdocHtml.indexOf("@>") > 0 || outdocHtml.indexOf("@&gt;") > 0) {
if (swEdit == 1) {
outdocHtml = stringReplace("@&gt;", "@>", outdocHtml);
outdocHtml = stringReplace("@&lt;", "@<", outdocHtml);
outdocHtml = setGridHtml(outdocHtml, swEdit);
} else {
outdocHtml = setGridHtml(outdocHtml, swEdit);
outdocHtml = stringReplace("@>", "@&gt;", outdocHtml);
outdocHtml = stringReplace("@<", "@&lt;", outdocHtml);
}
}
return outdocHtml;
}
var importOption;
Ext.onReady(function(){
Ext.QuickTips.init();
// turn on validation errors beside the field globally
Ext.form.Field.prototype.msgTarget = 'side';
var bd = Ext.getBody();
var sourceEdit = 0;
importOption = new Ext.Action({
text: _('ID_LOAD_FROM_FILE'),
iconCls: 'silk-add',
@@ -22,7 +105,7 @@ Ext.onReady(function(){
autoScroll: false,
maximizable: false,
resizable: false,
items: [
new Ext.FormPanel({
/*renderTo: 'form-panel',*/
@@ -58,25 +141,21 @@ Ext.onReady(function(){
uploader.getForm().submit({
url: 'outputdocs_Ajax?action=setTemplateFile',
waitMsg: _('ID_UPLOADING_FILE'),
success: function(o, resp){
success: function (o, resp) {
w.close();
Ext.Ajax.request({
url: 'outputdocs_Ajax?action=getTemplateFile&r='+Math.random(),
success: function(response){
txtParse = response.responseText;
if ((txtParse.indexOf('@>')>0)||(txtParse.indexOf('@&gt;')>0)){
txtParse = txtParse.replace('@<','@&lt;');
response.responseText = txtParse;
}
Ext.getCmp('OUT_DOC_TEMPLATE').setValue(response.responseText);
if(Ext.getCmp('OUT_DOC_TEMPLATE').getValue(response.responseText)=='')
Ext.Msg.alert(_('ID_ALERT_MESSAGE'), _('ID_INVALID_FILE'));
},
failure: function(){},
params: {request: 'getRows'}
});
Ext.Ajax.request({
url: "outputdocs_Ajax?action=getTemplateFile&r=" + Math.random(),
success: function (response) {
Ext.getCmp("OUT_DOC_TEMPLATE").setValue(setHtml(response.responseText, sourceEdit));
if (Ext.getCmp("OUT_DOC_TEMPLATE").getValue() == "") {
Ext.Msg.alert(_("ID_ALERT_MESSAGE"), _("ID_INVALID_FILE"));
}
},
failure: function () {},
params: {request: "getRows"}
});
},
failure: function(o, resp){
w.close();
@@ -99,7 +178,7 @@ Ext.onReady(function(){
w.show();
}
});
var top = new Ext.FormPanel({
labelAlign: 'top',
@@ -116,36 +195,17 @@ Ext.onReady(function(){
height:300,
anchor:'98%',
listeners: {
editmodechange: function(he,b){
txtParse = he.getRawValue();
if (!b){
if ((txtParse.indexOf('@>')>0)||(txtParse.indexOf('@&gt;')>0)){
txtParse = txtParse.replace('@<','@&lt;');
he.setValue(txtParse);
}
}
editmodechange: function (he, srcEdit) {
sourceEdit = (srcEdit == true)? 1 : 0;
he.setValue(setHtml(he.getRawValue(), sourceEdit));
},
beforepush: function(he, h){
txtParse = h;
if ((txtParse.indexOf('@>')>0)||(txtParse.indexOf('@&gt;')>0)){
if (txtParse.indexOf('@<')>0){
txtParse = txtParse.replace('@<','@&lt;');
he.setValue(txtParse);
}
//return false;
}
}//,
// beforesync: function(he, h){
// alert(h);
// txtParse = h;
// if ((txtParse.indexOf('@>')>0)||(txtParse.indexOf('@&gt;')>0)){
// if (txtParse.indexOf('@<')>0){
// txtParse = txtParse.replace('@<','@&lt;');
// he.setValue(txtParse);
// }
// //return false;
// }
// }
beforepush: function (he, outdocHtml) {
//
}
//,
//beforesync: function (he, h) {
//}
}
}],
@@ -153,24 +213,24 @@ Ext.onReady(function(){
text: _('ID_SAVE'),
handler: function(){
Ext.Ajax.request({
url: 'outputdocs_Save',
success: function(response){
Ext.Msg.show({
title: '',
msg: _('ID_SAVED_SUCCESSFULLY'),
fn: function(){},
animEl: 'elId',
icon: Ext.MessageBox.INFO,
buttons: Ext.MessageBox.OK
});
},
failure: function(){},
params: {
'form[OUT_DOC_UID]': OUT_DOC_UID,
'form[OUT_DOC_TEMPLATE]':Ext.getCmp('OUT_DOC_TEMPLATE').getValue()
}
url: "outputdocs_Save",
success: function (response) {
Ext.Msg.show({
title: "",
msg: _("ID_SAVED_SUCCESSFULLY"),
fn: function () {},
animEl: "elId",
icon: Ext.MessageBox.INFO,
buttons: Ext.MessageBox.OK
});
},
failure: function () {},
params: {
"form[OUT_DOC_UID]": OUT_DOC_UID,
"form[OUT_DOC_TEMPLATE]": setHtml(Ext.getCmp("OUT_DOC_TEMPLATE").getValue(), 1)
}
});
}
}
},{
text: _('ID_CANCEL'),
handler: function(){
@@ -184,18 +244,14 @@ Ext.onReady(function(){
});
top.render(document.body);
Ext.Ajax.request({
url: 'outputdocs_Ajax?action=loadTemplateContent&r='+Math.random(),
success: function(response){
Ext.getCmp('OUT_DOC_TEMPLATE').setValue(response.responseText);
},
failure: function(){},
params: {OUT_DOC_UID: OUT_DOC_UID}
});
Ext.Ajax.request({
url: "outputdocs_Ajax?action=loadTemplateContent&r=" + Math.random(),
success: function(response){
Ext.getCmp("OUT_DOC_TEMPLATE").setValue(setHtml(response.responseText, 0));
},
failure: function () {},
params: {OUT_DOC_UID: OUT_DOC_UID}
});
});
//function _(ID){
// return TRANSLATIONS[ID];
//}