CODE STYLE, gulliver/system/...

FILES:
class.dbMaintenance.php
class.dbconnection.php
class.dbrecordset.php
class.dbsession.php
class.dbtable.php
class.httpProxyController.php
class.i18n_po.php
class.mailer.php
class.menu.php
class.objectTemplate.php
class.testTools.php
class.tree.php
class.unitTest.php
class.webResource.php
class.xmlDocument.php
class.xmlformExtension.php
This commit is contained in:
jennylee
2012-10-18 10:54:46 -04:00
parent 37bb8a1f5f
commit e456979aa3
16 changed files with 3515 additions and 3358 deletions

View File

@@ -1,6 +1,8 @@
<?php
/**
* class.database_base.php
*
* @package gulliver.system
*
* ProcessMaker Open Source Edition
@@ -25,6 +27,7 @@
*/
/**
*
*
* Database Maintenance class
*
@@ -47,7 +50,7 @@ class DataBaseMaintenance
protected $outfile;
protected $infile;
/**
/**
* __construct
*
* @param string $host is null
@@ -56,159 +59,159 @@ class DataBaseMaintenance
*
* @return none
*/
public function __construct($host = null, $user = null, $passwd = null)
public function __construct ($host = null, $user = null, $passwd = null)
{
$this->tmpDir = './';
$this->link = null;
$this->dbName = null;
if( isset($host) && isset($user) && isset($passwd) ) {
if (isset( $host ) && isset( $user ) && isset( $passwd )) {
$this->host = $host;
$this->user = $user;
$this->passwd = $passwd;
}
}
/**
/**
* setUser
*
* @param string $user
*
* @return none
*/
public function setUser($user)
public function setUser ($user)
{
$this->user = $user;
}
/**
/**
* setPasswd
*
* @param string $passwd
*
* @return none
*/
public function setPasswd($passwd)
public function setPasswd ($passwd)
{
$this->passwd = $passwd;
}
/**
/**
* setHost
*
* @param string $host
*
* @return none
*/
public function setHost($host)
public function setHost ($host)
{
$this->host = $host;
}
/**
/**
* setTempDir
*
* @param string $tmpDir
*
* @return none
*/
public function setTempDir($tmpDir)
public function setTempDir ($tmpDir)
{
$this->tmpDir = $tmpDir;
if (!file_exists($tmpDir))
mkdir($this->tmpDir);
if (! file_exists( $tmpDir )) {
mkdir( $this->tmpDir );
}
}
/**
/**
* getTempDir
*
* @return $this->tmpDir
*/
public function getTempDir()
public function getTempDir ()
{
return $this->tmpDir;
}
/**
/**
* status
*
* @return $this->link
*/
public function status()
public function status ()
{
return $$this->link;
}
/**
/**
* connect
*
* @param string $dbname is null
*
* @return none
*/
public function connect($dbname = null)
public function connect ($dbname = null)
{
if( $this->link != null ) {
mysql_close($this->link);
if ($this->link != null) {
mysql_close( $this->link );
$this->link = null;
}
if( isset($dbname) ) {
if (isset( $dbname )) {
$this->dbName = $dbname;
}
$this->link = mysql_connect($this->host, $this->user, $this->passwd);
@mysql_query("SET NAMES 'utf8';");
if( ! $this->link ) {
throw new Exception("Couldn't connect to host {$this->host} with user {$this->user}");
$this->link = mysql_connect( $this->host, $this->user, $this->passwd );
@mysql_query( "SET NAMES 'utf8';" );
if (! $this->link) {
throw new Exception( "Couldn't connect to host {$this->host} with user {$this->user}" );
}
if( $this->dbName != null ) {
$this->selectDataBase($this->dbName);
if ($this->dbName != null) {
$this->selectDataBase( $this->dbName );
}
}
/**
/**
* setDbName
*
* @param string $dbname is null
*
* @return none
*/
public function setDbName($dbname)
public function setDbName ($dbname)
{
$this->dbName = $dbname;
}
/**
/**
* selectDataBase
*
* @param string $dbname
*
* @return none
*/
public function selectDataBase($dbname)
public function selectDataBase ($dbname)
{
$this->setDbName($dbname);
If( ! @mysql_select_db($this->dbName, $this->link) ) {
throw new Exception("Couldn't select database $dbname");
$this->setDbName( $dbname );
if (! @mysql_select_db( $this->dbName, $this->link )) {
throw new Exception( "Couldn't select database $dbname" );
}
}
/**
/**
* query
*
* @param string $sql
*
* @return $aRows
*/
public function query($sql)
public function query ($sql)
{
$this->result = @mysql_query($sql);
if($this->result){
$aRows = Array();
while( $aRow = @mysql_fetch_assoc($this->result) ) {
array_push($aRows, $aRow);
$this->result = @mysql_query( $sql );
if ($this->result) {
$aRows = Array ();
while ($aRow = @mysql_fetch_assoc( $this->result )) {
array_push( $aRows, $aRow );
}
return $aRows;
} else {
@@ -216,87 +219,87 @@ class DataBaseMaintenance
}
}
/**
/**
* error
*
* @return @mysql_error()
*/
public function error()
public function error ()
{
return @mysql_error($this->link);
return @mysql_error( $this->link );
}
/**
/**
* getTablesList
*
* @return $aRows
*/
public function getTablesList()
public function getTablesList ()
{
$this->result = @mysql_query("SHOW TABLES;");
$this->result = @mysql_query( "SHOW TABLES;" );
$aRows = Array ();
while( $aRow = mysql_fetch_row($this->result) ) {
array_push($aRows, $aRow[0]);
while ($aRow = mysql_fetch_row( $this->result )) {
array_push( $aRows, $aRow[0] );
}
return $aRows;
}
/**
/**
* dumpData
*
* @param string $table
*
* @return boolean true or false
*/
function dumpData($table)
function dumpData ($table)
{
$this->outfile = $this->tmpDir . $table . '.dump';
//if the file exists delete it
if( is_file($this->outfile) ) {
@unlink($this->outfile);
if (is_file( $this->outfile )) {
@unlink( $this->outfile );
}
$sql = "SELECT * INTO OUTFILE '{$this->outfile}' FIELDS TERMINATED BY '\t|\t' OPTIONALLY ENCLOSED BY '\"' LINES TERMINATED BY '\t\t\r\r\n' FROM $table";
// The mysql_escape_string function has been DEPRECATED as of PHP 5.3.0.
// Commented that is not assigned to a variable.
// mysql_escape_string("';");
if( ! @mysql_query($sql) ) {
if (! @mysql_query( $sql )) {
echo mysql_error() . "\n";
return false;
}
return true;
}
/**
/**
* restoreData
*
* @param string $backupFile
*
* @return boolean true or false
*/
function restoreData($backupFile)
function restoreData ($backupFile)
{
$tableName = str_replace('.dump', '', basename($backupFile));
$tableName = str_replace( '.dump', '', basename( $backupFile ) );
$sql = "LOAD DATA INFILE '$backupFile' INTO TABLE $tableName FIELDS TERMINATED BY '\t|\t' OPTIONALLY ENCLOSED BY '\"' LINES TERMINATED BY '\t\t\r\r\n'";
if( ! @mysql_query($sql) ) {
if (! @mysql_query( $sql )) {
print mysql_error() . "\n";
return false;
}
return true;
}
/**
/**
* backupData
*
* @return boolean true or false
*/
function backupData()
function backupData ()
{
$aTables = $this->getTablesList();
foreach( $aTables as $table ) {
if( $this->dumpData($table) !== false ) {
printf("%20s %s %s\n", 'Dump of table:', $table, " in file {$this->outfile}");
foreach ($aTables as $table) {
if ($this->dumpData( $table ) !== false) {
printf( "%20s %s %s\n", 'Dump of table:', $table, " in file {$this->outfile}" );
} else {
return false;
}
@@ -304,55 +307,56 @@ class DataBaseMaintenance
return true;
}
/**
/**
* backupSqlData
*
* @return boolean true or false
*/
function backupSqlData()
function backupSqlData ()
{
$aTables = $this->getTablesList();
foreach( $aTables as $table ) {
$fsize = $this->dumpSqlInserts($table);
$file = basename($this->outfile);
foreach ($aTables as $table) {
$fsize = $this->dumpSqlInserts( $table );
$file = basename( $this->outfile );
}
return true;
}
/**
/**
* restoreAllData
*
* @param string $type default value null
*
* @return none
*/
function restoreAllData($type = null)
function restoreAllData ($type = null)
{
$aTables = $this->getTablesList();
foreach( $aTables as $table ) {
if( isset($type) && $type == 'sql' ) {
foreach ($aTables as $table) {
if (isset( $type ) && $type == 'sql') {
$this->infile = $this->tmpDir . $table . ".sql";
if( is_file($this->infile) ) {
$queries = $this->restoreFromSql($this->infile, true);
if (!isset($queries))
if (is_file( $this->infile )) {
$queries = $this->restoreFromSql( $this->infile, true );
if (! isset( $queries )) {
$queries = "unknown";
printf("%-59s%20s", "Restored table $table", "$queries queries\n");
}
printf( "%-59s%20s", "Restored table $table", "$queries queries\n" );
}
} else {
$this->infile = $this->tmpDir . $table . ".dump";
if( is_file($this->infile) ) {
$this->restoreData($this->infile);
printf("%20s %s %s\n", 'Restoring data from ', $this->infile, " in table $table");
if (is_file( $this->infile )) {
$this->restoreData( $this->infile );
printf( "%20s %s %s\n", 'Restoring data from ', $this->infile, " in table $table" );
}
}
}
}
/**
/**
* createDb
*
* @param string $dbname
@@ -360,227 +364,233 @@ class DataBaseMaintenance
*
* @return none
*/
function createDb($dbname, $drop = false)
function createDb ($dbname, $drop = false)
{
if( $drop ) {
if ($drop) {
$sql = "DROP DATABASE IF EXISTS $dbname;";
if( ! @mysql_query($sql) ) {
throw new Exception(mysql_error());
if (! @mysql_query( $sql )) {
throw new Exception( mysql_error() );
}
}
$sql = "CREATE DATABASE IF NOT EXISTS $dbname DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;";
if( ! @mysql_query($sql) ) {
throw new Exception(mysql_error());
if (! @mysql_query( $sql )) {
throw new Exception( mysql_error() );
}
}
/**
/**
* restoreFromSql2
*
* @param string $sqlfile
*
* @return none
*/
function restoreFromSql2($sqlfile)
function restoreFromSql2 ($sqlfile)
{
ini_set('memory_limit', '512M');
if( ! is_file($sqlfile) ) {
throw new Exception("the $sqlfile doesn't exist!");
ini_set( 'memory_limit', '512M' );
if (! is_file( $sqlfile )) {
throw new Exception( "the $sqlfile doesn't exist!" );
}
$query = file_get_contents($sqlfile);
$mysqli = new mysqli($this->host, $this->user, $this->passwd, $this->dbName);
$query = file_get_contents( $sqlfile );
$mysqli = new mysqli( $this->host, $this->user, $this->passwd, $this->dbName );
/* check connection */
if( mysqli_connect_errno() ) {
printf("Connect failed: %s\n", mysqli_connect_error());
if (mysqli_connect_errno()) {
printf( "Connect failed: %s\n", mysqli_connect_error() );
exit();
}
/* execute multi query */
if( $mysqli->multi_query($query) ) {
if ($mysqli->multi_query( $query )) {
do {
/* store first result set */
if( $result = $mysqli->store_result() ) {
while( $row = $result->fetch_row() ) {
if ($result = $mysqli->store_result()) {
while ($row = $result->fetch_row()) {
}
$result->free();
}
} while( $mysqli->next_result() );
} while ($mysqli->next_result());
}
/* close connection */
$mysqli->close();
}
function lockTables() {
function lockTables ()
{
$aTables = $this->getTablesList();
if (empty($aTables))
if (empty( $aTables ))
return false;
printf("%-70s", "LOCK TABLES");
if( @mysql_query("LOCK TABLES ".implode(" READ, ", $aTables)." READ; ") ) {
printf( "%-70s", "LOCK TABLES" );
if (@mysql_query( "LOCK TABLES " . implode( " READ, ", $aTables ) . " READ; " )) {
echo " [OK]\n";
return true;
} else {
echo "[FAILED]\n".mysql_error()."\n";
echo "[FAILED]\n" . mysql_error() . "\n";
return false;
}
}
function unlockTables() {
printf("%-70s", "UNLOCK TABLES");
if( @mysql_query("UNLOCK TABLES;") )
function unlockTables ()
{
printf( "%-70s", "UNLOCK TABLES" );
if (@mysql_query( "UNLOCK TABLES;" )) {
echo " [OK]\n";
else
echo "[FAILED]\n".mysql_error()."\n";
} else {
echo "[FAILED]\n" . mysql_error() . "\n";
}
}
/**
/**
* dumpSqlInserts
*
* @param string $table
*
* @return integer $bytesSaved;
*/
function dumpSqlInserts($table)
function dumpSqlInserts ($table)
{
$bytesSaved = 0;
$result = @mysql_query("SELECT * FROM `$table`");
$result = @mysql_query( "SELECT * FROM `$table`" );
$num_rows = mysql_num_rows($result);
$num_fields = mysql_num_fields($result);
$num_rows = mysql_num_rows( $result );
$num_fields = mysql_num_fields( $result );
$data = "";
for( $i = 0; $i < $num_rows; $i ++ ) {
for ($i = 0; $i < $num_rows; $i ++) {
$row = mysql_fetch_object($result);
$row = mysql_fetch_object( $result );
$data .= "INSERT INTO `$table` VALUES (";
for( $x = 0; $x < $num_fields; $x ++ ) {
$field_name = mysql_field_name($result, $x);
for ($x = 0; $x < $num_fields; $x ++) {
$field_name = mysql_field_name( $result, $x );
$data .= ($row->$field_name === null) ? 'NULL' : "'" . mysql_real_escape_string($row->$field_name) . "'";
$data .= ($row->$field_name === null) ? 'NULL' : "'" . mysql_real_escape_string( $row->$field_name ) . "'";
$data .= ($x < ($num_fields - 1)) ? ", " : false;
}
$data .= ");\n";
}
printf("%-59s%20s", "Dump of table $table", strlen($data) . " Bytes Saved\n");
printf( "%-59s%20s", "Dump of table $table", strlen( $data ) . " Bytes Saved\n" );
return $data;
}
/**
/**
* backupDataBaseSchema
*
* @param string $outfile
*
* @return none
*/
function backupDataBase($outfile)
function backupDataBase ($outfile)
{
$aTables = $this->getTablesList();
$ws = explode('_', $this->dbName);
$ws = isset($ws[1]) ? $ws[1] : $this->dbName;
$ws = explode( '_', $this->dbName );
$ws = isset( $ws[1] ) ? $ws[1] : $this->dbName;
$schema = "\n";
$schema .= " -- Processmaker Data Base Maintenance Tool\n";
$schema .= " --\n";
$schema .= " -- Workspace: " . $ws . "\n";
$schema .= " -- Data Base: " . $this->dbName . "\n";
$schema .= " -- Tables: " . (count($aTables)) . "\n";
$schema .= " -- Date: " . (date('l jS \of F Y h:i:s A')) . "\n";
$schema .= " -- Tables: " . (count( $aTables )) . "\n";
$schema .= " -- Date: " . (date( 'l jS \of F Y h:i:s A' )) . "\n";
$schema .= " --\n\n";
$file = fopen($outfile, "w+");
$file = fopen( $outfile, "w+" );
fwrite($file, $schema);
fwrite( $file, $schema );
foreach( $aTables as $table ) {
foreach ($aTables as $table) {
$tableSchema = "\nDROP TABLE IF EXISTS `$table`;\n\n";
$tableSchema .= $this->getSchemaFromTable($table);
$data = $this->dumpSqlInserts($table);
fwrite($file, $tableSchema);
fwrite($file, $data);
$tableSchema .= $this->getSchemaFromTable( $table );
$data = $this->dumpSqlInserts( $table );
fwrite( $file, $tableSchema );
fwrite( $file, $data );
}
fclose($file);
fclose( $file );
}
/**
/**
* restoreFromSql
*
* @param string $sqlfile
*
* @return boolean false or true
*/
function restoreFromSql($sqlfile, $type='file')
function restoreFromSql ($sqlfile, $type = 'file')
{
ini_set('memory_limit', '64M');
if( $type == 'file' && !is_file($sqlfile) ) {
throw new Exception("the $sqlfile doesn't exist!");
ini_set( 'memory_limit', '64M' );
if ($type == 'file' && ! is_file( $sqlfile )) {
throw new Exception( "the $sqlfile doesn't exist!" );
}
$metaFile = str_replace('.sql', '.meta', $sqlfile);
$metaFile = str_replace( '.sql', '.meta', $sqlfile );
$queries = 0;
if( is_file($metaFile) ) {
if (is_file( $metaFile )) {
echo "Using $metaFile as metadata.\n";
$fp = fopen($sqlfile, 'rb');
$fpmd = fopen($metaFile, 'r');
while( $offset = fgets($fpmd, 1024) ) {
$buffer = intval($offset); //reading the size of $oData
$query = fread($fp, $buffer); //reading string $oData
$fp = fopen( $sqlfile, 'rb' );
$fpmd = fopen( $metaFile, 'r' );
while ($offset = fgets( $fpmd, 1024 )) {
$buffer = intval( $offset ); //reading the size of $oData
$query = fread( $fp, $buffer ); //reading string $oData
$queries += 1;
if( ! @mysql_query($query) ) {
if (! @mysql_query( $query )) {
echo mysql_error() . "\n";
echo "==>" . $query . "<==\n";
}
}
} else {
$queries = NULL;
try{
$mysqli = new mysqli($this->host, $this->user, $this->passwd, $this->dbName);
$queries = null;
try {
$mysqli = new mysqli( $this->host, $this->user, $this->passwd, $this->dbName );
/* check connection */
if( mysqli_connect_errno() ) {
printf("Connect failed: %s\n", mysqli_connect_error());
if (mysqli_connect_errno()) {
printf( "Connect failed: %s\n", mysqli_connect_error() );
exit();
}
if($type == 'file'){
$query = file_get_contents($sqlfile);
} else if($type == 'string'){
if ($type == 'file') {
$query = file_get_contents( $sqlfile );
} else if ($type == 'string') {
$query = $sqlfile;
} else {
return false;
}
if( trim($query) == "" )
if (trim( $query ) == "") {
return false;
}
/* execute multi query */
if( $mysqli->multi_query($query) ) {
if ($mysqli->multi_query( $query )) {
do {
/* store first result set */
if( $result = $mysqli->store_result() ) {
while( $row = $result->fetch_row() ) {
if ($result = $mysqli->store_result()) {
while ($row = $result->fetch_row()) {
//printf("%s\n", $row[0]);
}
$result->free();
}
/* print divider */
if( $mysqli->more_results() ) {
if ($mysqli->more_results()) {
//printf("-----------------\n");
}
} while( $mysqli->next_result() );
} else throw new Exception(mysqli_error($mysqli));
} while ($mysqli->next_result());
} else {
throw new Exception( mysqli_error( $mysqli ) );
}
/* close connection */
$mysqli->close();
} catch(Exception $e){
} catch (Exception $e) {
echo $query;
echo $e->getMessage();
}
@@ -588,44 +598,44 @@ class DataBaseMaintenance
return $queries;
}
/**
/**
* getSchemaFromTable
*
* @param string $tablename
*
* @return string $tableSchema
*/
function getSchemaFromTable($tablename)
function getSchemaFromTable ($tablename)
{
//$tableSchema = "/* Structure for table `$tablename` */\n";
//$tableSchema .= "DROP TABLE IF EXISTS `$tablename`;\n\n";
$tableSchema = "";
$sql = "show create table `$tablename`; ";
$result = @mysql_query($sql);
if( $result ) {
if( $row = mysql_fetch_assoc($result) ) {
$result = @mysql_query( $sql );
if ($result) {
if ($row = mysql_fetch_assoc( $result )) {
$tableSchema .= $row['Create Table'] . ";\n\n";
}
mysql_free_result($result);
} else
mysql_free_result( $result );
} else {
echo mysql_error();
}
return $tableSchema;
}
/**
/**
* removeCommentsIntoString
*
* @param string $str
*
* @return string $str
*/
function removeCommentsIntoString($str)
function removeCommentsIntoString ($str)
{
$str = preg_replace('/\/\*[\w\W]*\*\//', '', $str);
$str = preg_replace("/--[\w\W]*\\n/", '', $str);
$str = preg_replace("/\/\/[\w\W]*\\n/", '', $str);
$str = preg_replace("/\#[\w\W]*\\n/", '', $str);
$str = preg_replace( '/\/\*[\w\W]*\*\//', '', $str );
$str = preg_replace( "/--[\w\W]*\\n/", '', $str );
$str = preg_replace( "/\/\/[\w\W]*\\n/", '', $str );
$str = preg_replace( "/\#[\w\W]*\\n/", '', $str );
return $str;
}
}
@@ -649,11 +659,3 @@ $o2->restoreFromSql('/home/erik/backs/schema_os.sql');
$o2->restoreAllData('sql');
*/

View File

@@ -96,19 +96,22 @@ class DBConnection
function DBConnection ($strServer = DB_HOST, $strUser = DB_USER, $strPwd = DB_PASS, $strDB = DB_NAME, $type = DB_ADAPTER, $strPort = 0, $errorLevel = 2)
{
$this->errorLevel = $errorLevel;
if ($type == null)
if ($type == null) {
$type = 'mysql';
}
$this->type = $type;
//print "<hr>$type $strServer, $strUser, $strPwd, $strDB <hr>";
if ($type == "mysql")
if ($type == "mysql") {
$dsn = "mysql://$strUser:$strPwd@$strServer/$strDB";
}
if ($type == "pgsql") {
//$dsn = "pgsql://postgres@$strServer/$strDB";
$prt = ($strPort == 0 || $strPort == 5432 ? '' : ":$strPort");
$dsn = "pgsql://$strUser:$strPwd@$strServer$prt/$strDB";
}
if ($type == "odbc")
if ($type == "odbc") {
$dsn = "odbc://$strUser:$strPwd@$strServer/$strDB";
}
if ($type == "mssql") {
$strServer = substr( $strServer, 0, strpos( $strServer, ':' ) );
$prt = ($strPort == 0 || $strPort == 1433 ? '' : ":$strPort");
@@ -179,7 +182,7 @@ class DBConnection
* @param string $errorLevel
* @return void
*/
function logError ($obj, $errorLevel = NULL)
function logError ($obj, $errorLevel = null)
{
global $_SESSION;
global $_SERVER;

View File

@@ -1,6 +1,8 @@
<?php
/**
* class.dbrecordset.php
*
* @package gulliver.system
*
* ProcessMaker Open Source Edition
@@ -24,9 +26,10 @@
*
*/
/**
/**
* DBRecordset class definition
* Provides access to a generalized table it assumes that the dbconnection object is already initialized for the table should be also provided in order to provide
*
* @package gulliver.system
*
* @author Fernando Ontiveros Lira <fernando@colosa.com>
@@ -44,7 +47,7 @@ class DBRecordSet
* @param string $intResult Database recordset default value = false
* @return void
*/
function DBRecordSet( $intResult = null )
function DBRecordSet ($intResult = null)
{
$this->SetTo( $intResult );
}
@@ -57,31 +60,28 @@ class DBRecordSet
* @param string $intResult connection string default value = false
* @return void
*/
function SetTo( $intResult = null )
function SetTo ($intResult = null)
{
if ( $intResult === null ) {
$dberror = PEAR::raiseError(null, DB_ERROR_OBJECT_NOT_DEFINED, null, 'null',
"You tried to call to a DBRecordset with an invalid result recordset.",
'G_Error', true);
if ($intResult === null) {
$dberror = PEAR::raiseError( null, DB_ERROR_OBJECT_NOT_DEFINED, null, 'null', "You tried to call to a DBRecordset with an invalid result recordset.", 'G_Error', true );
DBconnection::logError( $dberror );
}
if ( $intResult ) {
if ($intResult) {
$this->result = $intResult;
}
}
/**
* Function Free
*
* @author David S. Callizaya S. <davidsantos@colosa.com>
* @access public
* @return string
*/
function Free()
function Free ()
{
if ( $this->result === null ) {
$dberror = PEAR::raiseError(null, DB_ERROR_OBJECT_NOT_DEFINED, null, 'null',
"You tried to call to a DBRecordset with an invalid result recordset.",
'G_Error', true);
if ($this->result === null) {
$dberror = PEAR::raiseError( null, DB_ERROR_OBJECT_NOT_DEFINED, null, 'null', "You tried to call to a DBRecordset with an invalid result recordset.", 'G_Error', true );
DBconnection::logError( $dberror );
}
$this->result->free();
@@ -90,16 +90,15 @@ class DBRecordSet
/**
* Function Count
*
* @author David S. Callizaya S. <davidsantos@colosa.com>
* @access public
* @return string
*/
function Count()
function Count ()
{
if ( $this->result === null ) {
$dberror = PEAR::raiseError(null, DB_ERROR_OBJECT_NOT_DEFINED, null, 'null',
"You tried to call to a DBRecordset with an invalid result recordset.",
'G_Error', true);
if ($this->result === null) {
$dberror = PEAR::raiseError( null, DB_ERROR_OBJECT_NOT_DEFINED, null, 'null', "You tried to call to a DBRecordset with an invalid result recordset.", 'G_Error', true );
DBconnection::logError( $dberror );
}
return $this->result->numRows();
@@ -107,22 +106,22 @@ class DBRecordSet
/**
* Function Read
*
* @author David S. Callizaya S. <davidsantos@colosa.com>
* @access public
* @return string
*/
function Read()
function Read ()
{
if ( $this->result === null ) {
$dberror = PEAR::raiseError(null, DB_ERROR_OBJECT_NOT_DEFINED, null, 'null',
"You tried to call to a DBRecordset with an invalid result recordset.",
'G_Error', true);
if ($this->result === null) {
$dberror = PEAR::raiseError( null, DB_ERROR_OBJECT_NOT_DEFINED, null, 'null', "You tried to call to a DBRecordset with an invalid result recordset.", 'G_Error', true );
DBconnection::logError( $dberror );
}
$res = $this->result->fetchRow(DB_FETCHMODE_ASSOC);
$res = $this->result->fetchRow( DB_FETCHMODE_ASSOC );
//for Pgsql databases,
//if ( PEAR_DATABASE == "pgsql" && is_array ( $res ) ) { $res = array_change_key_case( $res, CASE_UPPER); }
/* Comment Code: This block is not required now because
* of the the use of the G::sqlEscape() instead of addslashes
* funcion over each field in DBTable.
@@ -137,15 +136,17 @@ class DBRecordSet
/**
* Function ReadAbsolute
*
* @author David S. Callizaya S. <davidsantos@colosa.com>
* @access public
* @return string
*/
function ReadAbsolute()
function ReadAbsolute ()
{
$res = $this->result->fetchRow(DB_FETCHMODE_ORDERED);
$res = $this->result->fetchRow( DB_FETCHMODE_ORDERED );
//for Pgsql databases,
//if ( PEAR_DATABASE == "pgsql" && is_array ( $res ) ) { $res = array_change_key_case( $res, CASE_UPPER); }
return $res;
}
}

View File

@@ -1,6 +1,8 @@
<?php
/**
* class.dbsession.php
*
* @package gulliver.system
*
* ProcessMaker Open Source Edition
@@ -24,9 +26,10 @@
*
*/
/**
/**
* DBSession class definition
* It is useful to stablish a database connection using an specific database
*
* @package gulliver.system
* @author Fernando Ontiveros Lira <fernando@colosa.com>
* @copyright (C) 2002 by Colosa Development Team.
@@ -34,12 +37,13 @@
*/
class DBSession
{
var $dbc = NULL;
var $dbc = null;
var $dbname = '';
var $result = false;
/**
* Starts a session using a connection with an specific database
*
* @author Fernando Ontiveros Lira <fernando@colosa.com>
*
* @access public
@@ -48,15 +52,17 @@ class DBSession
* @return void
*
*/
function DBSession( $objConnection = NULL, $strDBName = '' )
function DBSession ($objConnection = null, $strDBName = '')
{
if ($strDBName!='') $strDBName = $objConnection->db->_db;
if ($strDBName != '') {
$strDBName = $objConnection->db->_db;
}
$this->setTo( $objConnection, $strDBName );
}
/**
* It's like a constructor
*
* @author Fernando Ontiveros Lira <fernando@colosa.com>
*
* @access public
@@ -65,24 +71,23 @@ class DBSession
* @return void
*
*/
function setTo( $objConnection = NULL, $strDBName = DB_NAME )
{
if ( $objConnection != NULL )
function setTo ($objConnection = null, $strDBName = DB_NAME)
{
if ($objConnection != null) {
$this->Free();
$this->dbc = $objConnection;
$this->dbname = $strDBName;
//enable utf8 in mysql databases
if ( $this->dbc->db->phptype == 'mysql' ) { //utf-8
$this->dbc->db->query ( "SET NAMES 'utf8'; " );
if ($this->dbc->db->phptype == 'mysql') { //utf-8
$this->dbc->db->query( "SET NAMES 'utf8'; " );
}
}
}
/**
* UseDB stablish a database for the connection
*
* @author Fernando Ontiveros Lira <fernando@colosa.com>
*
* @access public
@@ -90,39 +95,40 @@ class DBSession
* @return void
*
*/
function UseDB( $strDBName = DB_NAME )
function UseDB ($strDBName = DB_NAME)
{
$this->dbname = $strDBName;
}
/**
* Function Execute, to execute a query and send back the recordset.
*
* @access public
* @parameter string strQuery
* @parameter string debug
* @parameter string error
* @param eter string strQuery
* @param eter string debug
* @param eter string error
* @return string
*/
function Execute( $strQuery = '', $debug = false, $errorLevel = null )
function Execute ($strQuery = '', $debug = false, $errorLevel = null)
{
//BUG::traceRoute();
if ($this->dbc == NULL ) {
$dberror = PEAR::raiseError(null, DB_ERROR_OBJECT_NOT_DEFINED, null, 'null',
'You have tried to call a DBSession function without create an instance of DBConnection',
'G_Error', true);
if ($this->dbc == null) {
$dberror = PEAR::raiseError( null, DB_ERROR_OBJECT_NOT_DEFINED, null, 'null', 'You have tried to call a DBSession function without create an instance of DBConnection', 'G_Error', true );
DBconnection::logError( $dberror, $errorLevel );
return $dberror;
};
if ( $errorLevel === null ) $errorLevel = $this->dbc->errorLevel;
}
;
if ($errorLevel === null) {
$errorLevel = $this->dbc->errorLevel;
}
$this->Free( true );
if( $debug ) {
print( $strQuery . "<br>\n" );
if ($debug) {
print ($strQuery . "<br>\n") ;
}
$this->result = $this->dbc->db->query ( $strQuery );
if (DB::isError ($this->result)) {
$this->result = $this->dbc->db->query( $strQuery );
if (DB::isError( $this->result )) {
$this->dbc->logError( $this->result, $errorLevel );
return $this->result;
}
@@ -132,13 +138,14 @@ class DBSession
/**
* Function Query, just to execute the query.
*
* @access public
* @parameter string strQuery
* @parameter string debug
* @parameter string error
* @param eter string strQuery
* @param eter string debug
* @param eter string error
* @return string
*/
/* function deprecated... by Onti, 30th july 2007
/* function deprecated... by Onti, 30th july 2007
function Query( $strQuery = '', $debug = false, $error = '' )
{
if ( $error == '' && defined('ERROR_STATE') ) {
@@ -160,20 +167,21 @@ class DBSession
die;
}
return;
}
*/
/**
* Function Free
*
* @access public
* @parameter string debug
* @param eter string debug
* @return string
*/
function Free( $debug = false )
function Free ($debug = false)
{
if ( is_resource($this->result) )
if (is_resource( $this->result )) {
$this->result->Free();
}
return;
}
}

View File

@@ -1,6 +1,8 @@
<?php
/**
* class.dbtable.php
*
* @package gulliver.system
*
* ProcessMaker Open Source Edition
@@ -29,6 +31,7 @@
* This class provides acces to a generalized table
* it assumes that the dbconnection object is already initialized, the table name, as well as the primary keys
* for the table should be also provided in order to provide the class a way to generate an UPDATE query properly.
*
* @package gulliver.system
* @author Fernando Ontiveros Lira <fernando@colosa.com>
* @copyright (C) 2002 by Colosa Development Team.
@@ -46,7 +49,7 @@ class DBTable
var $errorLevel;
var $debug = false;
/**
/**
* Initiate a database conecction using default values
*
* @author Fernando Ontiveros Lira <fernando@colosa.com>
@@ -54,14 +57,13 @@ class DBTable
* @param object $objConnection conecction string
* @return void
*/
function dBTable( $objConnection = NULL, $strTable = "", $arrKeys = array( 'UID' ) )
function dBTable ($objConnection = null, $strTable = "", $arrKeys = array( 'UID' ))
{
$this->_dbc = NULL;
$this->_dbses = NULL;
$this->_dbc = null;
$this->_dbses = null;
$this->SetTo( $objConnection, $strTable, $arrKeys );
}
/**
* Initiate a database conecction using default values
*
@@ -72,68 +74,60 @@ class DBTable
* @param array $arrKeys table keys defaultvalue=UID
* @return void
*/
function setTo( $objDBConnection, $strTable = "", $arrKeys = array( 'UID' ) )
function setTo ($objDBConnection, $strTable = "", $arrKeys = array( 'UID' ))
{
$this->_dbc = $objDBConnection;
if( $this->_dbc != NULL && strcasecmp( get_class( $objDBConnection ) , 'dbconnection' ) == 0 )
{
if ($this->_dbc != null && strcasecmp( get_class( $objDBConnection ), 'dbconnection' ) == 0) {
$this->_dbses = new DBSession( $this->_dbc );
$this->_dbses->UseDB( DB_NAME );
}
else {
$dberror = PEAR::raiseError(null, DB_ERROR_OBJECT_NOT_DEFINED, null, 'null',
"You tried to call to a DBTable function without create an instance of DBConnection",
'G_Error', true);
} else {
$dberror = PEAR::raiseError( null, DB_ERROR_OBJECT_NOT_DEFINED, null, 'null', "You tried to call to a DBTable function without create an instance of DBConnection", 'G_Error', true );
//DBconnection::logError( $dberror );
return $dberror;
}
$this->is_new = true;
$this->Fields = NULL;
$this->Fields = null;
$this->table_name = $strTable;
if ( is_array ( $arrKeys ) )
if (is_array( $arrKeys )) {
$this->table_keys = $arrKeys;
else
$this->table_keys = array ( 0 => $arrKeys );
} else {
$this->table_keys = array (0 => $arrKeys
);
}
$this->errorLevel = $this->_dbc->errorLevel;
}
/**
/**
* Loads full description of a referenced table in Fields
*
* @author Fernando Ontiveros Lira <fernando@colosa.com>
* @access public
* @return void
*/
function loadEmpty()
function loadEmpty ()
{
$stQry = "DESCRIBE `" . $this->table_name. "`";
$stQry = "DESCRIBE `" . $this->table_name . "`";
$dset = $this->_dbses->execute( $stQry );
//$dset = new DBRecordSet( $this->_dbses->Result );
$nlim = $dset->Count();
$this->Fields = NULL;
for( $ncount = 0; $ncount < $nlim; $ncount++ )
{
$this->Fields = null;
for ($ncount = 0; $ncount < $nlim; $ncount ++) {
$data = $dset->Read();
$fname = $data['Field'];
$fval = "";
$ftypearr = explode($data['Type'], '(' );
$ftypearr = explode( $data['Type'], '(' );
$ftype = $ftypearr[0];
if( $data['Key'] == 'PRI' )
{
if( is_array($this->table_keys) )
{
if ($data['Key'] == 'PRI') {
if (is_array( $this->table_keys )) {
$this->table_keys[count( $this->table_keys ) - 1] = $fname;
}
else
{
} else {
$this->table_keys[0] = $fname;
}
}
switch( $ftype )
{
switch ($ftype) {
case 'int':
case 'smallint':
case 'tinyint':
@@ -145,12 +139,12 @@ class DBTable
break;
}
$this->Fields[ $fname ] = $fval;
$this->Fields[ $ncount ] = &$this->Fields[ $fname ];
$this->Fields[$fname] = $fval;
$this->Fields[$ncount] = &$this->Fields[$fname];
}
}
/**
/**
* Return specified field on the referenced table
*
* @author Fernando Ontiveros Lira <fernando@colosa.com>
@@ -158,32 +152,31 @@ class DBTable
* @param string $strWhere string which contains conditions
* @return strint
*/
function loadWhere( $strWhere )
function loadWhere ($strWhere)
{
$this->Fields = NULL;
$this->Fields = null;
$stQry = "SELECT * FROM `" . $this->table_name . "`";
if( $strWhere != "" ) $stQry .= " WHERE " . $strWhere;
$this->_dset = $this->_dbses->Execute ( $stQry , $this->debug, $this->errorLevel);
if (DB::isError ($this->_dset)) {
if ($strWhere != "") {
$stQry .= " WHERE " . $strWhere;
}
$this->_dset = $this->_dbses->Execute( $stQry, $this->debug, $this->errorLevel );
if (DB::isError( $this->_dset )) {
return $this->_dset;
}
if( $this->_dset->Count() > 0 ){
if ($this->_dset->Count() > 0) {
$this->Fields = $this->_dset->Read();
$this->is_new = false;
}
else
{
$this->Fields = NULL;
} else {
$this->Fields = null;
$this->is_new = true;
}
return $this->Fields;
}
/**
/**
* Return all fields on the referenced table
*
* @author Fernando Ontiveros Lira <fernando@colosa.com>
@@ -191,32 +184,28 @@ class DBTable
* @param array array of arguments key values
* @return void
*/
function load()
function load ()
{
// bug::traceRoute();
// bug::traceRoute();
$ncount = 0;
$stWhere = "";
$arrKeys = func_get_args();
if ( isset($arrKeys[0]) && is_array ($arrKeys[0] ) ) {
foreach ($this->table_keys as $key=>$val) {
if( $stWhere == "" ){
$stWhere .= " $val = '" . $arrKeys[0][ $val ] . "' ";
}else
$stWhere .= " AND $val = '" . $arrKeys[0][ $val ] . "' ";
if (isset( $arrKeys[0] ) && is_array( $arrKeys[0] )) {
foreach ($this->table_keys as $key => $val) {
if ($stWhere == "") {
$stWhere .= " $val = '" . $arrKeys[0][$val] . "' ";
} else {
$stWhere .= " AND $val = '" . $arrKeys[0][$val] . "' ";
}
}
else {
foreach( $arrKeys as $val )
{
if( $stWhere == "" )
{
} else {
foreach ($arrKeys as $val) {
if ($stWhere == "") {
$stWhere .= $this->table_keys[$ncount] . "='" . $val . "'";
}
else
{
} else {
$stWhere .= " AND " . $this->table_keys[$ncount] . "='" . $val . "'";
}
$ncount++;
$ncount ++;
}
}
return $this->LoadWhere( $stWhere );
@@ -224,21 +213,22 @@ class DBTable
/**
* Function nextvalPGSql
*
* @author David S. Callizaya S. <davidsantos@colosa.com>
* @access public
* @parameter string seq
* @param eter string seq
* @return string
*/
function nextvalPGSql( $seq )
function nextvalPGSql ($seq)
{
$stQry = " Select NEXTVAL( '$seq' ) ";
$dset = $this->_dbses->Execute( $stQry );
$row = $dset->Read();
if ( is_array ($row) ) {
if (is_array( $row )) {
return $row['NEXTVAL'];
}
die ("Sequence '$seq' is not exist!!");
return -1;
die( "Sequence '$seq' is not exist!!" );
return - 1;
}
/**
@@ -247,34 +237,37 @@ class DBTable
* @author Fernando Ontiveros Lira <fernando@colosa.com>
* @access public
* @return boolean
*
*/
function insert () {
function insert ()
{
$strFields = "";
$strValues = "";
if( defined('DB_ADAPTER'))
if (defined( 'DB_ADAPTER' )) {
$DBEngine = DB_ADAPTER;
else
} else {
$DBEngine = 'mysql';
foreach( $this->Fields as $field => $val ) {
}
foreach ($this->Fields as $field => $val) {
$strFields .= $field . ",";
$iskey = false;
if ( isset ( $this->table_keys ) && is_array ( $this->table_keys ) )
$iskey = in_array( $field, $this->table_keys ) && strtoupper(substr(trim($val),0,7) ) == "NEXTVAL";
$dbcType = isset ( $this->_dbc->type ) ? $this->_dbc->type : $DBEngine;
// Commented by new format of textarea in javascript
if( ! $iskey )
$val = "'" . $val . "'";
///-- $val = "'" . G::sqlEscape( $val , $dbcType ) . "'";
$strValues .= $val .", ";
if (isset( $this->table_keys ) && is_array( $this->table_keys )) {
$iskey = in_array( $field, $this->table_keys ) && strtoupper( substr( trim( $val ), 0, 7 ) ) == "NEXTVAL";
}
$strFields = substr( $strFields , 0, strlen($strFields)-1 );
$strValues = substr( $strValues , 0, strlen($strValues)-1 );
$dbcType = isset( $this->_dbc->type ) ? $this->_dbc->type : $DBEngine;
// Commented by new format of textarea in javascript
if (! $iskey) {
$val = "'" . $val . "'";
}
///-- $val = "'" . G::sqlEscape( $val , $dbcType ) . "'";
$strValues .= $val . ", ";
}
$strFields = substr( $strFields, 0, strlen( $strFields ) - 1 );
$strValues = substr( $strValues, 0, strlen( $strValues ) - 1 );
$stQry = "INSERT INTO `" . $this->table_name . "` ( " . $strFields . " ) values ( " . $strValues . " ) ";
$result = $this->_dbses->Execute( $stQry , $this->debug);
$result = $this->_dbses->Execute( $stQry, $this->debug );
return $result;
}
@@ -285,54 +278,60 @@ class DBTable
* @access public
* @return boolean
*/
function update()
function update ()
{
$stQry = "";
$stWhere = '';
$remainKeys = array();
$remainKeys = array ();
if(defined('DB_ADAPTER'))
if (defined( 'DB_ADAPTER' )) {
$DBEngine = DB_ADAPTER;
else
} else {
$DBEngine = 'mysql';
}
foreach ( $this->table_keys as $k => $v ) $remainKeys[ $v ] = false;
foreach( $this->Fields as $field => $val )
{
foreach ($this->table_keys as $k => $v) {
$remainKeys[$v] = false;
}
foreach ($this->Fields as $field => $val) {
$iskey = false;
$iskey = in_array( $field, $this->table_keys );
if( $iskey == false ) {
if ($iskey == false) {
$stQry .= $field . "='" . $val . "', ";
// Commented by new format of textarea in javascript
///-- $stQry .= $field . "='" . G::sqlEscape ( $val, isset( $this->_dbc->type) ? $this->_dbc->type : $DBEngine ) . "', ";
} else {
if ($stWhere == "") {
$stWhere .= $field . "='" . G::sqlEscape( $val, isset( $this->_dbc->type ) ? $this->_dbc->type : $DBEngine ) . "'";
} else {
$stWhere .= " AND " . $field . "='" . G::sqlEscape( $val, isset( $this->_dbc->type ) ? $this->_dbc->type : $DBEngine ) . "'";
}
else {
if( $stWhere == "" ) {
$stWhere .= $field . "='" . G::sqlEscape ( $val, isset( $this->_dbc->type) ? $this->_dbc->type : $DBEngine ) . "'";
}
else {
$stWhere .= " AND " . $field . "='" . G::sqlEscape ( $val, isset( $this->_dbc->type) ? $this->_dbc->type : $DBEngine ) . "'";
}
$remainKeys[ $field ] = true;
$remainKeys[$field] = true;
}
}
foreach( $remainKeys as $field => $bool )
if ( $bool == false) {
if( $stWhere != "" ) $stWhere = " AND ";
foreach ($remainKeys as $field => $bool)
if ($bool == false) {
if ($stWhere != "") {
$stWhere = " AND ";
}
$stWhere .= $field . "= ''";
$remainKeys[ $field ] = true;
$remainKeys[$field] = true;
}
$stQry = trim( $stQry );
$stQry = substr( $stQry , 0, strlen($stQry)-1 ); //to remove the last comma ,
if (!$stQry) return;
$stQry = substr( $stQry, 0, strlen( $stQry ) - 1 ); //to remove the last comma ,
if (! $stQry) {
return;
}
$stQry = "UPDATE `" . $this->table_name . "` SET " . $stQry;
$stWhere = trim( $stWhere );
if( $stWhere != "" ) $stQry .= " WHERE " . $stWhere;
if ($stWhere != "") {
$stQry .= " WHERE " . $stWhere;
}
$result = false;
$result = $this->_dbses->execute( $stQry , $this->debug, $this->errorLevel );
$result = $this->_dbses->execute( $stQry, $this->debug, $this->errorLevel );
$this->is_new = false;
return $result;
}
@@ -346,13 +345,14 @@ class DBTable
* @access public
* @return boolean
*/
function save()
function save ()
{
if ( $this->is_new == true )
if ($this->is_new == true) {
return $this->Insert();
else
} else {
return $this->Update();
}
}
/**
* Delete an existing row
@@ -361,53 +361,53 @@ class DBTable
* @access public
* @return boolean
*/
function delete()
function delete ()
{
$stQry = "delete from `" . $this->table_name . "` ";
$stWhere = '';
$remainKeys = array();
if(defined('DB_ADAPTER'))
$remainKeys = array ();
if (defined( 'DB_ADAPTER' )) {
$DBEngine = DB_ADAPTER;
else
} else {
$DBEngine = 'mysql';
foreach ( $this->table_keys as $k => $v ) $remainKeys[ $v ] = false;
if ( is_array ( $this->Fields ) ) {
foreach( $this->Fields as $field => $val )
{
}
foreach ($this->table_keys as $k => $v) {
$remainKeys[$v] = false;
}
if (is_array( $this->Fields )) {
foreach ($this->Fields as $field => $val) {
$iskey = false;
$iskey = in_array( $field, $this->table_keys );
if( $iskey == true ) {
if( $stWhere == "" ) {
$stWhere .= $field . "='" . G::sqlEscape ( $val, isset( $this->_dbc->type) ? $this->_dbc->type : $DBEngine ) . "'";
if ($iskey == true) {
if ($stWhere == "") {
$stWhere .= $field . "='" . G::sqlEscape( $val, isset( $this->_dbc->type ) ? $this->_dbc->type : $DBEngine ) . "'";
} else {
$stWhere .= " AND " . $field . "='" . G::sqlEscape( $val, isset( $this->_dbc->type ) ? $this->_dbc->type : $DBEngine ) . "'";
}
else {
$stWhere .= " AND " . $field . "='" . G::sqlEscape ( $val, isset( $this->_dbc->type) ? $this->_dbc->type : $DBEngine ) . "'";
}
$remainKeys[ $field ] = true;
$remainKeys[$field] = true;
}
}
}
foreach( $remainKeys as $field => $bool )
if ( $bool == false) {
if( $stWhere != "" ) $stWhere .= " AND ";
foreach ($remainKeys as $field => $bool)
if ($bool == false) {
if ($stWhere != "") {
$stWhere .= " AND ";
}
$stWhere .= $field . "= ''";
$remainKeys[ $field ] = true;
$remainKeys[$field] = true;
}
$stQry = trim( $stQry );
$stWhere = trim( $stWhere );
if ( $stWhere == '' ) {
$dberror = PEAR::raiseError(null, G_ERROR_WARNING_MESSAGE, null, 'null',
"You tried to call delete method without WHERE clause, if you want to delete all records use dbsession",
'G_Error', true);
if ($stWhere == '') {
$dberror = PEAR::raiseError( null, G_ERROR_WARNING_MESSAGE, null, 'null', "You tried to call delete method without WHERE clause, if you want to delete all records use dbsession", 'G_Error', true );
DBconnection::logError( $dberror, $this->errorLevel );
return $dberror;
}
$stQry .= " WHERE " . $stWhere;
$result = $this->_dbses->execute( $stQry , $this->debug, $this->errorLevel );
$result = $this->_dbses->execute( $stQry, $this->debug, $this->errorLevel );
$this->is_new = false;
return $result;
}
@@ -421,8 +421,9 @@ class DBTable
* @access public
* @return boolean
*/
function next()
function next ()
{
$this->Fields = $this->_dset->read ();
$this->Fields = $this->_dset->read();
}
}

View File

@@ -1,19 +1,23 @@
<?php
/**
* HttpProxyController
*
* @author Erik Amaru Ortiz <erik@colosa.com, aortiz.erik@gmail.com>
* @package gulliver.system
* @access private
*/
class HttpProxyController {
class HttpProxyController
{
/**
*
* @var array - private array to store proxy data
*/
private $__data__ = array();
private $__data__ = array ();
/**
*
* @var object - private object to store the http request data
*/
private $__request__;
@@ -21,13 +25,15 @@ class HttpProxyController {
public $jsonResponse = true;
private $sendResponse = true;
/**
* Magic setter method
*
* @param string $name
* @param string $value
*/
public function __set($name, $value) {
public function __set ($name, $value)
{
//echo "Setting '$name' to '$value'\n";
$this->__data__[$name] = $value;
}
@@ -38,9 +44,10 @@ class HttpProxyController {
* @param string $name
* @return string or NULL if the internal var doesn't exist
*/
public function __get($name) {
public function __get ($name)
{
//echo "Getting '$name'\n";
if (array_key_exists($name, $this->__data__)) {
if (array_key_exists( $name, $this->__data__ )) {
return $this->__data__[$name];
}
@@ -58,20 +65,21 @@ class HttpProxyController {
*
* @param string $name
*/
public function __isset($name) {
public function __isset ($name)
{
//echo "Is '$name' set?\n";
return isset($this->__data__[$name]);
return isset( $this->__data__[$name] );
}
/**
* Magic unset method
*
* @param string $name
*/
public function __unset($name) {
public function __unset ($name)
{
//echo "Unsetting '$name'\n";
unset($this->__data__[$name]);
unset( $this->__data__[$name] );
}
/**
@@ -79,36 +87,45 @@ class HttpProxyController {
*
* @param string $name
*/
public function call($name)
public function call ($name)
{
try {
$result = $this->$name($this->__request__);
$result = $this->$name( $this->__request__ );
if (!$this->jsonResponse) {
if (! $this->jsonResponse) {
return null;
}
if( ! $result )
if (! $result) {
$result = $this->__data__;
}
} catch (Exception $e) {
$result->success = false;
$result->message = $result->msg = $e->getMessage();
switch(get_class($e)) {
case 'Exception': $error = "SYSTEM ERROR"; break;
case 'PMException': $error = "PROCESSMAKER ERROR"; break;
case 'PropelException': $error = "DATABASE ERROR"; break;
case 'UserException': $error = "USER ERROR"; break;
switch (get_class( $e )) {
case 'Exception':
$error = "SYSTEM ERROR";
break;
case 'PMException':
$error = "PROCESSMAKER ERROR";
break;
case 'PropelException':
$error = "DATABASE ERROR";
break;
case 'UserException':
$error = "USER ERROR";
break;
}
$result->error = $e->getMessage();
$result->exception->class = get_class($e);
$result->exception->class = get_class( $e );
$result->exception->code = $e->getCode();
$result->exception->trace = $e->getTraceAsString();
}
if ($this->sendResponse) {
print G::json_encode($result);
print G::json_encode( $result );
}
}
@@ -117,16 +134,18 @@ class HttpProxyController {
*
* @param array $data
*/
public function setHttpRequestData($data)
public function setHttpRequestData ($data)
{
if( is_array($data) ) {
while( $var = each($data) )
if (is_array( $data )) {
while ($var = each( $data )) {
$this->__request__->$var['key'] = $var['value'];
} else
}
} else {
$this->__request__ = $data;
}
}
public function setJsonResponse($bool)
public function setJsonResponse ($bool)
{
$this->jsonResponse = $bool;
}
@@ -136,8 +155,9 @@ class HttpProxyController {
*
* @param boolean $val
*/
public function setSendResponse($val)
public function setSendResponse ($val)
{
$this->sendResponse = $val;
}
}

View File

@@ -1,6 +1,8 @@
<?php
/**
* class.dbtable.php
*
* @package gulliver.system
*
* ProcessMaker Open Source Edition
@@ -24,7 +26,7 @@
*
*/
/**
/**
* i18n_PO
* This class build biggers PO files without size limit and this not use much memory that the allowed
*
@@ -36,7 +38,7 @@
class i18n_PO
{
private $_file = NULL;
private $_file = null;
private $_string = '';
private $_meta;
private $_fp;
@@ -56,150 +58,160 @@ class i18n_PO
public $flags;
public $previousUntranslatedStrings;
function __construct($file)
function __construct ($file)
{
$this->file = $file;
}
function buildInit()
function buildInit ()
{
$this->_fp = fopen($this->file, 'w');
$this->_fp = fopen( $this->file, 'w' );
if ( ! is_resource($this->_fp) ) {
throw new Exception('Could\'t open ' . $this->file . ' file');
if (! is_resource( $this->_fp )) {
throw new Exception( 'Could\'t open ' . $this->file . ' file' );
}
// lock PO file exclusively
if ( ! flock($this->_fp, LOCK_EX) ) {
fclose($this->_fp);
return FALSE;
if (! flock( $this->_fp, LOCK_EX )) {
fclose( $this->_fp );
return false;
}
$this->_meta = 'msgid ""';
$this->_writeLine($this->_meta);
$this->_writeLine( $this->_meta );
$this->_meta = 'msgstr ""';
$this->_writeLine($this->_meta);
$this->_writeLine( $this->_meta );
$this->_editingHeader = TRUE;
$this->_editingHeader = true;
}
function readInit(){
$this->_fp = fopen($this->file, 'r');
function readInit ()
{
$this->_fp = fopen( $this->file, 'r' );
if ( ! is_resource($this->_fp) ) {
throw new Exception('Could\'t open ' . $this->file . ' file');
if (! is_resource( $this->_fp )) {
throw new Exception( 'Could\'t open ' . $this->file . ' file' );
}
//skipping comments
$this->skipCommets();
//deaing headers
$this->readHeaders();
$this->translatorComments = Array();
$this->extractedComments = Array();
$this->references = Array();
$this->flags = Array();
$this->previousUntranslatedStrings = Array();
$this->translatorComments = Array ();
$this->extractedComments = Array ();
$this->references = Array ();
$this->flags = Array ();
$this->previousUntranslatedStrings = Array ();
}
function addHeader($id, $value)
function addHeader ($id, $value)
{
if( $this->_editingHeader ) {
$meta = '"'.trim($id).': '.trim($value).'\n"';
$this->_writeLine($meta);
if ($this->_editingHeader) {
$meta = '"' . trim( $id ) . ': ' . trim( $value ) . '\n"';
$this->_writeLine( $meta );
}
}
function addTranslatorComment($str)
function addTranslatorComment ($str)
{
$this->headerStroke();
$comment = '# ' . trim($str);
$this->_writeLine($comment);
$comment = '# ' . trim( $str );
$this->_writeLine( $comment );
}
function addExtractedComment($str)
function addExtractedComment ($str)
{
$this->headerStroke();
$comment = '#. ' . trim($str);
$this->_writeLine($comment);
$comment = '#. ' . trim( $str );
$this->_writeLine( $comment );
}
function addReference($str)
function addReference ($str)
{
$this->headerStroke();
$reference = '#: ' . trim($str);
$this->_writeLine($reference);
$reference = '#: ' . trim( $str );
$this->_writeLine( $reference );
}
function addFlag($str)
function addFlag ($str)
{
$this->headerStroke();
$flag = '#, ' . trim($str);
$this->_writeLine($flag);
$flag = '#, ' . trim( $str );
$this->_writeLine( $flag );
}
function addPreviousUntranslatedString($str)
function addPreviousUntranslatedString ($str)
{
$this->headerStroke();
$str = '#| ' . trim($str);
$this->_writeLine($str);
$str = '#| ' . trim( $str );
$this->_writeLine( $str );
}
function addTranslation($msgid, $msgstr)
function addTranslation ($msgid, $msgstr)
{
$this->headerStroke();
$this->_writeLine('msgid "' . $this->prepare($msgid, true) . '"');
$this->_writeLine('msgstr "' . $this->prepare($msgstr, true) . '"');
$this->_writeLine('');
$this->_writeLine( 'msgid "' . $this->prepare( $msgid, true ) . '"' );
$this->_writeLine( 'msgstr "' . $this->prepare( $msgstr, true ) . '"' );
$this->_writeLine( '' );
}
function _writeLine($str)
function _writeLine ($str)
{
$this->_write($str . "\n");
$this->_write( $str . "\n" );
}
function _write($str)
function _write ($str)
{
fwrite($this->_fp, $str);
fwrite( $this->_fp, $str );
}
function prepare($string, $reverse = false)
function prepare ($string, $reverse = false)
{
//$string = str_replace('\"', '"', $string);
//$string = stripslashes($string);
if ($reverse) {
$smap = array('"', "\n", "\t", "\r");
$rmap = array('\"', '\\n"' . "\n" . '"', '\\t', '\\r');
return (string) str_replace($smap, $rmap, $string);
$smap = array ('"',"\n","\t","\r"
);
$rmap = array ('\"','\\n"' . "\n" . '"','\\t','\\r'
);
return (string) str_replace( $smap, $rmap, $string );
} else {
$string = preg_replace('/"\s+"/', '', $string);
$smap = array('\\n', '\\r', '\\t', '\"');
$rmap = array("\n", "\r", "\t", '"');
return (string) str_replace($smap, $rmap, $string);
$string = preg_replace( '/"\s+"/', '', $string );
$smap = array ('\\n','\\r','\\t','\"'
);
$rmap = array ("\n","\r","\t",'"'
);
return (string) str_replace( $smap, $rmap, $string );
}
}
function headerStroke()
function headerStroke ()
{
if( $this->_editingHeader ) {
$this->_editingHeader = FALSE;
$this->_writeLine('');;
if ($this->_editingHeader) {
$this->_editingHeader = false;
$this->_writeLine( '' );
;
}
}
/** read funtions **/
private function skipCommets(){
/**
* read funtions *
*/
private function skipCommets ()
{
$this->_fileComments = '';
do {
$lastPos = ftell($this->_fp);
$line = fgets($this->_fp);
$lastPos = ftell( $this->_fp );
$line = fgets( $this->_fp );
$this->_fileComments .= $line;
} while( (substr($line, 0, 1) == '#' || trim($line) == '') && ! feof($this->_fp) );
} while ((substr( $line, 0, 1 ) == '#' || trim( $line ) == '') && ! feof( $this->_fp ));
fseek($this->_fp, $lastPos);
fseek( $this->_fp, $lastPos );
}
private function readHeaders()
private function readHeaders ()
{
$this->flagEndHeaders = false;
$this->flagError = false;
@@ -207,17 +219,18 @@ class i18n_PO
$this->lineNumber = 0;
$errMsg = '';
while( ! $this->flagError && ! $this->flagEndHeaders ) {
while (! $this->flagError && ! $this->flagEndHeaders) {
if( $this->flagInit ) { //in first instance
if ($this->flagInit) { //in first instance
$this->flagInit = false; //unset init flag
//read the first and second line of the file
$firstLine = fgets($this->_fp);
$secondLine = fgets($this->_fp);
$firstLine = fgets( $this->_fp );
$secondLine = fgets( $this->_fp );
//verifying the file head
if( strpos($firstLine, 'msgid ""') === false || strpos($secondLine, 'msgstr ""') === false ){
if (strpos( $firstLine, 'msgid ""' ) === false || strpos( $secondLine, 'msgstr ""' ) === false) {
$this->flagError = true;
$errMsg = 'Misplace for firts msgid "" and msgstr "" in the header';
}
@@ -225,109 +238,113 @@ class i18n_PO
}
//getting the new line
$this->_fileLine = trim(fgets($this->_fp));
$this->_fileLine = trim( fgets( $this->_fp ) );
//set line number
$this->lineNumber++;
$this->lineNumber ++;
//verifying that is not end of file and applying a restriction for to read just the twenty firsts lines
if( trim($this->_fileLine) == '' || ! $this->_fileLine || $this->lineNumber >= 20 ) {
if (trim( $this->_fileLine ) == '' || ! $this->_fileLine || $this->lineNumber >= 20) {
$this->flagEndHeaders = true; // set ending to read the headers
continue;
}
//verify if has a valid mask header line
preg_match('/^"([a-z0-9\._-]+)\s*:\s*([\W\w]+)\\\n"$/i', $this->_fileLine, $match);
preg_match( '/^"([a-z0-9\._-]+)\s*:\s*([\W\w]+)\\\n"$/i', $this->_fileLine, $match );
//for a valid header line the $match size should three
if( sizeof($match) == 3 ) {
$key = trim($match[1]); //getting the key of the header
$value = trim($match[2]); //getting the value of the header
if (sizeof( $match ) == 3) {
$key = trim( $match[1] ); //getting the key of the header
$value = trim( $match[2] ); //getting the value of the header
$this->_meta[$key] = $value; //setting a new header
} else {
$this->flagEndHeaders = true; //otherwise set the ending to read the headers
break;
}
}//end looking for headeers
} //end looking for headeers
//verifying the headers data
if( ! isset($this->_meta['X-Poedit-Language']) ) {
if (! isset( $this->_meta['X-Poedit-Language'] )) {
$this->flagError = true;
$errMsg = "X-Poedit-Language meta doesn't exist";
} else if ( $this->_meta['X-Poedit-Language'] == '' ) {
} else if ($this->_meta['X-Poedit-Language'] == '') {
$this->flagError = true;
$errMsg = "X-Poedit-Language meta is empty";
}
//if the country is not present in metadata
if( ! isset($this->_meta['X-Poedit-Country']) ) {
if (! isset( $this->_meta['X-Poedit-Country'] )) {
$this->_meta['X-Poedit-Country'] = '.';
} else if( $this->_meta['X-Poedit-Country'] == '' ) {
} else if ($this->_meta['X-Poedit-Country'] == '') {
$this->_meta['X-Poedit-Country'] = '.';
}
//thowing the exception if is necesary
if( $this->flagError ){
throw new Exception("This file is not a valid PO file. ($errMsg)");
if ($this->flagError) {
throw new Exception( "This file is not a valid PO file. ($errMsg)" );
}
}
function getHeaders() {
function getHeaders ()
{
return $this->_meta;
}
public function getTranslation(){
public function getTranslation ()
{
$flagReadingComments = true;
$this->translatorComments = Array();
$this->extractedComments = Array();
$this->references = Array();
$this->flags = Array();
$this->translatorComments = Array ();
$this->extractedComments = Array ();
$this->references = Array ();
$this->flags = Array ();
//getting the new line
while( $flagReadingComments && ! $this->flagError ) {
while ($flagReadingComments && ! $this->flagError) {
$this->_fileLine = trim(fgets($this->_fp));
$this->_fileLine = trim( fgets( $this->_fp ) );
//set line number
$this->lineNumber++;
$this->lineNumber ++;
if( ! $this->_fileLine )
if (! $this->_fileLine) {
return false;
}
$prefix = substr($this->_fileLine, 0, 2);
$prefix = substr( $this->_fileLine, 0, 2 );
switch($prefix) {
switch ($prefix) {
case '# ':
$lineItem = str_replace('# ', '', $this->_fileLine);
$lineItem = str_replace( '# ', '', $this->_fileLine );
$this->translatorComments[] = $lineItem;
break;
case '#.':
if( substr_count($this->_fileLine, '#. ') == 0 )
if (substr_count( $this->_fileLine, '#. ' ) == 0) {
$this->flagError = true;
else {
$lineItem = str_replace('#. ', '', $this->_fileLine);
} else {
$lineItem = str_replace( '#. ', '', $this->_fileLine );
$this->extractedComments[] = $lineItem;
}
break;
case '#:':
if( substr_count($this->_fileLine, '#: ') == 0 )
if (substr_count( $this->_fileLine, '#: ' ) == 0) {
$this->flagError = true;
else {
$lineItem = str_replace('#: ', '', $this->_fileLine);
} else {
$lineItem = str_replace( '#: ', '', $this->_fileLine );
$this->references[] = $lineItem;
}
break;
case '#,':
if( substr_count($this->_fileLine, '#, ') == 0 )
if (substr_count( $this->_fileLine, '#, ' ) == 0) {
$this->flagError = true;
else {
$lineItem = str_replace('#, ', '', $this->_fileLine);
} else {
$lineItem = str_replace( '#, ', '', $this->_fileLine );
$this->flags[] = $lineItem;
}
break;
case '#|':
if( substr_count($this->_fileLine, '#| ') == 0 )
if (substr_count( $this->_fileLine, '#| ' ) == 0) {
$this->flagError = true;
else {
$lineItem = str_replace('#| ', '', $this->_fileLine);
} else {
$lineItem = str_replace( '#| ', '', $this->_fileLine );
$this->previousUntranslatedStrings[] = $lineItem;
}
break;
@@ -336,52 +353,57 @@ class i18n_PO
}
}
if( ! $this->_fileLine )
if (! $this->_fileLine) {
return false;
}
//Getting the msgid
preg_match('/\s*msgid\s*"(.*)"\s*/s', $this->_fileLine, $match);
preg_match( '/\s*msgid\s*"(.*)"\s*/s', $this->_fileLine, $match );
if( sizeof($match) != 2 )
throw new Exception('Invalid PO file format1');
if (sizeof( $match ) != 2) {
throw new Exception( 'Invalid PO file format1' );
}
$msgid = '';
do {
//g::pr($match);
$msgid .= $match[1];
$this->_fileLine = trim(fgets($this->_fp));
preg_match('/^"(.*)"\s*/s', $this->_fileLine, $match);
} while ( sizeof($match) == 2 );
$this->_fileLine = trim( fgets( $this->_fp ) );
preg_match( '/^"(.*)"\s*/s', $this->_fileLine, $match );
} while (sizeof( $match ) == 2);
//Getting the msgstr
preg_match('/\s*msgstr\s*"(.*)"\s*/s', $this->_fileLine, $match);
preg_match( '/\s*msgstr\s*"(.*)"\s*/s', $this->_fileLine, $match );
if( sizeof($match) != 2 )
throw new Exception('Invalid PO file format2');
if (sizeof( $match ) != 2) {
throw new Exception( 'Invalid PO file format2' );
}
$msgstr = '';
do {
//g::pr($match);
$msgstr .= $match[1] . "\n";
$this->_fileLine = trim(fgets($this->_fp));
preg_match('/^"(.*)"\s*/s', $this->_fileLine, $match);
} while ( sizeof($match) == 2 );
$this->_fileLine = trim( fgets( $this->_fp ) );
preg_match( '/^"(.*)"\s*/s', $this->_fileLine, $match );
} while (sizeof( $match ) == 2);
/*g::pr($this->translatorComments);
g::pr($this->references);
g::pr($match);
die;*/
return Array('msgid'=>trim($msgid), 'msgstr'=>trim($msgstr));
return Array ('msgid' => trim( $msgid ),'msgstr' => trim( $msgstr )
);
}
//garbage
function __destruct()
function __destruct ()
{
if ( $this->_fp )
fclose($this->_fp);
if ($this->_fp) {
fclose( $this->_fp );
}
}
}

View File

@@ -1,6 +1,7 @@
<?php
/**
* class.mailer.php
*
* @package gulliver.system
*
* ProcessMaker Open Source Edition
@@ -23,7 +24,7 @@
* Coral Gables, FL, 33134, USA, or email info@colosa.com.
*
*/
G::LoadThirdParty('phpmailer','class.phpmailer');
G::LoadThirdParty( 'phpmailer', 'class.phpmailer' );
/* Send emails using the class "PHPMailer"
* Email server configuration constants:
* MAIL_MAILER mail/smtp
@@ -39,10 +40,11 @@ G::LoadThirdParty('phpmailer','class.phpmailer');
* @author David Callizaya <davidsantos@colosa.com>
*/
/**
/**
*
* @package gulliver.system
**/
*
*/
class mailer
{
@@ -52,10 +54,10 @@ class mailer
*
* @return object(PHPMailer) $mailer
*/
function instanceMailer()
function instanceMailer ()
{
$mailer = new PHPMailer;
$mailer->PluginDir=PATH_THIRDPARTY.'phpmailer/';
$mailer = new PHPMailer();
$mailer->PluginDir = PATH_THIRDPARTY . 'phpmailer/';
//DEFAULT CONFIGURATION
$mailer->Mailer = 'mail';
$mailer->Host = "";
@@ -64,15 +66,31 @@ class mailer
$mailer->Password = "";
$mailer->Timeout = 30;
$mailer->CharSet = 'utf-8';
$mailer->Encoding='base64';
if (defined('MAIL_MAILER')) $mailer->Mailer = MAIL_MAILER;
if (defined('MAIL_HOST')) $mailer->Host = MAIL_HOST;
if (defined('MAIL_SMTPAUTH')) $mailer->SMTPAuth = MAIL_SMTPAUTH;
if (defined('MAIL_USERNAME')) $mailer->Username = MAIL_USERNAME;
if (defined('MAIL_PASSWORD')) $mailer->Password = MAIL_PASSWORD;
if (defined('MAIL_TIMEOUT')) $mailer->Timeout = MAIL_TIMEOUT;
if (defined('MAIL_CHARSET')) $mailer->CharSet = MAIL_CHARSET;
if (defined('MAIL_ENCODING')) $mailer->Encoding= MAIL_ENCODING;
$mailer->Encoding = 'base64';
if (defined( 'MAIL_MAILER' )) {
$mailer->Mailer = MAIL_MAILER;
}
if (defined( 'MAIL_HOST' )) {
$mailer->Host = MAIL_HOST;
}
if (defined( 'MAIL_SMTPAUTH' )) {
$mailer->SMTPAuth = MAIL_SMTPAUTH;
}
if (defined( 'MAIL_USERNAME' )) {
$mailer->Username = MAIL_USERNAME;
}
if (defined( 'MAIL_PASSWORD' )) {
$mailer->Password = MAIL_PASSWORD;
}
if (defined( 'MAIL_TIMEOUT' )) {
$mailer->Timeout = MAIL_TIMEOUT;
}
if (defined( 'MAIL_CHARSET' )) {
$mailer->CharSet = MAIL_CHARSET;
}
if (defined( 'MAIL_ENCODING' )) {
$mailer->Encoding = MAIL_ENCODING;
}
return $mailer;
}
@@ -81,13 +99,13 @@ class mailer
* email $address.
* @author David Callizaya
*/
function arpaEMAIL($address)
function arpaEMAIL ($address)
{
$arpa = array();
preg_match("/([^<>]*)(?:\<([^<>]*)\>)?/",$address,$matches);
$isEmail = preg_match("/\b[A-Z0-9._%-]+@[A-Z0-9.-]+\.[A-Z]{2,4}\b/i",$matches[1]);
$arpa['email'] = ((isset($matches[2]))&&($matches[2]!=''))?$matches[2]:(($isEmail)?$matches[1]:'');
$arpa['name'] = ($isEmail)?'':$matches[1];
$arpa = array ();
preg_match( "/([^<>]*)(?:\<([^<>]*)\>)?/", $address, $matches );
$isEmail = preg_match( "/\b[A-Z0-9._%-]+@[A-Z0-9.-]+\.[A-Z]{2,4}\b/i", $matches[1] );
$arpa['email'] = ((isset( $matches[2] )) && ($matches[2] != '')) ? $matches[2] : (($isEmail) ? $matches[1] : '');
$arpa['name'] = ($isEmail) ? '' : $matches[1];
return $arpa;
}
@@ -107,49 +125,56 @@ class mailer
*
* @return object $content or $result
*/
function sendTemplate( $from = "", $target = "", $cc = "", $bcc="" ,$subject = "", $Fields = array(), $templateFile = "empty.html", $attachs=array(), $plainText=false, $returnContent = false )
function sendTemplate ($from = "", $target = "", $cc = "", $bcc = "", $subject = "", $Fields = array(), $templateFile = "empty.html", $attachs = array(), $plainText = false, $returnContent = false)
{
// Read the content of the TemplateFile
$fp = fopen(PATH_HTMLMAIL . $templateFile,"r");
$content = fread($fp,filesize(PATH_HTMLMAIL . $templateFile));
fclose($fp);
$fp = fopen( PATH_HTMLMAIL . $templateFile, "r" );
$content = fread( $fp, filesize( PATH_HTMLMAIL . $templateFile ) );
fclose( $fp );
//Replace the @@Fields with the $Fields array.
$content = mailer::replaceFields($Fields,$content);
$content = mailer::replaceFields( $Fields, $content );
//Compatibility with class.Application
if ($attachs==='FALSE')
if ($attachs === 'FALSE') {
return $content;
}
//Create the alternative body (text only)
//$h2t =& new html2text($content);
$text = '';//$h2t->get_text();
$text = ''; //$h2t->get_text();
//Prepate el phpmailer
$mailer = mailer::instanceMailer();
$arpa = mailer::arpaEMAIL($from);
$mailer->From = $arpa['email']==''?$mailer->defaultEMail:$arpa['email'];
$arpa = mailer::arpaEMAIL( $from );
$mailer->From = $arpa['email'] == '' ? $mailer->defaultEMail : $arpa['email'];
$mailer->FromName = $arpa['name'];
$arpa = mailer::arpaEMAIL($target);
$mailer->AddAddress($arpa['email'],$arpa['name']);
$mailer->AddCC($cc);
$mailer->AddBCC($bcc);
$arpa = mailer::arpaEMAIL( $target );
$mailer->AddAddress( $arpa['email'], $arpa['name'] );
$mailer->AddCC( $cc );
$mailer->AddBCC( $bcc );
$mailer->Subject = $subject;
if ($plainText)
if ($plainText) {
$content = $text;
if ($content==='')
$content='empty';
}
if ($content === '') {
$content = 'empty';
}
$mailer->Body = $content;
//$mailer->AltBody = $text;
$mailer->isHTML(!$plainText);
$mailer->isHTML( ! $plainText );
//Attach the required files
if (is_array($attachs))
if (sizeof($attachs)>0)
foreach($attachs as $aFile)
$mailer->AddAttachment($aFile,basename($aFile));
if (is_array( $attachs ))
if (sizeof( $attachs ) > 0)
foreach ($attachs as $aFile)
$mailer->AddAttachment( $aFile, basename( $aFile ) );
//Send the e-mail.
for($r=1;$r<=4;$r++) {
for ($r = 1; $r <= 4; $r ++) {
$result = $mailer->Send();
if ($result) break;
if ($result) {
break;
}
}
//unset($h2t);
if ($result && $returnContent) return $content;
if ($result && $returnContent) {
return $content;
}
return $result;
}
@@ -169,40 +194,48 @@ class mailer
*
* @return object $result
*/
function sendHtml( $from = "", $target = "", $cc = "", $bcc="" ,$subject = "", $Fields = array(), $content = "", $attachs=array(), $plainText=false, $returnContent = false )
function sendHtml ($from = "", $target = "", $cc = "", $bcc = "", $subject = "", $Fields = array(), $content = "", $attachs = array(), $plainText = false, $returnContent = false)
{
//Replace the @@Fields with the $Fields array.
$content = mailer::replaceFields($Fields,$content);
$content = mailer::replaceFields( $Fields, $content );
//Create the alternative body (text only)
//$h2t =& new html2text($content);
$text = '';//$h2t->get_text();
$text = ''; //$h2t->get_text();
//Prepate el phpmailer
$mailer = mailer::instanceMailer();
$arpa = mailer::arpaEMAIL($from);
$mailer->From = $arpa['email']==''?$mailer->defaultEMail:$arpa['email'];
$arpa = mailer::arpaEMAIL( $from );
$mailer->From = $arpa['email'] == '' ? $mailer->defaultEMail : $arpa['email'];
$mailer->FromName = $arpa['name'];
$arpa = mailer::arpaEMAIL($target);
$mailer->AddAddress($arpa['email'],$arpa['name']);
$mailer->AddCC($cc);
$mailer->AddBCC($bcc);
$arpa = mailer::arpaEMAIL( $target );
$mailer->AddAddress( $arpa['email'], $arpa['name'] );
$mailer->AddCC( $cc );
$mailer->AddBCC( $bcc );
$mailer->Subject = $subject;
if ($plainText) $content = $text;
if ($content==='') $content='empty';
if ($plainText) {
$content = $text;
}
if ($content === '') {
$content = 'empty';
}
$mailer->Body = $content;
//$mailer->AltBody = $text;
$mailer->isHTML(!$plainText);
$mailer->isHTML( ! $plainText );
//Attach the required files
if (is_array($attachs))
if (sizeof($attachs)>0)
foreach($attachs as $aFile)
$mailer->AddAttachment($aFile,basename($aFile));
if (is_array( $attachs ))
if (sizeof( $attachs ) > 0)
foreach ($attachs as $aFile)
$mailer->AddAttachment( $aFile, basename( $aFile ) );
//Send the e-mail.
for($r=1;$r<=4;$r++) {
$result=$mailer->Send();
if ($result) break;
for ($r = 1; $r <= 4; $r ++) {
$result = $mailer->Send();
if ($result) {
break;
}
}
//unset($h2t);
if ($result && $returnContent) return $content;
if ($result && $returnContent) {
return $content;
}
return $result;
}
@@ -219,30 +252,36 @@ class mailer
*
* @return object $result
*/
function sendText( $from = "", $target = "", $cc = "", $bcc="" ,$subject = "", $content = "", $attachs=array())
function sendText ($from = "", $target = "", $cc = "", $bcc = "", $subject = "", $content = "", $attachs = array())
{
//Prepate el phpmailer
$mailer = mailer::instanceMailer();
$arpa = mailer::arpaEMAIL($from);
$mailer->From = $arpa['email']==''?$mailer->defaultEMail:$arpa['email'];
$arpa = mailer::arpaEMAIL( $from );
$mailer->From = $arpa['email'] == '' ? $mailer->defaultEMail : $arpa['email'];
$mailer->FromName = $arpa['name'];
$arpa = mailer::arpaEMAIL($target);
$mailer->AddAddress($arpa['email'],$arpa['name']);
$mailer->AddCC($cc);
$mailer->AddBCC($bcc);
$arpa = mailer::arpaEMAIL( $target );
$mailer->AddAddress( $arpa['email'], $arpa['name'] );
$mailer->AddCC( $cc );
$mailer->AddBCC( $bcc );
$mailer->Subject = $subject;
if ($content==='') $content='empty';
if ($content === '') {
$content = 'empty';
}
$mailer->Body = $content;
$mailer->AltBody = $content;
$mailer->isHTML(false);
$mailer->isHTML( false );
//Attach the required files
if (sizeof($attachs)>0)
foreach($attachs as $aFile)
$mailer->AddAttachment($aFile,basename($aFile));
if (sizeof( $attachs ) > 0) {
foreach ($attachs as $aFile) {
$mailer->AddAttachment( $aFile, basename( $aFile ) );
}
}
//Send the e-mail.
for($r=1;$r<=4;$r++) {
$result=$mailer->Send();
if ($result) break;
for ($r = 1; $r <= 4; $r ++) {
$result = $mailer->Send();
if ($result) {
break;
}
}
return $result;
}
@@ -255,21 +294,22 @@ class mailer
*
* @return none
*/
function replaceFields($Fields = array(), $content = "")
function replaceFields ($Fields = array(), $content = "")
{
return G::replaceDataField( $content , $Fields );
return G::replaceDataField( $content, $Fields );
}
/**
* html2text
*
* empty
*
* @return none
*/
function html2text()
function html2text ()
{
//$h2t =& new html2text($content);
//return $h2t->get_text();
}
}
?>

View File

@@ -1,6 +1,8 @@
<?php
/**
* class.menu.php
*
* @package gulliver.system
*
* ProcessMaker Open Source Edition
@@ -24,12 +26,16 @@
*
*/
/**
*
* @package gulliver.system
*/
*
*/
/**
*
*
* Menu class definition
* Render Menus
*
* @package gulliver.system
* @author Fernando Ontiveros Lira <fernando@colosa.com>
* @copyright (C) 2002 by Colosa Development Team.
@@ -37,18 +43,18 @@
*/
class Menu
{
var $Id = NULL;
var $Options = NULL;
var $Labels = NULL;
var $Icons = NULL;
var $JS = NULL;
var $Types = NULL;
var $Id = null;
var $Options = null;
var $Labels = null;
var $Icons = null;
var $JS = null;
var $Types = null;
var $Class = "mnu";
var $Classes = NULL;
var $Enabled = NULL;
var $optionOn = -1;
var $Classes = null;
var $Enabled = null;
var $optionOn = - 1;
var $id_optionOn = "";
var $ElementClass = NULL;
var $ElementClass = null;
/**
* Set menu style
@@ -58,7 +64,7 @@ class Menu
* @param $strClass name of style class default value 'mnu'
* @return void
*/
function SetClass( $strClass = "mnu" )
function SetClass ($strClass = "mnu")
{
$this->Class = "mnu";
}
@@ -71,51 +77,55 @@ class Menu
* @param $strMenuName name of menu
* @return void
*/
function Load( $strMenuName )
function Load ($strMenuName)
{
global $G_TMP_MENU;
$G_TMP_MENU = NULL;
$G_TMP_MENU = new Menu;
$G_TMP_MENU = null;
$G_TMP_MENU = new Menu();
$fMenu = G::ExpandPath( "menus" ) . $strMenuName . ".php";
//if the menu file doesn't exists, then try with the plugins folders
if ( !is_file( $fMenu) ) {
$aux = explode ( PATH_SEP, $strMenuName );
if ( count($aux) == 2 ) {
$oPluginRegistry =& PMPluginRegistry::getSingleton();
if ( $oPluginRegistry->isRegisteredFolder($aux[0]) )
if (! is_file( $fMenu )) {
$aux = explode( PATH_SEP, $strMenuName );
if (count( $aux ) == 2) {
$oPluginRegistry = & PMPluginRegistry::getSingleton();
if ($oPluginRegistry->isRegisteredFolder( $aux[0] )) {
$fMenu = PATH_PLUGINS . $aux[0] . PATH_SEP . $aux[1] . ".php";
}
}
}
if( !is_file( $fMenu ) )
if (! is_file( $fMenu )) {
return;
include( $fMenu );
}
include ($fMenu);
//this line will add options to current menu.
$oPluginRegistry =& PMPluginRegistry::getSingleton();
$oPluginRegistry->getMenus ( $strMenuName );
$oPluginRegistry = & PMPluginRegistry::getSingleton();
$oPluginRegistry->getMenus( $strMenuName );
//?
$c = 0;
for ($i = 0; $i < count ($G_TMP_MENU->Options) ; $i++)
for ($i = 0; $i < count( $G_TMP_MENU->Options ); $i ++)
if ($G_TMP_MENU->Enabled[$i] == 1) {
$this->Options[$c] = $G_TMP_MENU->Options[$i];
$this->Labels [$c] = $G_TMP_MENU->Labels[$i];
$this->Icons [$c] = $G_TMP_MENU->Icons[$i];
$this->JS [$c] = $G_TMP_MENU->JS[$i];
$this->Types [$c] = $G_TMP_MENU->Types[$i];
$this->Labels[$c] = $G_TMP_MENU->Labels[$i];
$this->Icons[$c] = $G_TMP_MENU->Icons[$i];
$this->JS[$c] = $G_TMP_MENU->JS[$i];
$this->Types[$c] = $G_TMP_MENU->Types[$i];
$this->Enabled[$c] = $G_TMP_MENU->Enabled[$i];
$this->Id [$c] = $G_TMP_MENU->Id[$i];
$this->Id[$c] = $G_TMP_MENU->Id[$i];
$this->Classes[$c] = $G_TMP_MENU->Classes[$i];
$this->ElementClass[$c] = $G_TMP_MENU->ElementClass[$i];
$c ++;
} else {
if ($i == $this->optionOn) $this->optionOn = -1;
elseif ($i < $this->optionOn) $this->optionOn--;
elseif ($this->optionOn > 0) $this->optionOn--;//added this line
if ($i == $this->optionOn)
$this->optionOn = - 1;
elseif ($i < $this->optionOn)
$this->optionOn --;
elseif ($this->optionOn > 0)
$this->optionOn --; //added this line
}
$G_TMP_MENU = NULL;
$G_TMP_MENU = null;
}
/**
@@ -125,11 +135,10 @@ class Menu
* @access public
* @return int
*/
function OptionCount()
function OptionCount ()
{
$result = 0;
if( is_array( $this->Options ) )
{
if (is_array( $this->Options )) {
$result = count( $this->Options );
}
return $result;
@@ -145,7 +154,7 @@ class Menu
* @param string $strType type, defualt value ='plugins'
* @return void
*/
function AddOption( $strLabel, $strURL, $strType = "plugins" )
function AddOption ($strLabel, $strURL, $strType = "plugins")
{
$pos = $this->OptionCount();
$this->Options[$pos] = $strURL;
@@ -167,19 +176,19 @@ class Menu
* @param string $strType type, defualt value ='plugins'
* @return void
*/
function AddIdOption( $strId, $strLabel, $strURL, $strType = "plugins" )
function AddIdOption ($strId, $strLabel, $strURL, $strType = "plugins")
{
$pos = $this->OptionCount();
$this->Options[$pos] = $strURL;
$this->Labels[$pos] = $strLabel;
$this->Types[$pos] = $strType;
$this->Enabled[$pos] = 1;
if (is_array ($strId)) {
if (is_array( $strId )) {
$this->Id[$pos] = $strId[0];
$this->Classes[$pos] = $strId[1];
}
else
} else {
$this->Id[$pos] = $strId;
}
unset( $pos );
}
@@ -192,7 +201,7 @@ class Menu
* @param string $strType type, defualt value ='plugins'
* @return void
*/
function AddRawOption( $strURL = "", $strType = "plugins" )
function AddRawOption ($strURL = "", $strType = "plugins")
{
$pos = $this->OptionCount();
$this->Options[$pos] = $strURL;
@@ -215,7 +224,7 @@ class Menu
* @param string $elementClass default value =''
* @return void
*/
function AddIdRawOption( $strId, $strURL = "", $label = "", $icon = "",$js = "", $strType = "plugins",$elementClass = '' )
function AddIdRawOption ($strId, $strURL = "", $label = "", $icon = "", $js = "", $strType = "plugins", $elementClass = '')
{
$pos = $this->OptionCount();
$this->Options[$pos] = $strURL;
@@ -225,12 +234,12 @@ class Menu
$this->Types[$pos] = $strType;
$this->Enabled[$pos] = 1;
$this->ElementClass[$pos] = $elementClass;
if (is_array ($strId)) {
if (is_array( $strId )) {
$this->Id[$pos] = $strId[0];
$this->Classes[$pos] = $strId[1];
}
else
} else {
$this->Id[$pos] = $strId;
}
unset( $pos );
}
@@ -242,7 +251,7 @@ class Menu
* @param string $intPos menu option's position
* @return void
*/
function DisableOptionPos( $intPos )
function DisableOptionPos ($intPos)
{
$this->Enabled[$intPos] = 0;
}
@@ -255,10 +264,11 @@ class Menu
* @param string $id menu's id
* @return void
*/
function DisableOptionId ( $id )
function DisableOptionId ($id)
{
if ( array_search ($id, $this->Id) )
$this->Enabled[ array_search ($id, $this->Id) ] = 0;
if (array_search( $id, $this->Id )) {
$this->Enabled[array_search( $id, $this->Id )] = 0;
}
}
/**
@@ -269,32 +279,31 @@ class Menu
* @param string $intPos menu option's position
* @return void
*/
function RenderOption( $intPos )
function RenderOption ($intPos)
{
if ( $this->Enabled[$intPos] != 1)
if ($this->Enabled[$intPos] != 1) {
return;
$classname = $this->Class . "Link";
if ( $this->Classes[$intPos] != "" ) $classname = $this->Classes[$intPos];
$target = $this->Options[$intPos];
if( $this->Types[$intPos] != "absolute" )
{
if (defined('ENABLE_ENCRYPT')) {
$target = "/sys" . SYS_SYS . "/" . SYS_LANG . "/" . SYS_SKIN . "/" . $target;
}
else
if (defined('SYS_SYS'))
$classname = $this->Class . "Link";
if ($this->Classes[$intPos] != "") {
$classname = $this->Classes[$intPos];
}
$target = $this->Options[$intPos];
if ($this->Types[$intPos] != "absolute") {
if (defined( 'ENABLE_ENCRYPT' )) {
$target = "/sys" . SYS_SYS . "/" . SYS_LANG . "/" . SYS_SKIN . "/" . $target;
else
} else if (defined( 'SYS_SYS' )) {
$target = "/sys" . SYS_SYS . "/" . SYS_LANG . "/" . SYS_SKIN . "/" . $target;
} else {
$target = "/sys/" . SYS_LANG . "/" . SYS_SKIN . "/" . $target;
}
}
$label = $this->Labels[$intPos];
$result = "<a href=\"$target\"";
$result .= " class=\"$classname\">";
$result .= htmlentities( $label , ENT_NOQUOTES , 'utf-8');
$result .= htmlentities( $label, ENT_NOQUOTES, 'utf-8' );
$result .= "</a>";
print( $result );
print ($result) ;
}
@@ -310,19 +319,18 @@ class Menu
* @param string $G_ID_MENU_SELECTED
* @return array
*/
function generateArrayForTemplate($G_MAIN_MENU,$classOn,$classOff,$G_MENU_SELECTED, $G_ID_MENU_SELECTED ) {
$menus = array();
function generateArrayForTemplate ($G_MAIN_MENU, $classOn, $classOff, $G_MENU_SELECTED, $G_ID_MENU_SELECTED)
{
$menus = array ();
if ($G_MAIN_MENU == null) {
return $menus;
}
$this->Load ($G_MAIN_MENU);
$this->Load( $G_MAIN_MENU );
$this->optionOn = $G_MENU_SELECTED;
$this->id_optionOn = $G_ID_MENU_SELECTED;
//$this->Class = $G_MENU_CLASS;
if (is_array($this->Options))
{
for ($ncount = 0; $ncount < $this->OptionCount(); $ncount++)
{
if (is_array( $this->Options )) {
for ($ncount = 0; $ncount < $this->OptionCount(); $ncount ++) {
$target = $this->Options[$ncount];
//$aux = $this->Icons[$ncount];
@@ -332,48 +340,45 @@ class Menu
$target = $this->Options[$ncount];
}
if ($this->Types[$ncount] != 'absolute') {
if (defined('SYS_SYS')) {
$target = '/sys' . SYS_TEMP . G::encryptLink('/' . SYS_LANG . '/' . SYS_SKIN . '/' . $this->Options[$ncount]);
}
else {
$target = '/sys/' . G::encryptLink(SYS_LANG . '/' . SYS_SKIN . '/' . $this->Options[$ncount]);
if (defined( 'SYS_SYS' )) {
$target = '/sys' . SYS_TEMP . G::encryptLink( '/' . SYS_LANG . '/' . SYS_SKIN . '/' . $this->Options[$ncount] );
} else {
$target = '/sys/' . G::encryptLink( SYS_LANG . '/' . SYS_SKIN . '/' . $this->Options[$ncount] );
}
}
$label = $this->Labels[$ncount];
if ($this->id_optionOn != '') {
$onMenu = ($this->Id[$ncount] == $this->id_optionOn ? true : false);
}
else {
} else {
$onMenu = ($ncount == $this->optionOn ? true : false);
}
$classname = ($onMenu ? $classOn : $classOff);
$imageLeft = ($onMenu ? "<img src=\"/images/bulletSubMenu.jpg\" />" : '');
$onclick = '';
if ($this->JS[$ncount] !== '' ) {
if ($this->JS[$ncount] !== '') {
$onclick = " onclick=\"" . $this->JS[$ncount] . "\"";
}
$icon = '';
if ($this->Icons[$ncount] !== '' ) {
$icon = " <a href=\"#\" onclick=\"" . $this->JS[$ncount] . "\" class=\"$classname\">" .
"<img src=\"". $this->Icons[$ncount] . "\" border=\"0\"/></a>";
if ($this->Icons[$ncount] !== '') {
$icon = " <a href=\"#\" onclick=\"" . $this->JS[$ncount] . "\" class=\"$classname\">" . "<img src=\"" . $this->Icons[$ncount] . "\" border=\"0\"/></a>";
$icon = $this->Icons[$ncount];
}
if ( $this->Classes[$ncount] != '') {
if ($this->Classes[$ncount] != '') {
$classname = $this->Classes[$ncount];
$target = "#";
}
$idName=$this->Id[$ncount];
$idName = $this->Id[$ncount];
$elementclass = '';
if($this->ElementClass[$ncount] != ''){
$elementclass = 'class="'.$this->ElementClass[$ncount].'"';
if ($this->ElementClass[$ncount] != '') {
$elementclass = 'class="' . $this->ElementClass[$ncount] . '"';
}
$menus[] = array ( 'id' => $ncount, 'target' => $target, 'label' => $label, 'onMenu' => $onMenu, 'classname' => $classname,
'imageLeft' => $imageLeft, 'onclick' => $onclick,
'icon' => $icon, 'aux' => $aux,'idName' => $idName,'elementclass'=>$elementclass);
$menus[] = array ('id' => $ncount,'target' => $target,'label' => $label,'onMenu' => $onMenu,'classname' => $classname,'imageLeft' => $imageLeft,'onclick' => $onclick,'icon' => $icon,'aux' => $aux,'idName' => $idName,'elementclass' => $elementclass
);
}
}
return $menus;
}
}

View File

@@ -1,6 +1,8 @@
<?php
/**
* class.objectTemplate.php
*
* @package gulliver.system
*
* ProcessMaker Open Source Edition
@@ -26,20 +28,23 @@
/**
* Class objectTemplate
*
* @package gulliver.system
* @access public
*/
class objectTemplate extends smarty
{
/**
* Function objectTemplate
*
* @access public
* @param object $templateFile
* @return void
*/
function objectTemplate( $templateFile )
function objectTemplate ($templateFile)
{
$this->template_dir = PATH_TPL;
$this->compile_dir = PATH_SMARTY_C;
@@ -51,13 +56,15 @@ class objectTemplate extends smarty
/**
* Function printObject
*
* @access public
* @param object $object
* @return string
*/
function printObject($object)
function printObject ($object)
{
$this->assign($object);
return $this->fetch($this->templateFile);
$this->assign( $object );
return $this->fetch( $this->templateFile );
}
}

View File

@@ -1,11 +1,12 @@
<?php
/**
* class.testTools.php
*
* @package gulliver.system
*
* 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
@@ -25,12 +26,15 @@
*
*/
/**
/**
*
* @package gulliver.system
**/
G::LoadSystem ( 'ymlDomain');
G::LoadSystem ( 'ymlTestCases');
G::LoadSystem ( 'unitTest');
*
*/
G::LoadSystem( 'ymlDomain' );
G::LoadSystem( 'ymlTestCases' );
G::LoadSystem( 'unitTest' );
class testTools
{
@@ -45,9 +49,9 @@ class testTools
*
* @return none
*/
function importDB( $host, $user, $password, $database, $importFile )
function importDB ($host, $user, $password, $database, $importFile)
{
exec("mysql -h " . $host . " --user=" . $user . " --password=" . $password . " $database < $importFile");
exec( "mysql -h " . $host . " --user=" . $user . " --password=" . $password . " $database < $importFile" );
}
/**
@@ -57,7 +61,7 @@ class testTools
*
* @return none
*/
function importLocalDB( $importFile )
function importLocalDB ($importFile)
{
self::importDB( DB_HOST, DB_USER, DB_PASS, DB_NAME, $importFile );
}
@@ -72,16 +76,16 @@ class testTools
*
* @return none
*/
function callMethod( $methodFile, $GET, $POST, $SESSION )
function callMethod ($methodFile, $GET, $POST, $SESSION)
{
//TODO $_SERVER
self::arrayDelete($_GET);
self::arrayDelete($_POST);
self::arrayDelete($_SESSION);
self::arrayAppend($_GET,$GET);
self::arrayAppend($_POST,$POST);
self::arrayAppend($_SESSION,$SESSION);
include( PATH_CORE . 'methods/' . $methodFile );
self::arrayDelete( $_GET );
self::arrayDelete( $_POST );
self::arrayDelete( $_SESSION );
self::arrayAppend( $_GET, $GET );
self::arrayAppend( $_POST, $POST );
self::arrayAppend( $_SESSION, $SESSION );
include (PATH_CORE . 'methods/' . $methodFile);
}
/**
@@ -92,9 +96,11 @@ class testTools
*
* @return boolean true
*/
function arrayAppend( &$to , $appendFrom )
function arrayAppend (&$to, $appendFrom)
{
foreach($appendFrom as $appendItem) $to[]=$appendItem;
foreach ($appendFrom as $appendItem) {
$to[] = $appendItem;
}
return true;
}
@@ -105,9 +111,11 @@ class testTools
*
* @return boolean true
*/
function arrayDelete( &$array )
function arrayDelete (&$array)
{
foreach($array as $key => $value) unset($array[$key]);
foreach ($array as $key => $value) {
unset( $array[$key] );
}
return true;
}
@@ -120,11 +128,11 @@ class testTools
* @return array $Fields
*/
//@@
function replaceVariables( $Fields, $ExternalVariables = array() )
function replaceVariables ($Fields, $ExternalVariables = array())
{
//TODO: Verify dependencies between fields
foreach($Fields as $key => $field) {
if (is_string($field)) {
foreach ($Fields as $key => $field) {
if (is_string( $field )) {
$mergedValues = G::array_merges( $Fields, $ExternalVariables );
$Fields[$key] = G::ReplaceDataField( $field, $mergedValues );
}
@@ -141,30 +149,32 @@ class testTools
*
* @return (boolean | string) ((true | false) | $value)
*/
function findValue( $value, &$obj )
function findValue ($value, &$obj)
{
if (is_array($obj)) {
foreach($obj as $key => $val ) {
if ($res=self::findValue( $value , $obj[$key] )) {
if ($res==true) return $key;
else return $key . '.' . $res;
}
}
return false;
}
elseif (is_object($obj)) {
foreach($obj as $key => $val ) {
if ($res=self::findValue( $value , $obj->$key )) {
if ($res==true)
if (is_array( $obj )) {
foreach ($obj as $key => $val) {
if ($res = self::findValue( $value, $obj[$key] )) {
if ($res == true) {
return $key;
else
} else {
return $key . '.' . $res;
}
}
return false;
}
else {
return $obj==$value;
return false;
} elseif (is_object( $obj )) {
foreach ($obj as $key => $val) {
if ($res = self::findValue( $value, $obj->$key )) {
if ($res == true) {
return $key;
} else {
return $key . '.' . $res;
}
}
}
return false;
} else {
return $obj == $value;
}
}
}
@@ -177,10 +187,13 @@ class testTools
* @return object $result
*/
function domain($location)
function domain ($location)
{
global $testDomain;
$result = $testDomain->get($location);
if (count($result)==0) trigger_error("'$location' is an empty domain.", E_USER_WARNING);
$result = $testDomain->get( $location );
if (count( $result ) == 0) {
trigger_error( "'$location' is an empty domain.", E_USER_WARNING );
}
return $result;
}

View File

@@ -1,17 +1,18 @@
<?php
/**
* class.tree.php
*
* @package gulliver.system
*
* 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
* License, or (at your option) any later version.
*<2A>
* <EFBFBD>
* 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
@@ -25,11 +26,14 @@
*
*/
/**
/**
*
* @package gulliver.system
*/
G::LoadSystem('objectTemplate');
class Tree extends Xml_Node {
G::LoadSystem( 'objectTemplate' );
class Tree extends Xml_Node
{
var $template = 'tree.html';
var $nodeType = 'base';
var $nodeClass = 'treeNode';
@@ -50,23 +54,24 @@
*
* @return none
*/
function Tree( $xmlnode = NULL )
function Tree ($xmlnode = null)
{
if (!isset($xmlnode))
if (! isset( $xmlnode )) {
return;
if (isset($xmlnode->attributes['nodeType']))
$this->nodeType=$xmlnode->attributes['nodeType'];
foreach($xmlnode as $key => $value) {
if ($key==='children') {
foreach( $xmlnode->children as $key => $value ) {
$this->children[ $key ] = new Tree( $value->toTree());
}
} elseif ($key==='attributes') {
foreach( $xmlnode->attributes as $key => $value ) {
if (isset( $xmlnode->attributes['nodeType'] )) {
$this->nodeType = $xmlnode->attributes['nodeType'];
}
foreach ($xmlnode as $key => $value) {
if ($key === 'children') {
foreach ($xmlnode->children as $key => $value) {
$this->children[$key] = new Tree( $value->toTree() );
}
} elseif ($key === 'attributes') {
foreach ($xmlnode->attributes as $key => $value) {
$this->{$key} = $value;
}
}
else {
} else {
$this->{$key} = $value;
}
}
@@ -82,10 +87,10 @@
* @return object(Tree) $newNode
*/
function &addChild( $name, $label, $attributes = array() )
function &addChild ($name, $label, $attributes = array())
{
$newNode = new Tree(new Xml_Node($name, 'open', $label, $attributes));
$this->children[] =& $newNode;
$newNode = new Tree( new Xml_Node( $name, 'open', $label, $attributes ) );
$this->children[] = & $newNode;
return $newNode;
}
@@ -94,23 +99,21 @@
*
* @return string '<span>...</span>'
*/
function printPlus()
function printPlus ()
{
$plus = 'none';
$minus = 'none';
$point = 'none';
if ($this->showSign) {
if ((sizeof($this->children)>0) && ($this->contracted)) {
if ((sizeof( $this->children ) > 0) && ($this->contracted)) {
$plus = '';
} elseif ((sizeof($this->children)>0) && (!$this->contracted)) {
} elseif ((sizeof( $this->children ) > 0) && (! $this->contracted)) {
$minus = '';
} else {
$point = '';
}
}
return "<span class='treePlus' name='plus' style='display:$plus;'>{$this->plus}</span>".
"<span class='treeMinus' name='minus' style='display:$minus'>{$this->minus}</span>".
"<span class='treePointer' name='point' style='display:$point'>{$this->point}</span>";
return "<span class='treePlus' name='plus' style='display:$plus;'>{$this->plus}</span>" . "<span class='treeMinus' name='minus' style='display:$minus'>{$this->minus}</span>" . "<span class='treePointer' name='point' style='display:$point'>{$this->point}</span>";
}
/**
@@ -118,7 +121,7 @@
*
* @return $this->value
*/
function printLabel()
function printLabel ()
{
return $this->value;
}
@@ -128,13 +131,14 @@
*
* @return string $html
*/
function printContent()
function printContent ()
{
$html = '';
$row = 0;
foreach($this->children as $child) {
if ($row)
foreach ($this->children as $child) {
if ($row) {
$child->nodeClass = 'treeNodeAlternate';
}
$html .= $child->render();
$row = ($row + 1) % 2;
}
@@ -143,11 +147,14 @@
/**
* render
*
* @return $obj->printObject( array( 'node' => &$this ) )
*/
function render() {
function render ()
{
$obj = new objectTemplate( $this->template );
return $obj->printObject( array( 'node' => &$this ) );
}
return $obj->printObject( array ('node' => &$this
) );
}
}

View File

@@ -1,11 +1,13 @@
<?php
/**
* class.unitTest.php
*
* @package gulliver.system
*
* 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
@@ -25,7 +27,8 @@
*
*/
/**
/**
*
* @package gulliver.system
*/
@@ -36,37 +39,41 @@ class unitTest
var $yml;
var $domain;
var $testLime;
function unitTest( $ymlFile, &$testLime, &$testDomain )
function unitTest ($ymlFile, &$testLime, &$testDomain)
{
if (!isset($testDomain)) $testDomain = new ymlDomain();
$this->domain =& $testDomain;
$this->testLime =& $testLime;
if (! isset( $testDomain )) {
$testDomain = new ymlDomain();
}
$this->domain = & $testDomain;
$this->testLime = & $testLime;
$this->yml = new ymlTestCases( $ymlFile, $this->domain, $this->testLime );
}
//Load a Test (group of unitary tests) defined in the Yml file.
function load( $testName, $fields=array() )
function load ($testName, $fields = array())
{
$this->yml->load( $testName, $fields );
}
//Run one single unit test from the loaded Test
function runSingle( $fields=array() )
function runSingle ($fields = array())
{
return $this->yml->runSingle( $this, $fields );
}
//Run a group of unit tests from the loaded Test
function runMultiple( $fields=array(), $count = -1, $start=0)
function runMultiple ($fields = array(), $count = -1, $start = 0)
{
return $this->yml->runMultiple( $this, $fields, $count, $start );
}
//Run all the unit tests from the loaded Test
function runAll( $fields=array())
function runAll ($fields = array())
{
return $this->yml->runMultiple( $this, $fields, -1, 0 );
return $this->yml->runMultiple( $this, $fields, - 1, 0 );
}
//A sample of "Function" to run a unit test.
function sampleTestFunction( $testCase , &$Fields )
function sampleTestFunction ($testCase, &$Fields)
{
$result = ($Fields['APP_UID']!='')?"OK":"FALSE";
$result = ($Fields['APP_UID'] != '') ? "OK" : "FALSE";
return $result;
}
}

View File

@@ -1,6 +1,8 @@
<?php
/**
* class.webResource.php
*
* @package gulliver.system
*
* ProcessMaker Open Source Edition
@@ -32,7 +34,8 @@
* @dependencies: grest.js *
*/
/**
/**
*
* @package gulliver.system
*/
class WebResource
@@ -47,25 +50,26 @@ class WebResource
*
* @return none
*/
function WebResource($uri, $post)
function WebResource ($uri, $post)
{
$this->_uri=$uri;
if (isset($post['function'])&&$post['function']!='') {
$this->_uri = $uri;
if (isset( $post['function'] ) && $post['function'] != '') {
/*Call a function*/
header('Content-Type: text/json');
header( 'Content-Type: text/json' );
//$parameters=G::json_decode((urldecode($post['parameters']))); //for %AC
$parameters=G::json_decode(($post['parameters']));
$paramsRef=array();
foreach($parameters as $key => $value)
{
if (is_string($key)) $paramsRef[]="\$parameters['".addcslashes($key,'\\\'')."']";
else $paramsRef[]='$parameters['.$key.']';
$parameters = G::json_decode( ($post['parameters']) );
$paramsRef = array ();
foreach ($parameters as $key => $value) {
if (is_string( $key )) {
$paramsRef[] = "\$parameters['" . addcslashes( $key, '\\\'' ) . "']";
} else {
$paramsRef[] = '$parameters[' . $key . ']';
}
$res=eval('return ($this->'.$post['function'].'('.implode(',',$paramsRef).'));');
$res=G::json_encode($res);
print($res);
}
else {
$res = eval( 'return ($this->' . $post['function'] . '(' . implode( ',', $paramsRef ) . '));' );
$res = G::json_encode( $res );
print ($res) ;
} else {
/*Print class definition*/
$this->_encode();
}
@@ -76,56 +80,52 @@ class WebResource
*
* @return none
*/
function _encode()
function _encode ()
{
header('Content-Type: text/json');
$methods=get_class_methods(get_class($this));
print('{');
header( 'Content-Type: text/json' );
$methods = get_class_methods( get_class( $this ) );
print ('{') ;
$first = true;
foreach($methods as $method) {
foreach ($methods as $method) {
//To avoid PHP version incompatibilities, put the $method name in lowercase
$method=strtolower($method);
if ((substr($method,0,1)==='_')||
(strcasecmp($method,'WebResource')==0)||
(strcasecmp($method,get_class($this))==0)
)
{
$method = strtolower( $method );
if ((substr( $method, 0, 1 ) === '_') || (strcasecmp( $method, 'WebResource' ) == 0) || (strcasecmp( $method, get_class( $this ) ) == 0)) {
} elseif (strcasecmp( substr( $method, 0, 3 ), 'js_' ) == 0) {
if (! $first) {
print (',') ;
}
elseif (strcasecmp(substr($method,0,3),'js_')==0)
{
if (!$first) print(',');
$this->{$method}();
$first=false;
$first = false;
} else {
if (! $first) {
print (',') ;
}
else
{
if (!$first) print(',');
print(
$method.
':function(){return __wrCall("'.
addslashes($this->_uri).
'","'.$method.'",arguments);}'
);
$first=false;
print ($method . ':function(){return __wrCall("' . addslashes( $this->_uri ) . '","' . $method . '",arguments);}') ;
$first = false;
}
}
print('}');
print ('}') ;
}
}
/* end class WebResource */
if (!function_exists('json_encode')) {
G::LoadThirdParty('pear/json','class.json');
function json_encode(&$value) {
$json= new Services_JSON;
return $json->encode($value);
if (! function_exists( 'json_encode' )) {
G::LoadThirdParty( 'pear/json', 'class.json' );
function json_encode (&$value)
{
$json = new Services_JSON();
return $json->encode( $value );
}
}
if (!function_exists('json_decode')) {
G::LoadThirdParty('pear/json','class.json');
function json_decode(&$value) {
$json= new Services_JSON;
return $json->decode($value);
if (! function_exists( 'json_decode' )) {
G::LoadThirdParty( 'pear/json', 'class.json' );
function json_decode (&$value)
{
$json = new Services_JSON();
return $json->decode( $value );
}
}

View File

@@ -1,6 +1,8 @@
<?php
/**
* class.xmlDocument.php
*
* @package gulliver.system
*
* ProcessMaker Open Source Edition
@@ -25,6 +27,7 @@
*/
/**
* Class Xml_Node
*
* @author David S. Callizaya S. <davidsantos@colosa.com>
* @package gulliver.system
* @access public
@@ -34,117 +37,132 @@ class Xml_Node
var $name = '';
var $type = '';
var $value = ''; //maybe not necesary
var $attributes = array();
var $children = array();
var $attributes = array ();
var $children = array ();
/**
* Function Xml_Node
*
* @author David S. Callizaya S. <davidsantos@colosa.com>
* @access public
* @parameter string name
* @parameter string type
* @parameter string value
* @parameter string attributes
* @param eter string name
* @param eter string type
* @param eter string value
* @param eter string attributes
* @return string
*/
function Xml_Node($name, $type, $value, $attributes = array() )
function Xml_Node ($name, $type, $value, $attributes = array())
{
$this->name = $name;
$this->type = $type;
$this->value = $value;
$this->attributes = $attributes;
}
/**
* Function addAttribute
*
* @author David S. Callizaya S. <davidsantos@colosa.com>
* @access public
* @parameter string name
* @parameter string value
* @param eter string name
* @param eter string value
* @return string
*/
function addAttribute( $name, $value )
function addAttribute ($name, $value)
{
$this->attributes[$name] = $value;
return true;
}
/**
* Function addChildNode
*
* @author David S. Callizaya S. <davidsantos@colosa.com>
* @access public
* @parameter string childNode
* @param eter string childNode
* @return string
*/
function addChildNode( $childNode )
function addChildNode ($childNode)
{
if (is_object($childNode) && strcasecmp( get_class($childNode), 'Xml_Node' ) == 0 ) {
if (is_object( $childNode ) && strcasecmp( get_class( $childNode ), 'Xml_Node' ) == 0) {
$this->type = 'open';
$childNode->parent = &$this;
$this->children[] = &$childNode;
return true;
}
else {
} else {
return false;
}
}
/**
* Function toTree
*
* @author David S. Callizaya S. <davidsantos@colosa.com>
* @access public
* @return string
*/
function toTree()
function toTree ()
{
$arr = new Xml_Node( $this->name, $this->type, $this->value, $this->attributes );
unset( $arr->parent );
foreach($this->children as $k => $v) {
unset($v->parent);
$arr->children[$k]=$v->toTree();
foreach ($this->children as $k => $v) {
unset( $v->parent );
$arr->children[$k] = $v->toTree();
}
return $arr;
}
function toArray( $obj = NULL ) {
$arr = array();
if ( !isset($obj) ) $obj = $this->toTree();
foreach($obj as $att => $val ) {
if (is_array($val) || is_object($val) ) {
$arr[$att] = Xml_Node::toArray($val);
function toArray ($obj = null)
{
$arr = array ();
if (! isset( $obj )) {
$obj = $this->toTree();
}
foreach ($obj as $att => $val) {
if (is_array( $val ) || is_object( $val )) {
$arr[$att] = Xml_Node::toArray( $val );
} else {
$arr[$att] = $val;
}
}
return $arr;
}
/**
* Function &findNode
*
* @author David S. Callizaya S. <davidsantos@colosa.com>
* @access public
* @parameter string xpath
* @param eter string xpath
* @return string
*/
function &findNode( $xpath )
function &findNode ($xpath)
{
$n = NULL;
$p = explode('/', $xpath);
if ( $p[0] === '') {
$n = null;
$p = explode( '/', $xpath );
if ($p[0] === '') {
return $this;
} elseif (substr( $p[0], 0, 1 ) === '@') {
$p[0] = substr( $p[0], 1 );
if (isset( $this->attributes[$p[0]] )) {
return $this->attributes[$p[0]];
}
elseif ( substr($p[0],0 , 1) === '@') {
$p[0] = substr($p[0], 1 );
if ( isset($this->attributes[$p[0]])) return $this->attributes[$p[0]];
} elseif ($p[0] === '..') {
array_shift( $p );
$n = & $this->parent->findNode( implode( '/', $p ) );
if (isset( $n )) {
return $n;
}
elseif ($p[0] === '..' ) {
array_shift($p);
$n = & $this->parent->findNode ( implode('/',$p) );
if (isset($n) ) return $n;
} else {
foreach ($this->children as $k => $v) {
if (($v->type !== 'cdata') && ($v->name === $p[0])) {
if (sizeof( $p ) > 1) {
array_shift( $p );
$n = & $this->children[$k]->findNode( implode( '/', $p ) );
if (isset( $n )) {
return $n;
}
else {
foreach( $this->children as $k => $v) {
if ( ($v->type!=='cdata')&&($v->name===$p[0])) {
if (sizeof($p)>1) {
array_shift($p);
$n=& $this->children[$k]->findNode(implode('/',$p));
if (isset($n)) return $n;
}
else {
} else {
return $this->children[$k];
}
}
@@ -152,21 +170,22 @@ class Xml_Node
}
return $n;
}
/**
* Function getXML
* Returns a string of the node in XML notation.
*
* @author David S. Callizaya S. <davidsantos@colosa.com>
* @access public
* @parameter string xpath
* @param eter string xpath
* @return string
*/
function getXML()
{
switch($this->type)
function getXML ()
{
switch ($this->type) {
case 'open':
$xml = '<'.$this->name;
foreach( $this->attributes as $attib => $value ) {
$xml = '<' . $this->name;
foreach ($this->attributes as $attib => $value) {
$value = htmlspecialchars( $value, ENT_QUOTES, 'utf-8' );
/*if(($attib == "hint")||($attib == "defaultvalue")){
$value = str_replace("&", "&amp;", $value);
@@ -181,38 +200,35 @@ class Xml_Node
$xml .= ' ' . $attib . '="' . $value . '"';
//check if the htmlentities result value is the euro symbol and
//replaced by their numeric character representation
if (strpos($xml, '&euro;') !== false) {
$xml = str_replace('&euro;', '&#8364;', $xml);
if (strpos( $xml, '&euro;' ) !== false) {
$xml = str_replace( '&euro;', '&#8364;', $xml );
}
}
$xml .= '>'.$this->getCDATAValue();
foreach( $this->children as $child )
$xml .= '>' . $this->getCDATAValue();
foreach ($this->children as $child) {
$xml .= $child->getXML();
$xml .= '</'.$this->name.'>';
}
$xml .= '</' . $this->name . '>';
break;
case 'close':
$xml = '</'.$this->name.'>';
$xml = '</' . $this->name . '>';
break;
case 'cdata':
$xml = $this->getCDATAValue();
break;
case 'complete':
$xml = '<'.$this->name;
foreach( $this->attributes as $attib => $value ) {
$xml .= ' ' . $attib . '="' . htmlentities($value, ENT_QUOTES, 'utf-8' ) . '"';
$xml = '<' . $this->name;
foreach ($this->attributes as $attib => $value) {
$xml .= ' ' . $attib . '="' . htmlentities( $value, ENT_QUOTES, 'utf-8' ) . '"';
//check if the htmlentities result value is the euro symbol and
//replaced by their numeric character representation
if (strpos($xml, '&euro;') !== false) {
$xml = str_replace('&euro;', '&#8364;', $xml);
if (strpos( $xml, '&euro;' ) !== false) {
$xml = str_replace( '&euro;', '&#8364;', $xml );
}
}
if ($this->value!=='') {
$xml .= '>'.$this->getCDATAValue();
$xml .= '</'.$this->name.'>';
if ($this->value !== '') {
$xml .= '>' . $this->getCDATAValue();
$xml .= '</' . $this->name . '>';
} else {
$xml .= '/>';
}
@@ -220,17 +236,21 @@ class Xml_Node
}
return $xml;
}
function getCDATAValue()
function getCDATAValue ()
{
$cdata = htmlentities( $this->value, ENT_QUOTES, 'utf-8' );
if ($this->value === $cdata)
if ($this->value === $cdata) {
return $this->value;
else
} else {
return '<![CDATA[' . $this->value . ']]>';
}
}
}
/**
* Class Xml_document
*
* @author David S. Callizaya S. <davidsantos@colosa.com>
* @package gulliver.system
* @access public
@@ -238,43 +258,46 @@ class Xml_Node
class Xml_document extends Xml_Node
{
var $currentNode;
/**
* Function Xml_document
*
* @author David S. Callizaya S. <davidsantos@colosa.com>
* @access public
* @return string
*/
function Xml_document()
function Xml_document ()
{
$this->currentNode = &$this;
}
/**
* Function parseXmlFile
*
* @author David S. Callizaya S. <davidsantos@colosa.com>
* @access public
* @parameter string filename
* @parameter string content
* @param eter string filename
* @param eter string content
* @return string
*/
function parseXmlFile($filename,$content="")
function parseXmlFile ($filename, $content = "")
{ //$content is a new variable, if it has any value then use it instead of the file content.
if($content==""){
if ( !file_exists ($filename) ) {
throw ( new Exception ( "failed to open Xmlform File : No such file or directory in $filename " ) );
if ($content == "") {
if (! file_exists( $filename )) {
throw (new Exception( "failed to open Xmlform File : No such file or directory in $filename " ));
}
$data = implode( '', file( $filename) );
}else{
$data = implode( '', file( $filename ) );
} else {
$data = $content;
}
$parser = xml_parser_create( 'utf-8' );
xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0);
xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 0);
xml_parse_into_struct($parser, $data, $values, $tags);
if (xml_get_error_code($parser)!== 0) {
$msg = sprintf( "XML error in <b>%s</b>: %s at line %d", $filename , xml_error_string(xml_get_error_code($parser)), xml_get_current_line_number($parser));
trigger_error ( $msg );
xml_parser_set_option( $parser, XML_OPTION_CASE_FOLDING, 0 );
xml_parser_set_option( $parser, XML_OPTION_SKIP_WHITE, 0 );
xml_parse_into_struct( $parser, $data, $values, $tags );
if (xml_get_error_code( $parser ) !== 0) {
$msg = sprintf( "XML error in <b>%s</b>: %s at line %d", $filename, xml_error_string( xml_get_error_code( $parser ) ), xml_get_current_line_number( $parser ) );
trigger_error( $msg );
}
xml_parser_free( $parser );
@@ -282,83 +305,77 @@ class Xml_document extends Xml_Node
$this->type = 'open';
$this->currentNode = &$this;
$m = &$this;
foreach($values as $k => $v)
{
switch ($v['type'])
{
foreach ($values as $k => $v) {
switch ($v['type']) {
case 'open':
$this->currentNode->addChildNode ( new Xml_Node ($v['tag'],
$v['type'], isset($v['value'])?$v['value'] : '',
isset($v['attributes']) ? $v['attributes']:array()));
$this->currentNode = &$this->findNode($v['tag']);
$this->currentNode->addChildNode( new Xml_Node( $v['tag'], $v['type'], isset( $v['value'] ) ? $v['value'] : '', isset( $v['attributes'] ) ? $v['attributes'] : array () ) );
$this->currentNode = &$this->findNode( $v['tag'] );
break;
case 'close':
$this->currentNode=& $this->findNode('..');
$this->currentNode = & $this->findNode( '..' );
break;
case 'cdata':
$this->currentNode->addChildNode(new Xml_Node('',
$v['type'], isset($v['value'])?$v['value']:''));
$this->currentNode->addChildNode( new Xml_Node( '', $v['type'], isset( $v['value'] ) ? $v['value'] : '' ) );
break;
case 'complete':
$this->currentNode->addChildNode( new Xml_Node($v['tag'],
$v['type'], isset($v['value'])?$v['value']:'',
isset($v['attributes'])?$v['attributes']:array()));
$this->currentNode->addChildNode( new Xml_Node( $v['tag'], $v['type'], isset( $v['value'] ) ? $v['value'] : '', isset( $v['attributes'] ) ? $v['attributes'] : array () ) );
break;
}
}
return true;
}
/**
* Function &findNode
*
* @author David S. Callizaya S. <davidsantos@colosa.com>
* @access public
* @parameter string xpath
* @param eter string xpath
* @return string
*/
function &findNode( $xpath )
function &findNode ($xpath)
{
if ( substr( $xpath, 0, 1 ) == '/' ) {
return parent::findNode( substr( $xpath,1) );
}
else {
if ( isset($this->currentNode) ){
if ( $this->currentNode->name === $this->name)
if (substr( $xpath, 0, 1 ) == '/') {
return parent::findNode( substr( $xpath, 1 ) );
} else {
if (isset( $this->currentNode )) {
if ($this->currentNode->name === $this->name) {
return parent::findNode( $xpath );
else
return $this->currentNode->findNode($xpath);
} else {
return $this->currentNode->findNode( $xpath );
}
else {
} else {
return $null;
}
}
} //function findNode
/**
* Function getXML
*
* @access public
* @return string $xml
*/
function getXML()
function getXML ()
{
$xml = '<?xml version="1.0" encoding="UTF-8"?>'."\n";
$xml = '<?xml version="1.0" encoding="UTF-8"?>' . "\n";
$xml .= $this->children[0]->getXML();
return $xml;
}
/**
* Function save
*
* @access public
* @return void
*/
function save ( $filename )
function save ($filename)
{
$xml = $this->getXML();
$fp = fopen( $filename , 'w' );
fwrite( $fp , $xml );
fclose( $fp );/**/
$fp = fopen( $filename, 'w' );
fwrite( $fp, $xml );
fclose( $fp );
}
}

View File

@@ -1,6 +1,8 @@
<?php
/**
* class.xmlformExtension.php
*
* @package gulliver.system
*
* ProcessMaker Open Source Edition
@@ -24,7 +26,8 @@
*
*/
/**
/**
*
* @package gulliver.system
*/
@@ -38,6 +41,7 @@ class XmlForm_Field_Label extends XmlForm_Field
* Special class for pagedTable
* condition: PHP expression whose result defines whether to "mark"
* the following columns (that is if true)
*
* @package gulliver.system
*/
class XmlForm_Field_cellMark extends XmlForm_Field
@@ -60,14 +64,13 @@ class XmlForm_Field_cellMark extends XmlForm_Field
*
* @return string $value
*/
function tdStyle( $values , $owner )
function tdStyle ($values, $owner)
{
$value = G::replaceDataField( $this->condition, $owner->values );
$value = @eval('return ('.$value.');');
$row=$values['row__'];
$style=((($row % 2)==0) && ($this->styleAlt!=0)) ?
$this->styleAlt : $this->style;
return ($value)?$style:'';
$value = @eval( 'return (' . $value . ');' );
$row = $values['row__'];
$style = ((($row % 2) == 0) && ($this->styleAlt != 0)) ? $this->styleAlt : $this->style;
return ($value) ? $style : '';
}
/**
@@ -78,22 +81,21 @@ class XmlForm_Field_cellMark extends XmlForm_Field
*
* @return $value
*/
function tdClass( $values, $owner )
function tdClass ($values, $owner)
{
$value = G::replaceDataField( $this->condition, $owner->values );
$value = @eval('return ('.$value.');');
$row=$values['row__'];
$style=(($row % 2)==0) ?
$this->classNameAlt : $this->className;
return ($value)?$style:'';
$value = @eval( 'return (' . $value . ');' );
$row = $values['row__'];
$style = (($row % 2) == 0) ? $this->classNameAlt : $this->className;
return ($value) ? $style : '';
}
}
/**
* XmlForm_Field_DVEditor
*
* extends XmlForm_Field
*
* @package gulliver.system
*
*/
@@ -101,7 +103,7 @@ class XmlForm_Field_DVEditor extends XmlForm_Field
{
var $toolbarSet = 'toolbar2lines.html';
var $width = '90%';
var $height = '200' ;
var $height = '200';
/**
* render
@@ -111,9 +113,9 @@ class XmlForm_Field_DVEditor extends XmlForm_Field
*
* @return string '<div> ... </div>'
*/
function render( $value, $owner = NULL )
function render ($value, $owner = null)
{
return '<div style="width:'.htmlentities($this->width,ENT_QUOTES,'utf-8').';height:'.htmlentities($this->height,ENT_QUOTES,'utf-8').'"><input id="form['.$this->name.']" name="form['.$this->name.']" type="hidden" value="'.htmlentities($value,ENT_QUOTES,'UTF-8').'"/></div>';
return '<div style="width:' . htmlentities( $this->width, ENT_QUOTES, 'utf-8' ) . ';height:' . htmlentities( $this->height, ENT_QUOTES, 'utf-8' ) . '"><input id="form[' . $this->name . ']" name="form[' . $this->name . ']" type="hidden" value="' . htmlentities( $value, ENT_QUOTES, 'UTF-8' ) . '"/></div>';
}
/**
@@ -123,9 +125,9 @@ class XmlForm_Field_DVEditor extends XmlForm_Field
*
* @return $html
*/
function attachEvents($element)
function attachEvents ($element)
{
$html = 'var _editor'.$this->name.'=new DVEditor(getField("form['.$this->name.']").parentNode,getField("form['.$this->name.']").value)';
$html = 'var _editor' . $this->name . '=new DVEditor(getField("form[' . $this->name . ']").parentNode,getField("form[' . $this->name . ']").value)';
return $html;
}
}
@@ -146,6 +148,7 @@ class XmlForm_Field_DVEditor extends XmlForm_Field
* <PAGED_TABLE_FAST_SEARCH type="text" colAlign="right" colWidth="180" onkeypress="if (event.keyCode===13)@#PAGED_TABLE_ID.doFastSearch(this.value);if (event.keyCode===13)return false;">
* <en>Search</en>
* </PAGED_TABLE_FAST_SEARCH>
*
* @package gulliver.system
*/
class XmlForm_Field_FastSearch extends XmlForm_Field_Text
@@ -155,3 +158,4 @@ class XmlForm_Field_FastSearch extends XmlForm_Field_Text
var $colWidth = "180";
var $label = "@G::LoadTranslation(ID_SEARCH)";
}