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
@@ -30,9 +31,9 @@
* @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) {
$this->root = $this->dom->firstChild;
} else
} 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!!');
}
}
function reload(){
$this->dom = NULL;
public function reload()
{
$this->dom = null;
$this->load();
}
@@ -75,7 +80,7 @@ class dynaFormHandler
* @access public
* @return void
*/
function __cloneEmpty()
public function __cloneEmpty()
{
$xPath = new DOMXPath($this->dom);
$nodeList = $xPath->query('/dynaForm/*');
@@ -92,11 +97,13 @@ class dynaFormHandler
* @param string $op
* @return void
*/
function toString($op='')
public function toString($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,7 +140,7 @@ 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'])) {
@@ -204,7 +212,7 @@ 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();
$element = $this->root->getElementsByTagName($replaced)->item(0);
@@ -227,7 +235,6 @@ class dynaFormHandler
if (!is_array($att_value)) {
$newnode->setAttribute($att_name, $att_value);
}
}
if (is_array($childs)) {
foreach ($element->childNodes as $pNode) {
@@ -241,10 +248,13 @@ class dynaFormHandler
$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) {
@@ -263,25 +273,27 @@ class dynaFormHandler
$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)) {
throw new Exception("The file {$this->xmlfile} is not writeable!");
@@ -299,7 +311,7 @@ class dynaFormHandler
* Function fixXmlFile
* @return void
*/
function fixXmlFile()
public function fixXmlFile()
{
$newxml = '';
$content = file($this->xmlfile);
@@ -317,22 +329,24 @@ class dynaFormHandler
* @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);
@@ -346,7 +360,7 @@ class dynaFormHandler
* @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");
@@ -361,7 +375,7 @@ class dynaFormHandler
* @param string $v
* @return void
*/
function remove($v)
public function remove($v)
{
if (!is_array($v)) {
$av[0] = $v;
@@ -391,7 +405,7 @@ class dynaFormHandler
* @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");
@@ -409,7 +423,7 @@ class dynaFormHandler
* @param string $selected_node
* @return void
*/
function moveUp($selected_node)
public function moveUp($selected_node)
{
/* DOMNode DOMNode::insertBefore ( DOMNode $newnode [, DOMNode $refnode ] )
This function inserts a new node right before the reference node. If you plan
@@ -442,7 +456,7 @@ class dynaFormHandler
* @param string $selected_node
* @return void
*/
function moveDown($selected_node)
public function moveDown($selected_node)
{
/* DOMNode DOMNode::insertBefore ( DOMNode $newnode [, DOMNode $refnode ] )
This function inserts a new node right before the reference node. If you plan
@@ -483,7 +497,7 @@ 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/*");
@@ -520,7 +534,7 @@ class dynaFormHandler
* @param array $aFilter
* @return array
*/
function getFieldNames( $aFilter = Array() )
public function getFieldNames($aFilter = Array())
{
$aList = $this->getFields($aFilter);
$aFieldNames = Array();
@@ -530,10 +544,9 @@ class dynaFormHandler
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) {
@@ -550,16 +563,17 @@ class dynaFormHandler
$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));
@@ -585,8 +599,8 @@ 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));
@@ -601,11 +615,12 @@ class dynaFormHandler
break;
}
}
} else
} else {
$xnode->appendChild($newNode);
}
}
function getArray($node, $attributes = null)
public function getArray($node, $attributes = null)
{
$array = false;
$array['__nodeName__'] = $node->nodeName;
@@ -615,9 +630,10 @@ class dynaFormHandler
if ($node->hasAttributes()) {
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,7 +25,6 @@
* Coral Gables, FL, 33134, USA, or email info@colosa.com.
*
*/
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,7 +54,7 @@ class DynaFormField extends DBTable
* @param string $objConnection
* @return void
*/
function SetTo ($objConnection)
public function SetTo($objConnection)
{
DBTable::SetTo($objConnection, 'dynaForm', array('XMLNODE_NAME'
));
@@ -64,7 +66,7 @@ class DynaFormField extends DBTable
* @param string $sUID
* @return void
*/
function Load ($sUID)
public function Load($sUID)
{
parent::Load($sUID);
if (is_array($this->Fields)) {
@@ -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,7 +98,7 @@ 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') {
@@ -124,9 +126,10 @@ class DynaFormField extends DBTable
*/
if ($this->is_new) {
foreach ($this->Fields as $key => $value) {
if ($value == "")
if ($value == "") {
unset($this->Fields[$key]);
}
}
} else {
$this->Fields['XMLNODE_NAME'] = $Fields['XMLNODE_NAME_OLD'];
}
@@ -176,7 +179,7 @@ class DynaFormField extends DBTable
}
}
function saveField ($Fields, $attributes = array(), $options = array())
public function saveField($Fields, $attributes = array(), $options = array())
{
$dynaform = new dynaFormHandler($this->getFileName());
if ($Fields['TYPE'] === 'javascript') {
@@ -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'] . '"');
return ($res->count() == 0);
}
}
?>

View File

@@ -1,4 +1,5 @@
<?php
/**
* class.dynaformEditor.php
*
@@ -23,7 +24,6 @@
* For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
* Coral Gables, FL, 33134, USA, or email info@colosa.com.
*/
/**
* Created on 21/12/2007
* Dynaform - Dynaform class
@@ -31,7 +31,6 @@
* @copyright 2007 COLOSA
* @author David Callizaya <davidsantos@colosa.com>
*/
G::LoadSystem("webResource");
G::LoadClass('toolBar');
G::LoadClass('dynaFormField');
@@ -39,19 +38,21 @@ require_once ('classes/model/Process.php');
require_once ('classes/model/Dynaform.php');
G::LoadClass('xmlDb');
G::LoadSystem('dynaformhandler');
/**
*
* @package workflow.engine.classes
*/
class dynaformEditor extends WebResource
{
private $isOldCopy = false;
var $file = '';
var $title = 'New Dynaform';
var $dyn_uid = '';
var $dyn_type = '';
var $home = '';
public $file = '';
public $title = 'New Dynaform';
public $dyn_uid = '';
public $dyn_type = '';
public $home = '';
/**
* Other Options for Editor:
* left: 'getAbsoluteLeft(document.getElementById("dynaformEditor[0]"))',
@@ -64,14 +65,12 @@ class dynaformEditor extends WebResource
* left: 'getAbsoluteLeft(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'
),'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
)
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'),
'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'
)
),'width' => 700,'height' => 600,'tabWidth' => 120,'modal' => true,'drag' => false,'resize' => false,'blinkToFront' => false
public $panelConf = array('style' => array('title' => array('textAlign' => 'center')),
'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
* @return void
*/
function dynaformEditor ($get)
public function dynaformEditor($get)
{
$this->panelConf = array_merge($this->panelConf, $this->defaultConfig['Editor']);
//'title' => G::LoadTranslation('ID_DYNAFORM_EDITOR').' - ['.$this->title.']',
@@ -92,7 +91,7 @@ class dynaformEditor extends WebResource
* @param string $filename
* @return void
*/
function _createDefaultXmlForm ($fileName)
public function _createDefaultXmlForm($fileName)
{
//Create the default Dynaform
$sampleForm = '<?xml version="1.0" encoding="UTF-8"?>' . "\n";
@@ -128,7 +127,7 @@ class dynaformEditor extends WebResource
*
* @return void
*/
function _render ()
public function _render()
{
global $G_PUBLISH;
$script = '';
@@ -206,6 +205,7 @@ class dynaformEditor extends WebResource
$G_PUBLISH->AddContent('blank');
$G_PUBLISH->AddContent('xmlform', 'xmlform', 'dynaforms/dynaforms_JSEditor', 'display:none', $JSEditor, '', '');
} catch (Exception $e) {
}
$G_PUBLISH->AddContent('xmlform', 'xmlform', 'dynaforms/dynaforms_Properties', 'display:none', $Properties, '', '');
//for showHide tab option @Neyek
@@ -239,7 +239,7 @@ class dynaformEditor extends WebResource
* @param string $file
* @return string
*/
function _getFilename ($file)
public function _getFilename($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
* @return void
*/
function _setUseTemporalCopy ($onOff)
public function _setUseTemporalCopy($onOff)
{
$file = self::_getFilename($this->file);
if ($onOff) {
$this->file = $file . '_tmp0';
self::_setTmpData( array ('useTmpCopy' => true
) );
if (! file_exists( PATH_DYNAFORM . $file . '.xml' ))
self::_setTmpData(array('useTmpCopy' => true ));
if (!file_exists(PATH_DYNAFORM . $file . '.xml')) {
$this->_createDefaultXmlForm(PATH_DYNAFORM . $file . '.xml');
}
//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');
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');
}
} else {
$this->file = $file;
self::_setTmpData(array());
@@ -276,7 +278,7 @@ class dynaformEditor extends WebResource
* @param $data
* @return void
*/
function _setTmpData ($data)
public function _setTmpData($data)
{
G::verifyPath(PATH_C . 'dynEditor/', true);
$fp = fopen(PATH_C . 'dynEditor/' . session_id() . '.php', 'w');
@@ -290,12 +292,13 @@ class dynaformEditor extends WebResource
* @param string $filename
* @return array
*/
function _getTmpData ()
public function _getTmpData()
{
$tmpData = array();
$file = PATH_C . 'dynEditor/' . session_id() . '.php';
if (file_exists( $file ))
if (file_exists($file)) {
eval(implode('', file($file)));
}
return $tmpData;
}
@@ -306,7 +309,7 @@ class dynaformEditor extends WebResource
* @param file $to
* @return void
*/
function _copyFile ($from, $to)
public function _copyFile($from, $to)
{
$copy = implode('', file($from));
$fcopy = fopen($to, "w");
@@ -325,7 +328,6 @@ interface iDynaformEditorAjax
*
* @package workflow.engine.classes
*/
class dynaformEditorAjax extends dynaformEditor implements iDynaformEditorAjax
{
@@ -335,7 +337,7 @@ class dynaformEditorAjax extends dynaformEditor implements iDynaformEditorAjax
* @param var $post
* @return void
*/
function dynaformEditorAjax ($post)
public function dynaformEditorAjax($post)
{
$this->_run($post);
}
@@ -346,7 +348,7 @@ class dynaformEditorAjax extends dynaformEditor implements iDynaformEditorAjax
* @param var $post
* @return void
*/
function _run ($post)
public function _run($post)
{
WebResource::WebResource($_SERVER['REQUEST_URI'], $post);
}
@@ -357,7 +359,7 @@ class dynaformEditorAjax extends dynaformEditor implements iDynaformEditorAjax
* @param object $A
* @return ob_get_clean
*/
function render_preview ($A)
public function render_preview($A)
{
ob_start();
$file = G::decrypt($A, URL_KEY);
@@ -375,9 +377,9 @@ class dynaformEditorAjax extends dynaformEditor implements iDynaformEditorAjax
$aFields = $aAux;
}
if (is_array($aFields)) {
foreach ($aFields as $key => $val)
$aFields[$key] = array (1 => "",2 => "",3 => "",4 => "",5 => ""
);
foreach ($aFields as $key => $val) {
$aFields[$key] = array(1 => "", 2 => "", 3 => "", 4 => "", 5 => "");
}
}
break;
default:
@@ -397,7 +399,7 @@ class dynaformEditorAjax extends dynaformEditor implements iDynaformEditorAjax
* @param object $A
* @return array
*/
function render_htmledit ($A)
public function render_htmledit($A)
{
$script = '';
$file = G::decrypt($A, URL_KEY);
@@ -429,7 +431,7 @@ class dynaformEditorAjax extends dynaformEditor implements iDynaformEditorAjax
* @param object $A
* @return code html
*/
function get_htmlcode ($A)
public function get_htmlcode($A)
{
try {
$script = null;
@@ -459,11 +461,12 @@ class dynaformEditorAjax extends dynaformEditor implements iDynaformEditorAjax
* Already checked the temporary file dynaforms editor.
*/
$tmp = self::_getTmpData();
if (! isset( $tmp['OLD_FIELDS'] ))
if (!isset($tmp['OLD_FIELDS'])) {
$tmp['OLD_FIELDS'] = array(); //var_dump($html);die;
}
$aAux = explode('</form>', $html);
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)
switch (strtolower($field->type)) {
case 'private':
@@ -497,7 +500,7 @@ class dynaformEditorAjax extends dynaformEditor implements iDynaformEditorAjax
* @param object $A
* @return code html
*/
function restore_html ($A)
public function restore_html($A)
{
$script = null;
$fileTmp = G::decrypt($A, URL_KEY);
@@ -527,7 +530,7 @@ class dynaformEditorAjax extends dynaformEditor implements iDynaformEditorAjax
* @param object $A
* @return array
*/
function set_htmlcode ($A, $htmlcode)
public function set_htmlcode($A, $htmlcode)
{
try {
$file = G::decrypt($A, URL_KEY);
@@ -548,7 +551,7 @@ class dynaformEditorAjax extends dynaformEditor implements iDynaformEditorAjax
* @param object $A
* @return array
*/
function get_xmlcode ($A)
public function get_xmlcode($A)
{
try {
$file = G::decrypt($A, URL_KEY);
@@ -568,7 +571,7 @@ class dynaformEditorAjax extends dynaformEditor implements iDynaformEditorAjax
* @param array $xmlcode
* @return string
*/
function set_xmlcode ($A, $xmlcode)
public function set_xmlcode($A, $xmlcode)
{
$xmlcode = urldecode($xmlcode);
$file = G::decrypt($A, URL_KEY);
@@ -586,7 +589,7 @@ class dynaformEditorAjax extends dynaformEditor implements iDynaformEditorAjax
* @param string $fieldName
* @return array
*/
function get_javascripts ($A, $fieldName)
public function get_javascripts($A, $fieldName)
{
try {
$file = G::decrypt($A, URL_KEY);
@@ -597,10 +600,11 @@ class dynaformEditorAjax extends dynaformEditor implements iDynaformEditorAjax
if (strcasecmp($value->type, "javascript") == 0) {
$aOptions[] = array('key' => $name, 'value' => $name
);
if ($name == $fieldName)
if ($name == $fieldName) {
$sCode = $value->code;
}
}
}
return array('aOptions' => $aOptions, 'sCode' => $sCode
);
} catch (Exception $e) {
@@ -616,7 +620,7 @@ class dynaformEditorAjax extends dynaformEditor implements iDynaformEditorAjax
* @param string $sCode
* @return array
*/
function set_javascript ($A, $fieldName, $sCode, $meta = '')
public function set_javascript($A, $fieldName, $sCode, $meta = '')
{
if ($fieldName == '___pm_boot_strap___') {
return 0;
@@ -650,7 +654,7 @@ class dynaformEditorAjax extends dynaformEditor implements iDynaformEditorAjax
* @param string $DYN_UID
* @return array
*/
function get_properties ($A, $DYN_UID)
public function get_properties($A, $DYN_UID)
{
$file = G::decrypt($A, URL_KEY);
$tmp = self::_getTmpData();
@@ -667,8 +671,9 @@ class dynaformEditorAjax extends dynaformEditor implements iDynaformEditorAjax
} else {
$form = new Form($file, PATH_DYNAFORM, SYS_LANG, true);
$Properties = $tmp['Properties'];
if (! isset( $Properties['ENABLETEMPLATE'] ))
if (!isset($Properties['ENABLETEMPLATE'])) {
$Properties['ENABLETEMPLATE'] = "0";
}
$Properties['WIDTH'] = $form->width;
$Properties['MODE'] = $form->mode;
}
@@ -683,7 +688,7 @@ class dynaformEditorAjax extends dynaformEditor implements iDynaformEditorAjax
* @param array $getFields
* @return array
*/
function set_properties ($A, $DYN_UID, $getFields)
public function set_properties($A, $DYN_UID, $getFields)
{
try {
$post = array();
@@ -745,7 +750,7 @@ class dynaformEditorAjax extends dynaformEditor implements iDynaformEditorAjax
* @param object $A
* @return string
*/
function get_enabletemplate ($A)
public function get_enabletemplate($A)
{
$file = G::decrypt($A, URL_KEY);
$form = new Form($file, PATH_DYNAFORM, SYS_LANG, true);
@@ -759,7 +764,7 @@ class dynaformEditorAjax extends dynaformEditor implements iDynaformEditorAjax
* @param string $value
* @return string
*/
function set_enabletemplate ($A, $value)
public function set_enabletemplate($A, $value)
{
$file = G::decrypt($A, URL_KEY);
$value = $value == "1" ? "1" : "0";
@@ -780,13 +785,14 @@ class dynaformEditorAjax extends dynaformEditor implements iDynaformEditorAjax
* @param string $DYN_UID
* @return array
*/
function save ($A, $DYN_UID)
public function save($A, $DYN_UID)
{
try {
$answer = 0;
$file = G::decrypt($A, URL_KEY);
$tmp = self::_getTmpData();
if (isset( $tmp['useTmpCopy'] )) { /*Save Register*/
if (isset($tmp['useTmpCopy'])) {
/* Save Register */
$dynaform = new dynaform();
$dynaform->update($tmp['Properties']);
/* Save file */
@@ -828,7 +834,7 @@ class dynaformEditorAjax extends dynaformEditor implements iDynaformEditorAjax
* @param object $A
* @return array
*/
function close ($A)
public function close($A)
{
try {
/*
@@ -849,10 +855,11 @@ class dynaformEditorAjax extends dynaformEditor implements iDynaformEditorAjax
if (file_exists($xmlFile)) {
unlink($xmlFile);
}
if (file_exists( $htmlFile ))
if (file_exists($htmlFile)) {
unlink($htmlFile);
}
}
}
return 0;
} catch (Exception $e) {
return (array) $e;
@@ -866,7 +873,7 @@ class dynaformEditorAjax extends dynaformEditor implements iDynaformEditorAjax
* @param string $DYN_UID
* @return array
*/
function is_modified ($A, $DYN_UID)
public function is_modified($A, $DYN_UID)
{
$file = G::decrypt($A, URL_KEY);
try {
@@ -895,10 +902,11 @@ class dynaformEditorAjax extends dynaformEditor implements iDynaformEditorAjax
if (!isset($P['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['ENABLETEMPLATE']!=$P['ENABLETEMPLATE']) ||
($sp['MODE']!=$P['MODE'])*/;
($sp['MODE']!=$P['MODE']) */
/* Compare copies */
$fileOrigen = dynaformEditor::_getFilename($file);
$copy = implode('', file(PATH_DYNAFORM . $file . '.xml'));
@@ -915,4 +923,4 @@ class dynaformEditorAjax extends dynaformEditor implements iDynaformEditorAjax
}
}
}
?>

View File

@@ -1,4 +1,5 @@
<?php
//print_r( $_POST); die;
/**
* fields_Save.php
@@ -25,21 +26,24 @@
*/
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::LoadClass('dynaFormField');
$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 ($_POST['form']['PME_REQUIRED'] == '') {
$_POST['form']['PME_REQUIRED'] = 0;
}
}
else {
} else {
$_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'] == '') {
$_POST['form']['PME_READONLY'] = 0;
}
}
else {
} else {
$_POST['form']['PME_READONLY'] = 0;
}
@@ -56,8 +59,7 @@ if (($RBAC_Response=$RBAC->userCanAccess("PM_FACTORY"))!=1) return $RBAC_Respons
if ($_POST['form']['PME_SAVELABEL'] == '') {
$_POST['form']['PME_SAVELABEL'] = 0;
}
}
else {
} else {
$_POST['form']['PME_SAVELABEL'] = 0;
}
$A = $_POST['form']['PME_A'];
@@ -90,9 +92,13 @@ if (($RBAC_Response=$RBAC->userCanAccess("PM_FACTORY"))!=1) return $RBAC_Respons
$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'];
if ($isGrid) {
$xmlGrid = $_POST['form']['PME_XMLGRID'];
}
//$form->validatePost();
if ($isGrid) $_POST['form']['PME_XMLGRID']=$xmlGrid;
if ($isGrid) {
$_POST['form']['PME_XMLGRID'] = $xmlGrid;
}
if ($type === 'checkbox') {
// added by Gustavo Cruz
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) {
if (substr($key,0,4)==='PME_')
if (substr($key, 0, 4) === 'PME_') {
$res[substr($key, 4)] = $value;
else
} else {
$res[$key] = $value;
}
}
$_POST['form'] = $res;
$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);
if ($_POST['form']['XMLNODE_NAME']==='') return;
if ($_POST['form']['XMLNODE_NAME'] === '') {
return;
}
$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");
}
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'] );
if (isset($attributes['LABEL'])) {
$labels = array(SYS_LANG => $attributes['LABEL']);
}
unset($attributes['A']);
unset($attributes['ACCEPT']);
unset($attributes['LABEL']);
unset($attributes['PRO_UID']);
$options = NULL;
$options = null;
foreach ($attributes as $key => $value) {
if ($key === 'OPTIONS') {
if (is_array($value)) {
@@ -170,10 +182,11 @@ if (($RBAC_Response=$RBAC->userCanAccess("PM_FACTORY"))!=1) return $RBAC_Respons
foreach ($value as $row) {
foreach ($langs as $lang) {
$LANG = strtoupper($lang);
if (isset($row['LABEL']))
if (isset($row['LABEL'])) {
$options[$lang][$row['NAME']] = $row['LABEL'];
}
}
}
/* $first = reset($value);
foreach( $first as $optKey => $optValue ) {
if (substr($optKey,0,6)==='LABEL_') {
@@ -248,4 +261,4 @@ if (($RBAC_Response=$RBAC->userCanAccess("PM_FACTORY"))!=1) return $RBAC_Respons
$editor = new dynaformEditorAjax($_POST);
$editor->set_javascript($A, $fieldName, $sCode);
}
?>