BUG 9286 Comments are deleted from the XML code for DynaForms SOLVED
- ProcessMaker deletes comments from XML code. For example if I have: - Change in the way of creating XML files in DynaForms.
This commit is contained in:
@@ -26,6 +26,7 @@
|
||||
*/
|
||||
|
||||
G::LoadClass( 'xmlDb' );
|
||||
G::LoadSystem('dynaformhandler');
|
||||
|
||||
/**
|
||||
* Dynaform Field - DynaformField class
|
||||
@@ -34,6 +35,16 @@ G::LoadClass( 'xmlDb' );
|
||||
*/
|
||||
class DynaFormField extends DBTable
|
||||
{
|
||||
private $fileName;
|
||||
public function getFileName()
|
||||
{
|
||||
return $this->fileName;
|
||||
}
|
||||
|
||||
public function setFileName($fileName)
|
||||
{
|
||||
$this->fileName = $fileName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function SetTo
|
||||
@@ -108,9 +119,9 @@ class DynaFormField extends DBTable
|
||||
$this->Fields = $Fields;
|
||||
unset( $this->Fields['XMLNODE_NAME_OLD'] );
|
||||
/*
|
||||
* MPD-10 to create fields that do not appear many attributes, only the main ones?
|
||||
* The show those who are not white
|
||||
*/
|
||||
* MPD-10 to create fields that do not appear many attributes, only the main ones?
|
||||
* The show those who are not white
|
||||
*/
|
||||
if ($this->is_new) {
|
||||
foreach ($this->Fields as $key => $value) {
|
||||
if ($value == "")
|
||||
@@ -125,12 +136,12 @@ class DynaFormField extends DBTable
|
||||
parent::Save();
|
||||
if ($this->is_new) {
|
||||
/*
|
||||
* Create a new field.
|
||||
*/
|
||||
* Create a new field.
|
||||
*/
|
||||
foreach ($labels as $lang => $value) {
|
||||
/*$res = $this->_dbses->Execute('INSERT INTO dynaForm'.
|
||||
' (XMLNODE_TYPE,XMLNODE_VALUE)'.
|
||||
' VALUES ("cdata", "'."\n".'")');*/
|
||||
' (XMLNODE_TYPE,XMLNODE_VALUE)'.
|
||||
' VALUES ("cdata", "'."\n".'")');*/
|
||||
$res = $this->_dbses->Execute( 'INSERT INTO dynaForm.' . $Fields['XMLNODE_NAME'] . ' (XMLNODE_NAME,XMLNODE_VALUE,XMLNODE_TYPE) ' . 'VALUES ("","' . "\n " . '","cdata")' );
|
||||
$res = $this->_dbses->Execute( 'INSERT INTO dynaForm.' . $Fields['XMLNODE_NAME'] . ' (XMLNODE_NAME,XMLNODE_VALUE) ' . 'VALUES ("' . $lang . '","' . str_replace( '"', '""', $value )/*."\n "*/.'")' );
|
||||
if (isset( $options[$lang] )) {
|
||||
@@ -165,6 +176,63 @@ class DynaFormField extends DBTable
|
||||
}
|
||||
}
|
||||
|
||||
function saveField ($Fields, $attributes = array(), $options = array())
|
||||
{
|
||||
$dynaform = new dynaFormHandler( $this->getFileName());
|
||||
if ($Fields['TYPE'] === 'javascript') {
|
||||
$Fields['XMLNODE_VALUE'] = $Fields['CODE'];
|
||||
unset( $Fields['CODE'] );
|
||||
$attributes = array ();
|
||||
}
|
||||
if ($Fields['XMLNODE_NAME_OLD'] == '') {
|
||||
if (($Fields['XMLNODE_NAME'][0] == '1') || ($Fields['XMLNODE_NAME'][0] == '2') || ($Fields['XMLNODE_NAME'][0] == '3') || ($Fields['XMLNODE_NAME'][0] == '4') || ($Fields['XMLNODE_NAME'][0] == '5') || ($Fields['XMLNODE_NAME'][0] == '6') || ($Fields['XMLNODE_NAME'][0] == '7') || ($Fields['XMLNODE_NAME'][0] == '8') || ($Fields['XMLNODE_NAME'][0] == '9') || ($Fields['XMLNODE_NAME'][0] == '10')) {
|
||||
$Fields['XMLNODE_NAME'] = '_' . $Fields['XMLNODE_NAME'];
|
||||
}
|
||||
$res = $this->_dbses->Execute( 'SELECT * FROM dynaForm WHERE XMLNODE_NAME="' . $Fields['XMLNODE_NAME'] . '"' );
|
||||
} else {
|
||||
if (($Fields['XMLNODE_NAME_OLD'][0] == '1') || ($Fields['XMLNODE_NAME_OLD'][0] == '2') || ($Fields['XMLNODE_NAME_OLD'][0] == '3') || ($Fields['XMLNODE_NAME_OLD'][0] == '4') || ($Fields['XMLNODE_NAME_OLD'][0] == '5') || ($Fields['XMLNODE_NAME_OLD'][0] == '6') || ($Fields['XMLNODE_NAME_OLD'][0] == '7') || ($Fields['XMLNODE_NAME_OLD'][0] == '8') || ($Fields['XMLNODE_NAME_OLD'][0] == '9') || ($Fields['XMLNODE_NAME_OLD'][0] == '10')) {
|
||||
$Fields['XMLNODE_NAME_OLD'] = '_' . $Fields['XMLNODE_NAME_OLD'];
|
||||
}
|
||||
$res = $this->_dbses->Execute( 'SELECT * FROM dynaForm WHERE XMLNODE_NAME="' . $Fields['XMLNODE_NAME_OLD'] . '"' );
|
||||
}
|
||||
$this->is_new = ($res->count() == 0);
|
||||
$this->Fields = $Fields;
|
||||
unset( $this->Fields['XMLNODE_NAME_OLD'] );
|
||||
/*
|
||||
* MPD-10 to create fields that do not appear many attributes, only the main ones?
|
||||
* The show those who are not white
|
||||
*/
|
||||
if ($this->is_new) {
|
||||
foreach ($this->Fields as $key => $value) {
|
||||
if ($value == "") {
|
||||
unset( $this->Fields[$key] );
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$this->Fields['XMLNODE_NAME'] = $Fields['XMLNODE_NAME_OLD'];
|
||||
}
|
||||
|
||||
// parent::Save();
|
||||
if (trim($Fields['XMLNODE_VALUE']) != "") {
|
||||
$attributes['#cdata'] = $Fields['XMLNODE_VALUE'];
|
||||
}
|
||||
|
||||
$aOptions = array();
|
||||
if(isset($Fields['OPTIONS']) && is_array($Fields['OPTIONS']) ) {
|
||||
foreach ($Fields['OPTIONS'] as $key => $value) {
|
||||
$aOptions[] = Array( 'name' => 'option', 'value' => $value['LABEL'],
|
||||
'attributes' => array('name'=>$value['NAME']) );
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->is_new) {
|
||||
// Create a new field
|
||||
$dynaform->add($Fields['XMLNODE_NAME'], $attributes, $options, $aOptions);
|
||||
} else {
|
||||
$dynaform->replace($Fields['XMLNODE_NAME_OLD'], $Fields['XMLNODE_NAME'], $attributes, $options, $aOptions);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Verify if is New the Field
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user