Merge pull request #868 from hector-cortez/BUG-9286
BUG 9286 Comments are deleted from the XML code for DynaForms SOLVED
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* class.dynaformhandler.php
|
* class.dynaformhandler.php
|
||||||
* @package gulliver.system
|
* @package gulliver.system
|
||||||
@@ -30,9 +31,9 @@
|
|||||||
* @description This class is a Dynaform handler for modify directly into file
|
* @description This class is a Dynaform handler for modify directly into file
|
||||||
* @package gulliver.system
|
* @package gulliver.system
|
||||||
*/
|
*/
|
||||||
|
|
||||||
class dynaFormHandler
|
class dynaFormHandler
|
||||||
{
|
{
|
||||||
|
|
||||||
private $xmlfile;
|
private $xmlfile;
|
||||||
private $dom;
|
private $dom;
|
||||||
private $root;
|
private $root;
|
||||||
@@ -43,30 +44,34 @@ class dynaFormHandler
|
|||||||
* @param string $file
|
* @param string $file
|
||||||
* @return void
|
* @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!!');
|
throw new Exception('[Class dynaFormHandler] ERROR: xml file was not set!!');
|
||||||
|
}
|
||||||
$this->xmlfile = $file;
|
$this->xmlfile = $file;
|
||||||
$this->load();
|
$this->load();
|
||||||
}
|
}
|
||||||
|
|
||||||
function load(){
|
public function load()
|
||||||
|
{
|
||||||
$this->dom = new DOMDocument();
|
$this->dom = new DOMDocument();
|
||||||
$this->dom->preserveWhiteSpace = false;
|
$this->dom->preserveWhiteSpace = false;
|
||||||
$this->dom->formatOutput = true;
|
$this->dom->formatOutput = true;
|
||||||
if (is_file($this->xmlfile)) {
|
if (is_file($this->xmlfile)) {
|
||||||
if (@$this->dom->load($this->xmlfile) === true) {
|
if (@$this->dom->load($this->xmlfile) === true) {
|
||||||
$this->root = $this->dom->firstChild;
|
$this->root = $this->dom->firstChild;
|
||||||
} else
|
} else {
|
||||||
throw new Exception('Error: ' . $this->xmlfile . ' is a invalid xml file!');
|
throw new Exception('Error: ' . $this->xmlfile . ' is a invalid xml file!');
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
throw new Exception('[Class dynaFormHandler] ERROR: the (' . $this->xmlfile . ') file doesn\'t exits!!');
|
throw new Exception('[Class dynaFormHandler] ERROR: the (' . $this->xmlfile . ') file doesn\'t exits!!');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function reload(){
|
public function reload()
|
||||||
$this->dom = NULL;
|
{
|
||||||
|
$this->dom = null;
|
||||||
$this->load();
|
$this->load();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -75,7 +80,7 @@ class dynaFormHandler
|
|||||||
* @access public
|
* @access public
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function __cloneEmpty()
|
public function __cloneEmpty()
|
||||||
{
|
{
|
||||||
$xPath = new DOMXPath($this->dom);
|
$xPath = new DOMXPath($this->dom);
|
||||||
$nodeList = $xPath->query('/dynaForm/*');
|
$nodeList = $xPath->query('/dynaForm/*');
|
||||||
@@ -92,11 +97,13 @@ class dynaFormHandler
|
|||||||
* @param string $op
|
* @param string $op
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function toString($op='')
|
public function toString($op = '')
|
||||||
{
|
{
|
||||||
switch ($op) {
|
switch ($op) {
|
||||||
case 'html': return htmlentities(file_get_contents($this->xmlfile));
|
case 'html': return htmlentities(file_get_contents($this->xmlfile));
|
||||||
|
break;
|
||||||
default: return file_get_contents($this->xmlfile);
|
default: return file_get_contents($this->xmlfile);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -106,7 +113,7 @@ class dynaFormHandler
|
|||||||
* @param string $nodename
|
* @param string $nodename
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function getNode($nodename)
|
public function getNode($nodename)
|
||||||
{
|
{
|
||||||
return $this->root->getElementsByTagName($nodename)->item(0);
|
return $this->root->getElementsByTagName($nodename)->item(0);
|
||||||
}
|
}
|
||||||
@@ -117,7 +124,8 @@ class dynaFormHandler
|
|||||||
* @param object $node
|
* @param object $node
|
||||||
* @return object
|
* @return object
|
||||||
*/
|
*/
|
||||||
function setNode($node){
|
public function setNode($node)
|
||||||
|
{
|
||||||
$newnode = $this->root->appendChild($node);
|
$newnode = $this->root->appendChild($node);
|
||||||
$this->save();
|
$this->save();
|
||||||
return $newnode;
|
return $newnode;
|
||||||
@@ -132,9 +140,15 @@ class dynaFormHandler
|
|||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
//attributes (String node-name, Array attributes(atribute-name =>attribute-value, ..., ...), Array childs(child-name=>child-content), Array Child-childs())
|
//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));
|
$newnode = $this->root->appendChild($this->dom->createElement($name));
|
||||||
|
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);
|
$newnode->setAttribute($att_name, $att_value);
|
||||||
}
|
}
|
||||||
@@ -159,6 +173,35 @@ class dynaFormHandler
|
|||||||
$this->save();
|
$this->save();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function hasChild($p)
|
||||||
|
{
|
||||||
|
if ($p->hasChildNodes()) {
|
||||||
|
foreach ($p->childNodes as $c) {
|
||||||
|
if ($c->nodeType == XML_ELEMENT_NODE) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function getChildNode($x)
|
||||||
|
{
|
||||||
|
$chidNode = array();
|
||||||
|
foreach ($x->childNodes as $p) {
|
||||||
|
if ($this->hasChild($p)) {
|
||||||
|
getChildNode($p);
|
||||||
|
} else {
|
||||||
|
if ($p->nodeType == XML_ELEMENT_NODE) {
|
||||||
|
|
||||||
|
$chidNode[] = array('node' => $x->nodeName, 'nodeName' => $p->nodeName,
|
||||||
|
'name' => $p->getAttribute('name'), 'nodeValue' => $p->nodeValue);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return array($x->nodeName => $chidNode);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function replace
|
* Function replace
|
||||||
* @access public
|
* @access public
|
||||||
@@ -169,32 +212,50 @@ class dynaFormHandler
|
|||||||
* @param array $childs_childs
|
* @param array $childs_childs
|
||||||
* @return void
|
* @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();
|
||||||
$element = $this->root->getElementsByTagName($replaced)->item(0);
|
$element = $this->root->getElementsByTagName($replaced)->item(0);
|
||||||
$this->root->replaceChild($this->dom->createElement($name), $element);
|
$this->root->replaceChild($this->dom->createElement($name), $element);
|
||||||
$newnode = $element = $this->root->getElementsByTagName($name)->item(0);
|
// $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']));
|
$newnode->appendChild($this->dom->createTextNode($attributes['#text']));
|
||||||
unset($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->createCDATASection($attributes['#cdata']));
|
||||||
|
$newnode->appendChild($this->dom->createTextNode("\n"));
|
||||||
unset($attributes['#cdata']);
|
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);
|
$newnode->setAttribute($att_name, $att_value);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (is_array($childs)) {
|
if (is_array($childs)) {
|
||||||
foreach($childs as $child_name => $child_text) {
|
foreach ($element->childNodes as $pNode) {
|
||||||
$newnode_child = $newnode->appendChild($this->dom->createElement($child_name));
|
if ($pNode->nodeName != SYS_LANG && $pNode->nodeName != '#cdata-section' && $pNode->nodeName != '#text') {
|
||||||
if( is_string($child_text) )
|
$chidNode[] = $this->getChildNode($pNode);
|
||||||
$newnode_child->appendChild($this->dom->createTextNode($child_text));
|
$childs[$pNode->nodeName] = $pNode->firstChild->nodeValue;
|
||||||
else if( is_array($child_text) && isset($child_text['cdata']) )
|
}
|
||||||
$newnode_child->appendChild($this->dom->createCDATASection($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)) {
|
||||||
|
$newnode_child->appendChild($this->dom->createTextNode($child_text));
|
||||||
|
} 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)) {
|
if ($childs_childs != null and is_array($childs_childs)) {
|
||||||
foreach ($childs_childs as $cc) {
|
foreach ($childs_childs as $cc) {
|
||||||
$ccmode = $newnode_child->appendChild($this->dom->createElement($cc['name']));
|
$ccmode = $newnode_child->appendChild($this->dom->createElement($cc['name']));
|
||||||
@@ -204,19 +265,35 @@ class dynaFormHandler
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
foreach ($chidNode as $valueNode) {
|
||||||
|
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']);
|
||||||
}
|
}
|
||||||
} else if( isset($childs) ){
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$newnode->appendChild($this->dom->createTextNode("\n"));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (isset($childs)) {
|
||||||
$text_node = $childs;
|
$text_node = $childs;
|
||||||
$newnode->appendChild($this->dom->createTextNode($text_node));
|
$newnode->appendChild($this->dom->createTextNode($text_node));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
$this->save();
|
$this->save();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function save
|
* Function save
|
||||||
* @param string $fname
|
* @param string $fname
|
||||||
* @return void
|
* @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!");
|
throw new Exception("The file {$this->xmlfile} is not writeable!");
|
||||||
@@ -234,7 +311,7 @@ class dynaFormHandler
|
|||||||
* Function fixXmlFile
|
* Function fixXmlFile
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function fixXmlFile()
|
public function fixXmlFile()
|
||||||
{
|
{
|
||||||
$newxml = '';
|
$newxml = '';
|
||||||
$content = file($this->xmlfile);
|
$content = file($this->xmlfile);
|
||||||
@@ -252,19 +329,24 @@ class dynaFormHandler
|
|||||||
* @param string $att_value
|
* @param string $att_value
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function setHeaderAttribute($att_name, $att_value)
|
public function setHeaderAttribute($att_name, $att_value)
|
||||||
{
|
{
|
||||||
$this->root->setAttribute($att_name, $att_value);
|
$this->root->setAttribute($att_name, $att_value);
|
||||||
$this->save();
|
$this->save();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getHeaderAttribute($att_name)
|
||||||
|
{
|
||||||
|
return $this->root->getAttribute($att_name);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function modifyHeaderAttribute
|
* Function modifyHeaderAttribute
|
||||||
* @param string $att_name
|
* @param string $att_name
|
||||||
* @param string $att_new_value
|
* @param string $att_new_value
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function modifyHeaderAttribute($att_name, $att_new_value)
|
public function modifyHeaderAttribute($att_name, $att_new_value)
|
||||||
{
|
{
|
||||||
$this->root->removeAttribute($att_name);
|
$this->root->removeAttribute($att_name);
|
||||||
$this->root->setAttribute($att_name, $att_new_value);
|
$this->root->setAttribute($att_name, $att_new_value);
|
||||||
@@ -278,7 +360,7 @@ class dynaFormHandler
|
|||||||
* @param string $att_new_value
|
* @param string $att_new_value
|
||||||
* @return void
|
* @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);
|
$xpath = new DOMXPath($this->dom);
|
||||||
$nodeList = $xpath->query("/dynaForm/$node_name");
|
$nodeList = $xpath->query("/dynaForm/$node_name");
|
||||||
@@ -293,7 +375,7 @@ class dynaFormHandler
|
|||||||
* @param string $v
|
* @param string $v
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function remove($v)
|
public function remove($v)
|
||||||
{
|
{
|
||||||
if (!is_array($v)) {
|
if (!is_array($v)) {
|
||||||
$av[0] = $v;
|
$av[0] = $v;
|
||||||
@@ -323,7 +405,7 @@ class dynaFormHandler
|
|||||||
* @param string $node_name
|
* @param string $node_name
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
function nodeExists($node_name)
|
public function nodeExists($node_name)
|
||||||
{
|
{
|
||||||
$xpath = new DOMXPath($this->dom);
|
$xpath = new DOMXPath($this->dom);
|
||||||
$nodeList = $xpath->query("/dynaForm/$node_name");
|
$nodeList = $xpath->query("/dynaForm/$node_name");
|
||||||
@@ -341,7 +423,7 @@ class dynaFormHandler
|
|||||||
* @param string $selected_node
|
* @param string $selected_node
|
||||||
* @return void
|
* @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
|
This function inserts a new node right before the reference node. If you plan
|
||||||
@@ -374,7 +456,7 @@ class dynaFormHandler
|
|||||||
* @param string $selected_node
|
* @param string $selected_node
|
||||||
* @return void
|
* @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
|
This function inserts a new node right before the reference node. If you plan
|
||||||
@@ -415,7 +497,7 @@ class dynaFormHandler
|
|||||||
* @param array $aFilter
|
* @param array $aFilter
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
function getFields( $aFilter = Array() )
|
public function getFields($aFilter = Array())
|
||||||
{
|
{
|
||||||
$xpath = new DOMXPath($this->dom);
|
$xpath = new DOMXPath($this->dom);
|
||||||
$nodeList = $xpath->query("/dynaForm/*");
|
$nodeList = $xpath->query("/dynaForm/*");
|
||||||
@@ -452,7 +534,7 @@ class dynaFormHandler
|
|||||||
* @param array $aFilter
|
* @param array $aFilter
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
function getFieldNames( $aFilter = Array() )
|
public function getFieldNames($aFilter = Array())
|
||||||
{
|
{
|
||||||
$aList = $this->getFields($aFilter);
|
$aList = $this->getFields($aFilter);
|
||||||
$aFieldNames = Array();
|
$aFieldNames = Array();
|
||||||
@@ -462,10 +544,9 @@ class dynaFormHandler
|
|||||||
return $aFieldNames;
|
return $aFieldNames;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
|
||||||
function addChilds($name, $childs, $childs_childs=null)
|
public function addChilds($name, $childs, $childs_childs = null)
|
||||||
{
|
{
|
||||||
//
|
|
||||||
$xpath = new DOMXPath($this->dom);
|
$xpath = new DOMXPath($this->dom);
|
||||||
$nodeList = @$xpath->query("/dynaForm/$name");
|
$nodeList = @$xpath->query("/dynaForm/$name");
|
||||||
if (!$nodeList) {
|
if (!$nodeList) {
|
||||||
@@ -482,16 +563,17 @@ class dynaFormHandler
|
|||||||
|
|
||||||
$nodeList = $xpath->query("/dynaForm/$name/$child_name");
|
$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
|
//$newnode_child
|
||||||
$childNode = $element->appendChild($this->dom->createElement($child_name));
|
$childNode = $element->appendChild($this->dom->createElement($child_name));
|
||||||
$childNode->appendChild($this->dom->createCDATASection($child_text));
|
$childNode->appendChild($this->dom->createCDATASection($child_text));
|
||||||
} else { // the node already exists
|
} else {
|
||||||
|
// the node already exists
|
||||||
//update its value
|
//update its value
|
||||||
$childNode = $element->getElementsByTagName($child_name)->item(0);
|
$childNode = $element->getElementsByTagName($child_name)->item(0);
|
||||||
|
|
||||||
//
|
if ($child_text !== null) {
|
||||||
if($child_text !== NULL){
|
|
||||||
$xnode = $this->dom->createElement($childNode->nodeName);
|
$xnode = $this->dom->createElement($childNode->nodeName);
|
||||||
$xnode->appendChild($this->dom->createCDATASection($child_text));
|
$xnode->appendChild($this->dom->createCDATASection($child_text));
|
||||||
|
|
||||||
@@ -517,8 +599,8 @@ class dynaFormHandler
|
|||||||
$this->save();
|
$this->save();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function addOrUpdateChild($xnode, $childName, $childValue, $childAttributes)
|
||||||
function addOrUpdateChild($xnode, $childName, $childValue, $childAttributes){
|
{
|
||||||
$newNode = $this->dom->createElement($childName);
|
$newNode = $this->dom->createElement($childName);
|
||||||
$newNode->appendChild($this->dom->createCDATASection($childValue));
|
$newNode->appendChild($this->dom->createCDATASection($childValue));
|
||||||
|
|
||||||
@@ -533,11 +615,12 @@ class dynaFormHandler
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else
|
} else {
|
||||||
$xnode->appendChild($newNode);
|
$xnode->appendChild($newNode);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function getArray($node, $attributes = null)
|
public function getArray($node, $attributes = null)
|
||||||
{
|
{
|
||||||
$array = false;
|
$array = false;
|
||||||
$array['__nodeName__'] = $node->nodeName;
|
$array['__nodeName__'] = $node->nodeName;
|
||||||
@@ -547,9 +630,10 @@ class dynaFormHandler
|
|||||||
if ($node->hasAttributes()) {
|
if ($node->hasAttributes()) {
|
||||||
if (isset($attributes)) {
|
if (isset($attributes)) {
|
||||||
foreach ($attributes as $attr) {
|
foreach ($attributes as $attr) {
|
||||||
if( $node->hasAttribute($attr) )
|
if ($node->hasAttribute($attr)) {
|
||||||
$array[$attr] = $node->getAttribute($attr);
|
$array[$attr] = $node->getAttribute($attr);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
foreach ($node->attributes as $attr) {
|
foreach ($node->attributes as $attr) {
|
||||||
$array[$attr->nodeName] = $attr->nodeValue;
|
$array[$attr->nodeName] = $attr->nodeValue;
|
||||||
@@ -558,9 +642,9 @@ class dynaFormHandler
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($node->hasChildNodes()) {
|
if ($node->hasChildNodes()) {
|
||||||
if ($node->childNodes->length == 0)
|
if ($node->childNodes->length == 0) {
|
||||||
$return;
|
$return;
|
||||||
else {
|
} else {
|
||||||
foreach ($node->childNodes as $childNode) {
|
foreach ($node->childNodes as $childNode) {
|
||||||
$childNode->normalize();
|
$childNode->normalize();
|
||||||
//if ($childNode->nodeType == XML_TEXT_NODE || $childNode->nodeType == XML_CDATA_SECTION_NODE) {
|
//if ($childNode->nodeType == XML_TEXT_NODE || $childNode->nodeType == XML_CDATA_SECTION_NODE) {
|
||||||
@@ -578,3 +662,4 @@ class dynaFormHandler
|
|||||||
return $array;
|
return $array;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* class.dynaFormField.php
|
* class.dynaFormField.php
|
||||||
*
|
*
|
||||||
@@ -24,8 +25,8 @@
|
|||||||
* Coral Gables, FL, 33134, USA, or email info@colosa.com.
|
* Coral Gables, FL, 33134, USA, or email info@colosa.com.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
G::LoadClass('xmlDb');
|
G::LoadClass('xmlDb');
|
||||||
|
G::LoadSystem('dynaformhandler');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Dynaform Field - DynaformField class
|
* Dynaform Field - DynaformField class
|
||||||
@@ -35,13 +36,25 @@ G::LoadClass( 'xmlDb' );
|
|||||||
class DynaFormField extends DBTable
|
class DynaFormField extends DBTable
|
||||||
{
|
{
|
||||||
|
|
||||||
|
private $fileName;
|
||||||
|
|
||||||
|
public function getFileName()
|
||||||
|
{
|
||||||
|
return $this->fileName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setFileName($fileName)
|
||||||
|
{
|
||||||
|
$this->fileName = $fileName;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function SetTo
|
* Function SetTo
|
||||||
*
|
*
|
||||||
* @param string $objConnection
|
* @param string $objConnection
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function SetTo ($objConnection)
|
public function SetTo($objConnection)
|
||||||
{
|
{
|
||||||
DBTable::SetTo($objConnection, 'dynaForm', array('XMLNODE_NAME'
|
DBTable::SetTo($objConnection, 'dynaForm', array('XMLNODE_NAME'
|
||||||
));
|
));
|
||||||
@@ -53,7 +66,7 @@ class DynaFormField extends DBTable
|
|||||||
* @param string $sUID
|
* @param string $sUID
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function Load ($sUID)
|
public function Load($sUID)
|
||||||
{
|
{
|
||||||
parent::Load($sUID);
|
parent::Load($sUID);
|
||||||
if (is_array($this->Fields)) {
|
if (is_array($this->Fields)) {
|
||||||
@@ -71,7 +84,7 @@ class DynaFormField extends DBTable
|
|||||||
* @param string $uid
|
* @param string $uid
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function Delete ($uid)
|
public function Delete($uid)
|
||||||
{
|
{
|
||||||
$this->Fields['XMLNODE_NAME'] = $uid;
|
$this->Fields['XMLNODE_NAME'] = $uid;
|
||||||
parent::Delete();
|
parent::Delete();
|
||||||
@@ -85,7 +98,7 @@ class DynaFormField extends DBTable
|
|||||||
* @param array $options
|
* @param array $options
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function Save ($Fields, $labels = array(), $options = array())
|
public function Save($Fields, $labels = array(), $options = array())
|
||||||
{
|
{
|
||||||
|
|
||||||
if ($Fields['TYPE'] === 'javascript') {
|
if ($Fields['TYPE'] === 'javascript') {
|
||||||
@@ -113,9 +126,10 @@ class DynaFormField extends DBTable
|
|||||||
*/
|
*/
|
||||||
if ($this->is_new) {
|
if ($this->is_new) {
|
||||||
foreach ($this->Fields as $key => $value) {
|
foreach ($this->Fields as $key => $value) {
|
||||||
if ($value == "")
|
if ($value == "") {
|
||||||
unset($this->Fields[$key]);
|
unset($this->Fields[$key]);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
$this->Fields['XMLNODE_NAME'] = $Fields['XMLNODE_NAME_OLD'];
|
$this->Fields['XMLNODE_NAME'] = $Fields['XMLNODE_NAME_OLD'];
|
||||||
}
|
}
|
||||||
@@ -165,16 +179,72 @@ class DynaFormField extends DBTable
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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 {
|
||||||
|
$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
|
* Verify if is New the Field
|
||||||
*
|
*
|
||||||
* @return array
|
* @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);
|
return ($res->count() == 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* class.dynaformEditor.php
|
* class.dynaformEditor.php
|
||||||
*
|
*
|
||||||
@@ -23,7 +24,6 @@
|
|||||||
* For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
|
* For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
|
||||||
* Coral Gables, FL, 33134, USA, or email info@colosa.com.
|
* Coral Gables, FL, 33134, USA, or email info@colosa.com.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created on 21/12/2007
|
* Created on 21/12/2007
|
||||||
* Dynaform - Dynaform class
|
* Dynaform - Dynaform class
|
||||||
@@ -31,27 +31,28 @@
|
|||||||
* @copyright 2007 COLOSA
|
* @copyright 2007 COLOSA
|
||||||
* @author David Callizaya <davidsantos@colosa.com>
|
* @author David Callizaya <davidsantos@colosa.com>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
G::LoadSystem("webResource");
|
G::LoadSystem("webResource");
|
||||||
G::LoadClass('toolBar');
|
G::LoadClass('toolBar');
|
||||||
G::LoadClass('dynaFormField');
|
G::LoadClass('dynaFormField');
|
||||||
require_once ('classes/model/Process.php');
|
require_once ('classes/model/Process.php');
|
||||||
require_once ('classes/model/Dynaform.php');
|
require_once ('classes/model/Dynaform.php');
|
||||||
G::LoadClass('xmlDb');
|
G::LoadClass('xmlDb');
|
||||||
|
G::LoadSystem('dynaformhandler');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @package workflow.engine.classes
|
* @package workflow.engine.classes
|
||||||
*/
|
*/
|
||||||
|
|
||||||
class dynaformEditor extends WebResource
|
class dynaformEditor extends WebResource
|
||||||
{
|
{
|
||||||
|
|
||||||
private $isOldCopy = false;
|
private $isOldCopy = false;
|
||||||
var $file = '';
|
public $file = '';
|
||||||
var $title = 'New Dynaform';
|
public $title = 'New Dynaform';
|
||||||
var $dyn_uid = '';
|
public $dyn_uid = '';
|
||||||
var $dyn_type = '';
|
public $dyn_type = '';
|
||||||
var $home = '';
|
public $home = '';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Other Options for Editor:
|
* Other Options for Editor:
|
||||||
* left: 'getAbsoluteLeft(document.getElementById("dynaformEditor[0]"))',
|
* left: 'getAbsoluteLeft(document.getElementById("dynaformEditor[0]"))',
|
||||||
@@ -64,14 +65,12 @@ class dynaformEditor extends WebResource
|
|||||||
* left: 'getAbsoluteLeft(document.getElementById("dynaformEditor[0]"))',
|
* left: 'getAbsoluteLeft(document.getElementById("dynaformEditor[0]"))',
|
||||||
* top: 'getAbsoluteTop(document.getElementById("dynaformEditor[0]"))',
|
* top: 'getAbsoluteTop(document.getElementById("dynaformEditor[0]"))',
|
||||||
*/
|
*/
|
||||||
var $defaultConfig = array ('Editor' => array ('left' => '0','top' => '0','width' => 'document.body.clientWidth-4','height' => 'document.body.clientHeight-4'
|
public $defaultConfig = array('Editor' => array('left' => '0', 'top' => '0', 'width' => 'document.body.clientWidth-4', 'height' => 'document.body.clientHeight-4'),
|
||||||
),'Toolbar' => array ('left' => 'document.body.clientWidth-2-toolbar.clientWidth-24-3+7','top' => '52'
|
'Toolbar' => array('left' => 'document.body.clientWidth-2-toolbar.clientWidth-24-3+7', 'top' => '52'),
|
||||||
),'FieldsList' => array ('left' => '4+toolbar.clientWidth+24','top' => 'getAbsoluteTop(document.getElementById("dynaformEditor[0]"))','width' => 244,'height' => 400
|
'FieldsList' => array('left' => '4+toolbar.clientWidth+24', 'top' => 'getAbsoluteTop(document.getElementById("dynaformEditor[0]"))', 'width' => 244, 'height' => 400)
|
||||||
)
|
|
||||||
);
|
);
|
||||||
var $panelConf = array ('style' => array ('title' => array ('textAlign' => 'center'
|
public $panelConf = array('style' => array('title' => array('textAlign' => 'center')),
|
||||||
)
|
'width' => 700, 'height' => 600, 'tabWidth' => 120, 'modal' => true, 'drag' => false, 'resize' => false, 'blinkToFront' => false
|
||||||
),'width' => 700,'height' => 600,'tabWidth' => 120,'modal' => true,'drag' => false,'resize' => false,'blinkToFront' => false
|
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -80,7 +79,7 @@ class dynaformEditor extends WebResource
|
|||||||
* @param string $get
|
* @param string $get
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function dynaformEditor ($get)
|
public function dynaformEditor($get)
|
||||||
{
|
{
|
||||||
$this->panelConf = array_merge($this->panelConf, $this->defaultConfig['Editor']);
|
$this->panelConf = array_merge($this->panelConf, $this->defaultConfig['Editor']);
|
||||||
//'title' => G::LoadTranslation('ID_DYNAFORM_EDITOR').' - ['.$this->title.']',
|
//'title' => G::LoadTranslation('ID_DYNAFORM_EDITOR').' - ['.$this->title.']',
|
||||||
@@ -92,7 +91,7 @@ class dynaformEditor extends WebResource
|
|||||||
* @param string $filename
|
* @param string $filename
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function _createDefaultXmlForm ($fileName)
|
public function _createDefaultXmlForm($fileName)
|
||||||
{
|
{
|
||||||
//Create the default Dynaform
|
//Create the default Dynaform
|
||||||
$sampleForm = '<?xml version="1.0" encoding="UTF-8"?>' . "\n";
|
$sampleForm = '<?xml version="1.0" encoding="UTF-8"?>' . "\n";
|
||||||
@@ -128,7 +127,7 @@ class dynaformEditor extends WebResource
|
|||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function _render ()
|
public function _render()
|
||||||
{
|
{
|
||||||
global $G_PUBLISH;
|
global $G_PUBLISH;
|
||||||
$script = '';
|
$script = '';
|
||||||
@@ -206,6 +205,7 @@ class dynaformEditor extends WebResource
|
|||||||
$G_PUBLISH->AddContent('blank');
|
$G_PUBLISH->AddContent('blank');
|
||||||
$G_PUBLISH->AddContent('xmlform', 'xmlform', 'dynaforms/dynaforms_JSEditor', 'display:none', $JSEditor, '', '');
|
$G_PUBLISH->AddContent('xmlform', 'xmlform', 'dynaforms/dynaforms_JSEditor', 'display:none', $JSEditor, '', '');
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
|
|
||||||
}
|
}
|
||||||
$G_PUBLISH->AddContent('xmlform', 'xmlform', 'dynaforms/dynaforms_Properties', 'display:none', $Properties, '', '');
|
$G_PUBLISH->AddContent('xmlform', 'xmlform', 'dynaforms/dynaforms_Properties', 'display:none', $Properties, '', '');
|
||||||
//for showHide tab option @Neyek
|
//for showHide tab option @Neyek
|
||||||
@@ -239,7 +239,7 @@ class dynaformEditor extends WebResource
|
|||||||
* @param string $file
|
* @param string $file
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
function _getFilename ($file)
|
public function _getFilename($file)
|
||||||
{
|
{
|
||||||
return (strcasecmp(substr($file, - 5), '_tmp0') == 0) ? substr($file, 0, strlen($file) - 5) : $file;
|
return (strcasecmp(substr($file, - 5), '_tmp0') == 0) ? substr($file, 0, strlen($file) - 5) : $file;
|
||||||
}
|
}
|
||||||
@@ -250,20 +250,22 @@ class dynaformEditor extends WebResource
|
|||||||
* @param string $onOff
|
* @param string $onOff
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function _setUseTemporalCopy ($onOff)
|
public function _setUseTemporalCopy($onOff)
|
||||||
{
|
{
|
||||||
$file = self::_getFilename($this->file);
|
$file = self::_getFilename($this->file);
|
||||||
if ($onOff) {
|
if ($onOff) {
|
||||||
$this->file = $file . '_tmp0';
|
$this->file = $file . '_tmp0';
|
||||||
self::_setTmpData( array ('useTmpCopy' => true
|
self::_setTmpData(array('useTmpCopy' => true ));
|
||||||
) );
|
if (!file_exists(PATH_DYNAFORM . $file . '.xml')) {
|
||||||
if (! file_exists( PATH_DYNAFORM . $file . '.xml' ))
|
|
||||||
$this->_createDefaultXmlForm(PATH_DYNAFORM . $file . '.xml');
|
$this->_createDefaultXmlForm(PATH_DYNAFORM . $file . '.xml');
|
||||||
|
}
|
||||||
//Creates a copy if it doesn't exist, else, use the old copy
|
//Creates a copy if it doesn't exist, else, use the old copy
|
||||||
if (! file_exists( PATH_DYNAFORM . $this->file . '.xml' ))
|
if (!file_exists(PATH_DYNAFORM . $this->file . '.xml')) {
|
||||||
self::_copyFile(PATH_DYNAFORM . $file . '.xml', PATH_DYNAFORM . $this->file . '.xml');
|
self::_copyFile(PATH_DYNAFORM . $file . '.xml', PATH_DYNAFORM . $this->file . '.xml');
|
||||||
if (! file_exists( PATH_DYNAFORM . $this->file . '.html' ) && file_exists( PATH_DYNAFORM . $file . '.html' ))
|
}
|
||||||
|
if (!file_exists(PATH_DYNAFORM . $this->file . '.html') && file_exists(PATH_DYNAFORM . $file . '.html')) {
|
||||||
self::_copyFile(PATH_DYNAFORM . $file . '.html', PATH_DYNAFORM . $this->file . '.html');
|
self::_copyFile(PATH_DYNAFORM . $file . '.html', PATH_DYNAFORM . $this->file . '.html');
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
$this->file = $file;
|
$this->file = $file;
|
||||||
self::_setTmpData(array());
|
self::_setTmpData(array());
|
||||||
@@ -276,7 +278,7 @@ class dynaformEditor extends WebResource
|
|||||||
* @param $data
|
* @param $data
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function _setTmpData ($data)
|
public function _setTmpData($data)
|
||||||
{
|
{
|
||||||
G::verifyPath(PATH_C . 'dynEditor/', true);
|
G::verifyPath(PATH_C . 'dynEditor/', true);
|
||||||
$fp = fopen(PATH_C . 'dynEditor/' . session_id() . '.php', 'w');
|
$fp = fopen(PATH_C . 'dynEditor/' . session_id() . '.php', 'w');
|
||||||
@@ -290,12 +292,13 @@ class dynaformEditor extends WebResource
|
|||||||
* @param string $filename
|
* @param string $filename
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
function _getTmpData ()
|
public function _getTmpData()
|
||||||
{
|
{
|
||||||
$tmpData = array();
|
$tmpData = array();
|
||||||
$file = PATH_C . 'dynEditor/' . session_id() . '.php';
|
$file = PATH_C . 'dynEditor/' . session_id() . '.php';
|
||||||
if (file_exists( $file ))
|
if (file_exists($file)) {
|
||||||
eval(implode('', file($file)));
|
eval(implode('', file($file)));
|
||||||
|
}
|
||||||
return $tmpData;
|
return $tmpData;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -306,7 +309,7 @@ class dynaformEditor extends WebResource
|
|||||||
* @param file $to
|
* @param file $to
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function _copyFile ($from, $to)
|
public function _copyFile($from, $to)
|
||||||
{
|
{
|
||||||
$copy = implode('', file($from));
|
$copy = implode('', file($from));
|
||||||
$fcopy = fopen($to, "w");
|
$fcopy = fopen($to, "w");
|
||||||
@@ -325,7 +328,6 @@ interface iDynaformEditorAjax
|
|||||||
*
|
*
|
||||||
* @package workflow.engine.classes
|
* @package workflow.engine.classes
|
||||||
*/
|
*/
|
||||||
|
|
||||||
class dynaformEditorAjax extends dynaformEditor implements iDynaformEditorAjax
|
class dynaformEditorAjax extends dynaformEditor implements iDynaformEditorAjax
|
||||||
{
|
{
|
||||||
|
|
||||||
@@ -335,7 +337,7 @@ class dynaformEditorAjax extends dynaformEditor implements iDynaformEditorAjax
|
|||||||
* @param var $post
|
* @param var $post
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function dynaformEditorAjax ($post)
|
public function dynaformEditorAjax($post)
|
||||||
{
|
{
|
||||||
$this->_run($post);
|
$this->_run($post);
|
||||||
}
|
}
|
||||||
@@ -346,7 +348,7 @@ class dynaformEditorAjax extends dynaformEditor implements iDynaformEditorAjax
|
|||||||
* @param var $post
|
* @param var $post
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function _run ($post)
|
public function _run($post)
|
||||||
{
|
{
|
||||||
WebResource::WebResource($_SERVER['REQUEST_URI'], $post);
|
WebResource::WebResource($_SERVER['REQUEST_URI'], $post);
|
||||||
}
|
}
|
||||||
@@ -357,7 +359,7 @@ class dynaformEditorAjax extends dynaformEditor implements iDynaformEditorAjax
|
|||||||
* @param object $A
|
* @param object $A
|
||||||
* @return ob_get_clean
|
* @return ob_get_clean
|
||||||
*/
|
*/
|
||||||
function render_preview ($A)
|
public function render_preview($A)
|
||||||
{
|
{
|
||||||
ob_start();
|
ob_start();
|
||||||
$file = G::decrypt($A, URL_KEY);
|
$file = G::decrypt($A, URL_KEY);
|
||||||
@@ -375,9 +377,9 @@ class dynaformEditorAjax extends dynaformEditor implements iDynaformEditorAjax
|
|||||||
$aFields = $aAux;
|
$aFields = $aAux;
|
||||||
}
|
}
|
||||||
if (is_array($aFields)) {
|
if (is_array($aFields)) {
|
||||||
foreach ($aFields as $key => $val)
|
foreach ($aFields as $key => $val) {
|
||||||
$aFields[$key] = array (1 => "",2 => "",3 => "",4 => "",5 => ""
|
$aFields[$key] = array(1 => "", 2 => "", 3 => "", 4 => "", 5 => "");
|
||||||
);
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@@ -397,7 +399,7 @@ class dynaformEditorAjax extends dynaformEditor implements iDynaformEditorAjax
|
|||||||
* @param object $A
|
* @param object $A
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
function render_htmledit ($A)
|
public function render_htmledit($A)
|
||||||
{
|
{
|
||||||
$script = '';
|
$script = '';
|
||||||
$file = G::decrypt($A, URL_KEY);
|
$file = G::decrypt($A, URL_KEY);
|
||||||
@@ -429,7 +431,7 @@ class dynaformEditorAjax extends dynaformEditor implements iDynaformEditorAjax
|
|||||||
* @param object $A
|
* @param object $A
|
||||||
* @return code html
|
* @return code html
|
||||||
*/
|
*/
|
||||||
function get_htmlcode ($A)
|
public function get_htmlcode($A)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
$script = null;
|
$script = null;
|
||||||
@@ -459,11 +461,12 @@ class dynaformEditorAjax extends dynaformEditor implements iDynaformEditorAjax
|
|||||||
* Already checked the temporary file dynaforms editor.
|
* Already checked the temporary file dynaforms editor.
|
||||||
*/
|
*/
|
||||||
$tmp = self::_getTmpData();
|
$tmp = self::_getTmpData();
|
||||||
if (! isset( $tmp['OLD_FIELDS'] ))
|
if (!isset($tmp['OLD_FIELDS'])) {
|
||||||
$tmp['OLD_FIELDS'] = array(); //var_dump($html);die;
|
$tmp['OLD_FIELDS'] = array(); //var_dump($html);die;
|
||||||
|
}
|
||||||
$aAux = explode('</form>', $html);
|
$aAux = explode('</form>', $html);
|
||||||
foreach ($form->fields as $field) {
|
foreach ($form->fields as $field) {
|
||||||
if ((strpos( $html, '{$form.' . $field->name . '}' ) === FALSE) && (strpos( $html, '{$' . $field->name . '}' ) === FALSE)) {
|
if ((strpos($html, '{$form.' . $field->name . '}') === false) && (strpos($html, '{$' . $field->name . '}') === false)) {
|
||||||
//Aparantly is new (but could be a deleted or non visible like private type fields)
|
//Aparantly is new (but could be a deleted or non visible like private type fields)
|
||||||
switch (strtolower($field->type)) {
|
switch (strtolower($field->type)) {
|
||||||
case 'private':
|
case 'private':
|
||||||
@@ -497,7 +500,7 @@ class dynaformEditorAjax extends dynaformEditor implements iDynaformEditorAjax
|
|||||||
* @param object $A
|
* @param object $A
|
||||||
* @return code html
|
* @return code html
|
||||||
*/
|
*/
|
||||||
function restore_html ($A)
|
public function restore_html($A)
|
||||||
{
|
{
|
||||||
$script = null;
|
$script = null;
|
||||||
$fileTmp = G::decrypt($A, URL_KEY);
|
$fileTmp = G::decrypt($A, URL_KEY);
|
||||||
@@ -527,7 +530,7 @@ class dynaformEditorAjax extends dynaformEditor implements iDynaformEditorAjax
|
|||||||
* @param object $A
|
* @param object $A
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
function set_htmlcode ($A, $htmlcode)
|
public function set_htmlcode($A, $htmlcode)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
$file = G::decrypt($A, URL_KEY);
|
$file = G::decrypt($A, URL_KEY);
|
||||||
@@ -548,7 +551,7 @@ class dynaformEditorAjax extends dynaformEditor implements iDynaformEditorAjax
|
|||||||
* @param object $A
|
* @param object $A
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
function get_xmlcode ($A)
|
public function get_xmlcode($A)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
$file = G::decrypt($A, URL_KEY);
|
$file = G::decrypt($A, URL_KEY);
|
||||||
@@ -568,7 +571,7 @@ class dynaformEditorAjax extends dynaformEditor implements iDynaformEditorAjax
|
|||||||
* @param array $xmlcode
|
* @param array $xmlcode
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
function set_xmlcode ($A, $xmlcode)
|
public function set_xmlcode($A, $xmlcode)
|
||||||
{
|
{
|
||||||
$xmlcode = urldecode($xmlcode);
|
$xmlcode = urldecode($xmlcode);
|
||||||
$file = G::decrypt($A, URL_KEY);
|
$file = G::decrypt($A, URL_KEY);
|
||||||
@@ -586,7 +589,7 @@ class dynaformEditorAjax extends dynaformEditor implements iDynaformEditorAjax
|
|||||||
* @param string $fieldName
|
* @param string $fieldName
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
function get_javascripts ($A, $fieldName)
|
public function get_javascripts($A, $fieldName)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
$file = G::decrypt($A, URL_KEY);
|
$file = G::decrypt($A, URL_KEY);
|
||||||
@@ -597,10 +600,11 @@ class dynaformEditorAjax extends dynaformEditor implements iDynaformEditorAjax
|
|||||||
if (strcasecmp($value->type, "javascript") == 0) {
|
if (strcasecmp($value->type, "javascript") == 0) {
|
||||||
$aOptions[] = array('key' => $name, 'value' => $name
|
$aOptions[] = array('key' => $name, 'value' => $name
|
||||||
);
|
);
|
||||||
if ($name == $fieldName)
|
if ($name == $fieldName) {
|
||||||
$sCode = $value->code;
|
$sCode = $value->code;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return array('aOptions' => $aOptions, 'sCode' => $sCode
|
return array('aOptions' => $aOptions, 'sCode' => $sCode
|
||||||
);
|
);
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
@@ -616,7 +620,7 @@ class dynaformEditorAjax extends dynaformEditor implements iDynaformEditorAjax
|
|||||||
* @param string $sCode
|
* @param string $sCode
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
function set_javascript ($A, $fieldName, $sCode, $meta = '')
|
public function set_javascript($A, $fieldName, $sCode, $meta = '')
|
||||||
{
|
{
|
||||||
if ($fieldName == '___pm_boot_strap___') {
|
if ($fieldName == '___pm_boot_strap___') {
|
||||||
return 0;
|
return 0;
|
||||||
@@ -650,7 +654,7 @@ class dynaformEditorAjax extends dynaformEditor implements iDynaformEditorAjax
|
|||||||
* @param string $DYN_UID
|
* @param string $DYN_UID
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
function get_properties ($A, $DYN_UID)
|
public function get_properties($A, $DYN_UID)
|
||||||
{
|
{
|
||||||
$file = G::decrypt($A, URL_KEY);
|
$file = G::decrypt($A, URL_KEY);
|
||||||
$tmp = self::_getTmpData();
|
$tmp = self::_getTmpData();
|
||||||
@@ -667,8 +671,9 @@ class dynaformEditorAjax extends dynaformEditor implements iDynaformEditorAjax
|
|||||||
} else {
|
} else {
|
||||||
$form = new Form($file, PATH_DYNAFORM, SYS_LANG, true);
|
$form = new Form($file, PATH_DYNAFORM, SYS_LANG, true);
|
||||||
$Properties = $tmp['Properties'];
|
$Properties = $tmp['Properties'];
|
||||||
if (! isset( $Properties['ENABLETEMPLATE'] ))
|
if (!isset($Properties['ENABLETEMPLATE'])) {
|
||||||
$Properties['ENABLETEMPLATE'] = "0";
|
$Properties['ENABLETEMPLATE'] = "0";
|
||||||
|
}
|
||||||
$Properties['WIDTH'] = $form->width;
|
$Properties['WIDTH'] = $form->width;
|
||||||
$Properties['MODE'] = $form->mode;
|
$Properties['MODE'] = $form->mode;
|
||||||
}
|
}
|
||||||
@@ -683,7 +688,7 @@ class dynaformEditorAjax extends dynaformEditor implements iDynaformEditorAjax
|
|||||||
* @param array $getFields
|
* @param array $getFields
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
function set_properties ($A, $DYN_UID, $getFields)
|
public function set_properties($A, $DYN_UID, $getFields)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
$post = array();
|
$post = array();
|
||||||
@@ -699,30 +704,40 @@ class dynaformEditorAjax extends dynaformEditor implements iDynaformEditorAjax
|
|||||||
$tmp['Properties'] = $Fields;
|
$tmp['Properties'] = $Fields;
|
||||||
self::_setTmpData($tmp);
|
self::_setTmpData($tmp);
|
||||||
}
|
}
|
||||||
|
$dynaform = new dynaFormHandler(PATH_DYNAFORM . "{$file}.xml");
|
||||||
$dbc2 = new DBConnection(PATH_DYNAFORM . $file . '.xml', '', '', '', 'myxml');
|
$dbc2 = new DBConnection(PATH_DYNAFORM . $file . '.xml', '', '', '', 'myxml');
|
||||||
$ses2 = new DBSession($dbc2);
|
$ses2 = new DBSession($dbc2);
|
||||||
//if (!isset($Fields['ENABLETEMPLATE'])) $Fields['ENABLETEMPLATE'] ="0";
|
//if (!isset($Fields['ENABLETEMPLATE'])) $Fields['ENABLETEMPLATE'] ="0";
|
||||||
if (isset( $Fields['WIDTH'] )) {
|
|
||||||
$ses2->execute( G::replaceDataField( "UPDATE . SET WIDTH = @@WIDTH WHERE XMLNODE_NAME = 'dynaForm' ", $Fields ) );
|
|
||||||
}
|
|
||||||
/* if (isset($Fields['ENABLETEMPLATE'])) {
|
/* if (isset($Fields['ENABLETEMPLATE'])) {
|
||||||
$ses2->execute(G::replaceDataField("UPDATE . SET ENABLETEMPLATE = @@ENABLETEMPLATE WHERE XMLNODE_NAME = 'dynaForm' ", $Fields));
|
$ses2->execute(G::replaceDataField("UPDATE . SET ENABLETEMPLATE = @@ENABLETEMPLATE WHERE XMLNODE_NAME = 'dynaForm' ", $Fields));
|
||||||
} */
|
} */
|
||||||
if (isset($Fields['DYN_TYPE'])) {
|
if (isset($Fields['DYN_TYPE'])) {
|
||||||
$ses2->execute( G::replaceDataField( "UPDATE . SET TYPE = @@DYN_TYPE WHERE XMLNODE_NAME = 'dynaForm' ", $Fields ) );
|
//$ses2->execute( G::replaceDataField( "UPDATE . SET TYPE = @@DYN_TYPE WHERE XMLNODE_NAME = 'dynaForm' ", $Fields ) );
|
||||||
|
$dynaform->modifyHeaderAttribute('type', $Fields['DYN_TYPE']);
|
||||||
|
}
|
||||||
|
if (isset($Fields['WIDTH'])) {
|
||||||
|
// $ses2->execute( G::replaceDataField( "UPDATE . SET WIDTH = @@WIDTH WHERE XMLNODE_NAME = 'dynaForm' ", $Fields ) );
|
||||||
|
$dynaform->modifyHeaderAttribute('width', $Fields['WIDTH']);
|
||||||
|
//g::pr($dynaform->getHeaderAttribute('width'));
|
||||||
}
|
}
|
||||||
if (isset($Fields['MODE'])) {
|
if (isset($Fields['MODE'])) {
|
||||||
$ses2->execute( G::replaceDataField( "UPDATE . SET MODE = @@MODE WHERE XMLNODE_NAME = 'dynaForm' ", $Fields ) );
|
// $ses2->execute( G::replaceDataField( "UPDATE . SET MODE = @@MODE WHERE XMLNODE_NAME = 'dynaForm' ", $Fields ) );
|
||||||
|
$dynaform->modifyHeaderAttribute('mode', $Fields['MODE']);
|
||||||
}
|
}
|
||||||
if (isset($Fields['NEXTSTEPSAVE'])) {
|
if (isset($Fields['NEXTSTEPSAVE'])) {
|
||||||
$ses2->execute( G::replaceDataField( "UPDATE . SET NEXTSTEPSAVE = @@NEXTSTEPSAVE WHERE XMLNODE_NAME = 'dynaForm' ", $Fields ) );
|
//$ses2->execute( G::replaceDataField( "UPDATE . SET NEXTSTEPSAVE = @@NEXTSTEPSAVE WHERE XMLNODE_NAME = 'dynaForm' ", $Fields ) );
|
||||||
|
$dynaform->modifyHeaderAttribute('nextstepsave', $Fields['NEXTSTEPSAVE']);
|
||||||
}
|
}
|
||||||
if (isset($Fields['PRINTDYNAFORM'])) {
|
if (isset($Fields['PRINTDYNAFORM'])) {
|
||||||
$ses2->execute( G::replaceDataField( "UPDATE . SET PRINTDYNAFORM = @@PRINTDYNAFORM WHERE XMLNODE_NAME = 'dynaForm' ", $Fields ) );
|
//$ses2->execute( G::replaceDataField( "UPDATE . SET PRINTDYNAFORM = @@PRINTDYNAFORM WHERE XMLNODE_NAME = 'dynaForm' ", $Fields ) );
|
||||||
|
$dynaform->modifyHeaderAttribute('printdynaform', $Fields['PRINTDYNAFORM']);
|
||||||
}
|
}
|
||||||
if (isset($Fields['ADJUSTGRIDSWIDTH'])) {
|
if (isset($Fields['ADJUSTGRIDSWIDTH'])) {
|
||||||
$ses2->execute( G::replaceDataField( "UPDATE . SET ADJUSTGRIDSWIDTH = @@ADJUSTGRIDSWIDTH WHERE XMLNODE_NAME = 'dynaForm' ", $Fields ) );
|
//$ses2->execute( G::replaceDataField( "UPDATE . SET ADJUSTGRIDSWIDTH = @@ADJUSTGRIDSWIDTH WHERE XMLNODE_NAME = 'dynaForm' ", $Fields ) );
|
||||||
|
$dynaform->modifyHeaderAttribute('adjustgridswidth', $Fields['ADJUSTGRIDSWIDTH']);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
return (array) $e;
|
return (array) $e;
|
||||||
@@ -735,7 +750,7 @@ class dynaformEditorAjax extends dynaformEditor implements iDynaformEditorAjax
|
|||||||
* @param object $A
|
* @param object $A
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
function get_enabletemplate ($A)
|
public function get_enabletemplate($A)
|
||||||
{
|
{
|
||||||
$file = G::decrypt($A, URL_KEY);
|
$file = G::decrypt($A, URL_KEY);
|
||||||
$form = new Form($file, PATH_DYNAFORM, SYS_LANG, true);
|
$form = new Form($file, PATH_DYNAFORM, SYS_LANG, true);
|
||||||
@@ -749,13 +764,17 @@ class dynaformEditorAjax extends dynaformEditor implements iDynaformEditorAjax
|
|||||||
* @param string $value
|
* @param string $value
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
function set_enabletemplate ($A, $value)
|
public function set_enabletemplate($A, $value)
|
||||||
{
|
{
|
||||||
$file = G::decrypt($A, URL_KEY);
|
$file = G::decrypt($A, URL_KEY);
|
||||||
$value = $value == "1" ? "1" : "0";
|
$value = $value == "1" ? "1" : "0";
|
||||||
$dbc2 = new DBConnection( PATH_DYNAFORM . $file . '.xml', '', '', '', 'myxml' );
|
// $dbc2 = new DBConnection( PATH_DYNAFORM . $file . '.xml', '', '', '', 'myxml' );
|
||||||
$ses2 = new DBSession( $dbc2 );
|
// $ses2 = new DBSession( $dbc2 );
|
||||||
$ses2->execute( "UPDATE . SET ENABLETEMPLATE = '$value'" );
|
// $ses2->execute( "UPDATE . SET ENABLETEMPLATE = '$value'" );
|
||||||
|
|
||||||
|
$dynaform = new dynaFormHandler(PATH_DYNAFORM . "{$file}.xml");
|
||||||
|
$dynaform->modifyHeaderAttribute('enabletemplate', $value);
|
||||||
|
|
||||||
return $value;
|
return $value;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -766,13 +785,14 @@ class dynaformEditorAjax extends dynaformEditor implements iDynaformEditorAjax
|
|||||||
* @param string $DYN_UID
|
* @param string $DYN_UID
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
function save ($A, $DYN_UID)
|
public function save($A, $DYN_UID)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
$answer = 0;
|
$answer = 0;
|
||||||
$file = G::decrypt($A, URL_KEY);
|
$file = G::decrypt($A, URL_KEY);
|
||||||
$tmp = self::_getTmpData();
|
$tmp = self::_getTmpData();
|
||||||
if (isset( $tmp['useTmpCopy'] )) { /*Save Register*/
|
if (isset($tmp['useTmpCopy'])) {
|
||||||
|
/* Save Register */
|
||||||
$dynaform = new dynaform();
|
$dynaform = new dynaform();
|
||||||
$dynaform->update($tmp['Properties']);
|
$dynaform->update($tmp['Properties']);
|
||||||
/* Save file */
|
/* Save file */
|
||||||
@@ -814,7 +834,7 @@ class dynaformEditorAjax extends dynaformEditor implements iDynaformEditorAjax
|
|||||||
* @param object $A
|
* @param object $A
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
function close ($A)
|
public function close($A)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
/*
|
/*
|
||||||
@@ -835,10 +855,11 @@ class dynaformEditorAjax extends dynaformEditor implements iDynaformEditorAjax
|
|||||||
if (file_exists($xmlFile)) {
|
if (file_exists($xmlFile)) {
|
||||||
unlink($xmlFile);
|
unlink($xmlFile);
|
||||||
}
|
}
|
||||||
if (file_exists( $htmlFile ))
|
if (file_exists($htmlFile)) {
|
||||||
unlink($htmlFile);
|
unlink($htmlFile);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
return (array) $e;
|
return (array) $e;
|
||||||
@@ -852,7 +873,7 @@ class dynaformEditorAjax extends dynaformEditor implements iDynaformEditorAjax
|
|||||||
* @param string $DYN_UID
|
* @param string $DYN_UID
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
function is_modified ($A, $DYN_UID)
|
public function is_modified($A, $DYN_UID)
|
||||||
{
|
{
|
||||||
$file = G::decrypt($A, URL_KEY);
|
$file = G::decrypt($A, URL_KEY);
|
||||||
try {
|
try {
|
||||||
@@ -881,10 +902,11 @@ class dynaformEditorAjax extends dynaformEditor implements iDynaformEditorAjax
|
|||||||
if (!isset($P['MODE'])) {
|
if (!isset($P['MODE'])) {
|
||||||
$P['MODE'] = $sp['MODE'];
|
$P['MODE'] = $sp['MODE'];
|
||||||
}
|
}
|
||||||
$modPro = ($sp['DYN_TITLE'] != $P['DYN_TITLE']) || ($sp['DYN_TYPE'] != $P['DYN_TYPE']) || ($sp['DYN_DESCRIPTION'] != $P['DYN_DESCRIPTION']) /*||
|
$modPro = ($sp['DYN_TITLE'] != $P['DYN_TITLE']) || ($sp['DYN_TYPE'] != $P['DYN_TYPE']) || ($sp['DYN_DESCRIPTION'] != $P['DYN_DESCRIPTION']);
|
||||||
|
/* ||
|
||||||
($sp['WIDTH']!=$P['WIDTH']) ||
|
($sp['WIDTH']!=$P['WIDTH']) ||
|
||||||
($sp['ENABLETEMPLATE']!=$P['ENABLETEMPLATE']) ||
|
($sp['ENABLETEMPLATE']!=$P['ENABLETEMPLATE']) ||
|
||||||
($sp['MODE']!=$P['MODE'])*/;
|
($sp['MODE']!=$P['MODE']) */
|
||||||
/* Compare copies */
|
/* Compare copies */
|
||||||
$fileOrigen = dynaformEditor::_getFilename($file);
|
$fileOrigen = dynaformEditor::_getFilename($file);
|
||||||
$copy = implode('', file(PATH_DYNAFORM . $file . '.xml'));
|
$copy = implode('', file(PATH_DYNAFORM . $file . '.xml'));
|
||||||
@@ -901,4 +923,4 @@ class dynaformEditorAjax extends dynaformEditor implements iDynaformEditorAjax
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
//print_r( $_POST); die;
|
//print_r( $_POST); die;
|
||||||
/**
|
/**
|
||||||
* fields_Save.php
|
* fields_Save.php
|
||||||
@@ -25,21 +26,24 @@
|
|||||||
*/
|
*/
|
||||||
G::LoadClass('dynaformEditor');
|
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']);
|
$type = strtolower($_POST['form']['PME_TYPE']);
|
||||||
if (!(isset($_POST['form']['PME_A']) && $_POST['form']['PME_A']!=='')) return;
|
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'] == '') {
|
if ($_POST['form']['PME_REQUIRED'] == '') {
|
||||||
$_POST['form']['PME_REQUIRED'] = 0;
|
$_POST['form']['PME_REQUIRED'] = 0;
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
$_POST['form']['PME_REQUIRED'] = 0;
|
$_POST['form']['PME_REQUIRED'] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -47,8 +51,7 @@ if (($RBAC_Response=$RBAC->userCanAccess("PM_FACTORY"))!=1) return $RBAC_Respons
|
|||||||
if ($_POST['form']['PME_READONLY'] == '') {
|
if ($_POST['form']['PME_READONLY'] == '') {
|
||||||
$_POST['form']['PME_READONLY'] = 0;
|
$_POST['form']['PME_READONLY'] = 0;
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
$_POST['form']['PME_READONLY'] = 0;
|
$_POST['form']['PME_READONLY'] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -56,16 +59,15 @@ if (($RBAC_Response=$RBAC->userCanAccess("PM_FACTORY"))!=1) return $RBAC_Respons
|
|||||||
if ($_POST['form']['PME_SAVELABEL'] == '') {
|
if ($_POST['form']['PME_SAVELABEL'] == '') {
|
||||||
$_POST['form']['PME_SAVELABEL'] = 0;
|
$_POST['form']['PME_SAVELABEL'] = 0;
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
$_POST['form']['PME_SAVELABEL'] = 0;
|
$_POST['form']['PME_SAVELABEL'] = 0;
|
||||||
}
|
}
|
||||||
|
$A = $_POST['form']['PME_A'];
|
||||||
if (isset($_POST['form']['PME_SAVELABEL'])
|
if (isset($_POST['form']['PME_SAVELABEL'])
|
||||||
&& isset($_POST['form']['PME_CODE'])
|
&& isset($_POST['form']['PME_CODE'])
|
||||||
&& $_POST['form']['PME_TYPE'] === 'javascript') {
|
&& $_POST['form']['PME_TYPE'] === 'javascript') {
|
||||||
$sType = $_POST['form']['PME_TYPE'];
|
$sType = $_POST['form']['PME_TYPE'];
|
||||||
$A = $_POST['form']['PME_A'];
|
// $A = $_POST['form']['PME_A'];
|
||||||
$fieldName = $_POST['form']['PME_XMLNODE_NAME'];
|
$fieldName = $_POST['form']['PME_XMLNODE_NAME'];
|
||||||
$pmeCode = $_POST['form']['PME_CODE'];
|
$pmeCode = $_POST['form']['PME_CODE'];
|
||||||
$_POST['form']['PME_CODE'] = '';
|
$_POST['form']['PME_CODE'] = '';
|
||||||
@@ -82,17 +84,21 @@ if (($RBAC_Response=$RBAC->userCanAccess("PM_FACTORY"))!=1) return $RBAC_Respons
|
|||||||
define('DB_XMLDB_NAME', '');
|
define('DB_XMLDB_NAME', '');
|
||||||
define('DB_XMLDB_TYPE', 'myxml');
|
define('DB_XMLDB_TYPE', 'myxml');
|
||||||
|
|
||||||
if (isset($_POST['form']['PME_XMLNODE_VALUE'])){
|
// if (isset($_POST['form']['PME_XMLNODE_VALUE'])){
|
||||||
$_POST['form']['PME_XMLNODE_VALUE'] = str_replace("'", "''" , $_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')) {
|
if (file_exists(PATH_XMLFORM . 'dynaforms/fields/' . $type . '.xml')) {
|
||||||
$form = new Form('dynaforms/fields/' . $type, PATH_XMLFORM);
|
$form = new Form('dynaforms/fields/' . $type, PATH_XMLFORM);
|
||||||
//TODO: Verify why validatePost removes PME_XMLGRID.
|
//TODO: Verify why validatePost removes PME_XMLGRID.
|
||||||
$isGrid = isset($_POST['form']['PME_XMLGRID']);
|
$isGrid = isset($_POST['form']['PME_XMLGRID']);
|
||||||
if ($isGrid) $xmlGrid=$_POST['form']['PME_XMLGRID'];
|
if ($isGrid) {
|
||||||
|
$xmlGrid = $_POST['form']['PME_XMLGRID'];
|
||||||
|
}
|
||||||
//$form->validatePost();
|
//$form->validatePost();
|
||||||
if ($isGrid) $_POST['form']['PME_XMLGRID']=$xmlGrid;
|
if ($isGrid) {
|
||||||
|
$_POST['form']['PME_XMLGRID'] = $xmlGrid;
|
||||||
|
}
|
||||||
if ($type === 'checkbox') {
|
if ($type === 'checkbox') {
|
||||||
// added by Gustavo Cruz
|
// added by Gustavo Cruz
|
||||||
if ($_POST['form']['PME_DEFAULTVALUE'] === "1") {
|
if ($_POST['form']['PME_DEFAULTVALUE'] === "1") {
|
||||||
@@ -124,14 +130,14 @@ if (($RBAC_Response=$RBAC->userCanAccess("PM_FACTORY"))!=1) return $RBAC_Respons
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
foreach ($_POST['form'] as $key => $value) {
|
foreach ($_POST['form'] as $key => $value) {
|
||||||
if (substr($key,0,4)==='PME_')
|
if (substr($key, 0, 4) === 'PME_') {
|
||||||
$res[substr($key, 4)] = $value;
|
$res[substr($key, 4)] = $value;
|
||||||
else
|
} else {
|
||||||
$res[$key] = $value;
|
$res[$key] = $value;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
$_POST['form'] = $res;
|
$_POST['form'] = $res;
|
||||||
|
|
||||||
$dbc = new DBConnection(PATH_DYNAFORM . $file . '.xml', '', '', '', 'myxml');
|
$dbc = new DBConnection(PATH_DYNAFORM . $file . '.xml', '', '', '', 'myxml');
|
||||||
@@ -139,7 +145,9 @@ if (($RBAC_Response=$RBAC->userCanAccess("PM_FACTORY"))!=1) return $RBAC_Respons
|
|||||||
|
|
||||||
$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'];
|
||||||
|
|
||||||
@@ -148,17 +156,21 @@ if (($RBAC_Response=$RBAC->userCanAccess("PM_FACTORY"))!=1) return $RBAC_Respons
|
|||||||
$attributes['HINT'] = htmlspecialchars($attributes['HINT'], ENT_QUOTES, "UTF-8");
|
$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();
|
$labels = array();
|
||||||
if (isset($attributes['LABEL'])) $labels = array ( SYS_LANG => $attributes['LABEL'] );
|
if (isset($attributes['LABEL'])) {
|
||||||
|
$labels = array(SYS_LANG => $attributes['LABEL']);
|
||||||
|
}
|
||||||
|
|
||||||
unset($attributes['A']);
|
unset($attributes['A']);
|
||||||
unset($attributes['ACCEPT']);
|
unset($attributes['ACCEPT']);
|
||||||
unset($attributes['LABEL']);
|
unset($attributes['LABEL']);
|
||||||
unset($attributes['PRO_UID']);
|
unset($attributes['PRO_UID']);
|
||||||
|
|
||||||
$options = NULL;
|
$options = null;
|
||||||
foreach ($attributes as $key => $value) {
|
foreach ($attributes as $key => $value) {
|
||||||
if ($key === 'OPTIONS') {
|
if ($key === 'OPTIONS') {
|
||||||
if (is_array($value)) {
|
if (is_array($value)) {
|
||||||
@@ -170,10 +182,11 @@ if (($RBAC_Response=$RBAC->userCanAccess("PM_FACTORY"))!=1) return $RBAC_Respons
|
|||||||
foreach ($value as $row) {
|
foreach ($value as $row) {
|
||||||
foreach ($langs as $lang) {
|
foreach ($langs as $lang) {
|
||||||
$LANG = strtoupper($lang);
|
$LANG = strtoupper($lang);
|
||||||
if (isset($row['LABEL']))
|
if (isset($row['LABEL'])) {
|
||||||
$options[$lang][$row['NAME']] = $row['LABEL'];
|
$options[$lang][$row['NAME']] = $row['LABEL'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
/* $first = reset($value);
|
/* $first = reset($value);
|
||||||
foreach( $first as $optKey => $optValue ) {
|
foreach( $first as $optKey => $optValue ) {
|
||||||
if (substr($optKey,0,6)==='LABEL_') {
|
if (substr($optKey,0,6)==='LABEL_') {
|
||||||
@@ -202,7 +215,22 @@ if (($RBAC_Response=$RBAC->userCanAccess("PM_FACTORY"))!=1) return $RBAC_Respons
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
unset($attributes['VALIDATE_NAME']);
|
unset($attributes['VALIDATE_NAME']);
|
||||||
$fields->Save( $attributes , $labels , $options );
|
$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) {
|
||||||
|
if ($value != "") {
|
||||||
|
$FieldAttrib[strtolower($key)] = $value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$fields->saveField($attributes, $FieldAttrib, $labels);
|
||||||
|
|
||||||
G::LoadClass('xmlDb');
|
G::LoadClass('xmlDb');
|
||||||
$i = 0;
|
$i = 0;
|
||||||
@@ -233,4 +261,4 @@ if (($RBAC_Response=$RBAC->userCanAccess("PM_FACTORY"))!=1) return $RBAC_Respons
|
|||||||
$editor = new dynaformEditorAjax($_POST);
|
$editor = new dynaformEditorAjax($_POST);
|
||||||
$editor->set_javascript($A, $fieldName, $sCode);
|
$editor->set_javascript($A, $fieldName, $sCode);
|
||||||
}
|
}
|
||||||
?>
|
|
||||||
Reference in New Issue
Block a user