BUG 9286 Comments are deleted from the XML code for DynaForms SOLVED

- ProcessMaker deletes comments from XML code.
- Adjustment in the standarized Code.
This commit is contained in:
Hector Cortez
2012-10-25 16:08:30 -04:00
parent 8e4229f53e
commit f62edeec83
4 changed files with 1178 additions and 1138 deletions

View File

@@ -1,4 +1,5 @@
<?php
/**
* class.dynaformhandler.php
* @package gulliver.system
@@ -25,14 +26,14 @@
*/
/**
* @author Erik Amaru Ortiz <erik@colosa.com>
* @date Aug 26th, 2009
* @description This class is a Dynaform handler for modify directly into file
* @package gulliver.system
*/
* @author Erik Amaru Ortiz <erik@colosa.com>
* @date Aug 26th, 2009
* @description This class is a Dynaform handler for modify directly into file
* @package gulliver.system
*/
class dynaFormHandler
{
private $xmlfile;
private $dom;
private $root;
@@ -43,30 +44,34 @@ class dynaFormHandler
* @param string $file
* @return void
*/
function __construct($file=null)
public function __construct($file = null)
{
if( !isset($file) )
if (!isset($file)) {
throw new Exception('[Class dynaFormHandler] ERROR: xml file was not set!!');
}
$this->xmlfile = $file;
$this->load();
}
function load(){
public function load()
{
$this->dom = new DOMDocument();
$this->dom->preserveWhiteSpace = false;
$this->dom->formatOutput = true;
if( is_file($this->xmlfile) ) {
if ( @$this->dom->load($this->xmlfile) === true ) {
if (is_file($this->xmlfile)) {
if (@$this->dom->load($this->xmlfile) === true) {
$this->root = $this->dom->firstChild;
} else
throw new Exception('Error: '.$this->xmlfile.' is a invalid xml file!');
} else {
throw new Exception('[Class dynaFormHandler] ERROR: the ('.$this->xmlfile.') file doesn\'t exits!!');
throw new Exception('Error: ' . $this->xmlfile . ' is a invalid xml file!');
}
} else {
throw new Exception('[Class dynaFormHandler] ERROR: the (' . $this->xmlfile . ') file doesn\'t exits!!');
}
}
function reload(){
$this->dom = NULL;
public function reload()
{
$this->dom = null;
$this->load();
}
@@ -75,11 +80,11 @@ class dynaFormHandler
* @access public
* @return void
*/
function __cloneEmpty()
public function __cloneEmpty()
{
$xPath = new DOMXPath($this->dom);
$nodeList = $xPath->query('/dynaForm/*');
foreach ($nodeList as $domElement){
foreach ($nodeList as $domElement) {
$elements[] = $domElement->nodeName;
}
$this->remove($elements);
@@ -92,11 +97,13 @@ class dynaFormHandler
* @param string $op
* @return void
*/
function toString($op='')
public function toString($op = '')
{
switch($op){
switch ($op) {
case 'html': return htmlentities(file_get_contents($this->xmlfile));
break;
default: return file_get_contents($this->xmlfile);
break;
}
}
@@ -106,7 +113,7 @@ class dynaFormHandler
* @param string $nodename
* @return void
*/
function getNode($nodename)
public function getNode($nodename)
{
return $this->root->getElementsByTagName($nodename)->item(0);
}
@@ -117,7 +124,8 @@ class dynaFormHandler
* @param object $node
* @return object
*/
function setNode($node){
public function setNode($node)
{
$newnode = $this->root->appendChild($node);
$this->save();
return $newnode;
@@ -132,27 +140,27 @@ class dynaFormHandler
* @return void
*/
//attributes (String node-name, Array attributes(atribute-name =>attribute-value, ..., ...), Array childs(child-name=>child-content), Array Child-childs())
function add($name, $attributes, $childs, $childs_childs=null)
public function add($name, $attributes, $childs, $childs_childs = null)
{
$newnode = $this->root->appendChild($this->dom->createElement($name));
if( isset($attributes['#cdata']) ) {
if (isset($attributes['#cdata'])) {
$newnode->appendChild($this->dom->createTextNode("\n"));
$newnode->appendChild($this->dom->createCDATASection($attributes['#cdata']));
$newnode->appendChild($this->dom->createTextNode("\n"));
unset($attributes['#cdata']);
}
foreach($attributes as $att_name => $att_value) {
foreach ($attributes as $att_name => $att_value) {
$newnode->setAttribute($att_name, $att_value);
}
if(is_array($childs)){
foreach($childs as $child_name => $child_text) {
if (is_array($childs)) {
foreach ($childs as $child_name => $child_text) {
$newnode_child = $newnode->appendChild($this->dom->createElement($child_name));
$newnode_child->appendChild($this->dom->createTextNode($child_text));
if($childs_childs != null and is_array($childs_childs)){
foreach($childs_childs as $cc) {
if ($childs_childs != null and is_array($childs_childs)) {
foreach ($childs_childs as $cc) {
$ccmode = $newnode_child->appendChild($this->dom->createElement($cc['name']));
$ccmode->appendChild($this->dom->createTextNode($cc['value']));
foreach($cc['attributes'] as $cc_att_name => $cc_att_value) {
foreach ($cc['attributes'] as $cc_att_name => $cc_att_value) {
$ccmode->setAttribute($cc_att_name, $cc_att_value);
}
}
@@ -204,90 +212,94 @@ class dynaFormHandler
* @param array $childs_childs
* @return void
*/
function replace($replaced, $name, $attributes, $childs=null, $childs_childs=null)
public function replace($replaced, $name, $attributes, $childs = null, $childs_childs = null)
{
$chidNode= array();
$chidNode = array();
$element = $this->root->getElementsByTagName($replaced)->item(0);
$this->root->replaceChild($this->dom->createElement($name), $element);
// $newnode = $element = $this->root->getElementsByTagName($name)->item(0);
$newnode = $this->root->getElementsByTagName($name)->item(0);
if( isset($attributes['#text']) ) {
if (isset($attributes['#text'])) {
$newnode->appendChild($this->dom->createTextNode($attributes['#text']));
unset($attributes['#text']);
}
if( isset($attributes['#cdata']) ) {
if (isset($attributes['#cdata'])) {
$newnode->appendChild($this->dom->createTextNode("\n"));
$newnode->appendChild($this->dom->createCDATASection($attributes['#cdata']));
$newnode->appendChild($this->dom->createTextNode("\n"));
unset($attributes['#cdata']);
}
foreach($attributes as $att_name => $att_value) {
foreach ($attributes as $att_name => $att_value) {
if (!is_array($att_value)) {
$newnode->setAttribute($att_name, $att_value);
}
}
if(is_array($childs)){
if (is_array($childs)) {
foreach ($element->childNodes as $pNode) {
if( $pNode->nodeName != SYS_LANG && $pNode->nodeName != '#cdata-section' && $pNode->nodeName != '#text') {
if ($pNode->nodeName != SYS_LANG && $pNode->nodeName != '#cdata-section' && $pNode->nodeName != '#text') {
$chidNode[] = $this->getChildNode($pNode);
$childs[$pNode->nodeName] = $pNode->firstChild->nodeValue;
}
}
foreach($childs as $child_name => $child_text) {
foreach ($childs as $child_name => $child_text) {
$newnode->appendChild($this->dom->createTextNode(" "));
$newnode_child = $newnode->appendChild($this->dom->createElement($child_name));
if( is_string($child_text) )
if (is_string($child_text)) {
$newnode_child->appendChild($this->dom->createTextNode($child_text));
else if( is_array($child_text) && isset($child_text['cdata']) )
} else {
if (is_array($child_text) && isset($child_text['cdata'])) {
$newnode_child->appendChild($this->dom->createCDATASection($child_text));
if ($child_name == SYS_LANG ) {
if($childs_childs != null and is_array($childs_childs)){
foreach($childs_childs as $cc) {
}
}
if ($child_name == SYS_LANG) {
if ($childs_childs != null and is_array($childs_childs)) {
foreach ($childs_childs as $cc) {
$ccmode = $newnode_child->appendChild($this->dom->createElement($cc['name']));
$ccmode->appendChild($this->dom->createTextNode($cc['value']));
foreach($cc['attributes'] as $cc_att_name => $cc_att_value) {
foreach ($cc['attributes'] as $cc_att_name => $cc_att_value) {
$ccmode->setAttribute($cc_att_name, $cc_att_value);
}
}
}
} else {
foreach ($chidNode as $valueNode) {
if ( array_key_exists($child_name, $valueNode) ) {
foreach($valueNode[$child_name] as $valOption) {
if (array_key_exists($child_name, $valueNode)) {
foreach ($valueNode[$child_name] as $valOption) {
$ccmode = $newnode_child->appendChild($this->dom->createElement($valOption['nodeName']));
$ccmode->appendChild($this->dom->createTextNode($valOption['nodeValue']));
$ccmode->setAttribute('name', $valOption['name']);
}
}
}
}
$newnode->appendChild($this->dom->createTextNode("\n"));
}
} else if( isset($childs) ){
} else {
if (isset($childs)) {
$text_node = $childs;
$newnode->appendChild($this->dom->createTextNode($text_node));
}
}
$this->save();
}
/**
* Function save
* @param string $fname
* @return void
*/
function save($fname=null)
public function save($fname = null)
{
if( ! is_writable($this->xmlfile) ) {
if (!is_writable($this->xmlfile)) {
throw new Exception("The file {$this->xmlfile} is not writeable!");
}
if( !isset($fname) ){
if (!isset($fname)) {
$this->dom->save($this->xmlfile);
} else {
$this->xmlfile = $fname;
@@ -295,58 +307,60 @@ class dynaFormHandler
}
}
/**
/**
* Function fixXmlFile
* @return void
*/
function fixXmlFile()
public function fixXmlFile()
{
$newxml = '';
$content = file($this->xmlfile);
foreach($content as $line){
if( trim($line) != ''){
foreach ($content as $line) {
if (trim($line) != '') {
$newxml .= $line;
}
}
file_put_contents($this->xmlfile, $newxml);
}
/**
/**
* Function setHeaderAttribute
* @param string $att_name
* @param string $att_value
* @return void
*/
function setHeaderAttribute($att_name, $att_value)
public function setHeaderAttribute($att_name, $att_value)
{
$this->root->setAttribute($att_name, $att_value);
$this->save();
}
function getHeaderAttribute($att_name)
public function getHeaderAttribute($att_name)
{
return $this->root->getAttribute($att_name);
}
/**
/**
* Function modifyHeaderAttribute
* @param string $att_name
* @param string $att_new_value
* @return void
*/
function modifyHeaderAttribute($att_name, $att_new_value)
public function modifyHeaderAttribute($att_name, $att_new_value)
{
$this->root->removeAttribute($att_name);
$this->root->setAttribute($att_name, $att_new_value);
$this->save();
}
/**
/**
* Function updateAttribute
* @param string $node_name
* @param string $att_name
* @param string $att_new_value
* @return void
*/
function updateAttribute($node_name, $att_name, $att_new_value)
public function updateAttribute($node_name, $att_name, $att_new_value)
{
$xpath = new DOMXPath($this->dom);
$nodeList = $xpath->query("/dynaForm/$node_name");
@@ -356,26 +370,26 @@ class dynaFormHandler
$this->save();
}
/**
/**
* Function remove
* @param string $v
* @return void
*/
function remove($v)
public function remove($v)
{
if(!is_array($v)){
if (!is_array($v)) {
$av[0] = $v;
} else{
} else {
$av = $v;
}
foreach($av as $e){
foreach ($av as $e) {
$xnode = $this->root->getElementsByTagName($e)->item(0);
if ( $xnode->nodeType == XML_ELEMENT_NODE ) {
if ($xnode->nodeType == XML_ELEMENT_NODE) {
$dropednode = $this->root->removeChild($xnode);
/*evaluation field aditional routines*/
/* evaluation field aditional routines */
$xpath = new DOMXPath($this->dom);
$nodeList = $xpath->query("/dynaForm/JS_$e");
if($nodeList->length != 0){
if ($nodeList->length != 0) {
$tmp_node = $nodeList->item(0);
$this->root->removeChild($tmp_node);
}
@@ -386,17 +400,17 @@ class dynaFormHandler
$this->save();
}
/**
/**
* Function nodeExists
* @param string $node_name
* @return boolean
*/
function nodeExists($node_name)
public function nodeExists($node_name)
{
$xpath = new DOMXPath($this->dom);
$nodeList = $xpath->query("/dynaForm/$node_name");
$node = $nodeList->item(0);
if($nodeList->length != 0){
if ($nodeList->length != 0) {
return true;
} else {
return false;
@@ -409,25 +423,25 @@ class dynaFormHandler
* @param string $selected_node
* @return void
*/
function moveUp($selected_node)
public function moveUp($selected_node)
{
/*DOMNode DOMNode::insertBefore ( DOMNode $newnode [, DOMNode $refnode ] )
/* DOMNode DOMNode::insertBefore ( DOMNode $newnode [, DOMNode $refnode ] )
This function inserts a new node right before the reference node. If you plan
to do further modifications on the appended child you must use the returned node. */
$xpath = new DOMXPath($this->dom);
$nodeList = $xpath->query("/dynaForm/*");
$flag = false;
for($i = 0; $i < $nodeList->length; $i++) {
for ($i = 0; $i < $nodeList->length; $i++) {
$xnode = $nodeList->item($i);
if($selected_node == $xnode->nodeName){
if ($selected_node == $xnode->nodeName) {
//if is a first node move it to final with a circular logic
if( $flag === false ){
if ($flag === false) {
$removed_node = $this->root->removeChild($xnode);
$this->root->appendChild($removed_node);
break;
} else {
$removed_node = $this->root->removeChild($xnode);
$predecessor_node = $nodeList->item($i-1);
$predecessor_node = $nodeList->item($i - 1);
$this->root->insertBefore($removed_node, $predecessor_node);
break;
}
@@ -442,29 +456,29 @@ class dynaFormHandler
* @param string $selected_node
* @return void
*/
function moveDown($selected_node)
public function moveDown($selected_node)
{
/*DOMNode DOMNode::insertBefore ( DOMNode $newnode [, DOMNode $refnode ] )
/* DOMNode DOMNode::insertBefore ( DOMNode $newnode [, DOMNode $refnode ] )
This function inserts a new node right before the reference node. If you plan
to do further modifications on the appended child you must use the returned node. */
$xpath = new DOMXPath($this->dom);
$nodeList = $xpath->query("/dynaForm/*");
$real_length = $nodeList->length;
for($i = 0; $i < $nodeList->length; $i++) {
for ($i = 0; $i < $nodeList->length; $i++) {
$xnode = $nodeList->item($i);
if($selected_node == $xnode->nodeName){
if ($selected_node == $xnode->nodeName) {
//if is a last node move it to final with a circular logic
if( ($i+1) == $real_length){
if($real_length != 1){
if (($i + 1) == $real_length) {
if ($real_length != 1) {
$first_node = $nodeList->item(0);
$removed_node = $this->root->removeChild($xnode);
$this->root->insertBefore($removed_node, $first_node);
}
break;
} else {
if( ($i+3) <= $real_length ){
if (($i + 3) <= $real_length) {
$removed_node = $this->root->removeChild($xnode);
$predecessor_node = $nodeList->item($i+2);
$predecessor_node = $nodeList->item($i + 2);
$this->root->insertBefore($removed_node, $predecessor_node);
break;
} else {
@@ -483,26 +497,26 @@ class dynaFormHandler
* @param array $aFilter
* @return array
*/
function getFields( $aFilter = Array() )
public function getFields($aFilter = Array())
{
$xpath = new DOMXPath($this->dom);
$nodeList = $xpath->query("/dynaForm/*");
$aList = Array();
for($i = 0; $i < $nodeList->length; $i++) {
for ($i = 0; $i < $nodeList->length; $i++) {
$xnode = $nodeList->item($i);
if( is_array($aFilter) && sizeof($aFilter) > 0 ){
if( isset($aFilter['IN']) ){
if( isset($aFilter['NOT_IN']) ){
if( in_array($xnode->nodeName, $aFilter['IN']) && !in_array($xnode->nodeName, $aFilter['NOT_IN']) ){
if (is_array($aFilter) && sizeof($aFilter) > 0) {
if (isset($aFilter['IN'])) {
if (isset($aFilter['NOT_IN'])) {
if (in_array($xnode->nodeName, $aFilter['IN']) && !in_array($xnode->nodeName, $aFilter['NOT_IN'])) {
array_push($aList, $xnode);
}
} else {
if( in_array($xnode->nodeName, $aFilter['IN']) ){
if (in_array($xnode->nodeName, $aFilter['IN'])) {
array_push($aList, $xnode);
}
}
} else if( isset($aFilter['NOT_IN']) ){
if( !in_array($xnode->nodeName, $aFilter['NOT_IN']) ){
} else if (isset($aFilter['NOT_IN'])) {
if (!in_array($xnode->nodeName, $aFilter['NOT_IN'])) {
array_push($aList, $xnode);
}
} else {
@@ -520,46 +534,46 @@ class dynaFormHandler
* @param array $aFilter
* @return array
*/
function getFieldNames( $aFilter = Array() )
public function getFieldNames($aFilter = Array())
{
$aList = $this->getFields($aFilter);
$aFieldNames = Array();
foreach( $aList as $item ){
foreach ($aList as $item) {
array_push($aFieldNames, $item->nodeName);
}
return $aFieldNames;
}
//
function addChilds($name, $childs, $childs_childs=null)
public function addChilds($name, $childs, $childs_childs = null)
{
//
$xpath = new DOMXPath($this->dom);
$nodeList = @$xpath->query("/dynaForm/$name");
if( ! $nodeList ){
if (!$nodeList) {
throw new Exception("Error trying get the field dynaform $name, maybe it doesn't exist in {$this->xmlfile}");
}
if( $nodeList->length == 0 ) {
if ($nodeList->length == 0) {
$element = $this->root->appendChild($this->dom->createElement($name));
} else
$element = $this->root->getElementsByTagName($name)->item(0);
if( is_array($childs) ) {
foreach( $childs as $child_name => $child_text ) {
if (is_array($childs)) {
foreach ($childs as $child_name => $child_text) {
$nodeList = $xpath->query("/dynaForm/$name/$child_name");
if( $nodeList->length == 0 ){ //the node doesn't exist
if ($nodeList->length == 0) {
//the node doesn't exist
//$newnode_child
$childNode = $element->appendChild($this->dom->createElement($child_name));
$childNode->appendChild($this->dom->createCDATASection($child_text));
} else { // the node already exists
} else {
// the node already exists
//update its value
$childNode = $element->getElementsByTagName($child_name)->item(0);
//
if($child_text !== NULL){
if ($child_text !== null) {
$xnode = $this->dom->createElement($childNode->nodeName);
$xnode->appendChild($this->dom->createCDATASection($child_text));
@@ -568,11 +582,11 @@ class dynaFormHandler
}
}
if($childs_childs != null and is_array($childs_childs)){
foreach($childs_childs as $cc) {
if ($childs_childs != null and is_array($childs_childs)) {
foreach ($childs_childs as $cc) {
$ccnode = $childNode->appendChild($this->dom->createElement($cc['name']));
$ccnode->appendChild($this->dom->createCDATASection($cc['value']));
foreach($cc['attributes'] as $cc_att_name => $cc_att_value) {
foreach ($cc['attributes'] as $cc_att_name => $cc_att_value) {
$ccnode->setAttribute($cc_att_name, $cc_att_value);
}
}
@@ -585,27 +599,28 @@ class dynaFormHandler
$this->save();
}
function addOrUpdateChild($xnode, $childName, $childValue, $childAttributes){
public function addOrUpdateChild($xnode, $childName, $childValue, $childAttributes)
{
$newNode = $this->dom->createElement($childName);
$newNode->appendChild($this->dom->createCDATASection($childValue));
foreach($childAttributes as $attName => $attValue) {
foreach ($childAttributes as $attName => $attValue) {
$newNode->setAttribute($attName, $attValue);
}
if( $xnode->hasChildNodes() ) {
foreach($xnode->childNodes as $cnode) {
if( $cnode->nodeName == $childName ) {
if ($xnode->hasChildNodes()) {
foreach ($xnode->childNodes as $cnode) {
if ($cnode->nodeName == $childName) {
$xnode->replaceChild($newNode, $cnode);
break;
}
}
} else
} else {
$xnode->appendChild($newNode);
}
}
function getArray($node, $attributes = null)
public function getArray($node, $attributes = null)
{
$array = false;
$array['__nodeName__'] = $node->nodeName;
@@ -613,11 +628,12 @@ class dynaFormHandler
$array['__nodeText__'] = trim((string) $text);
if ($node->hasAttributes()) {
if( isset($attributes) ) {
if (isset($attributes)) {
foreach ($attributes as $attr) {
if( $node->hasAttribute($attr) )
if ($node->hasAttribute($attr)) {
$array[$attr] = $node->getAttribute($attr);
}
}
} else {
foreach ($node->attributes as $attr) {
$array[$attr->nodeName] = $attr->nodeValue;
@@ -626,9 +642,9 @@ class dynaFormHandler
}
if ($node->hasChildNodes()) {
if ($node->childNodes->length == 0)
if ($node->childNodes->length == 0) {
$return;
else {
} else {
foreach ($node->childNodes as $childNode) {
$childNode->normalize();
//if ($childNode->nodeType == XML_TEXT_NODE || $childNode->nodeType == XML_CDATA_SECTION_NODE) {
@@ -646,3 +662,4 @@ class dynaFormHandler
return $array;
}
}

View File

@@ -1,4 +1,5 @@
<?php
/**
* class.dynaFormField.php
*
@@ -24,8 +25,7 @@
* Coral Gables, FL, 33134, USA, or email info@colosa.com.
*
*/
G::LoadClass( 'xmlDb' );
G::LoadClass('xmlDb');
G::LoadSystem('dynaformhandler');
/**
@@ -35,7 +35,9 @@ G::LoadSystem('dynaformhandler');
*/
class DynaFormField extends DBTable
{
private $fileName;
public function getFileName()
{
return $this->fileName;
@@ -52,10 +54,10 @@ class DynaFormField extends DBTable
* @param string $objConnection
* @return void
*/
function SetTo ($objConnection)
public function SetTo($objConnection)
{
DBTable::SetTo( $objConnection, 'dynaForm', array ('XMLNODE_NAME'
) );
DBTable::SetTo($objConnection, 'dynaForm', array('XMLNODE_NAME'
));
}
/**
@@ -64,13 +66,13 @@ class DynaFormField extends DBTable
* @param string $sUID
* @return void
*/
function Load ($sUID)
public function Load($sUID)
{
parent::Load( $sUID );
if (is_array( $this->Fields )) {
parent::Load($sUID);
if (is_array($this->Fields)) {
foreach ($this->Fields as $name => $value) {
if (strcasecmp( $name, 'dependentfields' ) == 0) {
$this->Fields[$name] = explode( ',', $value );
if (strcasecmp($name, 'dependentfields') == 0) {
$this->Fields[$name] = explode(',', $value);
}
}
}
@@ -82,7 +84,7 @@ class DynaFormField extends DBTable
* @param string $uid
* @return void
*/
function Delete ($uid)
public function Delete($uid)
{
$this->Fields['XMLNODE_NAME'] = $uid;
parent::Delete();
@@ -96,108 +98,28 @@ class DynaFormField extends DBTable
* @param array $options
* @return void
*/
function Save ($Fields, $labels = array(), $options = array())
public function Save($Fields, $labels = array(), $options = array())
{
if ($Fields['TYPE'] === 'javascript') {
$Fields['XMLNODE_VALUE'] = $Fields['CODE'];
unset( $Fields['CODE'] );
$labels = array ();
unset($Fields['CODE']);
$labels = 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'] . '"' );
$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'] . '"' );
$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'];
}
/*$res = $this->_dbses->Execute('INSERT INTO dynaForm'.
' (XMLNODE_TYPE,XMLNODE_VALUE)'.
' VALUES ("cdata", "'."\n".'")');*/
parent::Save();
if ($this->is_new) {
/*
* Create a new field.
*/
foreach ($labels as $lang => $value) {
/*$res = $this->_dbses->Execute('INSERT INTO dynaForm'.
' (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] )) {
foreach ($options[$lang] as $option => $text) {
$res = $this->_dbses->Execute( 'INSERT INTO dynaForm.' . $Fields['XMLNODE_NAME'] . '.' . $lang . ' (XMLNODE_NAME,XMLNODE_VALUE,XMLNODE_TYPE) ' . 'VALUES ("","' . " " . '","cdata")' );
$res = $this->_dbses->Execute( 'INSERT INTO dynaForm.' . $Fields['XMLNODE_NAME'] . '.' . $lang . ' (XMLNODE_NAME,XMLNODE_VALUE,name) ' . 'VALUES ("option","' . str_replace( '"', '""', $text ) . '","' . str_replace( '"', '""', $option ) . '")' );
$res = $this->_dbses->Execute( 'INSERT INTO dynaForm.' . $Fields['XMLNODE_NAME'] . '.' . $lang . ' (XMLNODE_NAME,XMLNODE_VALUE,XMLNODE_TYPE) ' . 'VALUES ("","' . "\n " . '","cdata")' );
}
}
$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' . ' (XMLNODE_TYPE,XMLNODE_VALUE)' . ' VALUES ("cdata", "' . "\n" . '")' );
} else {
/*
* Update an existing field.
*/
$this->_dbses->Execute( 'UPDATE dynaForm SET XMLNODE_NAME = "' . $Fields['XMLNODE_NAME'] . '" WHERE XMLNODE_NAME = "' . $Fields['XMLNODE_NAME_OLD'] . '"' );
foreach ($labels as $lang => $value) {
$res = $this->_dbses->Execute( 'SELECT * FROM dynaForm.' . $Fields['XMLNODE_NAME'] . ' WHERE XMLNODE_NAME ="' . $lang . '"' );
if ($res->count() > 0) {
$res = $this->_dbses->Execute( 'UPDATE dynaForm.' . $Fields['XMLNODE_NAME'] . ' SET XMLNODE_VALUE = ' . '"' . str_replace( '"', '""', $value ) . '" WHERE XMLNODE_NAME ="' . $lang . '"' );
} else {
$res = $this->_dbses->Execute( 'INSERT INTO dynaForm.' . $Fields['XMLNODE_NAME'] . ' (XMLNODE_NAME,XMLNODE_VALUE) ' . 'VALUES ("' . $lang . '","' . str_replace( '"', '""', $value ) . '")' );
}
if (isset( $options[$lang] )) {
$res = $this->_dbses->Execute( 'DELETE FROM dynaForm.' . $Fields['XMLNODE_NAME'] . '.' . $lang . ' WHERE 1' );
foreach ($options[$lang] as $option => $text) {
$res = $this->_dbses->Execute( 'INSERT INTO dynaForm.' . $Fields['XMLNODE_NAME'] . '.' . $lang . ' (XMLNODE_NAME,XMLNODE_VALUE,name) ' . 'VALUES ("option","' . str_replace( '"', '""', $text ) . '","' . str_replace( '"', '""', $option ) . '")' );
}
}
}
}
}
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'] );
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
@@ -205,7 +127,88 @@ class DynaFormField extends DBTable
if ($this->is_new) {
foreach ($this->Fields as $key => $value) {
if ($value == "") {
unset( $this->Fields[$key] );
unset($this->Fields[$key]);
}
}
} else {
$this->Fields['XMLNODE_NAME'] = $Fields['XMLNODE_NAME_OLD'];
}
/* $res = $this->_dbses->Execute('INSERT INTO dynaForm'.
' (XMLNODE_TYPE,XMLNODE_VALUE)'.
' VALUES ("cdata", "'."\n".'")'); */
parent::Save();
if ($this->is_new) {
/*
* Create a new field.
*/
foreach ($labels as $lang => $value) {
/* $res = $this->_dbses->Execute('INSERT INTO dynaForm'.
' (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])) {
foreach ($options[$lang] as $option => $text) {
$res = $this->_dbses->Execute('INSERT INTO dynaForm.' . $Fields['XMLNODE_NAME'] . '.' . $lang . ' (XMLNODE_NAME,XMLNODE_VALUE,XMLNODE_TYPE) ' . 'VALUES ("","' . " " . '","cdata")');
$res = $this->_dbses->Execute('INSERT INTO dynaForm.' . $Fields['XMLNODE_NAME'] . '.' . $lang . ' (XMLNODE_NAME,XMLNODE_VALUE,name) ' . 'VALUES ("option","' . str_replace('"', '""', $text) . '","' . str_replace('"', '""', $option) . '")');
$res = $this->_dbses->Execute('INSERT INTO dynaForm.' . $Fields['XMLNODE_NAME'] . '.' . $lang . ' (XMLNODE_NAME,XMLNODE_VALUE,XMLNODE_TYPE) ' . 'VALUES ("","' . "\n " . '","cdata")');
}
}
$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' . ' (XMLNODE_TYPE,XMLNODE_VALUE)' . ' VALUES ("cdata", "' . "\n" . '")');
} else {
/*
* Update an existing field.
*/
$this->_dbses->Execute('UPDATE dynaForm SET XMLNODE_NAME = "' . $Fields['XMLNODE_NAME'] . '" WHERE XMLNODE_NAME = "' . $Fields['XMLNODE_NAME_OLD'] . '"');
foreach ($labels as $lang => $value) {
$res = $this->_dbses->Execute('SELECT * FROM dynaForm.' . $Fields['XMLNODE_NAME'] . ' WHERE XMLNODE_NAME ="' . $lang . '"');
if ($res->count() > 0) {
$res = $this->_dbses->Execute('UPDATE dynaForm.' . $Fields['XMLNODE_NAME'] . ' SET XMLNODE_VALUE = ' . '"' . str_replace('"', '""', $value) . '" WHERE XMLNODE_NAME ="' . $lang . '"');
} else {
$res = $this->_dbses->Execute('INSERT INTO dynaForm.' . $Fields['XMLNODE_NAME'] . ' (XMLNODE_NAME,XMLNODE_VALUE) ' . 'VALUES ("' . $lang . '","' . str_replace('"', '""', $value) . '")');
}
if (isset($options[$lang])) {
$res = $this->_dbses->Execute('DELETE FROM dynaForm.' . $Fields['XMLNODE_NAME'] . '.' . $lang . ' WHERE 1');
foreach ($options[$lang] as $option => $text) {
$res = $this->_dbses->Execute('INSERT INTO dynaForm.' . $Fields['XMLNODE_NAME'] . '.' . $lang . ' (XMLNODE_NAME,XMLNODE_VALUE,name) ' . 'VALUES ("option","' . str_replace('"', '""', $text) . '","' . str_replace('"', '""', $option) . '")');
}
}
}
}
}
public 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 {
@@ -218,10 +221,10 @@ class DynaFormField extends DBTable
}
$aOptions = array();
if(isset($Fields['OPTIONS']) && is_array($Fields['OPTIONS']) ) {
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']) );
$aOptions[] = Array('name' => 'option', 'value' => $value['LABEL'],
'attributes' => array('name' => $value['NAME']));
}
}
@@ -238,11 +241,10 @@ class DynaFormField extends DBTable
*
* @return array
*/
function isNew ()
public function isNew()
{
$res = $this->_dbses->Execute( 'SELECT * FROM dynaForm WHERE XMLNODE_NAME="' . $this->Fields['XMLNODE_NAME'] . '"' );
$res = $this->_dbses->Execute('SELECT * FROM dynaForm WHERE XMLNODE_NAME="' . $this->Fields['XMLNODE_NAME'] . '"');
return ($res->count() == 0);
}
}
?>

File diff suppressed because it is too large Load Diff

View File

@@ -1,4 +1,5 @@
<?php
//print_r( $_POST); die;
/**
* fields_Save.php
@@ -25,90 +26,95 @@
*/
G::LoadClass('dynaformEditor');
if (($RBAC_Response=$RBAC->userCanAccess("PM_FACTORY"))!=1) return $RBAC_Response;
if (($RBAC_Response = $RBAC->userCanAccess("PM_FACTORY")) != 1) {
return $RBAC_Response;
}
//G::genericForceLogin( 'WF_MYINFO' , 'login/noViewPage', $urlLogin = 'login/login' );
//G::genericForceLogin( 'WF_MYINFO' , 'login/noViewPage', $urlLogin = 'login/login' );
G::LoadClass('dynaFormField');
G::LoadClass('dynaFormField');
$type=strtolower($_POST['form']['PME_TYPE']);
if (!(isset($_POST['form']['PME_A']) && $_POST['form']['PME_A']!=='')) return;
$type = strtolower($_POST['form']['PME_TYPE']);
if (!(isset($_POST['form']['PME_A']) && $_POST['form']['PME_A'] !== '')) {
return;
}
if (isset($_POST['form']['PME_REQUIRED'])) {
if (isset($_POST['form']['PME_REQUIRED'])) {
if ($_POST['form']['PME_REQUIRED'] == '') {
$_POST['form']['PME_REQUIRED'] = 0;
}
}
else {
} else {
$_POST['form']['PME_REQUIRED'] = 0;
}
}
if (isset($_POST['form']['PME_READONLY'])) {
if (isset($_POST['form']['PME_READONLY'])) {
if ($_POST['form']['PME_READONLY'] == '') {
$_POST['form']['PME_READONLY'] = 0;
}
}
else {
} else {
$_POST['form']['PME_READONLY'] = 0;
}
}
if (isset($_POST['form']['PME_SAVELABEL'])) {
if (isset($_POST['form']['PME_SAVELABEL'])) {
if ($_POST['form']['PME_SAVELABEL'] == '') {
$_POST['form']['PME_SAVELABEL'] = 0;
}
}
else {
} else {
$_POST['form']['PME_SAVELABEL'] = 0;
}
$A = $_POST['form']['PME_A'];
if (isset($_POST['form']['PME_SAVELABEL'])
}
$A = $_POST['form']['PME_A'];
if (isset($_POST['form']['PME_SAVELABEL'])
&& isset($_POST['form']['PME_CODE'])
&& $_POST['form']['PME_TYPE'] === 'javascript'){
&& $_POST['form']['PME_TYPE'] === 'javascript') {
$sType = $_POST['form']['PME_TYPE'];
// $A = $_POST['form']['PME_A'];
$fieldName = $_POST['form']['PME_XMLNODE_NAME'];
$pmeCode = $_POST['form']['PME_CODE'];
$_POST['form']['PME_CODE'] = '';
// $pmeCode = str_replace("'", "''", $pmeCode);
// $pmeCode = str_replace('"', '""', $pmeCode);
// $pmeCode = preg_replace("/\)\s*\n/", ") //\n", $pmeCode);
// $_POST['form']['PME_CODE'] = $pmeCode;
}
// $pmeCode = str_replace("'", "''", $pmeCode);
// $pmeCode = str_replace('"', '""', $pmeCode);
// $pmeCode = preg_replace("/\)\s*\n/", ") //\n", $pmeCode);
// $_POST['form']['PME_CODE'] = $pmeCode;
}
$file = G::decrypt( $_POST['form']['PME_A'] , URL_KEY );
define('DB_XMLDB_HOST', PATH_DYNAFORM . $file . '.xml' );
define('DB_XMLDB_USER','');
define('DB_XMLDB_PASS','');
define('DB_XMLDB_NAME','');
define('DB_XMLDB_TYPE','myxml');
$file = G::decrypt($_POST['form']['PME_A'], URL_KEY);
define('DB_XMLDB_HOST', PATH_DYNAFORM . $file . '.xml');
define('DB_XMLDB_USER', '');
define('DB_XMLDB_PASS', '');
define('DB_XMLDB_NAME', '');
define('DB_XMLDB_TYPE', 'myxml');
// if (isset($_POST['form']['PME_XMLNODE_VALUE'])){
// $_POST['form']['PME_XMLNODE_VALUE'] = str_replace("'", "''" , $_POST['form']['PME_XMLNODE_VALUE']);
// }
// if (isset($_POST['form']['PME_XMLNODE_VALUE'])){
// $_POST['form']['PME_XMLNODE_VALUE'] = str_replace("'", "''" , $_POST['form']['PME_XMLNODE_VALUE']);
// }
if (file_exists( PATH_XMLFORM . 'dynaforms/fields/' . $type . '.xml')) {
$form=new Form('dynaforms/fields/' . $type , PATH_XMLFORM);
if (file_exists(PATH_XMLFORM . 'dynaforms/fields/' . $type . '.xml')) {
$form = new Form('dynaforms/fields/' . $type, PATH_XMLFORM);
//TODO: Verify why validatePost removes PME_XMLGRID.
$isGrid=isset($_POST['form']['PME_XMLGRID']);
if ($isGrid) $xmlGrid=$_POST['form']['PME_XMLGRID'];
$isGrid = isset($_POST['form']['PME_XMLGRID']);
if ($isGrid) {
$xmlGrid = $_POST['form']['PME_XMLGRID'];
}
//$form->validatePost();
if ($isGrid) $_POST['form']['PME_XMLGRID']=$xmlGrid;
if ($type==='checkbox') {
if ($isGrid) {
$_POST['form']['PME_XMLGRID'] = $xmlGrid;
}
if ($type === 'checkbox') {
// added by Gustavo Cruz
if ($_POST['form']['PME_DEFAULTVALUE']==="1") {
$_POST['form']['PME_DEFAULTVALUE']=$_POST['form']['PME_VALUE'];
if ($_POST['form']['PME_DEFAULTVALUE'] === "1") {
$_POST['form']['PME_DEFAULTVALUE'] = $_POST['form']['PME_VALUE'];
} else {
$_POST['form']['PME_DEFAULTVALUE']=$_POST['form']['PME_FALSEVALUE'];
$_POST['form']['PME_DEFAULTVALUE'] = $_POST['form']['PME_FALSEVALUE'];
}
// end added code
// verify why $form->fields['PME_DEFAULTVALUE']->value doesn't capture the value 1
// if ($_POST['form']['PME_DEFAULTVALUE']===$form->fields['PME_DEFAULTVALUE']->value) {
// $_POST['form']['PME_DEFAULTVALUE']=$_POST['form']['PME_VALUE'];
// } else {
// $_POST['form']['PME_DEFAULTVALUE']=$_POST['form']['PME_FALSEVALUE'];
// }
// verify why $form->fields['PME_DEFAULTVALUE']->value doesn't capture the value 1
// if ($_POST['form']['PME_DEFAULTVALUE']===$form->fields['PME_DEFAULTVALUE']->value) {
// $_POST['form']['PME_DEFAULTVALUE']=$_POST['form']['PME_VALUE'];
// } else {
// $_POST['form']['PME_DEFAULTVALUE']=$_POST['form']['PME_FALSEVALUE'];
// }
}
if ($type==='grid') {
if ($type === 'grid') {
if (!isset($_POST['form']['PME_ADDROW'])) {
$_POST['form']['PME_ADDROW'] = '0';
}
@@ -116,65 +122,72 @@ if (($RBAC_Response=$RBAC->userCanAccess("PM_FACTORY"))!=1) return $RBAC_Respons
$_POST['form']['PME_DELETEROW'] = '0';
}
}
if ($type==='dropdown' || $type==='listbox' ) {
if(isset($_POST['form']['PME_OPTIONS'][1])){
if($_POST['form']['PME_OPTIONS']['1']['NAME'] === "" &&
$_POST['form']['PME_OPTIONS']['1']['LABEL'] === ""){
if ($type === 'dropdown' || $type === 'listbox') {
if (isset($_POST['form']['PME_OPTIONS'][1])) {
if ($_POST['form']['PME_OPTIONS']['1']['NAME'] === "" &&
$_POST['form']['PME_OPTIONS']['1']['LABEL'] === "") {
unset($_POST['form']['PME_OPTIONS']);
}
}
}
}
foreach ($_POST['form'] as $key => $value) {
if (substr($key, 0, 4) === 'PME_') {
$res[substr($key, 4)] = $value;
} else {
$res[$key] = $value;
}
foreach($_POST['form'] as $key => $value){
if (substr($key,0,4)==='PME_')
$res[substr($key,4)]=$value;
else
$res[$key]=$value;
}
$_POST['form']=$res;
}
$_POST['form'] = $res;
$dbc = new DBConnection( PATH_DYNAFORM . $file . '.xml' ,'','','','myxml' );
$ses = new DBSession($dbc);
$dbc = new DBConnection(PATH_DYNAFORM . $file . '.xml', '', '', '', 'myxml');
$ses = new DBSession($dbc);
$fields = new DynaFormField( $dbc );
$fields = new DynaFormField($dbc);
if ($_POST['form']['XMLNODE_NAME']==='') return;
if ($_POST['form']['XMLNODE_NAME'] === '') {
return;
}
$attributes = $_POST['form'];
$attributes = $_POST['form'];
if (isset($attributes['HINT'])) {
if (isset($attributes['HINT'])) {
$attributes['HINT'] = addslashes($attributes['HINT']);
$attributes['HINT'] = htmlspecialchars($attributes['HINT'], ENT_QUOTES, "UTF-8");
}
}
if (isset($attributes['CODE'])) $attributes['XMLNODE_VALUE'] = ($attributes['CODE']);
if (isset($attributes['CODE'])) {
$attributes['XMLNODE_VALUE'] = ($attributes['CODE']);
}
$labels = array();
if (isset($attributes['LABEL'])) $labels = array ( SYS_LANG => $attributes['LABEL'] );
$labels = array();
if (isset($attributes['LABEL'])) {
$labels = array(SYS_LANG => $attributes['LABEL']);
}
unset($attributes['A']);
unset($attributes['ACCEPT']);
unset($attributes['LABEL']);
unset($attributes['PRO_UID']);
unset($attributes['A']);
unset($attributes['ACCEPT']);
unset($attributes['LABEL']);
unset($attributes['PRO_UID']);
$options = NULL;
foreach($attributes as $key => $value ) {
if ($key==='OPTIONS') {
if (is_array($value)){
$options = null;
foreach ($attributes as $key => $value) {
if ($key === 'OPTIONS') {
if (is_array($value)) {
if (is_array(reset($value))) {
$langs = array();
$options = array();
$langs[] = SYS_LANG;
$options[SYS_LANG]=array();
foreach( $value as $row ) {
foreach( $langs as $lang ) {
$options[SYS_LANG] = array();
foreach ($value as $row) {
foreach ($langs as $lang) {
$LANG = strtoupper($lang);
if (isset($row['LABEL']))
$options[$lang][$row['NAME']]=$row['LABEL'];
if (isset($row['LABEL'])) {
$options[$lang][$row['NAME']] = $row['LABEL'];
}
}
/*$first = reset($value);
}
/* $first = reset($value);
foreach( $first as $optKey => $optValue ) {
if (substr($optKey,0,6)==='LABEL_') {
$langs[]=strtolower(substr($optKey,6));
@@ -187,65 +200,65 @@ if (($RBAC_Response=$RBAC->userCanAccess("PM_FACTORY"))!=1) return $RBAC_Respons
if (isset($row['LABEL_'.$LANG]))
$options[$lang][$row['NAME']]=$row['LABEL_'.$LANG];
}
}*/
} */
}
}
} else {
if (is_array($value)){
if (is_array($value)) {
//Is a list:
if (is_string(reset($value))) {
$attributes[$key] = implode(',',$value);
$attributes[$key] = implode(',', $value);
} else {
//Is a grid.
}
}
}
}
unset($attributes['VALIDATE_NAME']);
$fields->setFileName(PATH_DYNAFORM . $file . '.xml' );
}
unset($attributes['VALIDATE_NAME']);
$fields->setFileName(PATH_DYNAFORM . $file . '.xml');
$FieldAttributes = $attributes;
$FieldAttrib = array();
unset($FieldAttributes['XMLNODE_NAME']);
unset($FieldAttributes['XMLNODE_NAME_OLD']);
unset($FieldAttributes['XMLNODE_VALUE']);
unset($FieldAttributes['BTN_CANCEL']);
unset($FieldAttributes['SAVELABEL']);
foreach ($FieldAttributes as $key => $value) {
$FieldAttributes = $attributes;
$FieldAttrib = array();
unset($FieldAttributes['XMLNODE_NAME']);
unset($FieldAttributes['XMLNODE_NAME_OLD']);
unset($FieldAttributes['XMLNODE_VALUE']);
unset($FieldAttributes['BTN_CANCEL']);
unset($FieldAttributes['SAVELABEL']);
foreach ($FieldAttributes as $key => $value) {
if ($value != "") {
$FieldAttrib[strtolower($key)] = $value;
}
}
}
$fields->saveField($attributes, $FieldAttrib, $labels );
$fields->saveField($attributes, $FieldAttrib, $labels);
G::LoadClass('xmlDb');
$i = 0;
$aFields = array();
$aFields[] = array('XMLNODE_NAME' => 'char',
G::LoadClass('xmlDb');
$i = 0;
$aFields = array();
$aFields[] = array('XMLNODE_NAME' => 'char',
'TYPE' => 'char',
'UP' => 'char',
'DOWN' => 'char',
'row__' => 'integer');
$oSession = new DBSession(new DBConnection(PATH_DYNAFORM . $file . '.xml', '', '', '', 'myxml'));
$oDataset = $oSession->Execute('SELECT * FROM dynaForm WHERE NOT( XMLNODE_NAME = "" )');
$iMaximun = $oDataset->count();
while ($aRow = $oDataset->Read()) {
$oSession = new DBSession(new DBConnection(PATH_DYNAFORM . $file . '.xml', '', '', '', 'myxml'));
$oDataset = $oSession->Execute('SELECT * FROM dynaForm WHERE NOT( XMLNODE_NAME = "" )');
$iMaximun = $oDataset->count();
while ($aRow = $oDataset->Read()) {
$aFields[] = array('XMLNODE_NAME' => $aRow['XMLNODE_NAME'],
'TYPE' => $aRow['TYPE'],
'UP' => ($i > 0 ? G::LoadTranslation('ID_UP') : ''),
'DOWN' => ($i < $iMaximun-1 ? G::LoadTranslation('ID_DOWN') : ''),
'DOWN' => ($i < $iMaximun - 1 ? G::LoadTranslation('ID_DOWN') : ''),
'row__' => ($i + 1));
$i++;
}
global $_DBArray;
$_DBArray['fields'] = $aFields;
$_SESSION['_DBArray'] = $_DBArray;
}
global $_DBArray;
$_DBArray['fields'] = $aFields;
$_SESSION['_DBArray'] = $_DBArray;
// Additions to javascript
if(isset($sType) && $sType === 'javascript'){
// Additions to javascript
if (isset($sType) && $sType === 'javascript') {
$sCode = urlencode($pmeCode);
$editor = new dynaformEditorAjax($_POST);
$editor->set_javascript($A, $fieldName, $sCode);
}
?>
}