diff --git a/gulliver/js/form/core/form.js b/gulliver/js/form/core/form.js index 5ab003a95..2648f4d54 100755 --- a/gulliver/js/form/core/form.js +++ b/gulliver/js/form/core/form.js @@ -284,7 +284,7 @@ function G_Field ( form, element, name ) return me.element.value; }; this.toJSONString=function() { - return '{'+me.name+':'+me.element.value.toJSONString()+'}'; + return '{"'+me.name+'":'+me.element.value.toJSONString()+'}'; }; this.highLight=function(){ try{ diff --git a/gulliver/js/maborak/core/maborak.js b/gulliver/js/maborak/core/maborak.js index c8d7827ab..1bc94bef2 100644 --- a/gulliver/js/maborak/core/maborak.js +++ b/gulliver/js/maborak/core/maborak.js @@ -960,7 +960,7 @@ var callServer;callServer=new leimnud.module.rpc.xmlhttp({url:me.form.ajaxServer else{for(var i=0;i1)dd.remove(0);}else{for(var key in dd.options){dd.options[key]=null;}} for(var o=0;o. - * - * For more information, contact Colosa Inc, 2566 Le Jeune Rd., - * Coral Gables, FL, 33134, USA, or email info@colosa.com. - * - */ - - /*NEXT LINE: Runs any configuration defined to be executed before dependent fields recalc*/ - if ( isset($_SESSION['CURRENT_PAGE_INITILIZATION']) ) - eval($_SESSION['CURRENT_PAGE_INITILIZATION']); - - - //G::LoadThirdParty('pear/json','class.json'); - //$json=new Services_JSON(); - if (!defined('XMLFORM_AJAX_PATH')) define('XMLFORM_AJAX_PATH',PATH_XMLFORM); - - $_DBArray = array(); - if (isset($_SESSION['_DBArray'])) { - $_DBArray = $_SESSION['_DBArray']; - } - - $xmlFile = G::getUIDName(urlDecode($_POST['form'])); - $sPath = XMLFORM_AJAX_PATH; - - //if the xmlform file doesn't exist, then try with the plugins folders - if ( !is_file ( XMLFORM_AJAX_PATH . $xmlFile ) ) { - $aux = explode ( PATH_SEP, $xmlFile ); - //check if G_PLUGIN_CLASS is defined, because publisher can be called without an environment - if ( count($aux) == 2 && defined ( 'G_PLUGIN_CLASS' ) ) { - $oPluginRegistry =& PMPluginRegistry::getSingleton(); - if ( $oPluginRegistry->isRegisteredFolder($aux[0]) ) { - $sPath = PATH_PLUGINS; - } - } - } - $G_FORM=new form( $xmlFile , $sPath ); - $G_FORM->id=urlDecode($_POST['form']); - $G_FORM->values=isset($_SESSION[$G_FORM->id]) ? $_SESSION[$G_FORM->id] : array(); - $newValues=(Bootstrap::json_decode(urlDecode(stripslashes($_POST['fields'])))); - if (isset($_POST['grid'])) { - $_POST['row'] = (int)$_POST['row']; - $aAux = array(); - foreach ($newValues as $sKey => $newValue) { - $newValue = (array)$newValue; - $aKeys = array_keys($newValue); - $aValues = array(); - for ($i = 1; $i <= ($_POST['row'] - 1); $i++) { - $aValues[$i] = array($aKeys[0] => ''); - } - $aValues[$_POST['row']] = array($aKeys[0] => $newValue[$aKeys[0]]); - $newValues[$sKey]->$_POST['grid'] = $aValues; - unset($newValues[$sKey]->$aKeys[0]); - } - } - - //Next Lines re-build newValues array to send multiple dependent fields merged by row into a grid. - if (sizeof($newValues)>1 && isset($_POST['grid'])){ - $fieldBase = array(); - foreach ($newValues as $key => $values){ - for ($r2=1; $r2 <= $_POST['row']; $r2++){ - foreach ($values as $class => $value){ - if ($class == $_POST['grid']){ - $value = (array) $value; - $arrayK = $value[$r2]; - foreach ($arrayK as $key2 => $val) { - $fieldBase[$r2][$key2] = is_array($val)? $val[$key2] : $val; - } - } - } - } - } - $newValues = array(); +. + * + * For more information, contact Colosa Inc, 2566 Le Jeune Rd., + * Coral Gables, FL, 33134, USA, or email info@colosa.com. + */ + +/*NEXT LINE: Runs any configuration defined to be executed before dependent fields recalc*/ +if (isset( $_SESSION['CURRENT_PAGE_INITILIZATION'] )) + eval( $_SESSION['CURRENT_PAGE_INITILIZATION'] ); + + // G::LoadThirdParty('pear/json','class.json'); + // $json=new Services_JSON(); +if (! defined( 'XMLFORM_AJAX_PATH' )) + define( 'XMLFORM_AJAX_PATH', PATH_XMLFORM ); + +$_DBArray = array (); +if (isset( $_SESSION['_DBArray'] )) { + $_DBArray = $_SESSION['_DBArray']; +} + +$xmlFile = G::getUIDName( urlDecode( $_POST['form'] ) ); +$sPath = XMLFORM_AJAX_PATH; + +//if the xmlform file doesn't exist, then try with the plugins folders +if (! is_file( XMLFORM_AJAX_PATH . $xmlFile )) { + $aux = explode( PATH_SEP, $xmlFile ); + //check if G_PLUGIN_CLASS is defined, because publisher can be called without an environment + if (count( $aux ) == 2 && defined( 'G_PLUGIN_CLASS' )) { + $oPluginRegistry = & PMPluginRegistry::getSingleton(); + if ($oPluginRegistry->isRegisteredFolder( $aux[0] )) { + $sPath = PATH_PLUGINS; + } + } +} +$G_FORM = new form( $xmlFile, $sPath ); +$G_FORM->id = urlDecode( $_POST['form'] ); +$G_FORM->values = isset( $_SESSION[$G_FORM->id] ) ? $_SESSION[$G_FORM->id] : array (); +$newValues = (Bootstrap::json_decode( urlDecode( stripslashes( $_POST['fields'] ) ) )); +if (isset( $_POST['grid'] )) { + $_POST['row'] = (int) $_POST['row']; + $aAux = array (); + foreach ($newValues as $sKey => $newValue) { + $newValue = (array) $newValue; + $aKeys = array_keys( $newValue ); + $aValues = array (); + for ($i = 1; $i <= ($_POST['row'] - 1); $i ++) { + $aValues[$i] = array ($aKeys[0] => '' + ); + } + $aValues[$_POST['row']] = array ($aKeys[0] => $newValue[$aKeys[0]] + ); + $newValues[$sKey]->$_POST['grid'] = $aValues; + unset( $newValues[$sKey]->$aKeys[0] ); + } +} + +//Next Lines re-build newValues array to send multiple dependent fields merged by row into a grid. +if (sizeof( $newValues ) > 1 && isset( $_POST['grid'] )) { + $fieldBase = array (); + foreach ($newValues as $key => $values) { + for ($r2 = 1; $r2 <= $_POST['row']; $r2 ++) { + foreach ($values as $class => $value) { + if ($class == $_POST['grid']) { + $value = (array) $value; + $arrayK = $value[$r2]; + foreach ($arrayK as $key2 => $val) { + $fieldBase[$r2][$key2] = is_array( $val ) ? $val[$key2] : $val; + } + } + } + } + } + $newValues = array (); //$fieldBase = (array) $fieldBase; - $newValues[0]->$_POST['grid'] = $fieldBase; - } - - //Resolve dependencies - //Returns an array ($dependentFields) with the names of the fields - //that depends of fields passed through AJAX ($_GET/$_POST) - $dependentFields=array(); $aux=array(); - for($r=0;$rsetValues($newValues[$r]); - //Search dependent fields - foreach($newValues[$r] as $k => $v) { - if (!is_array($v)) { - $myDependentFields = subDependencies( $k , $G_FORM , $aux ); - $_SESSION[$G_FORM->id][$k] = $v; - } - else { - foreach($v[$_POST['row']] as $k1 => $v1) { - $myDependentFields = subDependencies( $k1 , $G_FORM , $aux, $_POST['grid'] ); - $_SESSION[$G_FORM->id][$_POST['grid']][$_POST['row']][$k1] = $v1; - } - } - $dependentFields=array_merge($dependentFields, $myDependentFields); - } - } - if (isset($_POST['grid'])) $G_FORM->values=isset($_SESSION[$G_FORM->id]) ? $_SESSION[$G_FORM->id] : array(); - - $dependentFields=array_unique($dependentFields); - - //Parse and update the new content - $template = PATH_CORE . 'templates/xmlform.html'; - $newContent=$G_FORM->getFields($template, (isset($_POST['row']) ? $_POST['row'] : -1)); - //Returns the dependentFields's content - $sendContent=array(); - $r=0; - - foreach($dependentFields as $d) { - $sendContent[$r]->name=$d; - $sendContent[$r]->content=NULL; - if (!isset($_POST['grid'])) { - if (isset($G_FORM->fields[$d])) { - foreach($G_FORM->fields[$d] as $attribute => $value) { - switch($attribute) { - case 'type': - $sendContent[$r]->content->{$attribute}=$value;break; - case 'options': - $sendContent[$r]->content->{$attribute}=toJSArray($value, $sendContent[$r]->content->type); break; - } - } - $sendContent[$r]->value=isset($G_FORM->values[$d]) ? $G_FORM->values[$d] : ''; - } - } - else { - foreach($G_FORM->fields[$_POST['grid']]->fields[$d] as $attribute => $value) { - switch($attribute) { - case 'type': - $sendContent[$r]->content->{$attribute}=$value; break; - case 'options': - if ($sendContent[$r]->content->type != 'text') { - $sendContent[$r]->content->{$attribute}=toJSArray($value); - } - else { - $sendContent[$r]->content->{$attribute}=toJSArray((isset($value[$_POST['row']]) ? array($value[$_POST['row']]) : array())); - } - break; - } - } - $sendContent[$r]->value=isset($G_FORM->values[$_POST['grid']][$_POST['row']][$d]) ? $G_FORM->values[$_POST['grid']][$_POST['row']][$d] : ''; - } - $r++; - } - echo(Bootstrap::json_encode($sendContent)); - - function toJSArray($array, $type= '') - { - $result=array(); - foreach($array as $k => $v){ - $o=NULL; - $o->key=$k; - // TODO: review the condition to make the differentiation to dependent dropdowns in a grid function. - // this way of validation is if you have a dependent field in text fields - $o->value= ($type =='text' || $type =='textarea')? $k:$v; - $result[]=$o; - } - return $result; - } - - function subDependencies( $k , &$G_FORM , &$aux, $grid = '') { - if (array_search( $k, $aux )!==FALSE) return array(); - if ($grid == '') { - if (!array_key_exists( $k , $G_FORM->fields )) return array(); - if (!isset($G_FORM->fields[$k]->dependentFields)) return array(); - $aux[] = $k; - if (strpos($G_FORM->fields[$k]->dependentFields, ',') !== false) { - $myDependentFields = explode( ',', $G_FORM->fields[$k]->dependentFields); - } - else { - $myDependentFields = explode( '|', $G_FORM->fields[$k]->dependentFields); - } - for( $r=0 ; $r < sizeof($myDependentFields) ; $r++ ) { - if ($myDependentFields[$r]=="") unset($myDependentFields[$r]); - } - // $mD = $myDependentFields; - // foreach( $mD as $ki) { - // $myDependentFields = array_merge( $myDependentFields , subDependencies( $ki , $G_FORM , $aux ) ); - // } - } - else { - if (!array_key_exists( $k , $G_FORM->fields[$grid]->fields )) return array(); - if (!isset($G_FORM->fields[$grid]->fields[$k]->dependentFields)) return array(); - $aux[] = $k; - if (strpos($G_FORM->fields[$grid]->fields[$k]->dependentFields, ',') !== false) { - $myDependentFields = explode( ',', $G_FORM->fields[$grid]->fields[$k]->dependentFields); - } - else { - $myDependentFields = explode( '|', $G_FORM->fields[$grid]->fields[$k]->dependentFields); - } - for( $r=0 ; $r < sizeof($myDependentFields) ; $r++ ) { - if ($myDependentFields[$r]=="") unset($myDependentFields[$r]); - } -// $mD = $myDependentFields; -// foreach( $mD as $ki) { -// $myDependentFields = array_merge( $myDependentFields , subDependencies( $ki , $G_FORM , $aux, $grid) ); -// } - } - return $myDependentFields; - } -?> + $newValues[0]->$_POST['grid'] = $fieldBase; +} + +//Resolve dependencies +//Returns an array ($dependentFields) with the names of the fields +//that depends of fields passed through AJAX ($_GET/$_POST) +$dependentFields = array (); +$aux = array (); +for ($r = 0; $r < sizeof( $newValues ); $r ++) { + $newValues[$r] = (array) $newValues[$r]; + $G_FORM->setValues( $newValues[$r] ); + //Search dependent fields + foreach ($newValues[$r] as $k => $v) { + if (! is_array( $v )) { + $myDependentFields = subDependencies( $k, $G_FORM, $aux ); + $_SESSION[$G_FORM->id][$k] = $v; + } else { + foreach ($v[$_POST['row']] as $k1 => $v1) { + $myDependentFields = subDependencies( $k1, $G_FORM, $aux, $_POST['grid'] ); + $_SESSION[$G_FORM->id][$_POST['grid']][$_POST['row']][$k1] = $v1; + } + } + $dependentFields = array_merge( $dependentFields, $myDependentFields ); + } +} +if (isset( $_POST['grid'] )) + $G_FORM->values = isset( $_SESSION[$G_FORM->id] ) ? $_SESSION[$G_FORM->id] : array (); + +$dependentFields = array_unique( $dependentFields ); + +//Parse and update the new content +$template = PATH_CORE . 'templates/xmlform.html'; +$newContent = $G_FORM->getFields( $template, (isset( $_POST['row'] ) ? $_POST['row'] : - 1) ); +//Returns the dependentFields's content +$sendContent = array (); +$r = 0; + +foreach ($dependentFields as $d) { + $sendContent[$r]->name = $d; + $sendContent[$r]->content = NULL; + if (! isset( $_POST['grid'] )) { + if (isset( $G_FORM->fields[$d] )) { + foreach ($G_FORM->fields[$d] as $attribute => $value) { + switch ($attribute) { + case 'type': + $sendContent[$r]->content->{$attribute} = $value; + break; + case 'options': + $sendContent[$r]->content->{$attribute} = toJSArray( $value, $sendContent[$r]->content->type ); + break; + } + } + $sendContent[$r]->value = isset( $G_FORM->values[$d] ) ? $G_FORM->values[$d] : ''; + } + } else { + foreach ($G_FORM->fields[$_POST['grid']]->fields[$d] as $attribute => $value) { + switch ($attribute) { + case 'type': + $sendContent[$r]->content->{$attribute} = $value; + break; + case 'options': + if ($sendContent[$r]->content->type != 'text') { + $sendContent[$r]->content->{$attribute} = toJSArray( $value ); + } else { + $sendContent[$r]->content->{$attribute} = toJSArray( (isset( $value[$_POST['row']] ) ? array ($value[$_POST['row']] + ) : array ()) ); + } + break; + } + } + $sendContent[$r]->value = isset( $G_FORM->values[$_POST['grid']][$_POST['row']][$d] ) ? $G_FORM->values[$_POST['grid']][$_POST['row']][$d] : ''; + } + $r ++; +} +echo (Bootstrap::json_encode( $sendContent )); + +function toJSArray ($array, $type = '') +{ + $result = array (); + foreach ($array as $k => $v) { + $o = NULL; + $o->key = $k; + // TODO: review the condition to make the differentiation to dependent dropdowns in a grid function. + // this way of validation is if you have a dependent field in text fields + $o->value = ($type == 'text' || $type == 'textarea') ? $k : $v; + $result[] = $o; + } + return $result; +} + +function subDependencies ($k, &$G_FORM, &$aux, $grid = '') +{ + if (array_search( $k, $aux ) !== FALSE) + return array (); + if ($grid == '') { + if (! array_key_exists( $k, $G_FORM->fields )) + return array (); + if (! isset( $G_FORM->fields[$k]->dependentFields )) + return array (); + $aux[] = $k; + if (strpos( $G_FORM->fields[$k]->dependentFields, ',' ) !== false) { + $myDependentFields = explode( ',', $G_FORM->fields[$k]->dependentFields ); + } else { + $myDependentFields = explode( '|', $G_FORM->fields[$k]->dependentFields ); + } + for ($r = 0; $r < sizeof( $myDependentFields ); $r ++) { + if ($myDependentFields[$r] == "") + unset( $myDependentFields[$r] ); + } + // $mD = $myDependentFields; + // foreach( $mD as $ki) { + // $myDependentFields = array_merge( $myDependentFields , subDependencies( $ki , $G_FORM , $aux ) ); + // } + } else { + if (! array_key_exists( $k, $G_FORM->fields[$grid]->fields )) + return array (); + if (! isset( $G_FORM->fields[$grid]->fields[$k]->dependentFields )) + return array (); + $aux[] = $k; + if (strpos( $G_FORM->fields[$grid]->fields[$k]->dependentFields, ',' ) !== false) { + $myDependentFields = explode( ',', $G_FORM->fields[$grid]->fields[$k]->dependentFields ); + } else { + $myDependentFields = explode( '|', $G_FORM->fields[$grid]->fields[$k]->dependentFields ); + } + for ($r = 0; $r < sizeof( $myDependentFields ); $r ++) { + if ($myDependentFields[$r] == "") + unset( $myDependentFields[$r] ); + } + // $mD = $myDependentFields; + // foreach( $mD as $ki) { + // $myDependentFields = array_merge( $myDependentFields , subDependencies( $ki , $G_FORM , $aux, $grid) ); + // } + } + return $myDependentFields; +} diff --git a/gulliver/system/class.webResource.php b/gulliver/system/class.webResource.php index a64d3596d..021d00ba9 100755 --- a/gulliver/system/class.webResource.php +++ b/gulliver/system/class.webResource.php @@ -109,7 +109,7 @@ class WebResource } /* end class WebResource */ -if (! function_exists( 'json_encode' )) { +/*if (! function_exists( 'json_encode' )) { G::LoadThirdParty( 'pear/json', 'class.json' ); function json_encode (&$value) @@ -127,5 +127,5 @@ if (! function_exists( 'json_decode' )) { $json = new Services_JSON(); return $json->decode( $value ); } -} +}*/ diff --git a/workflow/engine/classes/model/StepSupervisorPeer.php b/workflow/engine/classes/model/StepSupervisorPeer.php index 6e92b7a78..02bb99925 100755 --- a/workflow/engine/classes/model/StepSupervisorPeer.php +++ b/workflow/engine/classes/model/StepSupervisorPeer.php @@ -5,10 +5,10 @@ */ // include base peer class - require_once 'classes/model/om/BaseStepSupervisorPeer.php'; + //require_once 'classes/model/om/BaseStepSupervisorPeer.php'; // include object class - include_once 'classes/model/StepSupervisor.php'; + //include_once 'classes/model/StepSupervisor.php'; /** diff --git a/workflow/public_html/sysGeneric.php b/workflow/public_html/sysGeneric.php index f7a9d13da..be9967c27 100755 --- a/workflow/public_html/sysGeneric.php +++ b/workflow/public_html/sysGeneric.php @@ -581,6 +581,9 @@ Bootstrap::registerClass('StepPeer', PATH_HOME . "engine/classes/mode Bootstrap::registerClass('BaseStepSupervisor', PATH_HOME . "engine/classes/model/om/BaseStepSupervisor.php"); Bootstrap::registerClass('StepSupervisor', PATH_HOME . "engine/classes/model/StepSupervisor.php"); +Bootstrap::registerClass('BaseStepSupervisorPeer',PATH_HOME . "engine/classes/model/om/BaseStepSupervisorPeer.php"); +Bootstrap::registerClass('StepSupervisorPeer', PATH_HOME . "engine/classes/model/StepSupervisorPeer.php"); + Bootstrap::registerClass('BaseStepTrigger', PATH_HOME . "engine/classes/model/om/BaseStepTrigger.php"); Bootstrap::registerClass('StepTrigger', PATH_HOME . "engine/classes/model/StepTrigger.php"); Bootstrap::registerClass('StepTriggerPeer', PATH_HOME . "engine/classes/model/StepTriggerPeer.php");