CODE STYLE class.pmScript.php

This commit is contained in:
Fernando Ontiveros
2012-10-09 12:59:01 -04:00
parent c0b6951bf1
commit edf40d2490

View File

@@ -2,6 +2,7 @@
/** /**
* class.pmScript.php * class.pmScript.php
*
* @package workflow.engine.ProcessMaker * @package workflow.engine.ProcessMaker
* *
* ProcessMaker Open Source Edition * ProcessMaker Open Source Edition
@@ -32,8 +33,10 @@
// License: LGPL, see LICENSE // License: LGPL, see LICENSE
//////////////////////////////////////////////////// ////////////////////////////////////////////////////
/** /**
* PMScript - PMScript class * PMScript - PMScript class
*
* @author Julio Cesar Laura Avenda<64>o <juliocesar@colosa.com> * @author Julio Cesar Laura Avenda<64>o <juliocesar@colosa.com>
* last modify 2008.08.13 by Erik Amaru Ortiz <erik@colosa.com> * last modify 2008.08.13 by Erik Amaru Ortiz <erik@colosa.com>
* last modify comment was added and adapted the catch errors * last modify comment was added and adapted the catch errors
@@ -84,6 +87,7 @@ if (file_exists($dir)) {
/** /**
* PMScript - PMScript class * PMScript - PMScript class
*
* @copyright 2007 COLOSA * @copyright 2007 COLOSA
* @package workflow.engine.ProcessMaker * @package workflow.engine.ProcessMaker
*/ */
@@ -117,6 +121,7 @@ class PMScript
/** /**
* Constructor of the class PMScript * Constructor of the class PMScript
*
* @return void * @return void
*/ */
public function PMScript () public function PMScript ()
@@ -126,6 +131,7 @@ class PMScript
/** /**
* Set the fields to use * Set the fields to use
*
* @param array $aFields * @param array $aFields
* @return void * @return void
*/ */
@@ -139,6 +145,7 @@ class PMScript
/** /**
* Set the current script * Set the current script
*
* @param string $sScript * @param string $sScript
* @return void * @return void
*/ */
@@ -149,6 +156,7 @@ class PMScript
/** /**
* Verify the syntax * Verify the syntax
*
* @param string $sScript * @param string $sScript
* @return boolean * @return boolean
*/ */
@@ -169,6 +177,7 @@ class PMScript
/** /**
* Execute the current script * Execute the current script
*
* @return void * @return void
*/ */
public function execute () public function execute ()
@@ -176,9 +185,7 @@ class PMScript
$sScript = ""; $sScript = "";
$iAux = 0; $iAux = 0;
$bEqual = false; $bEqual = false;
$iOcurrences = preg_match_all( '/\@(?:([\@\%\#\?\$\=])([a-zA-Z\_]\w*)|([a-zA-Z\_][\w\-\>\:]*)\(((?:[^\\\\\)]' $iOcurrences = preg_match_all( '/\@(?:([\@\%\#\?\$\=])([a-zA-Z\_]\w*)|([a-zA-Z\_][\w\-\>\:]*)\(((?:[^\\\\\)]' . '*(?:[\\\\][\w\W])?)*)\))((?:\s*\[[\'"]?\w+[\'"]?\])+)?/', $this->sScript, $aMatch, PREG_PATTERN_ORDER | PREG_OFFSET_CAPTURE );
. '*(?:[\\\\][\w\W])?)*)\))((?:\s*\[[\'"]?\w+[\'"]?\])+)?/',
$this->sScript, $aMatch, PREG_PATTERN_ORDER | PREG_OFFSET_CAPTURE);
if ($iOcurrences) { if ($iOcurrences) {
for ($i = 0; $i < $iOcurrences; $i ++) { for ($i = 0; $i < $iOcurrences; $i ++) {
$sAux = substr( $this->sScript, $iAux, $aMatch[0][$i][1] - $iAux ); $sAux = substr( $this->sScript, $iAux, $aMatch[0][$i][1] - $iAux );
@@ -198,15 +205,9 @@ class PMScript
} }
if ($bEqual) { if ($bEqual) {
if (! isset( $aMatch[5][$i][0] )) { if (! isset( $aMatch[5][$i][0] )) {
eval("if (!isset(\$this->aFields['" . $aMatch[2][$i][0] . "'])) { \$this->aFields['" eval( "if (!isset(\$this->aFields['" . $aMatch[2][$i][0] . "'])) { \$this->aFields['" . $aMatch[2][$i][0] . "'] = null; }" );
. $aMatch[2][$i][0] . "'] = null; }");
} else { } else {
eval( "if (!isset(\$this->aFields" eval( "if (!isset(\$this->aFields" . (isset( $aMatch[2][$i][0] ) ? "['" . $aMatch[2][$i][0] . "']" : '') . $aMatch[5][$i][0] . ")) { \$this->aFields" . (isset( $aMatch[2][$i][0] ) ? "['" . $aMatch[2][$i][0] . "']" : '') . $aMatch[5][$i][0] . " = null; }" );
. (isset($aMatch[2][$i][0])
? "['" . $aMatch[2][$i][0] . "']"
: '') . $aMatch[5][$i][0] . ")) { \$this->aFields"
. (isset($aMatch[2][$i][0]) ? "['" . $aMatch[2][$i][0]
. "']" : '') . $aMatch[5][$i][0] . " = null; }");
} }
} }
$sScript .= $sAux; $sScript .= $sAux;
@@ -217,19 +218,13 @@ class PMScript
if (! isset( $aMatch[5][$i][0] )) { if (! isset( $aMatch[5][$i][0] )) {
$sScript .= "pmToString(\$this->aFields['" . $aMatch[2][$i][0] . "'])"; $sScript .= "pmToString(\$this->aFields['" . $aMatch[2][$i][0] . "'])";
} else { } else {
$sScript .= "pmToString(\$this->aFields" $sScript .= "pmToString(\$this->aFields" . (isset( $aMatch[2][$i][0] ) ? "['" . $aMatch[2][$i][0] . "']" : '') . $aMatch[5][$i][0] . ")";
. (isset($aMatch[2][$i][0])
? "['" . $aMatch[2][$i][0] . "']"
: '') . $aMatch[5][$i][0] . ")";
} }
} else { } else {
if (! isset( $aMatch[5][$i][0] )) { if (! isset( $aMatch[5][$i][0] )) {
$sScript .= "\$this->aFields['" . $aMatch[2][$i][0] . "']"; $sScript .= "\$this->aFields['" . $aMatch[2][$i][0] . "']";
} else { } else {
$sScript .= "\$this->aFields" $sScript .= "\$this->aFields" . (isset( $aMatch[2][$i][0] ) ? "['" . $aMatch[2][$i][0] . "']" : '') . $aMatch[5][$i][0];
. (isset($aMatch[2][$i][0])
? "['" . $aMatch[2][$i][0] . "']"
: '') . $aMatch[5][$i][0];
} }
} }
break; break;
@@ -238,19 +233,13 @@ class PMScript
if (! isset( $aMatch[5][$i][0] )) { if (! isset( $aMatch[5][$i][0] )) {
$sScript .= "pmToInteger(\$this->aFields['" . $aMatch[2][$i][0] . "'])"; $sScript .= "pmToInteger(\$this->aFields['" . $aMatch[2][$i][0] . "'])";
} else { } else {
$sScript .= "pmToInteger(\$this->aFields" $sScript .= "pmToInteger(\$this->aFields" . (isset( $aMatch[2][$i][0] ) ? "['" . $aMatch[2][$i][0] . "']" : '') . $aMatch[5][$i][0] . ")";
. (isset($aMatch[2][$i][0])
? "['" . $aMatch[2][$i][0] . "']"
: '') . $aMatch[5][$i][0] . ")";
} }
} else { } else {
if (! isset( $aMatch[5][$i][0] )) { if (! isset( $aMatch[5][$i][0] )) {
$sScript .= "\$this->aFields['" . $aMatch[2][$i][0] . "']"; $sScript .= "\$this->aFields['" . $aMatch[2][$i][0] . "']";
} else { } else {
$sScript .= "\$this->aFields" $sScript .= "\$this->aFields" . (isset( $aMatch[2][$i][0] ) ? "['" . $aMatch[2][$i][0] . "']" : '') . $aMatch[5][$i][0];
. (isset($aMatch[2][$i][0])
? "['" . $aMatch[2][$i][0] . "']"
: '') . $aMatch[5][$i][0];
} }
} }
break; break;
@@ -259,19 +248,13 @@ class PMScript
if (! isset( $aMatch[5][$i][0] )) { if (! isset( $aMatch[5][$i][0] )) {
$sScript .= "pmToFloat(\$this->aFields['" . $aMatch[2][$i][0] . "'])"; $sScript .= "pmToFloat(\$this->aFields['" . $aMatch[2][$i][0] . "'])";
} else { } else {
$sScript .= "pmToFloat(\$this->aFields" $sScript .= "pmToFloat(\$this->aFields" . (isset( $aMatch[2][$i][0] ) ? "['" . $aMatch[2][$i][0] . "']" : '') . $aMatch[5][$i][0] . ")";
. (isset($aMatch[2][$i][0])
? "['" . $aMatch[2][$i][0] . "']"
: '') . $aMatch[5][$i][0] . ")";
} }
} else { } else {
if (! isset( $aMatch[5][$i][0] )) { if (! isset( $aMatch[5][$i][0] )) {
$sScript .= "\$this->aFields['" . $aMatch[2][$i][0] . "']"; $sScript .= "\$this->aFields['" . $aMatch[2][$i][0] . "']";
} else { } else {
$sScript .= "\$this->aFields" $sScript .= "\$this->aFields" . (isset( $aMatch[2][$i][0] ) ? "['" . $aMatch[2][$i][0] . "']" : '') . $aMatch[5][$i][0];
. (isset($aMatch[2][$i][0])
? "['" . $aMatch[2][$i][0] . "']"
: '') . $aMatch[5][$i][0];
} }
} }
break; break;
@@ -280,19 +263,13 @@ class PMScript
if (! isset( $aMatch[5][$i][0] )) { if (! isset( $aMatch[5][$i][0] )) {
$sScript .= "pmToUrl(\$this->aFields['" . $aMatch[2][$i][0] . "'])"; $sScript .= "pmToUrl(\$this->aFields['" . $aMatch[2][$i][0] . "'])";
} else { } else {
$sScript .= "pmToUrl(\$this->aFields" $sScript .= "pmToUrl(\$this->aFields" . (isset( $aMatch[2][$i][0] ) ? "['" . $aMatch[2][$i][0] . "']" : '') . $aMatch[5][$i][0] . ")";
. (isset($aMatch[2][$i][0])
? "['" . $aMatch[2][$i][0] . "']"
: '') . $aMatch[5][$i][0] . ")";
} }
} else { } else {
if (! isset( $aMatch[5][$i][0] )) { if (! isset( $aMatch[5][$i][0] )) {
$sScript .= "\$this->aFields['" . $aMatch[2][$i][0] . "']"; $sScript .= "\$this->aFields['" . $aMatch[2][$i][0] . "']";
} else { } else {
$sScript .= "\$this->aFields" $sScript .= "\$this->aFields" . (isset( $aMatch[2][$i][0] ) ? "['" . $aMatch[2][$i][0] . "']" : '') . $aMatch[5][$i][0];
. (isset($aMatch[2][$i][0])
? "['" . $aMatch[2][$i][0] . "']"
: '') . $aMatch[5][$i][0];
} }
} }
break; break;
@@ -301,19 +278,13 @@ class PMScript
if (! isset( $aMatch[5][$i][0] )) { if (! isset( $aMatch[5][$i][0] )) {
$sScript .= "pmSqlEscape(\$this->aFields['" . $aMatch[2][$i][0] . "'])"; $sScript .= "pmSqlEscape(\$this->aFields['" . $aMatch[2][$i][0] . "'])";
} else { } else {
$sScript .= "pmSqlEscape(\$this->aFields" $sScript .= "pmSqlEscape(\$this->aFields" . (isset( $aMatch[2][$i][0] ) ? "['" . $aMatch[2][$i][0] . "']" : '') . $aMatch[5][$i][0] . ")";
. (isset($aMatch[2][$i][0])
? "['" . $aMatch[2][$i][0] . "']"
: '') . $aMatch[5][$i][0] . ")";
} }
} else { } else {
if (! isset( $aMatch[5][$i][0] )) { if (! isset( $aMatch[5][$i][0] )) {
$sScript .= "\$this->aFields['" . $aMatch[2][$i][0] . "']"; $sScript .= "\$this->aFields['" . $aMatch[2][$i][0] . "']";
} else { } else {
$sScript .= "\$this->aFields" $sScript .= "\$this->aFields" . (isset( $aMatch[2][$i][0] ) ? "['" . $aMatch[2][$i][0] . "']" : '') . $aMatch[5][$i][0];
. (isset($aMatch[2][$i][0])
? "['" . $aMatch[2][$i][0] . "']"
: '') . $aMatch[5][$i][0];
} }
} }
break; break;
@@ -322,19 +293,13 @@ class PMScript
if (! isset( $aMatch[5][$i][0] )) { if (! isset( $aMatch[5][$i][0] )) {
$sScript .= "\$this->aFields['" . $aMatch[2][$i][0] . "']"; $sScript .= "\$this->aFields['" . $aMatch[2][$i][0] . "']";
} else { } else {
$sScript .= "\$this->aFields" $sScript .= "\$this->aFields" . (isset( $aMatch[2][$i][0] ) ? "['" . $aMatch[2][$i][0] . "']" : '') . $aMatch[5][$i][0];
. (isset($aMatch[2][$i][0])
? "['" . $aMatch[2][$i][0] . "']"
: '') . $aMatch[5][$i][0];
} }
} else { } else {
if (! isset( $aMatch[5][$i][0] )) { if (! isset( $aMatch[5][$i][0] )) {
$sScript .= "\$this->aFields['" . $aMatch[2][$i][0] . "']"; $sScript .= "\$this->aFields['" . $aMatch[2][$i][0] . "']";
} else { } else {
$sScript .= "\$this->aFields" $sScript .= "\$this->aFields" . (isset( $aMatch[2][$i][0] ) ? "['" . $aMatch[2][$i][0] . "']" : '') . $aMatch[5][$i][0];
. (isset($aMatch[2][$i][0])
? "['" . $aMatch[2][$i][0] . "']"
: '') . $aMatch[5][$i][0];
} }
} }
break; break;
@@ -343,16 +308,11 @@ class PMScript
} }
} }
$sScript .= substr( $this->sScript, $iAux ); $sScript .= substr( $this->sScript, $iAux );
$sScript = "try {\n" . $sScript . "\n} catch (Exception \$oException) {\n " $sScript = "try {\n" . $sScript . "\n} catch (Exception \$oException) {\n " . " \$this->aFields['__ERROR__'] = utf8_encode(\$oException->getMessage());\n}";
. " \$this->aFields['__ERROR__'] = utf8_encode(\$oException->getMessage());\n}";
//echo '<pre>-->'; print_r($this->aFields); echo '<---</pre>'; //echo '<pre>-->'; print_r($this->aFields); echo '<---</pre>';
$this->executeAndCatchErrors( $sScript, $this->sScript ); $this->executeAndCatchErrors( $sScript, $this->sScript );
for ($i = 0; $i < count( $this->affected_fields ); $i ++) { for ($i = 0; $i < count( $this->affected_fields ); $i ++) {
$_SESSION['TRIGGER_DEBUG']['DATA'][] = Array( $_SESSION['TRIGGER_DEBUG']['DATA'][] = Array ('key' => $this->affected_fields[$i],'value' => isset( $this->aFields[$this->affected_fields[$i]] ) ? $this->aFields[$this->affected_fields[$i]] : ''
'key' => $this->affected_fields[$i],
'value' => isset($this->aFields[$this->affected_fields[$i]])
? $this->aFields[$this->affected_fields[$i]]
: ''
); );
} }
//echo '<pre>-->'; print_r($_SESSION['TRIGGER_DEBUG']['DATA']); echo '<---</pre>'; //echo '<pre>-->'; print_r($_SESSION['TRIGGER_DEBUG']['DATA']); echo '<---</pre>';
@@ -360,6 +320,7 @@ class PMScript
/** /**
* Evaluate the current script * Evaluate the current script
*
* @return void * @return void
*/ */
public function evaluate () public function evaluate ()
@@ -369,9 +330,7 @@ class PMScript
$iAux = 0; $iAux = 0;
$bEqual = false; $bEqual = false;
$variableIsDefined = true; $variableIsDefined = true;
$iOcurrences = preg_match_all('/\@(?:([\@\%\#\?\$\=])([a-zA-Z\_]\w*)|([a-zA-Z\_][\w\-\>\:]*)\(((?:[^\\\\\)]' $iOcurrences = preg_match_all( '/\@(?:([\@\%\#\?\$\=])([a-zA-Z\_]\w*)|([a-zA-Z\_][\w\-\>\:]*)\(((?:[^\\\\\)]' . '*(?:[\\\\][\w\W])?)*)\))((?:\s*\[[\'"]?\w+[\'"]?\])+)?/', $this->sScript, $aMatch, PREG_PATTERN_ORDER | PREG_OFFSET_CAPTURE );
. '*(?:[\\\\][\w\W])?)*)\))((?:\s*\[[\'"]?\w+[\'"]?\])+)?/',
$this->sScript, $aMatch, PREG_PATTERN_ORDER | PREG_OFFSET_CAPTURE);
if ($iOcurrences) { if ($iOcurrences) {
for ($i = 0; $i < $iOcurrences; $i ++) { for ($i = 0; $i < $iOcurrences; $i ++) {
// if the variables for that condition has not been previously defined then $variableIsDefined // if the variables for that condition has not been previously defined then $variableIsDefined
@@ -399,19 +358,13 @@ class PMScript
if (! isset( $aMatch[5][$i][0] )) { if (! isset( $aMatch[5][$i][0] )) {
$sScript .= "pmToString(\$this->aFields['" . $aMatch[2][$i][0] . "'])"; $sScript .= "pmToString(\$this->aFields['" . $aMatch[2][$i][0] . "'])";
} else { } else {
$sScript .= "pmToString(\$this->aFields" $sScript .= "pmToString(\$this->aFields" . (isset( $aMatch[2][$i][0] ) ? "['" . $aMatch[2][$i][0] . "']" : '') . $aMatch[5][$i][0] . ")";
. (isset($aMatch[2][$i][0])
? "['" . $aMatch[2][$i][0] . "']"
: '') . $aMatch[5][$i][0] . ")";
} }
} else { } else {
if (! isset( $aMatch[5][$i][0] )) { if (! isset( $aMatch[5][$i][0] )) {
$sScript .= "\$this->aFields['" . $aMatch[2][$i][0] . "']"; $sScript .= "\$this->aFields['" . $aMatch[2][$i][0] . "']";
} else { } else {
$sScript .= "\$this->aFields" $sScript .= "\$this->aFields" . (isset( $aMatch[2][$i][0] ) ? "['" . $aMatch[2][$i][0] . "']" : '') . $aMatch[5][$i][0];
. (isset($aMatch[2][$i][0])
? "['" . $aMatch[2][$i][0] . "']"
: '') . $aMatch[5][$i][0];
} }
} }
break; break;
@@ -420,19 +373,13 @@ class PMScript
if (! isset( $aMatch[5][$i][0] )) { if (! isset( $aMatch[5][$i][0] )) {
$sScript .= "pmToInteger(\$this->aFields['" . $aMatch[2][$i][0] . "'])"; $sScript .= "pmToInteger(\$this->aFields['" . $aMatch[2][$i][0] . "'])";
} else { } else {
$sScript .= "pmToInteger(\$this->aFields" $sScript .= "pmToInteger(\$this->aFields" . (isset( $aMatch[2][$i][0] ) ? "['" . $aMatch[2][$i][0] . "']" : '') . $aMatch[5][$i][0] . ")";
. (isset($aMatch[2][$i][0])
? "['" . $aMatch[2][$i][0] . "']"
: '') . $aMatch[5][$i][0] . ")";
} }
} else { } else {
if (! isset( $aMatch[5][$i][0] )) { if (! isset( $aMatch[5][$i][0] )) {
$sScript .= "\$this->aFields['" . $aMatch[2][$i][0] . "']"; $sScript .= "\$this->aFields['" . $aMatch[2][$i][0] . "']";
} else { } else {
$sScript .= "\$this->aFields" $sScript .= "\$this->aFields" . (isset( $aMatch[2][$i][0] ) ? "['" . $aMatch[2][$i][0] . "']" : '') . $aMatch[5][$i][0];
. (isset($aMatch[2][$i][0])
? "['" . $aMatch[2][$i][0] . "']"
: '') . $aMatch[5][$i][0];
} }
} }
break; break;
@@ -441,19 +388,13 @@ class PMScript
if (! isset( $aMatch[5][$i][0] )) { if (! isset( $aMatch[5][$i][0] )) {
$sScript .= "pmToFloat(\$this->aFields['" . $aMatch[2][$i][0] . "'])"; $sScript .= "pmToFloat(\$this->aFields['" . $aMatch[2][$i][0] . "'])";
} else { } else {
$sScript .= "pmToFloat(\$this->aFields" $sScript .= "pmToFloat(\$this->aFields" . (isset( $aMatch[2][$i][0] ) ? "['" . $aMatch[2][$i][0] . "']" : '') . $aMatch[5][$i][0] . ")";
. (isset($aMatch[2][$i][0])
? "['" . $aMatch[2][$i][0] . "']"
: '') . $aMatch[5][$i][0] . ")";
} }
} else { } else {
if (! isset( $aMatch[5][$i][0] )) { if (! isset( $aMatch[5][$i][0] )) {
$sScript .= "\$this->aFields['" . $aMatch[2][$i][0] . "']"; $sScript .= "\$this->aFields['" . $aMatch[2][$i][0] . "']";
} else { } else {
$sScript .= "\$this->aFields" $sScript .= "\$this->aFields" . (isset( $aMatch[2][$i][0] ) ? "['" . $aMatch[2][$i][0] . "']" : '') . $aMatch[5][$i][0];
. (isset($aMatch[2][$i][0])
? "['" . $aMatch[2][$i][0] . "']"
: '') . $aMatch[5][$i][0];
} }
} }
break; break;
@@ -462,19 +403,13 @@ class PMScript
if (! isset( $aMatch[5][$i][0] )) { if (! isset( $aMatch[5][$i][0] )) {
$sScript .= "pmToUrl(\$this->aFields['" . $aMatch[2][$i][0] . "'])"; $sScript .= "pmToUrl(\$this->aFields['" . $aMatch[2][$i][0] . "'])";
} else { } else {
$sScript .= "pmToUrl(\$this->aFields" $sScript .= "pmToUrl(\$this->aFields" . (isset( $aMatch[2][$i][0] ) ? "['" . $aMatch[2][$i][0] . "']" : '') . $aMatch[5][$i][0] . ")";
. (isset($aMatch[2][$i][0])
? "['" . $aMatch[2][$i][0] . "']"
: '') . $aMatch[5][$i][0] . ")";
} }
} else { } else {
if (! isset( $aMatch[5][$i][0] )) { if (! isset( $aMatch[5][$i][0] )) {
$sScript .= "\$this->aFields['" . $aMatch[2][$i][0] . "']"; $sScript .= "\$this->aFields['" . $aMatch[2][$i][0] . "']";
} else { } else {
$sScript .= "\$this->aFields" $sScript .= "\$this->aFields" . (isset( $aMatch[2][$i][0] ) ? "['" . $aMatch[2][$i][0] . "']" : '') . $aMatch[5][$i][0];
. (isset($aMatch[2][$i][0])
? "['" . $aMatch[2][$i][0] . "']"
: '') . $aMatch[5][$i][0];
} }
} }
break; break;
@@ -483,19 +418,13 @@ class PMScript
if (! isset( $aMatch[5][$i][0] )) { if (! isset( $aMatch[5][$i][0] )) {
$sScript .= "pmSqlEscape(\$this->aFields['" . $aMatch[2][$i][0] . "'])"; $sScript .= "pmSqlEscape(\$this->aFields['" . $aMatch[2][$i][0] . "'])";
} else { } else {
$sScript .= "pmSqlEscape(\$this->aFields" $sScript .= "pmSqlEscape(\$this->aFields" . (isset( $aMatch[2][$i][0] ) ? "['" . $aMatch[2][$i][0] . "']" : '') . $aMatch[5][$i][0] . ")";
. (isset($aMatch[2][$i][0])
? "['" . $aMatch[2][$i][0] . "']"
: '') . $aMatch[5][$i][0] . ")";
} }
} else { } else {
if (! isset( $aMatch[5][$i][0] )) { if (! isset( $aMatch[5][$i][0] )) {
$sScript .= "\$this->aFields['" . $aMatch[2][$i][0] . "']"; $sScript .= "\$this->aFields['" . $aMatch[2][$i][0] . "']";
} else { } else {
$sScript .= "\$this->aFields" $sScript .= "\$this->aFields" . (isset( $aMatch[2][$i][0] ) ? "['" . $aMatch[2][$i][0] . "']" : '') . $aMatch[5][$i][0];
. (isset($aMatch[2][$i][0])
? "['" . $aMatch[2][$i][0] . "']"
: '') . $aMatch[5][$i][0];
} }
} }
break; break;
@@ -504,19 +433,13 @@ class PMScript
if (! isset( $aMatch[5][$i][0] )) { if (! isset( $aMatch[5][$i][0] )) {
$sScript .= "\$this->aFields['" . $aMatch[2][$i][0] . "']"; $sScript .= "\$this->aFields['" . $aMatch[2][$i][0] . "']";
} else { } else {
$sScript .= "\$this->aFields" $sScript .= "\$this->aFields" . (isset( $aMatch[2][$i][0] ) ? "['" . $aMatch[2][$i][0] . "']" : '') . $aMatch[5][$i][0];
. (isset($aMatch[2][$i][0])
? "['" . $aMatch[2][$i][0] . "']"
: '') . $aMatch[5][$i][0];
} }
} else { } else {
if (! isset( $aMatch[5][$i][0] )) { if (! isset( $aMatch[5][$i][0] )) {
$sScript .= "\$this->aFields['" . $aMatch[2][$i][0] . "']"; $sScript .= "\$this->aFields['" . $aMatch[2][$i][0] . "']";
} else { } else {
$sScript .= "\$this->aFields" $sScript .= "\$this->aFields" . (isset( $aMatch[2][$i][0] ) ? "['" . $aMatch[2][$i][0] . "']" : '') . $aMatch[5][$i][0];
. (isset($aMatch[2][$i][0])
? "['" . $aMatch[2][$i][0] . "']"
: '') . $aMatch[5][$i][0];
} }
} }
break; break;
@@ -540,8 +463,10 @@ class PMScript
//Start - Private functions //Start - Private functions
/** /**
* Convert to string * Convert to string
*
* @param variant $vValue * @param variant $vValue
* @return string * @return string
*/ */
@@ -552,6 +477,7 @@ function pmToString($vValue)
/** /**
* Convert to integer * Convert to integer
*
* @param variant $vValue * @param variant $vValue
* @return integer * @return integer
*/ */
@@ -562,6 +488,7 @@ function pmToInteger($vValue)
/** /**
* Convert to float * Convert to float
*
* @param variant $vValue * @param variant $vValue
* @return float * @return float
*/ */
@@ -572,6 +499,7 @@ function pmToFloat($vValue)
/** /**
* Convert to Url * Convert to Url
*
* @param variant $vValue * @param variant $vValue
* @return url * @return url
*/ */
@@ -582,6 +510,7 @@ function pmToUrl($vValue)
/** /**
* Convert to data base escaped string * Convert to data base escaped string
*
* @param variant $vValue * @param variant $vValue
* @return string * @return string
*/ */
@@ -593,7 +522,6 @@ function pmSqlEscape($vValue)
//End - Private functions //End - Private functions
/* * ************************************************************************* /* * *************************************************************************
* Error handler * Error handler
* author: Julio Cesar Laura Avenda<64>o <juliocesar@colosa.com> * author: Julio Cesar Laura Avenda<64>o <juliocesar@colosa.com>
@@ -636,28 +564,22 @@ function handleFatalErrors($buffer)
if (strpos( $_SERVER['REQUEST_URI'], '&ACTION=GENERATE' ) !== false) { if (strpos( $_SERVER['REQUEST_URI'], '&ACTION=GENERATE' ) !== false) {
G::LoadClass( 'case' ); G::LoadClass( 'case' );
$oCase = new Cases(); $oCase = new Cases();
$aNextStep = $oCase->getNextStep($_SESSION['PROCESS'], $aNextStep = $oCase->getNextStep( $_SESSION['PROCESS'], $_SESSION['APPLICATION'], $_SESSION['INDEX'], $_SESSION['STEP_POSITION'] );
$_SESSION['APPLICATION'],
$_SESSION['INDEX'],
$_SESSION['STEP_POSITION']);
if ($_SESSION['TRIGGER_DEBUG']['ISSET']) { if ($_SESSION['TRIGGER_DEBUG']['ISSET']) {
$_SESSION['TRIGGER_DEBUG']['TIME'] = 'AFTER'; $_SESSION['TRIGGER_DEBUG']['TIME'] = 'AFTER';
$_SESSION['TRIGGER_DEBUG']['BREAKPAGE'] = $aNextStep['PAGE']; $_SESSION['TRIGGER_DEBUG']['BREAKPAGE'] = $aNextStep['PAGE'];
$aNextStep['PAGE'] = $aNextStep['PAGE'] . '&breakpoint=triggerdebug'; $aNextStep['PAGE'] = $aNextStep['PAGE'] . '&breakpoint=triggerdebug';
} }
G::header( 'Location: ' . $aNextStep['PAGE'] ); G::header( 'Location: ' . $aNextStep['PAGE'] );
die; die();
} }
$_SESSION['_NO_EXECUTE_TRIGGERS_'] = 1; $_SESSION['_NO_EXECUTE_TRIGGERS_'] = 1;
G::header( 'Location: ' . $_SERVER['REQUEST_URI'] ); G::header( 'Location: ' . $_SERVER['REQUEST_URI'] );
die; die();
} else { } else {
G::LoadClass( 'case' ); G::LoadClass( 'case' );
$oCase = new Cases(); $oCase = new Cases();
$aNextStep = $oCase->getNextStep($_SESSION['PROCESS'], $aNextStep = $oCase->getNextStep( $_SESSION['PROCESS'], $_SESSION['APPLICATION'], $_SESSION['INDEX'], $_SESSION['STEP_POSITION'] );
$_SESSION['APPLICATION'],
$_SESSION['INDEX'],
$_SESSION['STEP_POSITION']);
if ($_SESSION['TRIGGER_DEBUG']['ISSET']) { if ($_SESSION['TRIGGER_DEBUG']['ISSET']) {
$_SESSION['TRIGGER_DEBUG']['TIME'] = 'AFTER'; $_SESSION['TRIGGER_DEBUG']['TIME'] = 'AFTER';
$_SESSION['TRIGGER_DEBUG']['BREAKPAGE'] = $aNextStep['PAGE']; $_SESSION['TRIGGER_DEBUG']['BREAKPAGE'] = $aNextStep['PAGE'];
@@ -667,7 +589,7 @@ function handleFatalErrors($buffer)
G::SendMessageText( 'Fatal error in trigger', 'error' ); G::SendMessageText( 'Fatal error in trigger', 'error' );
} }
G::header( 'Location: ' . $aNextStep['PAGE'] ); G::header( 'Location: ' . $aNextStep['PAGE'] );
die; die();
} }
} }
return $buffer; return $buffer;
@@ -685,8 +607,7 @@ function handleFatalErrors($buffer)
function registerError ($iType, $sError, $iLine, $sCode) function registerError ($iType, $sError, $iLine, $sCode)
{ {
$sType = ($iType == 1 ? 'ERROR' : 'FATAL'); $sType = ($iType == 1 ? 'ERROR' : 'FATAL');
$_SESSION['TRIGGER_DEBUG']['ERRORS'][][$sType] = $sError . ($iLine > 0 ? ' (line ' . $iLine . ')' : '') $_SESSION['TRIGGER_DEBUG']['ERRORS'][][$sType] = $sError . ($iLine > 0 ? ' (line ' . $iLine . ')' : '') . ':<br /><br />' . $sCode;
. ':<br /><br />' . $sCode;
} }
/** /**