CODE STYLE, changes...

FILES:
workflow/engine/classes/class.derivation.php
workflow/engine/classes/class.popupMenu.php
workflow/engine/classes/class.processes.php
workflow/engine/classes/class.xmlDb.php
workflow/engine/classes/triggers/api/class.zimbraApi.php
This commit is contained in:
jennylee
2012-10-22 15:45:47 -04:00
parent d7de707543
commit ef66773130
5 changed files with 5155 additions and 5126 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -1,11 +1,13 @@
<?php
/**
* class.popupMenu.php
*
* @package workflow.engine.ProcessMaker
*
*
* ProcessMaker Open Source Edition
* Copyright (C) 2004 - 2011 Colosa Inc.
*
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
@@ -13,89 +15,85 @@
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
* Coral Gables, FL, 33134, USA, or email info@colosa.com.
*
*
*/
/**
* popupMenu - popupMenu class
*
* @package workflow.engine.ProcessMaker
* @copyright COLOSA
*/
class popupMenu extends form
{
var $type = 'popupMenu';
var $theme = 'processmaker';
/**
* Print the popup
* @param string $tableId
* @param array $tableFields
* @return array
*/
function renderPopup( $tableId, $tableFields )
{
$this->name =$tableId;
$fields = array_keys( $tableFields);
foreach( $fields as $f ) {
switch ( strtolower($tableFields[$f]['Type'])) {
case 'javascript':
case 'button':
case 'private':
case 'hidden':
case 'cellmark':
break;
default:
$label = ($tableFields[$f]['Label'] !='' ) ? $tableFields[$f]['Label'] : $f;
$label = str_replace("\n", ' ', $label);
$pmXmlNode = new Xml_Node( $f,
'complete',
'',
array ( 'label' => $label,
'type' => 'popupOption',
'launch' => $tableId . '.showHideField("' . $f . '")'
)
);
$this->fields[$f] = new XmlForm_Field_popupOption( $pmXmlNode );
$this->values[$f]='';
class popupMenu extends form
{
var $type = 'popupMenu';
var $theme = 'processmaker';
/**
* Print the popup
*
* @param string $tableId
* @param array $tableFields
* @return array
*/
function renderPopup ($tableId, $tableFields)
{
$this->name = $tableId;
$fields = array_keys( $tableFields );
foreach ($fields as $f) {
switch (strtolower( $tableFields[$f]['Type'] )) {
case 'javascript':
case 'button':
case 'private':
case 'hidden':
case 'cellmark':
break;
default:
$label = ($tableFields[$f]['Label'] != '') ? $tableFields[$f]['Label'] : $f;
$label = str_replace( "\n", ' ', $label );
$pmXmlNode = new Xml_Node( $f, 'complete', '', array ('label' => $label,'type' => 'popupOption','launch' => $tableId . '.showHideField("' . $f . '")'
) );
$this->fields[$f] = new XmlForm_Field_popupOption( $pmXmlNode );
$this->values[$f] = '';
}
}
}
$scTemp = '';
$this->values['PAGED_TABLE_ID'] = $tableId;
print( parent::render( PATH_CORE . 'templates/popupMenu.html', $scTemp));
$sc = "<script type=\"text/javascript\">\n$scTemp\n loadPopupMenu_$tableId(); \n</script>" ;
return $sc;
}
$scTemp = '';
$this->values['PAGED_TABLE_ID'] = $tableId;
print (parent::render( PATH_CORE . 'templates/popupMenu.html', $scTemp )) ;
$sc = "<script type=\"text/javascript\">\n$scTemp\n loadPopupMenu_$tableId(); \n</script>";
return $sc;
}
}
/**
* XmlForm_Field_popupOption - XmlForm_Field_popupOption class
*
* @package workflow.engine.ProcessMaker
* @copyright COLOSA
*/
class XmlForm_Field_popupOption extends XmlForm_Field
{
var $launch = '';
/**
* Get Events
* @return string
*/
function getEvents( )
{
$script = '{name:"' . $this->name . '",text:"' . addcslashes($this->label,'\\"') .
'", launch:leimnud.closure({Function:function(target){' . $this->launch . '}, args:target})}';
return $script;
}
var $launch = '';
/**
* Get Events
*
* @return string
*/
function getEvents ()
{
$script = '{name:"' . $this->name . '",text:"' . addcslashes( $this->label, '\\"' ) . '", launch:leimnud.closure({Function:function(target){' . $this->launch . '}, args:target})}';
return $script;
}
}
?>

File diff suppressed because it is too large Load Diff

View File

@@ -44,7 +44,7 @@ class XMLDB
* @param string $dsn
* @return array $options
*/
function &connect ($dsn, $options = array())
public function &connect ($dsn, $options = array())
{
//Needed for $mysql_real_escape_string
$mresdbc = new DBConnection();
@@ -63,7 +63,7 @@ class XMLDB
* @param string $result
* @return boolean is_a($result, 'DB_Error')
*/
function isError ($result)
public function isError ($result)
{
return is_a( $result, 'DB_Error' );
}
@@ -82,7 +82,7 @@ class XMLConnection
{
var $phptype = 'myxml';
var $caseFolding = true;
var $xmldoc = NULL;
var $xmldoc = null;
var $xmlFile = '';
/**
@@ -91,7 +91,7 @@ class XMLConnection
* @param string $file
* @return void
*/
function XMLConnection ($file)
public function XMLConnection ($file)
{
$this->xmldoc = new Xml_Document();
$this->xmldoc->parseXmlFile( $file );
@@ -105,7 +105,7 @@ class XMLConnection
* @param string $sql
* @return object(XMLResult) $result
*/
function &query ($sql)
public function &query ($sql)
{
if (! isset( $this->xmldoc )) {
$err = new DB_Error( "Error: Closed xmlConnection." );
@@ -127,8 +127,8 @@ class XMLConnection
$fieldsList[$name] = $match[1][$r][0];
}
/* End Block */
/* Start Block: Order list */
$count = preg_match_all( '/\s*(\*|[\w\.]+)(\s+ASC|\s+DESC)?\s*,?/im', $sqlOrderBy, $match, PREG_PATTERN_ORDER | PREG_OFFSET_CAPTURE );
/* Start Block: Order list */
$count = preg_match_all( '/\s*(\*|[\w\.]+)(\s+ASC|\s+DESC)?\s*,?/im', $sqlOrderBy, $match, PREG_PATTERN_ORDER | PREG_OFFSET_CAPTURE );
$orderList = array ();
for ($r = $count - 1; $r >= 0; $r --) {
$direction = (is_array( $match[2][$r] ) && $match[2][$r][0] !== '') ? $match[2][$r][0] : 'ASC';
@@ -173,21 +173,22 @@ class XMLConnection
for ($r = 0; $r < sizeof( $res ); $r ++) {
$evalWhere = false;
@eval( '$evalWhere = ' . $sqlWhere . ';' );
if ($evalWhere)
if ($evalWhere) {
$newRes[] = $res[$r];
}
}
$res = $newRes;
}
/* End Block */
/* Start Block: Expands the resultant data according to fill an array
* with the required fields in the query.
*/
for ($r = 0; $r < sizeof( $res ); $r ++) {
/* Start Block: Expands the resultant data according to fill an array
* with the required fields in the query.
*/
for ($r = 0; $r < sizeof( $res ); $r ++) {
$res[$r] = $this->expandFields( $res[$r], $fieldsList );
}
/* End Block */
/* Start Block: ORDER BY*/
foreach ($orderList as $field => $direction) {
/* Start Block: ORDER BY*/
foreach ($orderList as $field => $direction) {
for ($i = 0; $i < sizeof( $res ); $i ++) {
for ($j = $i + 1; $j < sizeof( $res ); $j ++) {
$condition = ($direction === 'ASC') ? ($res[$j] < $res[$i]) : ($res[$j] > $res[$i]);
@@ -200,8 +201,8 @@ class XMLConnection
}
}
/* End Block */
/* Start Block: Apply limits */
if ($sqlLowLimit != '' && $sqlHighLimit != '') {
/* Start Block: Apply limits */
if ($sqlLowLimit != '' && $sqlHighLimit != '') {
$sqlLowLimit = (int) $sqlLowLimit;
$sqlHighLimit = (int) $sqlHighLimit;
$res = array_slice( $res, $sqlLowLimit, $sqlHighLimit );
@@ -213,8 +214,8 @@ class XMLConnection
$sqlFrom = isset( $matches[1] ) ? $matches[1] : '';
$sqlWhere = isset( $matches[2] ) ? $matches[2] : '1';
/* Start Block: WHERE*/
/*Start Block: Replace the operator */
$blocks = preg_split( '/("(?:(?:[^"]|"")*)"|\'(?:(?:[^\']|\'\')*)\')/im', $sqlWhere, - 1, PREG_SPLIT_DELIM_CAPTURE );
/*Start Block: Replace the operator */
$blocks = preg_split( '/("(?:(?:[^"]|"")*)"|\'(?:(?:[^\']|\'\')*)\')/im', $sqlWhere, - 1, PREG_SPLIT_DELIM_CAPTURE );
$sqlWhere = '';
for ($r = 0; $r < sizeof( $blocks ); $r ++) {
if (($r % 2) === 0) {
@@ -274,8 +275,8 @@ class XMLConnection
$fieldsList[] = $match[1][$r][0];
}
/* End Block */
/* Start Block: Fields Values */
$count = preg_match_all( '/("(?:(?:[^"]|"")*)"|\'(?:(?:[^\']|\'\')*)\'|\d+)/im', $sqlValues, $match, PREG_PATTERN_ORDER | PREG_OFFSET_CAPTURE );
/* Start Block: Fields Values */
$count = preg_match_all( '/("(?:(?:[^"]|"")*)"|\'(?:(?:[^\']|\'\')*)\'|\d+)/im', $sqlValues, $match, PREG_PATTERN_ORDER | PREG_OFFSET_CAPTURE );
$fieldsValues = array ();
for ($r = 0; $r < $count; $r ++) {
if (substr( $match[1][$r][0], 0, 1 ) === '"') {
@@ -318,8 +319,8 @@ class XMLConnection
$fieldsValues[$match[1][$r][0]] = $match[2][$r][0];
}
/* Start Block: WHERE*/
/*Start Block: Replace the operator */
$blocks = preg_split( '/("(?:(?:[^"]|"")*)"|\'(?:(?:[^\']|\'\')*)\')/im', $sqlWhere, - 1, PREG_SPLIT_DELIM_CAPTURE );
/*Start Block: Replace the operator */
$blocks = preg_split( '/("(?:(?:[^"]|"")*)"|\'(?:(?:[^\']|\'\')*)\')/im', $sqlWhere, - 1, PREG_SPLIT_DELIM_CAPTURE );
$sqlWhere = '';
for ($r = 0; $r < sizeof( $blocks ); $r ++) {
if (($r % 2) === 0) {
@@ -377,7 +378,7 @@ class XMLConnection
* @param string $a
* @return void $b
*/
function sqlLike ($a, $b)
public function sqlLike ($a, $b)
{
$b = addcslashes( $b, '[]()\/{}.?' );
$b = str_replace( "%", '.*', $b );
@@ -392,15 +393,16 @@ class XMLConnection
* @param string $fieldsList
* @return array $res
*/
function expandFields ($resRow, $fieldsList)
public function expandFields ($resRow, $fieldsList)
{
$res = array ();
foreach ($fieldsList as $key => $value) {
if ($key === '*') {
foreach ($resRow as $k => $v)
foreach ($resRow as $k => $v) {
$res[$k] = $v;
}
} else {
$res[$key] = array_key_exists( $value, $resRow ) ? $resRow[$value] : NULL;
$res[$key] = array_key_exists( $value, $resRow ) ? $resRow[$value] : null;
}
}
return $res;
@@ -412,13 +414,14 @@ class XMLConnection
* @param object &$node
* @return array $res
*/
function fetchNode (&$node)
public function fetchNode (&$node)
{
$res = array ('XMLNODE_NAME' => $node->name,'XMLNODE_TYPE' => $node->type,'XMLNODE_VALUE' => $node->value
);
foreach ($node->attributes as $name => $value) {
if ($this->caseFolding)
if ($this->caseFolding) {
$name = strtoupper( $name );
}
$res[$name] = $value;
}
return $res;
@@ -430,7 +433,7 @@ class XMLConnection
* @param string &$node
* @return array $res
*/
function fetchChildren (&$node)
public function fetchChildren (&$node)
{
$res = array ();
foreach ($node->children as $name => $child) {
@@ -444,7 +447,7 @@ class XMLConnection
*
* @return void
*/
function disconnect ()
public function disconnect ()
{
unset( $this->xmldoc );
}
@@ -454,7 +457,7 @@ class XMLConnection
* @param array $match
* @return object(DB_Error) $err
*/
function sqlWhereLike ($match)
public function sqlWhereLike ($match)
{
switch (substr( $match[2], 0, 1 )) {
case '"':
@@ -476,7 +479,7 @@ class XMLConnection
* @param array $match
* @return object(DB_Error) $err
*/
function sqlString ($match)
public function sqlString ($match)
{
switch (substr( $match[0], 0, 1 )) {
case '"':
@@ -507,7 +510,7 @@ class XMLConnection
* @param object $values
* @return void
*/
function insertRow (&$node, $values)
public function insertRow (&$node, $values)
{
$attributes = array ();
foreach ($values as $field => $value) {
@@ -533,7 +536,7 @@ class XMLConnection
* @param object $values
* @return void
*/
function updateRow (&$node, $values)
public function updateRow (&$node, $values)
{
foreach ($values as $field => $value) {
switch ($field) {
@@ -573,7 +576,7 @@ class XMLResult
* @param array $result
* @return void
*/
function XMLResult ($result = array())
public function XMLResult ($result = array())
{
$this->result = $result;
$this->cursor = 0;
@@ -584,7 +587,7 @@ class XMLResult
*
* @return integer sizeof($this->result)
*/
function numRows ()
public function numRows ()
{
return sizeof( $this->result );
}
@@ -595,10 +598,11 @@ class XMLResult
* @param string $const
* @return integer $this->result[ $this->cursor-1 ];
*/
function fetchRow ($const)
public function fetchRow ($const)
{
if ($this->cursor >= $this->numRows())
return NULL;
if ($this->cursor >= $this->numRows()) {
return null;
}
$this->cursor ++;
return $this->result[$this->cursor - 1];
}
@@ -621,4 +625,3 @@ function getNames ($children)
return $names;
}
?>

File diff suppressed because it is too large Load Diff