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:
@@ -1,6 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* class.database_base.php
|
* class.database_base.php
|
||||||
|
*
|
||||||
* @package gulliver.system
|
* @package gulliver.system
|
||||||
*
|
*
|
||||||
* ProcessMaker Open Source Edition
|
* ProcessMaker Open Source Edition
|
||||||
@@ -25,6 +27,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
*
|
||||||
*
|
*
|
||||||
* Database Maintenance class
|
* Database Maintenance class
|
||||||
*
|
*
|
||||||
@@ -47,7 +50,7 @@ class DataBaseMaintenance
|
|||||||
protected $outfile;
|
protected $outfile;
|
||||||
protected $infile;
|
protected $infile;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* __construct
|
* __construct
|
||||||
*
|
*
|
||||||
* @param string $host is null
|
* @param string $host is null
|
||||||
@@ -56,159 +59,159 @@ class DataBaseMaintenance
|
|||||||
*
|
*
|
||||||
* @return none
|
* @return none
|
||||||
*/
|
*/
|
||||||
public function __construct($host = null, $user = null, $passwd = null)
|
public function __construct ($host = null, $user = null, $passwd = null)
|
||||||
{
|
{
|
||||||
$this->tmpDir = './';
|
$this->tmpDir = './';
|
||||||
$this->link = null;
|
$this->link = null;
|
||||||
$this->dbName = null;
|
$this->dbName = null;
|
||||||
|
|
||||||
if( isset($host) && isset($user) && isset($passwd) ) {
|
if (isset( $host ) && isset( $user ) && isset( $passwd )) {
|
||||||
$this->host = $host;
|
$this->host = $host;
|
||||||
$this->user = $user;
|
$this->user = $user;
|
||||||
$this->passwd = $passwd;
|
$this->passwd = $passwd;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* setUser
|
* setUser
|
||||||
*
|
*
|
||||||
* @param string $user
|
* @param string $user
|
||||||
*
|
*
|
||||||
* @return none
|
* @return none
|
||||||
*/
|
*/
|
||||||
public function setUser($user)
|
public function setUser ($user)
|
||||||
{
|
{
|
||||||
$this->user = $user;
|
$this->user = $user;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* setPasswd
|
* setPasswd
|
||||||
*
|
*
|
||||||
* @param string $passwd
|
* @param string $passwd
|
||||||
*
|
*
|
||||||
* @return none
|
* @return none
|
||||||
*/
|
*/
|
||||||
public function setPasswd($passwd)
|
public function setPasswd ($passwd)
|
||||||
{
|
{
|
||||||
$this->passwd = $passwd;
|
$this->passwd = $passwd;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* setHost
|
* setHost
|
||||||
*
|
*
|
||||||
* @param string $host
|
* @param string $host
|
||||||
*
|
*
|
||||||
* @return none
|
* @return none
|
||||||
*/
|
*/
|
||||||
public function setHost($host)
|
public function setHost ($host)
|
||||||
{
|
{
|
||||||
$this->host = $host;
|
$this->host = $host;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* setTempDir
|
* setTempDir
|
||||||
*
|
*
|
||||||
* @param string $tmpDir
|
* @param string $tmpDir
|
||||||
*
|
*
|
||||||
* @return none
|
* @return none
|
||||||
*/
|
*/
|
||||||
public function setTempDir($tmpDir)
|
public function setTempDir ($tmpDir)
|
||||||
{
|
{
|
||||||
$this->tmpDir = $tmpDir;
|
$this->tmpDir = $tmpDir;
|
||||||
if (!file_exists($tmpDir))
|
if (! file_exists( $tmpDir )) {
|
||||||
mkdir($this->tmpDir);
|
mkdir( $this->tmpDir );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* getTempDir
|
* getTempDir
|
||||||
*
|
*
|
||||||
* @return $this->tmpDir
|
* @return $this->tmpDir
|
||||||
*/
|
*/
|
||||||
public function getTempDir()
|
public function getTempDir ()
|
||||||
{
|
{
|
||||||
return $this->tmpDir;
|
return $this->tmpDir;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* status
|
* status
|
||||||
*
|
*
|
||||||
* @return $this->link
|
* @return $this->link
|
||||||
*/
|
*/
|
||||||
public function status()
|
public function status ()
|
||||||
{
|
{
|
||||||
return $$this->link;
|
return $$this->link;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
/**
|
|
||||||
* connect
|
* connect
|
||||||
*
|
*
|
||||||
* @param string $dbname is null
|
* @param string $dbname is null
|
||||||
*
|
*
|
||||||
* @return none
|
* @return none
|
||||||
*/
|
*/
|
||||||
public function connect($dbname = null)
|
public function connect ($dbname = null)
|
||||||
{
|
{
|
||||||
if( $this->link != null ) {
|
if ($this->link != null) {
|
||||||
mysql_close($this->link);
|
mysql_close( $this->link );
|
||||||
$this->link = null;
|
$this->link = null;
|
||||||
}
|
}
|
||||||
if( isset($dbname) ) {
|
if (isset( $dbname )) {
|
||||||
$this->dbName = $dbname;
|
$this->dbName = $dbname;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->link = mysql_connect($this->host, $this->user, $this->passwd);
|
$this->link = mysql_connect( $this->host, $this->user, $this->passwd );
|
||||||
@mysql_query("SET NAMES 'utf8';");
|
@mysql_query( "SET NAMES 'utf8';" );
|
||||||
if( ! $this->link ) {
|
if (! $this->link) {
|
||||||
throw new Exception("Couldn't connect to host {$this->host} with user {$this->user}");
|
throw new Exception( "Couldn't connect to host {$this->host} with user {$this->user}" );
|
||||||
}
|
}
|
||||||
|
|
||||||
if( $this->dbName != null ) {
|
if ($this->dbName != null) {
|
||||||
$this->selectDataBase($this->dbName);
|
$this->selectDataBase( $this->dbName );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* setDbName
|
* setDbName
|
||||||
*
|
*
|
||||||
* @param string $dbname is null
|
* @param string $dbname is null
|
||||||
*
|
*
|
||||||
* @return none
|
* @return none
|
||||||
*/
|
*/
|
||||||
public function setDbName($dbname)
|
public function setDbName ($dbname)
|
||||||
{
|
{
|
||||||
$this->dbName = $dbname;
|
$this->dbName = $dbname;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* selectDataBase
|
* selectDataBase
|
||||||
*
|
*
|
||||||
* @param string $dbname
|
* @param string $dbname
|
||||||
*
|
*
|
||||||
* @return none
|
* @return none
|
||||||
*/
|
*/
|
||||||
public function selectDataBase($dbname)
|
public function selectDataBase ($dbname)
|
||||||
{
|
{
|
||||||
$this->setDbName($dbname);
|
$this->setDbName( $dbname );
|
||||||
If( ! @mysql_select_db($this->dbName, $this->link) ) {
|
if (! @mysql_select_db( $this->dbName, $this->link )) {
|
||||||
throw new Exception("Couldn't select database $dbname");
|
throw new Exception( "Couldn't select database $dbname" );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* query
|
* query
|
||||||
*
|
*
|
||||||
* @param string $sql
|
* @param string $sql
|
||||||
*
|
*
|
||||||
* @return $aRows
|
* @return $aRows
|
||||||
*/
|
*/
|
||||||
public function query($sql)
|
public function query ($sql)
|
||||||
{
|
{
|
||||||
$this->result = @mysql_query($sql);
|
$this->result = @mysql_query( $sql );
|
||||||
if($this->result){
|
if ($this->result) {
|
||||||
$aRows = Array();
|
$aRows = Array ();
|
||||||
while( $aRow = @mysql_fetch_assoc($this->result) ) {
|
while ($aRow = @mysql_fetch_assoc( $this->result )) {
|
||||||
array_push($aRows, $aRow);
|
array_push( $aRows, $aRow );
|
||||||
}
|
}
|
||||||
return $aRows;
|
return $aRows;
|
||||||
} else {
|
} else {
|
||||||
@@ -216,87 +219,87 @@ class DataBaseMaintenance
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* error
|
* error
|
||||||
*
|
*
|
||||||
* @return @mysql_error()
|
* @return @mysql_error()
|
||||||
*/
|
*/
|
||||||
public function error()
|
public function error ()
|
||||||
{
|
{
|
||||||
return @mysql_error($this->link);
|
return @mysql_error( $this->link );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* getTablesList
|
* getTablesList
|
||||||
*
|
*
|
||||||
* @return $aRows
|
* @return $aRows
|
||||||
*/
|
*/
|
||||||
public function getTablesList()
|
public function getTablesList ()
|
||||||
{
|
{
|
||||||
$this->result = @mysql_query("SHOW TABLES;");
|
$this->result = @mysql_query( "SHOW TABLES;" );
|
||||||
$aRows = Array ();
|
$aRows = Array ();
|
||||||
while( $aRow = mysql_fetch_row($this->result) ) {
|
while ($aRow = mysql_fetch_row( $this->result )) {
|
||||||
array_push($aRows, $aRow[0]);
|
array_push( $aRows, $aRow[0] );
|
||||||
}
|
}
|
||||||
return $aRows;
|
return $aRows;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* dumpData
|
* dumpData
|
||||||
*
|
*
|
||||||
* @param string $table
|
* @param string $table
|
||||||
*
|
*
|
||||||
* @return boolean true or false
|
* @return boolean true or false
|
||||||
*/
|
*/
|
||||||
function dumpData($table)
|
function dumpData ($table)
|
||||||
{
|
{
|
||||||
$this->outfile = $this->tmpDir . $table . '.dump';
|
$this->outfile = $this->tmpDir . $table . '.dump';
|
||||||
|
|
||||||
//if the file exists delete it
|
//if the file exists delete it
|
||||||
if( is_file($this->outfile) ) {
|
if (is_file( $this->outfile )) {
|
||||||
@unlink($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";
|
$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.
|
// The mysql_escape_string function has been DEPRECATED as of PHP 5.3.0.
|
||||||
// Commented that is not assigned to a variable.
|
// Commented that is not assigned to a variable.
|
||||||
// mysql_escape_string("';");
|
// mysql_escape_string("';");
|
||||||
if( ! @mysql_query($sql) ) {
|
if (! @mysql_query( $sql )) {
|
||||||
echo mysql_error() . "\n";
|
echo mysql_error() . "\n";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* restoreData
|
* restoreData
|
||||||
*
|
*
|
||||||
* @param string $backupFile
|
* @param string $backupFile
|
||||||
*
|
*
|
||||||
* @return boolean true or false
|
* @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'";
|
$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";
|
print mysql_error() . "\n";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* backupData
|
* backupData
|
||||||
*
|
*
|
||||||
* @return boolean true or false
|
* @return boolean true or false
|
||||||
*/
|
*/
|
||||||
function backupData()
|
function backupData ()
|
||||||
{
|
{
|
||||||
$aTables = $this->getTablesList();
|
$aTables = $this->getTablesList();
|
||||||
foreach( $aTables as $table ) {
|
foreach ($aTables as $table) {
|
||||||
if( $this->dumpData($table) !== false ) {
|
if ($this->dumpData( $table ) !== false) {
|
||||||
printf("%20s %s %s\n", 'Dump of table:', $table, " in file {$this->outfile}");
|
printf( "%20s %s %s\n", 'Dump of table:', $table, " in file {$this->outfile}" );
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -304,55 +307,56 @@ class DataBaseMaintenance
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* backupSqlData
|
* backupSqlData
|
||||||
*
|
*
|
||||||
* @return boolean true or false
|
* @return boolean true or false
|
||||||
*/
|
*/
|
||||||
function backupSqlData()
|
function backupSqlData ()
|
||||||
{
|
{
|
||||||
$aTables = $this->getTablesList();
|
$aTables = $this->getTablesList();
|
||||||
foreach( $aTables as $table ) {
|
foreach ($aTables as $table) {
|
||||||
$fsize = $this->dumpSqlInserts($table);
|
$fsize = $this->dumpSqlInserts( $table );
|
||||||
$file = basename($this->outfile);
|
$file = basename( $this->outfile );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* restoreAllData
|
* restoreAllData
|
||||||
*
|
*
|
||||||
* @param string $type default value null
|
* @param string $type default value null
|
||||||
*
|
*
|
||||||
* @return none
|
* @return none
|
||||||
*/
|
*/
|
||||||
function restoreAllData($type = null)
|
function restoreAllData ($type = null)
|
||||||
{
|
{
|
||||||
|
|
||||||
$aTables = $this->getTablesList();
|
$aTables = $this->getTablesList();
|
||||||
|
|
||||||
foreach( $aTables as $table ) {
|
foreach ($aTables as $table) {
|
||||||
if( isset($type) && $type == 'sql' ) {
|
if (isset( $type ) && $type == 'sql') {
|
||||||
$this->infile = $this->tmpDir . $table . ".sql";
|
$this->infile = $this->tmpDir . $table . ".sql";
|
||||||
if( is_file($this->infile) ) {
|
if (is_file( $this->infile )) {
|
||||||
$queries = $this->restoreFromSql($this->infile, true);
|
$queries = $this->restoreFromSql( $this->infile, true );
|
||||||
if (!isset($queries))
|
if (! isset( $queries )) {
|
||||||
$queries = "unknown";
|
$queries = "unknown";
|
||||||
printf("%-59s%20s", "Restored table $table", "$queries queries\n");
|
}
|
||||||
|
printf( "%-59s%20s", "Restored table $table", "$queries queries\n" );
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$this->infile = $this->tmpDir . $table . ".dump";
|
$this->infile = $this->tmpDir . $table . ".dump";
|
||||||
if( is_file($this->infile) ) {
|
if (is_file( $this->infile )) {
|
||||||
$this->restoreData($this->infile);
|
$this->restoreData( $this->infile );
|
||||||
printf("%20s %s %s\n", 'Restoring data from ', $this->infile, " in table $table");
|
printf( "%20s %s %s\n", 'Restoring data from ', $this->infile, " in table $table" );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* createDb
|
* createDb
|
||||||
*
|
*
|
||||||
* @param string $dbname
|
* @param string $dbname
|
||||||
@@ -360,227 +364,233 @@ class DataBaseMaintenance
|
|||||||
*
|
*
|
||||||
* @return none
|
* @return none
|
||||||
*/
|
*/
|
||||||
function createDb($dbname, $drop = false)
|
function createDb ($dbname, $drop = false)
|
||||||
{
|
{
|
||||||
if( $drop ) {
|
if ($drop) {
|
||||||
$sql = "DROP DATABASE IF EXISTS $dbname;";
|
$sql = "DROP DATABASE IF EXISTS $dbname;";
|
||||||
if( ! @mysql_query($sql) ) {
|
if (! @mysql_query( $sql )) {
|
||||||
throw new Exception(mysql_error());
|
throw new Exception( mysql_error() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$sql = "CREATE DATABASE IF NOT EXISTS $dbname DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;";
|
$sql = "CREATE DATABASE IF NOT EXISTS $dbname DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;";
|
||||||
if( ! @mysql_query($sql) ) {
|
if (! @mysql_query( $sql )) {
|
||||||
throw new Exception(mysql_error());
|
throw new Exception( mysql_error() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* restoreFromSql2
|
* restoreFromSql2
|
||||||
*
|
*
|
||||||
* @param string $sqlfile
|
* @param string $sqlfile
|
||||||
*
|
*
|
||||||
* @return none
|
* @return none
|
||||||
*/
|
*/
|
||||||
function restoreFromSql2($sqlfile)
|
function restoreFromSql2 ($sqlfile)
|
||||||
{
|
{
|
||||||
|
|
||||||
ini_set('memory_limit', '512M');
|
ini_set( 'memory_limit', '512M' );
|
||||||
if( ! is_file($sqlfile) ) {
|
if (! is_file( $sqlfile )) {
|
||||||
throw new Exception("the $sqlfile doesn't exist!");
|
throw new Exception( "the $sqlfile doesn't exist!" );
|
||||||
}
|
}
|
||||||
$query = file_get_contents($sqlfile);
|
$query = file_get_contents( $sqlfile );
|
||||||
$mysqli = new mysqli($this->host, $this->user, $this->passwd, $this->dbName);
|
$mysqli = new mysqli( $this->host, $this->user, $this->passwd, $this->dbName );
|
||||||
|
|
||||||
/* check connection */
|
/* check connection */
|
||||||
if( mysqli_connect_errno() ) {
|
if (mysqli_connect_errno()) {
|
||||||
printf("Connect failed: %s\n", mysqli_connect_error());
|
printf( "Connect failed: %s\n", mysqli_connect_error() );
|
||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* execute multi query */
|
/* execute multi query */
|
||||||
if( $mysqli->multi_query($query) ) {
|
if ($mysqli->multi_query( $query )) {
|
||||||
do {
|
do {
|
||||||
/* store first result set */
|
/* store first result set */
|
||||||
if( $result = $mysqli->store_result() ) {
|
if ($result = $mysqli->store_result()) {
|
||||||
while( $row = $result->fetch_row() ) {
|
while ($row = $result->fetch_row()) {
|
||||||
}
|
}
|
||||||
$result->free();
|
$result->free();
|
||||||
}
|
}
|
||||||
|
|
||||||
} while( $mysqli->next_result() );
|
} while ($mysqli->next_result());
|
||||||
}
|
}
|
||||||
|
|
||||||
/* close connection */
|
/* close connection */
|
||||||
$mysqli->close();
|
$mysqli->close();
|
||||||
}
|
}
|
||||||
|
|
||||||
function lockTables() {
|
function lockTables ()
|
||||||
|
{
|
||||||
$aTables = $this->getTablesList();
|
$aTables = $this->getTablesList();
|
||||||
if (empty($aTables))
|
if (empty( $aTables ))
|
||||||
return false;
|
return false;
|
||||||
printf("%-70s", "LOCK TABLES");
|
printf( "%-70s", "LOCK TABLES" );
|
||||||
if( @mysql_query("LOCK TABLES ".implode(" READ, ", $aTables)." READ; ") ) {
|
if (@mysql_query( "LOCK TABLES " . implode( " READ, ", $aTables ) . " READ; " )) {
|
||||||
echo " [OK]\n";
|
echo " [OK]\n";
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
echo "[FAILED]\n".mysql_error()."\n";
|
echo "[FAILED]\n" . mysql_error() . "\n";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function unlockTables() {
|
function unlockTables ()
|
||||||
printf("%-70s", "UNLOCK TABLES");
|
{
|
||||||
if( @mysql_query("UNLOCK TABLES;") )
|
printf( "%-70s", "UNLOCK TABLES" );
|
||||||
|
if (@mysql_query( "UNLOCK TABLES;" )) {
|
||||||
echo " [OK]\n";
|
echo " [OK]\n";
|
||||||
else
|
} else {
|
||||||
echo "[FAILED]\n".mysql_error()."\n";
|
echo "[FAILED]\n" . mysql_error() . "\n";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* dumpSqlInserts
|
* dumpSqlInserts
|
||||||
*
|
*
|
||||||
* @param string $table
|
* @param string $table
|
||||||
*
|
*
|
||||||
* @return integer $bytesSaved;
|
* @return integer $bytesSaved;
|
||||||
*/
|
*/
|
||||||
function dumpSqlInserts($table)
|
function dumpSqlInserts ($table)
|
||||||
{
|
{
|
||||||
|
|
||||||
$bytesSaved = 0;
|
$bytesSaved = 0;
|
||||||
$result = @mysql_query("SELECT * FROM `$table`");
|
$result = @mysql_query( "SELECT * FROM `$table`" );
|
||||||
|
|
||||||
$num_rows = mysql_num_rows($result);
|
$num_rows = mysql_num_rows( $result );
|
||||||
$num_fields = mysql_num_fields($result);
|
$num_fields = mysql_num_fields( $result );
|
||||||
|
|
||||||
$data = "";
|
$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 (";
|
$data .= "INSERT INTO `$table` VALUES (";
|
||||||
|
|
||||||
for( $x = 0; $x < $num_fields; $x ++ ) {
|
for ($x = 0; $x < $num_fields; $x ++) {
|
||||||
$field_name = mysql_field_name($result, $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 .= ($x < ($num_fields - 1)) ? ", " : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$data .= ");\n";
|
$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;
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* backupDataBaseSchema
|
* backupDataBaseSchema
|
||||||
*
|
*
|
||||||
* @param string $outfile
|
* @param string $outfile
|
||||||
*
|
*
|
||||||
* @return none
|
* @return none
|
||||||
*/
|
*/
|
||||||
function backupDataBase($outfile)
|
function backupDataBase ($outfile)
|
||||||
{
|
{
|
||||||
$aTables = $this->getTablesList();
|
$aTables = $this->getTablesList();
|
||||||
$ws = explode('_', $this->dbName);
|
$ws = explode( '_', $this->dbName );
|
||||||
$ws = isset($ws[1]) ? $ws[1] : $this->dbName;
|
$ws = isset( $ws[1] ) ? $ws[1] : $this->dbName;
|
||||||
$schema = "\n";
|
$schema = "\n";
|
||||||
$schema .= " -- Processmaker Data Base Maintenance Tool\n";
|
$schema .= " -- Processmaker Data Base Maintenance Tool\n";
|
||||||
$schema .= " --\n";
|
$schema .= " --\n";
|
||||||
$schema .= " -- Workspace: " . $ws . "\n";
|
$schema .= " -- Workspace: " . $ws . "\n";
|
||||||
$schema .= " -- Data Base: " . $this->dbName . "\n";
|
$schema .= " -- Data Base: " . $this->dbName . "\n";
|
||||||
$schema .= " -- Tables: " . (count($aTables)) . "\n";
|
$schema .= " -- Tables: " . (count( $aTables )) . "\n";
|
||||||
$schema .= " -- Date: " . (date('l jS \of F Y h:i:s A')) . "\n";
|
$schema .= " -- Date: " . (date( 'l jS \of F Y h:i:s A' )) . "\n";
|
||||||
$schema .= " --\n\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 = "\nDROP TABLE IF EXISTS `$table`;\n\n";
|
||||||
$tableSchema .= $this->getSchemaFromTable($table);
|
$tableSchema .= $this->getSchemaFromTable( $table );
|
||||||
$data = $this->dumpSqlInserts($table);
|
$data = $this->dumpSqlInserts( $table );
|
||||||
fwrite($file, $tableSchema);
|
fwrite( $file, $tableSchema );
|
||||||
fwrite($file, $data);
|
fwrite( $file, $data );
|
||||||
}
|
}
|
||||||
|
|
||||||
fclose($file);
|
fclose( $file );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* restoreFromSql
|
* restoreFromSql
|
||||||
*
|
*
|
||||||
* @param string $sqlfile
|
* @param string $sqlfile
|
||||||
*
|
*
|
||||||
* @return boolean false or true
|
* @return boolean false or true
|
||||||
*/
|
*/
|
||||||
function restoreFromSql($sqlfile, $type='file')
|
function restoreFromSql ($sqlfile, $type = 'file')
|
||||||
{
|
{
|
||||||
ini_set('memory_limit', '64M');
|
ini_set( 'memory_limit', '64M' );
|
||||||
if( $type == 'file' && !is_file($sqlfile) ) {
|
if ($type == 'file' && ! is_file( $sqlfile )) {
|
||||||
throw new Exception("the $sqlfile doesn't exist!");
|
throw new Exception( "the $sqlfile doesn't exist!" );
|
||||||
}
|
}
|
||||||
|
|
||||||
$metaFile = str_replace('.sql', '.meta', $sqlfile);
|
$metaFile = str_replace( '.sql', '.meta', $sqlfile );
|
||||||
|
|
||||||
$queries = 0;
|
$queries = 0;
|
||||||
|
|
||||||
if( is_file($metaFile) ) {
|
if (is_file( $metaFile )) {
|
||||||
echo "Using $metaFile as metadata.\n";
|
echo "Using $metaFile as metadata.\n";
|
||||||
$fp = fopen($sqlfile, 'rb');
|
$fp = fopen( $sqlfile, 'rb' );
|
||||||
$fpmd = fopen($metaFile, 'r');
|
$fpmd = fopen( $metaFile, 'r' );
|
||||||
while( $offset = fgets($fpmd, 1024) ) {
|
while ($offset = fgets( $fpmd, 1024 )) {
|
||||||
$buffer = intval($offset); //reading the size of $oData
|
$buffer = intval( $offset ); //reading the size of $oData
|
||||||
$query = fread($fp, $buffer); //reading string $oData
|
$query = fread( $fp, $buffer ); //reading string $oData
|
||||||
$queries += 1;
|
$queries += 1;
|
||||||
|
|
||||||
if( ! @mysql_query($query) ) {
|
if (! @mysql_query( $query )) {
|
||||||
echo mysql_error() . "\n";
|
echo mysql_error() . "\n";
|
||||||
echo "==>" . $query . "<==\n";
|
echo "==>" . $query . "<==\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
$queries = NULL;
|
$queries = null;
|
||||||
try{
|
try {
|
||||||
$mysqli = new mysqli($this->host, $this->user, $this->passwd, $this->dbName);
|
$mysqli = new mysqli( $this->host, $this->user, $this->passwd, $this->dbName );
|
||||||
/* check connection */
|
/* check connection */
|
||||||
if( mysqli_connect_errno() ) {
|
if (mysqli_connect_errno()) {
|
||||||
printf("Connect failed: %s\n", mysqli_connect_error());
|
printf( "Connect failed: %s\n", mysqli_connect_error() );
|
||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
if($type == 'file'){
|
if ($type == 'file') {
|
||||||
$query = file_get_contents($sqlfile);
|
$query = file_get_contents( $sqlfile );
|
||||||
} else if($type == 'string'){
|
} else if ($type == 'string') {
|
||||||
$query = $sqlfile;
|
$query = $sqlfile;
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( trim($query) == "" )
|
if (trim( $query ) == "") {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/* execute multi query */
|
/* execute multi query */
|
||||||
if( $mysqli->multi_query($query) ) {
|
if ($mysqli->multi_query( $query )) {
|
||||||
do {
|
do {
|
||||||
/* store first result set */
|
/* store first result set */
|
||||||
if( $result = $mysqli->store_result() ) {
|
if ($result = $mysqli->store_result()) {
|
||||||
while( $row = $result->fetch_row() ) {
|
while ($row = $result->fetch_row()) {
|
||||||
//printf("%s\n", $row[0]);
|
//printf("%s\n", $row[0]);
|
||||||
}
|
}
|
||||||
$result->free();
|
$result->free();
|
||||||
}
|
}
|
||||||
/* print divider */
|
/* print divider */
|
||||||
if( $mysqli->more_results() ) {
|
if ($mysqli->more_results()) {
|
||||||
//printf("-----------------\n");
|
//printf("-----------------\n");
|
||||||
}
|
}
|
||||||
} while( $mysqli->next_result() );
|
} while ($mysqli->next_result());
|
||||||
} else throw new Exception(mysqli_error($mysqli));
|
} else {
|
||||||
|
throw new Exception( mysqli_error( $mysqli ) );
|
||||||
|
}
|
||||||
|
|
||||||
/* close connection */
|
/* close connection */
|
||||||
$mysqli->close();
|
$mysqli->close();
|
||||||
} catch(Exception $e){
|
} catch (Exception $e) {
|
||||||
echo $query;
|
echo $query;
|
||||||
echo $e->getMessage();
|
echo $e->getMessage();
|
||||||
}
|
}
|
||||||
@@ -588,44 +598,44 @@ class DataBaseMaintenance
|
|||||||
return $queries;
|
return $queries;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* getSchemaFromTable
|
* getSchemaFromTable
|
||||||
*
|
*
|
||||||
* @param string $tablename
|
* @param string $tablename
|
||||||
*
|
*
|
||||||
* @return string $tableSchema
|
* @return string $tableSchema
|
||||||
*/
|
*/
|
||||||
function getSchemaFromTable($tablename)
|
function getSchemaFromTable ($tablename)
|
||||||
{
|
{
|
||||||
//$tableSchema = "/* Structure for table `$tablename` */\n";
|
//$tableSchema = "/* Structure for table `$tablename` */\n";
|
||||||
//$tableSchema .= "DROP TABLE IF EXISTS `$tablename`;\n\n";
|
//$tableSchema .= "DROP TABLE IF EXISTS `$tablename`;\n\n";
|
||||||
$tableSchema = "";
|
$tableSchema = "";
|
||||||
$sql = "show create table `$tablename`; ";
|
$sql = "show create table `$tablename`; ";
|
||||||
$result = @mysql_query($sql);
|
$result = @mysql_query( $sql );
|
||||||
if( $result ) {
|
if ($result) {
|
||||||
if( $row = mysql_fetch_assoc($result) ) {
|
if ($row = mysql_fetch_assoc( $result )) {
|
||||||
$tableSchema .= $row['Create Table'] . ";\n\n";
|
$tableSchema .= $row['Create Table'] . ";\n\n";
|
||||||
}
|
}
|
||||||
mysql_free_result($result);
|
mysql_free_result( $result );
|
||||||
} else
|
} else {
|
||||||
echo mysql_error();
|
echo mysql_error();
|
||||||
|
}
|
||||||
return $tableSchema;
|
return $tableSchema;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* removeCommentsIntoString
|
* removeCommentsIntoString
|
||||||
*
|
*
|
||||||
* @param string $str
|
* @param string $str
|
||||||
*
|
*
|
||||||
* @return string $str
|
* @return string $str
|
||||||
*/
|
*/
|
||||||
function removeCommentsIntoString($str)
|
function removeCommentsIntoString ($str)
|
||||||
{
|
{
|
||||||
$str = preg_replace('/\/\*[\w\W]*\*\//', '', $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]*\\n/", '', $str );
|
||||||
$str = preg_replace("/\#[\w\W]*\\n/", '', $str);
|
$str = preg_replace( "/\#[\w\W]*\\n/", '', $str );
|
||||||
return $str;
|
return $str;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -649,11 +659,3 @@ $o2->restoreFromSql('/home/erik/backs/schema_os.sql');
|
|||||||
$o2->restoreAllData('sql');
|
$o2->restoreAllData('sql');
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -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)
|
function DBConnection ($strServer = DB_HOST, $strUser = DB_USER, $strPwd = DB_PASS, $strDB = DB_NAME, $type = DB_ADAPTER, $strPort = 0, $errorLevel = 2)
|
||||||
{
|
{
|
||||||
$this->errorLevel = $errorLevel;
|
$this->errorLevel = $errorLevel;
|
||||||
if ($type == null)
|
if ($type == null) {
|
||||||
$type = 'mysql';
|
$type = 'mysql';
|
||||||
|
}
|
||||||
$this->type = $type;
|
$this->type = $type;
|
||||||
//print "<hr>$type $strServer, $strUser, $strPwd, $strDB <hr>";
|
//print "<hr>$type $strServer, $strUser, $strPwd, $strDB <hr>";
|
||||||
if ($type == "mysql")
|
if ($type == "mysql") {
|
||||||
$dsn = "mysql://$strUser:$strPwd@$strServer/$strDB";
|
$dsn = "mysql://$strUser:$strPwd@$strServer/$strDB";
|
||||||
|
}
|
||||||
if ($type == "pgsql") {
|
if ($type == "pgsql") {
|
||||||
//$dsn = "pgsql://postgres@$strServer/$strDB";
|
//$dsn = "pgsql://postgres@$strServer/$strDB";
|
||||||
$prt = ($strPort == 0 || $strPort == 5432 ? '' : ":$strPort");
|
$prt = ($strPort == 0 || $strPort == 5432 ? '' : ":$strPort");
|
||||||
$dsn = "pgsql://$strUser:$strPwd@$strServer$prt/$strDB";
|
$dsn = "pgsql://$strUser:$strPwd@$strServer$prt/$strDB";
|
||||||
}
|
}
|
||||||
if ($type == "odbc")
|
if ($type == "odbc") {
|
||||||
$dsn = "odbc://$strUser:$strPwd@$strServer/$strDB";
|
$dsn = "odbc://$strUser:$strPwd@$strServer/$strDB";
|
||||||
|
}
|
||||||
if ($type == "mssql") {
|
if ($type == "mssql") {
|
||||||
$strServer = substr( $strServer, 0, strpos( $strServer, ':' ) );
|
$strServer = substr( $strServer, 0, strpos( $strServer, ':' ) );
|
||||||
$prt = ($strPort == 0 || $strPort == 1433 ? '' : ":$strPort");
|
$prt = ($strPort == 0 || $strPort == 1433 ? '' : ":$strPort");
|
||||||
@@ -179,7 +182,7 @@ class DBConnection
|
|||||||
* @param string $errorLevel
|
* @param string $errorLevel
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function logError ($obj, $errorLevel = NULL)
|
function logError ($obj, $errorLevel = null)
|
||||||
{
|
{
|
||||||
global $_SESSION;
|
global $_SESSION;
|
||||||
global $_SERVER;
|
global $_SERVER;
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* class.dbrecordset.php
|
* class.dbrecordset.php
|
||||||
|
*
|
||||||
* @package gulliver.system
|
* @package gulliver.system
|
||||||
*
|
*
|
||||||
* ProcessMaker Open Source Edition
|
* ProcessMaker Open Source Edition
|
||||||
@@ -24,9 +26,10 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* DBRecordset class definition
|
* 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
|
* 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
|
* @package gulliver.system
|
||||||
*
|
*
|
||||||
* @author Fernando Ontiveros Lira <fernando@colosa.com>
|
* @author Fernando Ontiveros Lira <fernando@colosa.com>
|
||||||
@@ -44,7 +47,7 @@ class DBRecordSet
|
|||||||
* @param string $intResult Database recordset default value = false
|
* @param string $intResult Database recordset default value = false
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function DBRecordSet( $intResult = null )
|
function DBRecordSet ($intResult = null)
|
||||||
{
|
{
|
||||||
$this->SetTo( $intResult );
|
$this->SetTo( $intResult );
|
||||||
}
|
}
|
||||||
@@ -57,31 +60,28 @@ class DBRecordSet
|
|||||||
* @param string $intResult connection string default value = false
|
* @param string $intResult connection string default value = false
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function SetTo( $intResult = null )
|
function SetTo ($intResult = null)
|
||||||
{
|
{
|
||||||
if ( $intResult === null ) {
|
if ($intResult === null) {
|
||||||
$dberror = PEAR::raiseError(null, DB_ERROR_OBJECT_NOT_DEFINED, null, '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 );
|
||||||
"You tried to call to a DBRecordset with an invalid result recordset.",
|
|
||||||
'G_Error', true);
|
|
||||||
DBconnection::logError( $dberror );
|
DBconnection::logError( $dberror );
|
||||||
}
|
}
|
||||||
if ( $intResult ) {
|
if ($intResult) {
|
||||||
$this->result = $intResult;
|
$this->result = $intResult;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function Free
|
* Function Free
|
||||||
|
*
|
||||||
* @author David S. Callizaya S. <davidsantos@colosa.com>
|
* @author David S. Callizaya S. <davidsantos@colosa.com>
|
||||||
* @access public
|
* @access public
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
function Free()
|
function Free ()
|
||||||
{
|
{
|
||||||
if ( $this->result === null ) {
|
if ($this->result === null) {
|
||||||
$dberror = PEAR::raiseError(null, DB_ERROR_OBJECT_NOT_DEFINED, null, '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 );
|
||||||
"You tried to call to a DBRecordset with an invalid result recordset.",
|
|
||||||
'G_Error', true);
|
|
||||||
DBconnection::logError( $dberror );
|
DBconnection::logError( $dberror );
|
||||||
}
|
}
|
||||||
$this->result->free();
|
$this->result->free();
|
||||||
@@ -90,16 +90,15 @@ class DBRecordSet
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Function Count
|
* Function Count
|
||||||
|
*
|
||||||
* @author David S. Callizaya S. <davidsantos@colosa.com>
|
* @author David S. Callizaya S. <davidsantos@colosa.com>
|
||||||
* @access public
|
* @access public
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
function Count()
|
function Count ()
|
||||||
{
|
{
|
||||||
if ( $this->result === null ) {
|
if ($this->result === null) {
|
||||||
$dberror = PEAR::raiseError(null, DB_ERROR_OBJECT_NOT_DEFINED, null, '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 );
|
||||||
"You tried to call to a DBRecordset with an invalid result recordset.",
|
|
||||||
'G_Error', true);
|
|
||||||
DBconnection::logError( $dberror );
|
DBconnection::logError( $dberror );
|
||||||
}
|
}
|
||||||
return $this->result->numRows();
|
return $this->result->numRows();
|
||||||
@@ -107,22 +106,22 @@ class DBRecordSet
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Function Read
|
* Function Read
|
||||||
|
*
|
||||||
* @author David S. Callizaya S. <davidsantos@colosa.com>
|
* @author David S. Callizaya S. <davidsantos@colosa.com>
|
||||||
* @access public
|
* @access public
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
function Read()
|
function Read ()
|
||||||
{
|
{
|
||||||
if ( $this->result === null ) {
|
if ($this->result === null) {
|
||||||
$dberror = PEAR::raiseError(null, DB_ERROR_OBJECT_NOT_DEFINED, null, '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 );
|
||||||
"You tried to call to a DBRecordset with an invalid result recordset.",
|
|
||||||
'G_Error', true);
|
|
||||||
DBconnection::logError( $dberror );
|
DBconnection::logError( $dberror );
|
||||||
}
|
}
|
||||||
$res = $this->result->fetchRow(DB_FETCHMODE_ASSOC);
|
$res = $this->result->fetchRow( DB_FETCHMODE_ASSOC );
|
||||||
//for Pgsql databases,
|
//for Pgsql databases,
|
||||||
//if ( PEAR_DATABASE == "pgsql" && is_array ( $res ) ) { $res = array_change_key_case( $res, CASE_UPPER); }
|
//if ( PEAR_DATABASE == "pgsql" && is_array ( $res ) ) { $res = array_change_key_case( $res, CASE_UPPER); }
|
||||||
|
|
||||||
|
|
||||||
/* Comment Code: This block is not required now because
|
/* Comment Code: This block is not required now because
|
||||||
* of the the use of the G::sqlEscape() instead of addslashes
|
* of the the use of the G::sqlEscape() instead of addslashes
|
||||||
* funcion over each field in DBTable.
|
* funcion over each field in DBTable.
|
||||||
@@ -137,15 +136,17 @@ class DBRecordSet
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Function ReadAbsolute
|
* Function ReadAbsolute
|
||||||
|
*
|
||||||
* @author David S. Callizaya S. <davidsantos@colosa.com>
|
* @author David S. Callizaya S. <davidsantos@colosa.com>
|
||||||
* @access public
|
* @access public
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
function ReadAbsolute()
|
function ReadAbsolute ()
|
||||||
{
|
{
|
||||||
$res = $this->result->fetchRow(DB_FETCHMODE_ORDERED);
|
$res = $this->result->fetchRow( DB_FETCHMODE_ORDERED );
|
||||||
//for Pgsql databases,
|
//for Pgsql databases,
|
||||||
//if ( PEAR_DATABASE == "pgsql" && is_array ( $res ) ) { $res = array_change_key_case( $res, CASE_UPPER); }
|
//if ( PEAR_DATABASE == "pgsql" && is_array ( $res ) ) { $res = array_change_key_case( $res, CASE_UPPER); }
|
||||||
return $res;
|
return $res;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* class.dbsession.php
|
* class.dbsession.php
|
||||||
|
*
|
||||||
* @package gulliver.system
|
* @package gulliver.system
|
||||||
*
|
*
|
||||||
* ProcessMaker Open Source Edition
|
* ProcessMaker Open Source Edition
|
||||||
@@ -24,9 +26,10 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* DBSession class definition
|
* DBSession class definition
|
||||||
* It is useful to stablish a database connection using an specific database
|
* It is useful to stablish a database connection using an specific database
|
||||||
|
*
|
||||||
* @package gulliver.system
|
* @package gulliver.system
|
||||||
* @author Fernando Ontiveros Lira <fernando@colosa.com>
|
* @author Fernando Ontiveros Lira <fernando@colosa.com>
|
||||||
* @copyright (C) 2002 by Colosa Development Team.
|
* @copyright (C) 2002 by Colosa Development Team.
|
||||||
@@ -34,12 +37,13 @@
|
|||||||
*/
|
*/
|
||||||
class DBSession
|
class DBSession
|
||||||
{
|
{
|
||||||
var $dbc = NULL;
|
var $dbc = null;
|
||||||
var $dbname = '';
|
var $dbname = '';
|
||||||
var $result = false;
|
var $result = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Starts a session using a connection with an specific database
|
* Starts a session using a connection with an specific database
|
||||||
|
*
|
||||||
* @author Fernando Ontiveros Lira <fernando@colosa.com>
|
* @author Fernando Ontiveros Lira <fernando@colosa.com>
|
||||||
*
|
*
|
||||||
* @access public
|
* @access public
|
||||||
@@ -48,15 +52,17 @@ class DBSession
|
|||||||
* @return void
|
* @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 );
|
$this->setTo( $objConnection, $strDBName );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* It's like a constructor
|
* It's like a constructor
|
||||||
|
*
|
||||||
* @author Fernando Ontiveros Lira <fernando@colosa.com>
|
* @author Fernando Ontiveros Lira <fernando@colosa.com>
|
||||||
*
|
*
|
||||||
* @access public
|
* @access public
|
||||||
@@ -65,24 +71,23 @@ class DBSession
|
|||||||
* @return void
|
* @return void
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
function setTo( $objConnection = NULL, $strDBName = DB_NAME )
|
function setTo ($objConnection = null, $strDBName = DB_NAME)
|
||||||
{
|
|
||||||
if ( $objConnection != NULL )
|
|
||||||
{
|
{
|
||||||
|
if ($objConnection != null) {
|
||||||
$this->Free();
|
$this->Free();
|
||||||
$this->dbc = $objConnection;
|
$this->dbc = $objConnection;
|
||||||
$this->dbname = $strDBName;
|
$this->dbname = $strDBName;
|
||||||
|
|
||||||
//enable utf8 in mysql databases
|
//enable utf8 in mysql databases
|
||||||
if ( $this->dbc->db->phptype == 'mysql' ) { //utf-8
|
if ($this->dbc->db->phptype == 'mysql') { //utf-8
|
||||||
$this->dbc->db->query ( "SET NAMES 'utf8'; " );
|
$this->dbc->db->query( "SET NAMES 'utf8'; " );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* UseDB stablish a database for the connection
|
* UseDB stablish a database for the connection
|
||||||
|
*
|
||||||
* @author Fernando Ontiveros Lira <fernando@colosa.com>
|
* @author Fernando Ontiveros Lira <fernando@colosa.com>
|
||||||
*
|
*
|
||||||
* @access public
|
* @access public
|
||||||
@@ -90,39 +95,40 @@ class DBSession
|
|||||||
* @return void
|
* @return void
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
function UseDB( $strDBName = DB_NAME )
|
function UseDB ($strDBName = DB_NAME)
|
||||||
{
|
{
|
||||||
$this->dbname = $strDBName;
|
$this->dbname = $strDBName;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function Execute, to execute a query and send back the recordset.
|
* Function Execute, to execute a query and send back the recordset.
|
||||||
|
*
|
||||||
* @access public
|
* @access public
|
||||||
* @parameter string strQuery
|
* @param eter string strQuery
|
||||||
* @parameter string debug
|
* @param eter string debug
|
||||||
* @parameter string error
|
* @param eter string error
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
function Execute( $strQuery = '', $debug = false, $errorLevel = null )
|
function Execute ($strQuery = '', $debug = false, $errorLevel = null)
|
||||||
{
|
{
|
||||||
//BUG::traceRoute();
|
//BUG::traceRoute();
|
||||||
if ($this->dbc == NULL ) {
|
if ($this->dbc == null) {
|
||||||
$dberror = PEAR::raiseError(null, DB_ERROR_OBJECT_NOT_DEFINED, null, '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 );
|
||||||
'You have tried to call a DBSession function without create an instance of DBConnection',
|
|
||||||
'G_Error', true);
|
|
||||||
DBconnection::logError( $dberror, $errorLevel );
|
DBconnection::logError( $dberror, $errorLevel );
|
||||||
return $dberror;
|
return $dberror;
|
||||||
};
|
}
|
||||||
|
;
|
||||||
if ( $errorLevel === null ) $errorLevel = $this->dbc->errorLevel;
|
|
||||||
|
|
||||||
|
if ($errorLevel === null) {
|
||||||
|
$errorLevel = $this->dbc->errorLevel;
|
||||||
|
}
|
||||||
$this->Free( true );
|
$this->Free( true );
|
||||||
|
|
||||||
if( $debug ) {
|
if ($debug) {
|
||||||
print( $strQuery . "<br>\n" );
|
print ($strQuery . "<br>\n") ;
|
||||||
}
|
}
|
||||||
$this->result = $this->dbc->db->query ( $strQuery );
|
$this->result = $this->dbc->db->query( $strQuery );
|
||||||
if (DB::isError ($this->result)) {
|
if (DB::isError( $this->result )) {
|
||||||
$this->dbc->logError( $this->result, $errorLevel );
|
$this->dbc->logError( $this->result, $errorLevel );
|
||||||
return $this->result;
|
return $this->result;
|
||||||
}
|
}
|
||||||
@@ -132,13 +138,14 @@ class DBSession
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Function Query, just to execute the query.
|
* Function Query, just to execute the query.
|
||||||
|
*
|
||||||
* @access public
|
* @access public
|
||||||
* @parameter string strQuery
|
* @param eter string strQuery
|
||||||
* @parameter string debug
|
* @param eter string debug
|
||||||
* @parameter string error
|
* @param eter string error
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
/* function deprecated... by Onti, 30th july 2007
|
/* function deprecated... by Onti, 30th july 2007
|
||||||
function Query( $strQuery = '', $debug = false, $error = '' )
|
function Query( $strQuery = '', $debug = false, $error = '' )
|
||||||
{
|
{
|
||||||
if ( $error == '' && defined('ERROR_STATE') ) {
|
if ( $error == '' && defined('ERROR_STATE') ) {
|
||||||
@@ -160,20 +167,21 @@ class DBSession
|
|||||||
die;
|
die;
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function Free
|
* Function Free
|
||||||
|
*
|
||||||
* @access public
|
* @access public
|
||||||
* @parameter string debug
|
* @param eter string debug
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
function Free( $debug = false )
|
function Free ($debug = false)
|
||||||
{
|
{
|
||||||
if ( is_resource($this->result) )
|
if (is_resource( $this->result )) {
|
||||||
$this->result->Free();
|
$this->result->Free();
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* class.dbtable.php
|
* class.dbtable.php
|
||||||
|
*
|
||||||
* @package gulliver.system
|
* @package gulliver.system
|
||||||
*
|
*
|
||||||
* ProcessMaker Open Source Edition
|
* ProcessMaker Open Source Edition
|
||||||
@@ -29,6 +31,7 @@
|
|||||||
* This class provides acces to a generalized table
|
* 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
|
* 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.
|
* for the table should be also provided in order to provide the class a way to generate an UPDATE query properly.
|
||||||
|
*
|
||||||
* @package gulliver.system
|
* @package gulliver.system
|
||||||
* @author Fernando Ontiveros Lira <fernando@colosa.com>
|
* @author Fernando Ontiveros Lira <fernando@colosa.com>
|
||||||
* @copyright (C) 2002 by Colosa Development Team.
|
* @copyright (C) 2002 by Colosa Development Team.
|
||||||
@@ -46,7 +49,7 @@ class DBTable
|
|||||||
var $errorLevel;
|
var $errorLevel;
|
||||||
var $debug = false;
|
var $debug = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initiate a database conecction using default values
|
* Initiate a database conecction using default values
|
||||||
*
|
*
|
||||||
* @author Fernando Ontiveros Lira <fernando@colosa.com>
|
* @author Fernando Ontiveros Lira <fernando@colosa.com>
|
||||||
@@ -54,14 +57,13 @@ class DBTable
|
|||||||
* @param object $objConnection conecction string
|
* @param object $objConnection conecction string
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function dBTable( $objConnection = NULL, $strTable = "", $arrKeys = array( 'UID' ) )
|
function dBTable ($objConnection = null, $strTable = "", $arrKeys = array( 'UID' ))
|
||||||
{
|
{
|
||||||
$this->_dbc = NULL;
|
$this->_dbc = null;
|
||||||
$this->_dbses = NULL;
|
$this->_dbses = null;
|
||||||
$this->SetTo( $objConnection, $strTable, $arrKeys );
|
$this->SetTo( $objConnection, $strTable, $arrKeys );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initiate a database conecction using default values
|
* Initiate a database conecction using default values
|
||||||
*
|
*
|
||||||
@@ -72,68 +74,60 @@ class DBTable
|
|||||||
* @param array $arrKeys table keys defaultvalue=UID
|
* @param array $arrKeys table keys defaultvalue=UID
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function setTo( $objDBConnection, $strTable = "", $arrKeys = array( 'UID' ) )
|
function setTo ($objDBConnection, $strTable = "", $arrKeys = array( 'UID' ))
|
||||||
{
|
{
|
||||||
|
|
||||||
$this->_dbc = $objDBConnection;
|
$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 = new DBSession( $this->_dbc );
|
||||||
$this->_dbses->UseDB( DB_NAME );
|
$this->_dbses->UseDB( DB_NAME );
|
||||||
}
|
} else {
|
||||||
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 );
|
||||||
$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 );
|
//DBconnection::logError( $dberror );
|
||||||
return $dberror;
|
return $dberror;
|
||||||
}
|
}
|
||||||
$this->is_new = true;
|
$this->is_new = true;
|
||||||
$this->Fields = NULL;
|
$this->Fields = null;
|
||||||
$this->table_name = $strTable;
|
$this->table_name = $strTable;
|
||||||
if ( is_array ( $arrKeys ) )
|
if (is_array( $arrKeys )) {
|
||||||
$this->table_keys = $arrKeys;
|
$this->table_keys = $arrKeys;
|
||||||
else
|
} else {
|
||||||
$this->table_keys = array ( 0 => $arrKeys );
|
$this->table_keys = array (0 => $arrKeys
|
||||||
|
);
|
||||||
|
}
|
||||||
$this->errorLevel = $this->_dbc->errorLevel;
|
$this->errorLevel = $this->_dbc->errorLevel;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Loads full description of a referenced table in Fields
|
* Loads full description of a referenced table in Fields
|
||||||
*
|
*
|
||||||
* @author Fernando Ontiveros Lira <fernando@colosa.com>
|
* @author Fernando Ontiveros Lira <fernando@colosa.com>
|
||||||
* @access public
|
* @access public
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function loadEmpty()
|
function loadEmpty ()
|
||||||
{
|
{
|
||||||
$stQry = "DESCRIBE `" . $this->table_name. "`";
|
$stQry = "DESCRIBE `" . $this->table_name . "`";
|
||||||
$dset = $this->_dbses->execute( $stQry );
|
$dset = $this->_dbses->execute( $stQry );
|
||||||
//$dset = new DBRecordSet( $this->_dbses->Result );
|
//$dset = new DBRecordSet( $this->_dbses->Result );
|
||||||
$nlim = $dset->Count();
|
$nlim = $dset->Count();
|
||||||
$this->Fields = NULL;
|
$this->Fields = null;
|
||||||
for( $ncount = 0; $ncount < $nlim; $ncount++ )
|
for ($ncount = 0; $ncount < $nlim; $ncount ++) {
|
||||||
{
|
|
||||||
$data = $dset->Read();
|
$data = $dset->Read();
|
||||||
$fname = $data['Field'];
|
$fname = $data['Field'];
|
||||||
$fval = "";
|
$fval = "";
|
||||||
$ftypearr = explode($data['Type'], '(' );
|
$ftypearr = explode( $data['Type'], '(' );
|
||||||
$ftype = $ftypearr[0];
|
$ftype = $ftypearr[0];
|
||||||
|
|
||||||
if( $data['Key'] == 'PRI' )
|
if ($data['Key'] == 'PRI') {
|
||||||
{
|
if (is_array( $this->table_keys )) {
|
||||||
if( is_array($this->table_keys) )
|
|
||||||
{
|
|
||||||
$this->table_keys[count( $this->table_keys ) - 1] = $fname;
|
$this->table_keys[count( $this->table_keys ) - 1] = $fname;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
$this->table_keys[0] = $fname;
|
$this->table_keys[0] = $fname;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
switch( $ftype )
|
switch ($ftype) {
|
||||||
{
|
|
||||||
case 'int':
|
case 'int':
|
||||||
case 'smallint':
|
case 'smallint':
|
||||||
case 'tinyint':
|
case 'tinyint':
|
||||||
@@ -145,12 +139,12 @@ class DBTable
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->Fields[ $fname ] = $fval;
|
$this->Fields[$fname] = $fval;
|
||||||
$this->Fields[ $ncount ] = &$this->Fields[ $fname ];
|
$this->Fields[$ncount] = &$this->Fields[$fname];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return specified field on the referenced table
|
* Return specified field on the referenced table
|
||||||
*
|
*
|
||||||
* @author Fernando Ontiveros Lira <fernando@colosa.com>
|
* @author Fernando Ontiveros Lira <fernando@colosa.com>
|
||||||
@@ -158,32 +152,31 @@ class DBTable
|
|||||||
* @param string $strWhere string which contains conditions
|
* @param string $strWhere string which contains conditions
|
||||||
* @return strint
|
* @return strint
|
||||||
*/
|
*/
|
||||||
function loadWhere( $strWhere )
|
function loadWhere ($strWhere)
|
||||||
{
|
{
|
||||||
$this->Fields = NULL;
|
$this->Fields = null;
|
||||||
|
|
||||||
$stQry = "SELECT * FROM `" . $this->table_name . "`";
|
$stQry = "SELECT * FROM `" . $this->table_name . "`";
|
||||||
if( $strWhere != "" ) $stQry .= " WHERE " . $strWhere;
|
if ($strWhere != "") {
|
||||||
|
$stQry .= " WHERE " . $strWhere;
|
||||||
$this->_dset = $this->_dbses->Execute ( $stQry , $this->debug, $this->errorLevel);
|
}
|
||||||
if (DB::isError ($this->_dset)) {
|
$this->_dset = $this->_dbses->Execute( $stQry, $this->debug, $this->errorLevel );
|
||||||
|
if (DB::isError( $this->_dset )) {
|
||||||
return $this->_dset;
|
return $this->_dset;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( $this->_dset->Count() > 0 ){
|
if ($this->_dset->Count() > 0) {
|
||||||
$this->Fields = $this->_dset->Read();
|
$this->Fields = $this->_dset->Read();
|
||||||
$this->is_new = false;
|
$this->is_new = false;
|
||||||
}
|
} else {
|
||||||
else
|
$this->Fields = null;
|
||||||
{
|
|
||||||
$this->Fields = NULL;
|
|
||||||
$this->is_new = true;
|
$this->is_new = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->Fields;
|
return $this->Fields;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return all fields on the referenced table
|
* Return all fields on the referenced table
|
||||||
*
|
*
|
||||||
* @author Fernando Ontiveros Lira <fernando@colosa.com>
|
* @author Fernando Ontiveros Lira <fernando@colosa.com>
|
||||||
@@ -191,32 +184,28 @@ class DBTable
|
|||||||
* @param array array of arguments key values
|
* @param array array of arguments key values
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function load()
|
function load ()
|
||||||
{
|
{
|
||||||
// bug::traceRoute();
|
// bug::traceRoute();
|
||||||
$ncount = 0;
|
$ncount = 0;
|
||||||
$stWhere = "";
|
$stWhere = "";
|
||||||
$arrKeys = func_get_args();
|
$arrKeys = func_get_args();
|
||||||
if ( isset($arrKeys[0]) && is_array ($arrKeys[0] ) ) {
|
if (isset( $arrKeys[0] ) && is_array( $arrKeys[0] )) {
|
||||||
foreach ($this->table_keys as $key=>$val) {
|
foreach ($this->table_keys as $key => $val) {
|
||||||
if( $stWhere == "" ){
|
if ($stWhere == "") {
|
||||||
$stWhere .= " $val = '" . $arrKeys[0][ $val ] . "' ";
|
$stWhere .= " $val = '" . $arrKeys[0][$val] . "' ";
|
||||||
}else
|
} else {
|
||||||
$stWhere .= " AND $val = '" . $arrKeys[0][ $val ] . "' ";
|
$stWhere .= " AND $val = '" . $arrKeys[0][$val] . "' ";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
} else {
|
||||||
foreach( $arrKeys as $val )
|
foreach ($arrKeys as $val) {
|
||||||
{
|
if ($stWhere == "") {
|
||||||
if( $stWhere == "" )
|
|
||||||
{
|
|
||||||
$stWhere .= $this->table_keys[$ncount] . "='" . $val . "'";
|
$stWhere .= $this->table_keys[$ncount] . "='" . $val . "'";
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
$stWhere .= " AND " . $this->table_keys[$ncount] . "='" . $val . "'";
|
$stWhere .= " AND " . $this->table_keys[$ncount] . "='" . $val . "'";
|
||||||
}
|
}
|
||||||
$ncount++;
|
$ncount ++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $this->LoadWhere( $stWhere );
|
return $this->LoadWhere( $stWhere );
|
||||||
@@ -224,21 +213,22 @@ class DBTable
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Function nextvalPGSql
|
* Function nextvalPGSql
|
||||||
|
*
|
||||||
* @author David S. Callizaya S. <davidsantos@colosa.com>
|
* @author David S. Callizaya S. <davidsantos@colosa.com>
|
||||||
* @access public
|
* @access public
|
||||||
* @parameter string seq
|
* @param eter string seq
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
function nextvalPGSql( $seq )
|
function nextvalPGSql ($seq)
|
||||||
{
|
{
|
||||||
$stQry = " Select NEXTVAL( '$seq' ) ";
|
$stQry = " Select NEXTVAL( '$seq' ) ";
|
||||||
$dset = $this->_dbses->Execute( $stQry );
|
$dset = $this->_dbses->Execute( $stQry );
|
||||||
$row = $dset->Read();
|
$row = $dset->Read();
|
||||||
if ( is_array ($row) ) {
|
if (is_array( $row )) {
|
||||||
return $row['NEXTVAL'];
|
return $row['NEXTVAL'];
|
||||||
}
|
}
|
||||||
die ("Sequence '$seq' is not exist!!");
|
die( "Sequence '$seq' is not exist!!" );
|
||||||
return -1;
|
return - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -247,34 +237,37 @@ class DBTable
|
|||||||
* @author Fernando Ontiveros Lira <fernando@colosa.com>
|
* @author Fernando Ontiveros Lira <fernando@colosa.com>
|
||||||
* @access public
|
* @access public
|
||||||
* @return boolean
|
* @return boolean
|
||||||
|
*
|
||||||
*/
|
*/
|
||||||
function insert () {
|
function insert ()
|
||||||
|
{
|
||||||
$strFields = "";
|
$strFields = "";
|
||||||
$strValues = "";
|
$strValues = "";
|
||||||
if( defined('DB_ADAPTER'))
|
if (defined( 'DB_ADAPTER' )) {
|
||||||
$DBEngine = DB_ADAPTER;
|
$DBEngine = DB_ADAPTER;
|
||||||
else
|
} else {
|
||||||
$DBEngine = 'mysql';
|
$DBEngine = 'mysql';
|
||||||
foreach( $this->Fields as $field => $val ) {
|
}
|
||||||
|
foreach ($this->Fields as $field => $val) {
|
||||||
$strFields .= $field . ",";
|
$strFields .= $field . ",";
|
||||||
$iskey = false;
|
$iskey = false;
|
||||||
if ( isset ( $this->table_keys ) && is_array ( $this->table_keys ) )
|
if (isset( $this->table_keys ) && is_array( $this->table_keys )) {
|
||||||
$iskey = in_array( $field, $this->table_keys ) && strtoupper(substr(trim($val),0,7) ) == "NEXTVAL";
|
$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 .", ";
|
|
||||||
}
|
}
|
||||||
$strFields = substr( $strFields , 0, strlen($strFields)-1 );
|
$dbcType = isset( $this->_dbc->type ) ? $this->_dbc->type : $DBEngine;
|
||||||
$strValues = substr( $strValues , 0, strlen($strValues)-1 );
|
// 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 . " ) ";
|
$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;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -285,54 +278,60 @@ class DBTable
|
|||||||
* @access public
|
* @access public
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
function update()
|
function update ()
|
||||||
{
|
{
|
||||||
$stQry = "";
|
$stQry = "";
|
||||||
|
|
||||||
$stWhere = '';
|
$stWhere = '';
|
||||||
$remainKeys = array();
|
$remainKeys = array ();
|
||||||
|
|
||||||
if(defined('DB_ADAPTER'))
|
if (defined( 'DB_ADAPTER' )) {
|
||||||
$DBEngine = DB_ADAPTER;
|
$DBEngine = DB_ADAPTER;
|
||||||
else
|
} else {
|
||||||
$DBEngine = 'mysql';
|
$DBEngine = 'mysql';
|
||||||
|
}
|
||||||
|
|
||||||
foreach ( $this->table_keys as $k => $v ) $remainKeys[ $v ] = false;
|
foreach ($this->table_keys as $k => $v) {
|
||||||
foreach( $this->Fields as $field => $val )
|
$remainKeys[$v] = false;
|
||||||
{
|
}
|
||||||
|
foreach ($this->Fields as $field => $val) {
|
||||||
$iskey = false;
|
$iskey = false;
|
||||||
$iskey = in_array( $field, $this->table_keys );
|
$iskey = in_array( $field, $this->table_keys );
|
||||||
if( $iskey == false ) {
|
if ($iskey == false) {
|
||||||
$stQry .= $field . "='" . $val . "', ";
|
$stQry .= $field . "='" . $val . "', ";
|
||||||
// Commented by new format of textarea in javascript
|
// Commented by new format of textarea in javascript
|
||||||
///-- $stQry .= $field . "='" . G::sqlEscape ( $val, isset( $this->_dbc->type) ? $this->_dbc->type : $DBEngine ) . "', ";
|
///-- $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 {
|
$remainKeys[$field] = 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 ) . "'";
|
|
||||||
}
|
|
||||||
$remainKeys[ $field ] = true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
foreach( $remainKeys as $field => $bool )
|
foreach ($remainKeys as $field => $bool)
|
||||||
if ( $bool == false) {
|
if ($bool == false) {
|
||||||
if( $stWhere != "" ) $stWhere = " AND ";
|
if ($stWhere != "") {
|
||||||
|
$stWhere = " AND ";
|
||||||
|
}
|
||||||
$stWhere .= $field . "= ''";
|
$stWhere .= $field . "= ''";
|
||||||
$remainKeys[ $field ] = true;
|
$remainKeys[$field] = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
$stQry = trim( $stQry );
|
$stQry = trim( $stQry );
|
||||||
$stQry = substr( $stQry , 0, strlen($stQry)-1 ); //to remove the last comma ,
|
$stQry = substr( $stQry, 0, strlen( $stQry ) - 1 ); //to remove the last comma ,
|
||||||
if (!$stQry) return;
|
if (! $stQry) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
$stQry = "UPDATE `" . $this->table_name . "` SET " . $stQry;
|
$stQry = "UPDATE `" . $this->table_name . "` SET " . $stQry;
|
||||||
$stWhere = trim( $stWhere );
|
$stWhere = trim( $stWhere );
|
||||||
if( $stWhere != "" ) $stQry .= " WHERE " . $stWhere;
|
if ($stWhere != "") {
|
||||||
|
$stQry .= " WHERE " . $stWhere;
|
||||||
|
}
|
||||||
$result = false;
|
$result = false;
|
||||||
|
|
||||||
$result = $this->_dbses->execute( $stQry , $this->debug, $this->errorLevel );
|
$result = $this->_dbses->execute( $stQry, $this->debug, $this->errorLevel );
|
||||||
$this->is_new = false;
|
$this->is_new = false;
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
@@ -346,13 +345,14 @@ class DBTable
|
|||||||
* @access public
|
* @access public
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
function save()
|
function save ()
|
||||||
{
|
{
|
||||||
if ( $this->is_new == true )
|
if ($this->is_new == true) {
|
||||||
return $this->Insert();
|
return $this->Insert();
|
||||||
else
|
} else {
|
||||||
return $this->Update();
|
return $this->Update();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Delete an existing row
|
* Delete an existing row
|
||||||
@@ -361,53 +361,53 @@ class DBTable
|
|||||||
* @access public
|
* @access public
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
function delete()
|
function delete ()
|
||||||
{
|
{
|
||||||
$stQry = "delete from `" . $this->table_name . "` ";
|
$stQry = "delete from `" . $this->table_name . "` ";
|
||||||
|
|
||||||
$stWhere = '';
|
$stWhere = '';
|
||||||
$remainKeys = array();
|
$remainKeys = array ();
|
||||||
if(defined('DB_ADAPTER'))
|
if (defined( 'DB_ADAPTER' )) {
|
||||||
$DBEngine = DB_ADAPTER;
|
$DBEngine = DB_ADAPTER;
|
||||||
else
|
} else {
|
||||||
$DBEngine = 'mysql';
|
$DBEngine = 'mysql';
|
||||||
foreach ( $this->table_keys as $k => $v ) $remainKeys[ $v ] = false;
|
}
|
||||||
|
foreach ($this->table_keys as $k => $v) {
|
||||||
if ( is_array ( $this->Fields ) ) {
|
$remainKeys[$v] = false;
|
||||||
foreach( $this->Fields as $field => $val )
|
}
|
||||||
{
|
if (is_array( $this->Fields )) {
|
||||||
|
foreach ($this->Fields as $field => $val) {
|
||||||
$iskey = false;
|
$iskey = false;
|
||||||
$iskey = in_array( $field, $this->table_keys );
|
$iskey = in_array( $field, $this->table_keys );
|
||||||
if( $iskey == true ) {
|
if ($iskey == true) {
|
||||||
if( $stWhere == "" ) {
|
if ($stWhere == "") {
|
||||||
$stWhere .= $field . "='" . G::sqlEscape ( $val, isset( $this->_dbc->type) ? $this->_dbc->type : $DBEngine ) . "'";
|
$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 {
|
$remainKeys[$field] = true;
|
||||||
$stWhere .= " AND " . $field . "='" . G::sqlEscape ( $val, isset( $this->_dbc->type) ? $this->_dbc->type : $DBEngine ) . "'";
|
|
||||||
}
|
|
||||||
$remainKeys[ $field ] = true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
foreach( $remainKeys as $field => $bool )
|
foreach ($remainKeys as $field => $bool)
|
||||||
if ( $bool == false) {
|
if ($bool == false) {
|
||||||
if( $stWhere != "" ) $stWhere .= " AND ";
|
if ($stWhere != "") {
|
||||||
|
$stWhere .= " AND ";
|
||||||
|
}
|
||||||
$stWhere .= $field . "= ''";
|
$stWhere .= $field . "= ''";
|
||||||
$remainKeys[ $field ] = true;
|
$remainKeys[$field] = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
$stQry = trim( $stQry );
|
$stQry = trim( $stQry );
|
||||||
$stWhere = trim( $stWhere );
|
$stWhere = trim( $stWhere );
|
||||||
if ( $stWhere == '' ) {
|
if ($stWhere == '') {
|
||||||
$dberror = PEAR::raiseError(null, G_ERROR_WARNING_MESSAGE, null, 'null',
|
$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 );
|
||||||
"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 );
|
DBconnection::logError( $dberror, $this->errorLevel );
|
||||||
return $dberror;
|
return $dberror;
|
||||||
}
|
}
|
||||||
$stQry .= " WHERE " . $stWhere;
|
$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;
|
$this->is_new = false;
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
@@ -421,8 +421,9 @@ class DBTable
|
|||||||
* @access public
|
* @access public
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
function next()
|
function next ()
|
||||||
{
|
{
|
||||||
$this->Fields = $this->_dset->read ();
|
$this->Fields = $this->_dset->read();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,19 +1,23 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* HttpProxyController
|
* HttpProxyController
|
||||||
|
*
|
||||||
* @author Erik Amaru Ortiz <erik@colosa.com, aortiz.erik@gmail.com>
|
* @author Erik Amaru Ortiz <erik@colosa.com, aortiz.erik@gmail.com>
|
||||||
* @package gulliver.system
|
* @package gulliver.system
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
class HttpProxyController {
|
class HttpProxyController
|
||||||
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
*
|
||||||
* @var array - private array to store proxy data
|
* @var array - private array to store proxy data
|
||||||
*/
|
*/
|
||||||
private $__data__ = array();
|
private $__data__ = array ();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
*
|
||||||
* @var object - private object to store the http request data
|
* @var object - private object to store the http request data
|
||||||
*/
|
*/
|
||||||
private $__request__;
|
private $__request__;
|
||||||
@@ -21,13 +25,15 @@ class HttpProxyController {
|
|||||||
public $jsonResponse = true;
|
public $jsonResponse = true;
|
||||||
|
|
||||||
private $sendResponse = true;
|
private $sendResponse = true;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Magic setter method
|
* Magic setter method
|
||||||
*
|
*
|
||||||
* @param string $name
|
* @param string $name
|
||||||
* @param string $value
|
* @param string $value
|
||||||
*/
|
*/
|
||||||
public function __set($name, $value) {
|
public function __set ($name, $value)
|
||||||
|
{
|
||||||
//echo "Setting '$name' to '$value'\n";
|
//echo "Setting '$name' to '$value'\n";
|
||||||
$this->__data__[$name] = $value;
|
$this->__data__[$name] = $value;
|
||||||
}
|
}
|
||||||
@@ -38,9 +44,10 @@ class HttpProxyController {
|
|||||||
* @param string $name
|
* @param string $name
|
||||||
* @return string or NULL if the internal var doesn't exist
|
* @return string or NULL if the internal var doesn't exist
|
||||||
*/
|
*/
|
||||||
public function __get($name) {
|
public function __get ($name)
|
||||||
|
{
|
||||||
//echo "Getting '$name'\n";
|
//echo "Getting '$name'\n";
|
||||||
if (array_key_exists($name, $this->__data__)) {
|
if (array_key_exists( $name, $this->__data__ )) {
|
||||||
return $this->__data__[$name];
|
return $this->__data__[$name];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -58,20 +65,21 @@ class HttpProxyController {
|
|||||||
*
|
*
|
||||||
* @param string $name
|
* @param string $name
|
||||||
*/
|
*/
|
||||||
public function __isset($name) {
|
public function __isset ($name)
|
||||||
|
{
|
||||||
//echo "Is '$name' set?\n";
|
//echo "Is '$name' set?\n";
|
||||||
return isset($this->__data__[$name]);
|
return isset( $this->__data__[$name] );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Magic unset method
|
* Magic unset method
|
||||||
*
|
*
|
||||||
* @param string $name
|
* @param string $name
|
||||||
*/
|
*/
|
||||||
public function __unset($name) {
|
public function __unset ($name)
|
||||||
|
{
|
||||||
//echo "Unsetting '$name'\n";
|
//echo "Unsetting '$name'\n";
|
||||||
unset($this->__data__[$name]);
|
unset( $this->__data__[$name] );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -79,36 +87,45 @@ class HttpProxyController {
|
|||||||
*
|
*
|
||||||
* @param string $name
|
* @param string $name
|
||||||
*/
|
*/
|
||||||
public function call($name)
|
public function call ($name)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
$result = $this->$name($this->__request__);
|
$result = $this->$name( $this->__request__ );
|
||||||
|
|
||||||
if (!$this->jsonResponse) {
|
if (! $this->jsonResponse) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( ! $result )
|
if (! $result) {
|
||||||
$result = $this->__data__;
|
$result = $this->__data__;
|
||||||
|
}
|
||||||
|
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
$result->success = false;
|
$result->success = false;
|
||||||
$result->message = $result->msg = $e->getMessage();
|
$result->message = $result->msg = $e->getMessage();
|
||||||
switch(get_class($e)) {
|
switch (get_class( $e )) {
|
||||||
case 'Exception': $error = "SYSTEM ERROR"; break;
|
case 'Exception':
|
||||||
case 'PMException': $error = "PROCESSMAKER ERROR"; break;
|
$error = "SYSTEM ERROR";
|
||||||
case 'PropelException': $error = "DATABASE ERROR"; break;
|
break;
|
||||||
case 'UserException': $error = "USER 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->error = $e->getMessage();
|
||||||
|
|
||||||
$result->exception->class = get_class($e);
|
$result->exception->class = get_class( $e );
|
||||||
$result->exception->code = $e->getCode();
|
$result->exception->code = $e->getCode();
|
||||||
$result->exception->trace = $e->getTraceAsString();
|
$result->exception->trace = $e->getTraceAsString();
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->sendResponse) {
|
if ($this->sendResponse) {
|
||||||
print G::json_encode($result);
|
print G::json_encode( $result );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -117,16 +134,18 @@ class HttpProxyController {
|
|||||||
*
|
*
|
||||||
* @param array $data
|
* @param array $data
|
||||||
*/
|
*/
|
||||||
public function setHttpRequestData($data)
|
public function setHttpRequestData ($data)
|
||||||
{
|
{
|
||||||
if( is_array($data) ) {
|
if (is_array( $data )) {
|
||||||
while( $var = each($data) )
|
while ($var = each( $data )) {
|
||||||
$this->__request__->$var['key'] = $var['value'];
|
$this->__request__->$var['key'] = $var['value'];
|
||||||
} else
|
}
|
||||||
|
} else {
|
||||||
$this->__request__ = $data;
|
$this->__request__ = $data;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public function setJsonResponse($bool)
|
public function setJsonResponse ($bool)
|
||||||
{
|
{
|
||||||
$this->jsonResponse = $bool;
|
$this->jsonResponse = $bool;
|
||||||
}
|
}
|
||||||
@@ -136,8 +155,9 @@ class HttpProxyController {
|
|||||||
*
|
*
|
||||||
* @param boolean $val
|
* @param boolean $val
|
||||||
*/
|
*/
|
||||||
public function setSendResponse($val)
|
public function setSendResponse ($val)
|
||||||
{
|
{
|
||||||
$this->sendResponse = $val;
|
$this->sendResponse = $val;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* class.dbtable.php
|
* class.dbtable.php
|
||||||
|
*
|
||||||
* @package gulliver.system
|
* @package gulliver.system
|
||||||
*
|
*
|
||||||
* ProcessMaker Open Source Edition
|
* ProcessMaker Open Source Edition
|
||||||
@@ -24,7 +26,7 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* i18n_PO
|
* i18n_PO
|
||||||
* This class build biggers PO files without size limit and this not use much memory that the allowed
|
* 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
|
class i18n_PO
|
||||||
{
|
{
|
||||||
private $_file = NULL;
|
private $_file = null;
|
||||||
private $_string = '';
|
private $_string = '';
|
||||||
private $_meta;
|
private $_meta;
|
||||||
private $_fp;
|
private $_fp;
|
||||||
@@ -56,150 +58,160 @@ class i18n_PO
|
|||||||
public $flags;
|
public $flags;
|
||||||
public $previousUntranslatedStrings;
|
public $previousUntranslatedStrings;
|
||||||
|
|
||||||
function __construct($file)
|
function __construct ($file)
|
||||||
{
|
{
|
||||||
$this->file = $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) ) {
|
if (! is_resource( $this->_fp )) {
|
||||||
throw new Exception('Could\'t open ' . $this->file . ' file');
|
throw new Exception( 'Could\'t open ' . $this->file . ' file' );
|
||||||
}
|
}
|
||||||
|
|
||||||
// lock PO file exclusively
|
// lock PO file exclusively
|
||||||
if ( ! flock($this->_fp, LOCK_EX) ) {
|
if (! flock( $this->_fp, LOCK_EX )) {
|
||||||
fclose($this->_fp);
|
fclose( $this->_fp );
|
||||||
return FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->_meta = 'msgid ""';
|
$this->_meta = 'msgid ""';
|
||||||
$this->_writeLine($this->_meta);
|
$this->_writeLine( $this->_meta );
|
||||||
$this->_meta = 'msgstr ""';
|
$this->_meta = 'msgstr ""';
|
||||||
$this->_writeLine($this->_meta);
|
$this->_writeLine( $this->_meta );
|
||||||
|
|
||||||
$this->_editingHeader = TRUE;
|
$this->_editingHeader = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
function readInit(){
|
function readInit ()
|
||||||
$this->_fp = fopen($this->file, 'r');
|
{
|
||||||
|
$this->_fp = fopen( $this->file, 'r' );
|
||||||
|
|
||||||
if ( ! is_resource($this->_fp) ) {
|
if (! is_resource( $this->_fp )) {
|
||||||
throw new Exception('Could\'t open ' . $this->file . ' file');
|
throw new Exception( 'Could\'t open ' . $this->file . ' file' );
|
||||||
}
|
}
|
||||||
//skipping comments
|
//skipping comments
|
||||||
$this->skipCommets();
|
$this->skipCommets();
|
||||||
//deaing headers
|
//deaing headers
|
||||||
$this->readHeaders();
|
$this->readHeaders();
|
||||||
|
|
||||||
$this->translatorComments = Array();
|
$this->translatorComments = Array ();
|
||||||
$this->extractedComments = Array();
|
$this->extractedComments = Array ();
|
||||||
$this->references = Array();
|
$this->references = Array ();
|
||||||
$this->flags = Array();
|
$this->flags = Array ();
|
||||||
$this->previousUntranslatedStrings = Array();
|
$this->previousUntranslatedStrings = Array ();
|
||||||
}
|
}
|
||||||
|
|
||||||
function addHeader($id, $value)
|
function addHeader ($id, $value)
|
||||||
{
|
{
|
||||||
if( $this->_editingHeader ) {
|
if ($this->_editingHeader) {
|
||||||
$meta = '"'.trim($id).': '.trim($value).'\n"';
|
$meta = '"' . trim( $id ) . ': ' . trim( $value ) . '\n"';
|
||||||
$this->_writeLine($meta);
|
$this->_writeLine( $meta );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function addTranslatorComment($str)
|
function addTranslatorComment ($str)
|
||||||
{
|
{
|
||||||
$this->headerStroke();
|
$this->headerStroke();
|
||||||
$comment = '# ' . trim($str);
|
$comment = '# ' . trim( $str );
|
||||||
$this->_writeLine($comment);
|
$this->_writeLine( $comment );
|
||||||
}
|
}
|
||||||
|
|
||||||
function addExtractedComment($str)
|
function addExtractedComment ($str)
|
||||||
{
|
{
|
||||||
$this->headerStroke();
|
$this->headerStroke();
|
||||||
$comment = '#. ' . trim($str);
|
$comment = '#. ' . trim( $str );
|
||||||
$this->_writeLine($comment);
|
$this->_writeLine( $comment );
|
||||||
}
|
}
|
||||||
|
|
||||||
function addReference($str)
|
function addReference ($str)
|
||||||
{
|
{
|
||||||
$this->headerStroke();
|
$this->headerStroke();
|
||||||
$reference = '#: ' . trim($str);
|
$reference = '#: ' . trim( $str );
|
||||||
$this->_writeLine($reference);
|
$this->_writeLine( $reference );
|
||||||
}
|
}
|
||||||
|
|
||||||
function addFlag($str)
|
function addFlag ($str)
|
||||||
{
|
{
|
||||||
$this->headerStroke();
|
$this->headerStroke();
|
||||||
$flag = '#, ' . trim($str);
|
$flag = '#, ' . trim( $str );
|
||||||
$this->_writeLine($flag);
|
$this->_writeLine( $flag );
|
||||||
}
|
}
|
||||||
|
|
||||||
function addPreviousUntranslatedString($str)
|
function addPreviousUntranslatedString ($str)
|
||||||
{
|
{
|
||||||
$this->headerStroke();
|
$this->headerStroke();
|
||||||
$str = '#| ' . trim($str);
|
$str = '#| ' . trim( $str );
|
||||||
$this->_writeLine($str);
|
$this->_writeLine( $str );
|
||||||
}
|
}
|
||||||
|
|
||||||
function addTranslation($msgid, $msgstr)
|
function addTranslation ($msgid, $msgstr)
|
||||||
{
|
{
|
||||||
$this->headerStroke();
|
$this->headerStroke();
|
||||||
$this->_writeLine('msgid "' . $this->prepare($msgid, true) . '"');
|
$this->_writeLine( 'msgid "' . $this->prepare( $msgid, true ) . '"' );
|
||||||
$this->_writeLine('msgstr "' . $this->prepare($msgstr, true) . '"');
|
$this->_writeLine( 'msgstr "' . $this->prepare( $msgstr, true ) . '"' );
|
||||||
$this->_writeLine('');
|
$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 = str_replace('\"', '"', $string);
|
||||||
//$string = stripslashes($string);
|
//$string = stripslashes($string);
|
||||||
|
|
||||||
|
|
||||||
if ($reverse) {
|
if ($reverse) {
|
||||||
$smap = array('"', "\n", "\t", "\r");
|
$smap = array ('"',"\n","\t","\r"
|
||||||
$rmap = array('\"', '\\n"' . "\n" . '"', '\\t', '\\r');
|
);
|
||||||
return (string) str_replace($smap, $rmap, $string);
|
$rmap = array ('\"','\\n"' . "\n" . '"','\\t','\\r'
|
||||||
|
);
|
||||||
|
return (string) str_replace( $smap, $rmap, $string );
|
||||||
} else {
|
} else {
|
||||||
$string = preg_replace('/"\s+"/', '', $string);
|
$string = preg_replace( '/"\s+"/', '', $string );
|
||||||
$smap = array('\\n', '\\r', '\\t', '\"');
|
$smap = array ('\\n','\\r','\\t','\"'
|
||||||
$rmap = array("\n", "\r", "\t", '"');
|
);
|
||||||
return (string) str_replace($smap, $rmap, $string);
|
$rmap = array ("\n","\r","\t",'"'
|
||||||
|
);
|
||||||
|
return (string) str_replace( $smap, $rmap, $string );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function headerStroke()
|
function headerStroke ()
|
||||||
{
|
{
|
||||||
if( $this->_editingHeader ) {
|
if ($this->_editingHeader) {
|
||||||
$this->_editingHeader = FALSE;
|
$this->_editingHeader = false;
|
||||||
$this->_writeLine('');;
|
$this->_writeLine( '' );
|
||||||
|
;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** read funtions **/
|
/**
|
||||||
private function skipCommets(){
|
* read funtions *
|
||||||
|
*/
|
||||||
|
private function skipCommets ()
|
||||||
|
{
|
||||||
$this->_fileComments = '';
|
$this->_fileComments = '';
|
||||||
do {
|
do {
|
||||||
$lastPos = ftell($this->_fp);
|
$lastPos = ftell( $this->_fp );
|
||||||
$line = fgets($this->_fp);
|
$line = fgets( $this->_fp );
|
||||||
$this->_fileComments .= $line;
|
$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->flagEndHeaders = false;
|
||||||
$this->flagError = false;
|
$this->flagError = false;
|
||||||
@@ -207,17 +219,18 @@ class i18n_PO
|
|||||||
$this->lineNumber = 0;
|
$this->lineNumber = 0;
|
||||||
$errMsg = '';
|
$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
|
$this->flagInit = false; //unset init flag
|
||||||
|
|
||||||
|
|
||||||
//read the first and second line of the file
|
//read the first and second line of the file
|
||||||
$firstLine = fgets($this->_fp);
|
$firstLine = fgets( $this->_fp );
|
||||||
$secondLine = fgets($this->_fp);
|
$secondLine = fgets( $this->_fp );
|
||||||
|
|
||||||
//verifying the file head
|
//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;
|
$this->flagError = true;
|
||||||
$errMsg = 'Misplace for firts msgid "" and msgstr "" in the header';
|
$errMsg = 'Misplace for firts msgid "" and msgstr "" in the header';
|
||||||
}
|
}
|
||||||
@@ -225,109 +238,113 @@ class i18n_PO
|
|||||||
}
|
}
|
||||||
|
|
||||||
//getting the new line
|
//getting the new line
|
||||||
$this->_fileLine = trim(fgets($this->_fp));
|
$this->_fileLine = trim( fgets( $this->_fp ) );
|
||||||
//set line number
|
//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
|
//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
|
$this->flagEndHeaders = true; // set ending to read the headers
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
//verify if has a valid mask header line
|
//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
|
//for a valid header line the $match size should three
|
||||||
if( sizeof($match) == 3 ) {
|
if (sizeof( $match ) == 3) {
|
||||||
$key = trim($match[1]); //getting the key of the header
|
$key = trim( $match[1] ); //getting the key of the header
|
||||||
$value = trim($match[2]); //getting the value of the header
|
$value = trim( $match[2] ); //getting the value of the header
|
||||||
$this->_meta[$key] = $value; //setting a new header
|
$this->_meta[$key] = $value; //setting a new header
|
||||||
} else {
|
} else {
|
||||||
$this->flagEndHeaders = true; //otherwise set the ending to read the headers
|
$this->flagEndHeaders = true; //otherwise set the ending to read the headers
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}//end looking for headeers
|
} //end looking for headeers
|
||||||
|
|
||||||
|
|
||||||
//verifying the headers data
|
//verifying the headers data
|
||||||
if( ! isset($this->_meta['X-Poedit-Language']) ) {
|
if (! isset( $this->_meta['X-Poedit-Language'] )) {
|
||||||
$this->flagError = true;
|
$this->flagError = true;
|
||||||
$errMsg = "X-Poedit-Language meta doesn't exist";
|
$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;
|
$this->flagError = true;
|
||||||
$errMsg = "X-Poedit-Language meta is empty";
|
$errMsg = "X-Poedit-Language meta is empty";
|
||||||
}
|
}
|
||||||
|
|
||||||
//if the country is not present in metadata
|
//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'] = '.';
|
$this->_meta['X-Poedit-Country'] = '.';
|
||||||
} else if( $this->_meta['X-Poedit-Country'] == '' ) {
|
} else if ($this->_meta['X-Poedit-Country'] == '') {
|
||||||
$this->_meta['X-Poedit-Country'] = '.';
|
$this->_meta['X-Poedit-Country'] = '.';
|
||||||
}
|
}
|
||||||
|
|
||||||
//thowing the exception if is necesary
|
//thowing the exception if is necesary
|
||||||
if( $this->flagError ){
|
if ($this->flagError) {
|
||||||
throw new Exception("This file is not a valid PO file. ($errMsg)");
|
throw new Exception( "This file is not a valid PO file. ($errMsg)" );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function getHeaders() {
|
function getHeaders ()
|
||||||
|
{
|
||||||
return $this->_meta;
|
return $this->_meta;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getTranslation(){
|
public function getTranslation ()
|
||||||
|
{
|
||||||
|
|
||||||
$flagReadingComments = true;
|
$flagReadingComments = true;
|
||||||
$this->translatorComments = Array();
|
$this->translatorComments = Array ();
|
||||||
$this->extractedComments = Array();
|
$this->extractedComments = Array ();
|
||||||
$this->references = Array();
|
$this->references = Array ();
|
||||||
$this->flags = Array();
|
$this->flags = Array ();
|
||||||
|
|
||||||
//getting the new line
|
//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
|
//set line number
|
||||||
$this->lineNumber++;
|
$this->lineNumber ++;
|
||||||
|
|
||||||
if( ! $this->_fileLine )
|
if (! $this->_fileLine) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
$prefix = substr($this->_fileLine, 0, 2);
|
$prefix = substr( $this->_fileLine, 0, 2 );
|
||||||
|
|
||||||
switch($prefix) {
|
switch ($prefix) {
|
||||||
case '# ':
|
case '# ':
|
||||||
$lineItem = str_replace('# ', '', $this->_fileLine);
|
$lineItem = str_replace( '# ', '', $this->_fileLine );
|
||||||
$this->translatorComments[] = $lineItem;
|
$this->translatorComments[] = $lineItem;
|
||||||
break;
|
break;
|
||||||
case '#.':
|
case '#.':
|
||||||
if( substr_count($this->_fileLine, '#. ') == 0 )
|
if (substr_count( $this->_fileLine, '#. ' ) == 0) {
|
||||||
$this->flagError = true;
|
$this->flagError = true;
|
||||||
else {
|
} else {
|
||||||
$lineItem = str_replace('#. ', '', $this->_fileLine);
|
$lineItem = str_replace( '#. ', '', $this->_fileLine );
|
||||||
$this->extractedComments[] = $lineItem;
|
$this->extractedComments[] = $lineItem;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case '#:':
|
case '#:':
|
||||||
if( substr_count($this->_fileLine, '#: ') == 0 )
|
if (substr_count( $this->_fileLine, '#: ' ) == 0) {
|
||||||
$this->flagError = true;
|
$this->flagError = true;
|
||||||
else {
|
} else {
|
||||||
$lineItem = str_replace('#: ', '', $this->_fileLine);
|
$lineItem = str_replace( '#: ', '', $this->_fileLine );
|
||||||
$this->references[] = $lineItem;
|
$this->references[] = $lineItem;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case '#,':
|
case '#,':
|
||||||
if( substr_count($this->_fileLine, '#, ') == 0 )
|
if (substr_count( $this->_fileLine, '#, ' ) == 0) {
|
||||||
$this->flagError = true;
|
$this->flagError = true;
|
||||||
else {
|
} else {
|
||||||
$lineItem = str_replace('#, ', '', $this->_fileLine);
|
$lineItem = str_replace( '#, ', '', $this->_fileLine );
|
||||||
$this->flags[] = $lineItem;
|
$this->flags[] = $lineItem;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case '#|':
|
case '#|':
|
||||||
if( substr_count($this->_fileLine, '#| ') == 0 )
|
if (substr_count( $this->_fileLine, '#| ' ) == 0) {
|
||||||
$this->flagError = true;
|
$this->flagError = true;
|
||||||
else {
|
} else {
|
||||||
$lineItem = str_replace('#| ', '', $this->_fileLine);
|
$lineItem = str_replace( '#| ', '', $this->_fileLine );
|
||||||
$this->previousUntranslatedStrings[] = $lineItem;
|
$this->previousUntranslatedStrings[] = $lineItem;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -336,52 +353,57 @@ class i18n_PO
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if( ! $this->_fileLine )
|
if (! $this->_fileLine) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
//Getting the msgid
|
//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 )
|
if (sizeof( $match ) != 2) {
|
||||||
throw new Exception('Invalid PO file format1');
|
throw new Exception( 'Invalid PO file format1' );
|
||||||
|
}
|
||||||
|
|
||||||
$msgid = '';
|
$msgid = '';
|
||||||
|
|
||||||
do {
|
do {
|
||||||
//g::pr($match);
|
//g::pr($match);
|
||||||
$msgid .= $match[1];
|
$msgid .= $match[1];
|
||||||
$this->_fileLine = trim(fgets($this->_fp));
|
$this->_fileLine = trim( fgets( $this->_fp ) );
|
||||||
preg_match('/^"(.*)"\s*/s', $this->_fileLine, $match);
|
preg_match( '/^"(.*)"\s*/s', $this->_fileLine, $match );
|
||||||
} while ( sizeof($match) == 2 );
|
} while (sizeof( $match ) == 2);
|
||||||
|
|
||||||
//Getting the msgstr
|
//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 )
|
if (sizeof( $match ) != 2) {
|
||||||
throw new Exception('Invalid PO file format2');
|
throw new Exception( 'Invalid PO file format2' );
|
||||||
|
}
|
||||||
|
|
||||||
$msgstr = '';
|
$msgstr = '';
|
||||||
|
|
||||||
do {
|
do {
|
||||||
//g::pr($match);
|
//g::pr($match);
|
||||||
$msgstr .= $match[1] . "\n";
|
$msgstr .= $match[1] . "\n";
|
||||||
$this->_fileLine = trim(fgets($this->_fp));
|
$this->_fileLine = trim( fgets( $this->_fp ) );
|
||||||
preg_match('/^"(.*)"\s*/s', $this->_fileLine, $match);
|
preg_match( '/^"(.*)"\s*/s', $this->_fileLine, $match );
|
||||||
} while ( sizeof($match) == 2 );
|
} while (sizeof( $match ) == 2);
|
||||||
|
|
||||||
|
|
||||||
/*g::pr($this->translatorComments);
|
/*g::pr($this->translatorComments);
|
||||||
g::pr($this->references);
|
g::pr($this->references);
|
||||||
g::pr($match);
|
g::pr($match);
|
||||||
die;*/
|
die;*/
|
||||||
|
|
||||||
return Array('msgid'=>trim($msgid), 'msgstr'=>trim($msgstr));
|
return Array ('msgid' => trim( $msgid ),'msgstr' => trim( $msgstr )
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
//garbage
|
//garbage
|
||||||
function __destruct()
|
function __destruct ()
|
||||||
{
|
{
|
||||||
if ( $this->_fp )
|
if ($this->_fp) {
|
||||||
fclose($this->_fp);
|
fclose( $this->_fp );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
/**
|
/**
|
||||||
* class.mailer.php
|
* class.mailer.php
|
||||||
|
*
|
||||||
* @package gulliver.system
|
* @package gulliver.system
|
||||||
*
|
*
|
||||||
* ProcessMaker Open Source Edition
|
* ProcessMaker Open Source Edition
|
||||||
@@ -23,7 +24,7 @@
|
|||||||
* Coral Gables, FL, 33134, USA, or email info@colosa.com.
|
* 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"
|
/* Send emails using the class "PHPMailer"
|
||||||
* Email server configuration constants:
|
* Email server configuration constants:
|
||||||
* MAIL_MAILER mail/smtp
|
* MAIL_MAILER mail/smtp
|
||||||
@@ -39,10 +40,11 @@ G::LoadThirdParty('phpmailer','class.phpmailer');
|
|||||||
* @author David Callizaya <davidsantos@colosa.com>
|
* @author David Callizaya <davidsantos@colosa.com>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
/**
|
*
|
||||||
* @package gulliver.system
|
* @package gulliver.system
|
||||||
**/
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
class mailer
|
class mailer
|
||||||
{
|
{
|
||||||
@@ -52,10 +54,10 @@ class mailer
|
|||||||
*
|
*
|
||||||
* @return object(PHPMailer) $mailer
|
* @return object(PHPMailer) $mailer
|
||||||
*/
|
*/
|
||||||
function instanceMailer()
|
function instanceMailer ()
|
||||||
{
|
{
|
||||||
$mailer = new PHPMailer;
|
$mailer = new PHPMailer();
|
||||||
$mailer->PluginDir=PATH_THIRDPARTY.'phpmailer/';
|
$mailer->PluginDir = PATH_THIRDPARTY . 'phpmailer/';
|
||||||
//DEFAULT CONFIGURATION
|
//DEFAULT CONFIGURATION
|
||||||
$mailer->Mailer = 'mail';
|
$mailer->Mailer = 'mail';
|
||||||
$mailer->Host = "";
|
$mailer->Host = "";
|
||||||
@@ -64,15 +66,31 @@ class mailer
|
|||||||
$mailer->Password = "";
|
$mailer->Password = "";
|
||||||
$mailer->Timeout = 30;
|
$mailer->Timeout = 30;
|
||||||
$mailer->CharSet = 'utf-8';
|
$mailer->CharSet = 'utf-8';
|
||||||
$mailer->Encoding='base64';
|
$mailer->Encoding = 'base64';
|
||||||
if (defined('MAIL_MAILER')) $mailer->Mailer = MAIL_MAILER;
|
if (defined( 'MAIL_MAILER' )) {
|
||||||
if (defined('MAIL_HOST')) $mailer->Host = MAIL_HOST;
|
$mailer->Mailer = MAIL_MAILER;
|
||||||
if (defined('MAIL_SMTPAUTH')) $mailer->SMTPAuth = MAIL_SMTPAUTH;
|
}
|
||||||
if (defined('MAIL_USERNAME')) $mailer->Username = MAIL_USERNAME;
|
if (defined( 'MAIL_HOST' )) {
|
||||||
if (defined('MAIL_PASSWORD')) $mailer->Password = MAIL_PASSWORD;
|
$mailer->Host = MAIL_HOST;
|
||||||
if (defined('MAIL_TIMEOUT')) $mailer->Timeout = MAIL_TIMEOUT;
|
}
|
||||||
if (defined('MAIL_CHARSET')) $mailer->CharSet = MAIL_CHARSET;
|
if (defined( 'MAIL_SMTPAUTH' )) {
|
||||||
if (defined('MAIL_ENCODING')) $mailer->Encoding= MAIL_ENCODING;
|
$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;
|
return $mailer;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -81,13 +99,13 @@ class mailer
|
|||||||
* email $address.
|
* email $address.
|
||||||
* @author David Callizaya
|
* @author David Callizaya
|
||||||
*/
|
*/
|
||||||
function arpaEMAIL($address)
|
function arpaEMAIL ($address)
|
||||||
{
|
{
|
||||||
$arpa = array();
|
$arpa = array ();
|
||||||
preg_match("/([^<>]*)(?:\<([^<>]*)\>)?/",$address,$matches);
|
preg_match( "/([^<>]*)(?:\<([^<>]*)\>)?/", $address, $matches );
|
||||||
$isEmail = preg_match("/\b[A-Z0-9._%-]+@[A-Z0-9.-]+\.[A-Z]{2,4}\b/i",$matches[1]);
|
$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['email'] = ((isset( $matches[2] )) && ($matches[2] != '')) ? $matches[2] : (($isEmail) ? $matches[1] : '');
|
||||||
$arpa['name'] = ($isEmail)?'':$matches[1];
|
$arpa['name'] = ($isEmail) ? '' : $matches[1];
|
||||||
return $arpa;
|
return $arpa;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -107,49 +125,56 @@ class mailer
|
|||||||
*
|
*
|
||||||
* @return object $content or $result
|
* @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
|
// Read the content of the TemplateFile
|
||||||
$fp = fopen(PATH_HTMLMAIL . $templateFile,"r");
|
$fp = fopen( PATH_HTMLMAIL . $templateFile, "r" );
|
||||||
$content = fread($fp,filesize(PATH_HTMLMAIL . $templateFile));
|
$content = fread( $fp, filesize( PATH_HTMLMAIL . $templateFile ) );
|
||||||
fclose($fp);
|
fclose( $fp );
|
||||||
//Replace the @@Fields with the $Fields array.
|
//Replace the @@Fields with the $Fields array.
|
||||||
$content = mailer::replaceFields($Fields,$content);
|
$content = mailer::replaceFields( $Fields, $content );
|
||||||
//Compatibility with class.Application
|
//Compatibility with class.Application
|
||||||
if ($attachs==='FALSE')
|
if ($attachs === 'FALSE') {
|
||||||
return $content;
|
return $content;
|
||||||
|
}
|
||||||
//Create the alternative body (text only)
|
//Create the alternative body (text only)
|
||||||
//$h2t =& new html2text($content);
|
//$h2t =& new html2text($content);
|
||||||
$text = '';//$h2t->get_text();
|
$text = ''; //$h2t->get_text();
|
||||||
//Prepate el phpmailer
|
//Prepate el phpmailer
|
||||||
$mailer = mailer::instanceMailer();
|
$mailer = mailer::instanceMailer();
|
||||||
$arpa = mailer::arpaEMAIL($from);
|
$arpa = mailer::arpaEMAIL( $from );
|
||||||
$mailer->From = $arpa['email']==''?$mailer->defaultEMail:$arpa['email'];
|
$mailer->From = $arpa['email'] == '' ? $mailer->defaultEMail : $arpa['email'];
|
||||||
$mailer->FromName = $arpa['name'];
|
$mailer->FromName = $arpa['name'];
|
||||||
$arpa = mailer::arpaEMAIL($target);
|
$arpa = mailer::arpaEMAIL( $target );
|
||||||
$mailer->AddAddress($arpa['email'],$arpa['name']);
|
$mailer->AddAddress( $arpa['email'], $arpa['name'] );
|
||||||
$mailer->AddCC($cc);
|
$mailer->AddCC( $cc );
|
||||||
$mailer->AddBCC($bcc);
|
$mailer->AddBCC( $bcc );
|
||||||
$mailer->Subject = $subject;
|
$mailer->Subject = $subject;
|
||||||
if ($plainText)
|
if ($plainText) {
|
||||||
$content = $text;
|
$content = $text;
|
||||||
if ($content==='')
|
}
|
||||||
$content='empty';
|
if ($content === '') {
|
||||||
|
$content = 'empty';
|
||||||
|
}
|
||||||
$mailer->Body = $content;
|
$mailer->Body = $content;
|
||||||
//$mailer->AltBody = $text;
|
//$mailer->AltBody = $text;
|
||||||
$mailer->isHTML(!$plainText);
|
$mailer->isHTML( ! $plainText );
|
||||||
//Attach the required files
|
//Attach the required files
|
||||||
if (is_array($attachs))
|
if (is_array( $attachs ))
|
||||||
if (sizeof($attachs)>0)
|
if (sizeof( $attachs ) > 0)
|
||||||
foreach($attachs as $aFile)
|
foreach ($attachs as $aFile)
|
||||||
$mailer->AddAttachment($aFile,basename($aFile));
|
$mailer->AddAttachment( $aFile, basename( $aFile ) );
|
||||||
//Send the e-mail.
|
//Send the e-mail.
|
||||||
for($r=1;$r<=4;$r++) {
|
for ($r = 1; $r <= 4; $r ++) {
|
||||||
$result = $mailer->Send();
|
$result = $mailer->Send();
|
||||||
if ($result) break;
|
if ($result) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
//unset($h2t);
|
//unset($h2t);
|
||||||
if ($result && $returnContent) return $content;
|
if ($result && $returnContent) {
|
||||||
|
return $content;
|
||||||
|
}
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -169,40 +194,48 @@ class mailer
|
|||||||
*
|
*
|
||||||
* @return object $result
|
* @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.
|
//Replace the @@Fields with the $Fields array.
|
||||||
$content = mailer::replaceFields($Fields,$content);
|
$content = mailer::replaceFields( $Fields, $content );
|
||||||
//Create the alternative body (text only)
|
//Create the alternative body (text only)
|
||||||
//$h2t =& new html2text($content);
|
//$h2t =& new html2text($content);
|
||||||
$text = '';//$h2t->get_text();
|
$text = ''; //$h2t->get_text();
|
||||||
//Prepate el phpmailer
|
//Prepate el phpmailer
|
||||||
$mailer = mailer::instanceMailer();
|
$mailer = mailer::instanceMailer();
|
||||||
$arpa = mailer::arpaEMAIL($from);
|
$arpa = mailer::arpaEMAIL( $from );
|
||||||
$mailer->From = $arpa['email']==''?$mailer->defaultEMail:$arpa['email'];
|
$mailer->From = $arpa['email'] == '' ? $mailer->defaultEMail : $arpa['email'];
|
||||||
$mailer->FromName = $arpa['name'];
|
$mailer->FromName = $arpa['name'];
|
||||||
$arpa = mailer::arpaEMAIL($target);
|
$arpa = mailer::arpaEMAIL( $target );
|
||||||
$mailer->AddAddress($arpa['email'],$arpa['name']);
|
$mailer->AddAddress( $arpa['email'], $arpa['name'] );
|
||||||
$mailer->AddCC($cc);
|
$mailer->AddCC( $cc );
|
||||||
$mailer->AddBCC($bcc);
|
$mailer->AddBCC( $bcc );
|
||||||
$mailer->Subject = $subject;
|
$mailer->Subject = $subject;
|
||||||
if ($plainText) $content = $text;
|
if ($plainText) {
|
||||||
if ($content==='') $content='empty';
|
$content = $text;
|
||||||
|
}
|
||||||
|
if ($content === '') {
|
||||||
|
$content = 'empty';
|
||||||
|
}
|
||||||
$mailer->Body = $content;
|
$mailer->Body = $content;
|
||||||
//$mailer->AltBody = $text;
|
//$mailer->AltBody = $text;
|
||||||
$mailer->isHTML(!$plainText);
|
$mailer->isHTML( ! $plainText );
|
||||||
//Attach the required files
|
//Attach the required files
|
||||||
if (is_array($attachs))
|
if (is_array( $attachs ))
|
||||||
if (sizeof($attachs)>0)
|
if (sizeof( $attachs ) > 0)
|
||||||
foreach($attachs as $aFile)
|
foreach ($attachs as $aFile)
|
||||||
$mailer->AddAttachment($aFile,basename($aFile));
|
$mailer->AddAttachment( $aFile, basename( $aFile ) );
|
||||||
//Send the e-mail.
|
//Send the e-mail.
|
||||||
for($r=1;$r<=4;$r++) {
|
for ($r = 1; $r <= 4; $r ++) {
|
||||||
$result=$mailer->Send();
|
$result = $mailer->Send();
|
||||||
if ($result) break;
|
if ($result) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
//unset($h2t);
|
//unset($h2t);
|
||||||
if ($result && $returnContent) return $content;
|
if ($result && $returnContent) {
|
||||||
|
return $content;
|
||||||
|
}
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -219,30 +252,36 @@ class mailer
|
|||||||
*
|
*
|
||||||
* @return object $result
|
* @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
|
//Prepate el phpmailer
|
||||||
$mailer = mailer::instanceMailer();
|
$mailer = mailer::instanceMailer();
|
||||||
$arpa = mailer::arpaEMAIL($from);
|
$arpa = mailer::arpaEMAIL( $from );
|
||||||
$mailer->From = $arpa['email']==''?$mailer->defaultEMail:$arpa['email'];
|
$mailer->From = $arpa['email'] == '' ? $mailer->defaultEMail : $arpa['email'];
|
||||||
$mailer->FromName = $arpa['name'];
|
$mailer->FromName = $arpa['name'];
|
||||||
$arpa = mailer::arpaEMAIL($target);
|
$arpa = mailer::arpaEMAIL( $target );
|
||||||
$mailer->AddAddress($arpa['email'],$arpa['name']);
|
$mailer->AddAddress( $arpa['email'], $arpa['name'] );
|
||||||
$mailer->AddCC($cc);
|
$mailer->AddCC( $cc );
|
||||||
$mailer->AddBCC($bcc);
|
$mailer->AddBCC( $bcc );
|
||||||
$mailer->Subject = $subject;
|
$mailer->Subject = $subject;
|
||||||
if ($content==='') $content='empty';
|
if ($content === '') {
|
||||||
|
$content = 'empty';
|
||||||
|
}
|
||||||
$mailer->Body = $content;
|
$mailer->Body = $content;
|
||||||
$mailer->AltBody = $content;
|
$mailer->AltBody = $content;
|
||||||
$mailer->isHTML(false);
|
$mailer->isHTML( false );
|
||||||
//Attach the required files
|
//Attach the required files
|
||||||
if (sizeof($attachs)>0)
|
if (sizeof( $attachs ) > 0) {
|
||||||
foreach($attachs as $aFile)
|
foreach ($attachs as $aFile) {
|
||||||
$mailer->AddAttachment($aFile,basename($aFile));
|
$mailer->AddAttachment( $aFile, basename( $aFile ) );
|
||||||
|
}
|
||||||
|
}
|
||||||
//Send the e-mail.
|
//Send the e-mail.
|
||||||
for($r=1;$r<=4;$r++) {
|
for ($r = 1; $r <= 4; $r ++) {
|
||||||
$result=$mailer->Send();
|
$result = $mailer->Send();
|
||||||
if ($result) break;
|
if ($result) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
@@ -255,21 +294,22 @@ class mailer
|
|||||||
*
|
*
|
||||||
* @return none
|
* @return none
|
||||||
*/
|
*/
|
||||||
function replaceFields($Fields = array(), $content = "")
|
function replaceFields ($Fields = array(), $content = "")
|
||||||
{
|
{
|
||||||
return G::replaceDataField( $content , $Fields );
|
return G::replaceDataField( $content, $Fields );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* html2text
|
* html2text
|
||||||
*
|
*
|
||||||
* empty
|
* empty
|
||||||
|
*
|
||||||
* @return none
|
* @return none
|
||||||
*/
|
*/
|
||||||
function html2text()
|
function html2text ()
|
||||||
{
|
{
|
||||||
//$h2t =& new html2text($content);
|
//$h2t =& new html2text($content);
|
||||||
//return $h2t->get_text();
|
//return $h2t->get_text();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* class.menu.php
|
* class.menu.php
|
||||||
|
*
|
||||||
* @package gulliver.system
|
* @package gulliver.system
|
||||||
*
|
*
|
||||||
* ProcessMaker Open Source Edition
|
* ProcessMaker Open Source Edition
|
||||||
@@ -24,12 +26,16 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
/**
|
/**
|
||||||
|
*
|
||||||
* @package gulliver.system
|
* @package gulliver.system
|
||||||
*/
|
*
|
||||||
|
*/
|
||||||
/**
|
/**
|
||||||
|
*
|
||||||
*
|
*
|
||||||
* Menu class definition
|
* Menu class definition
|
||||||
* Render Menus
|
* Render Menus
|
||||||
|
*
|
||||||
* @package gulliver.system
|
* @package gulliver.system
|
||||||
* @author Fernando Ontiveros Lira <fernando@colosa.com>
|
* @author Fernando Ontiveros Lira <fernando@colosa.com>
|
||||||
* @copyright (C) 2002 by Colosa Development Team.
|
* @copyright (C) 2002 by Colosa Development Team.
|
||||||
@@ -37,18 +43,18 @@
|
|||||||
*/
|
*/
|
||||||
class Menu
|
class Menu
|
||||||
{
|
{
|
||||||
var $Id = NULL;
|
var $Id = null;
|
||||||
var $Options = NULL;
|
var $Options = null;
|
||||||
var $Labels = NULL;
|
var $Labels = null;
|
||||||
var $Icons = NULL;
|
var $Icons = null;
|
||||||
var $JS = NULL;
|
var $JS = null;
|
||||||
var $Types = NULL;
|
var $Types = null;
|
||||||
var $Class = "mnu";
|
var $Class = "mnu";
|
||||||
var $Classes = NULL;
|
var $Classes = null;
|
||||||
var $Enabled = NULL;
|
var $Enabled = null;
|
||||||
var $optionOn = -1;
|
var $optionOn = - 1;
|
||||||
var $id_optionOn = "";
|
var $id_optionOn = "";
|
||||||
var $ElementClass = NULL;
|
var $ElementClass = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set menu style
|
* Set menu style
|
||||||
@@ -58,7 +64,7 @@ class Menu
|
|||||||
* @param $strClass name of style class default value 'mnu'
|
* @param $strClass name of style class default value 'mnu'
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function SetClass( $strClass = "mnu" )
|
function SetClass ($strClass = "mnu")
|
||||||
{
|
{
|
||||||
$this->Class = "mnu";
|
$this->Class = "mnu";
|
||||||
}
|
}
|
||||||
@@ -71,51 +77,55 @@ class Menu
|
|||||||
* @param $strMenuName name of menu
|
* @param $strMenuName name of menu
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function Load( $strMenuName )
|
function Load ($strMenuName)
|
||||||
{
|
{
|
||||||
global $G_TMP_MENU;
|
global $G_TMP_MENU;
|
||||||
$G_TMP_MENU = NULL;
|
$G_TMP_MENU = null;
|
||||||
$G_TMP_MENU = new Menu;
|
$G_TMP_MENU = new Menu();
|
||||||
$fMenu = G::ExpandPath( "menus" ) . $strMenuName . ".php";
|
$fMenu = G::ExpandPath( "menus" ) . $strMenuName . ".php";
|
||||||
|
|
||||||
//if the menu file doesn't exists, then try with the plugins folders
|
//if the menu file doesn't exists, then try with the plugins folders
|
||||||
if ( !is_file( $fMenu) ) {
|
if (! is_file( $fMenu )) {
|
||||||
$aux = explode ( PATH_SEP, $strMenuName );
|
$aux = explode( PATH_SEP, $strMenuName );
|
||||||
if ( count($aux) == 2 ) {
|
if (count( $aux ) == 2) {
|
||||||
$oPluginRegistry =& PMPluginRegistry::getSingleton();
|
$oPluginRegistry = & PMPluginRegistry::getSingleton();
|
||||||
if ( $oPluginRegistry->isRegisteredFolder($aux[0]) )
|
if ($oPluginRegistry->isRegisteredFolder( $aux[0] )) {
|
||||||
$fMenu = PATH_PLUGINS . $aux[0] . PATH_SEP . $aux[1] . ".php";
|
$fMenu = PATH_PLUGINS . $aux[0] . PATH_SEP . $aux[1] . ".php";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if( !is_file( $fMenu ) )
|
if (! is_file( $fMenu )) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
include( $fMenu );
|
include ($fMenu);
|
||||||
//this line will add options to current menu.
|
//this line will add options to current menu.
|
||||||
$oPluginRegistry =& PMPluginRegistry::getSingleton();
|
$oPluginRegistry = & PMPluginRegistry::getSingleton();
|
||||||
$oPluginRegistry->getMenus ( $strMenuName );
|
$oPluginRegistry->getMenus( $strMenuName );
|
||||||
|
|
||||||
//?
|
//?
|
||||||
$c = 0;
|
$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) {
|
if ($G_TMP_MENU->Enabled[$i] == 1) {
|
||||||
$this->Options[$c] = $G_TMP_MENU->Options[$i];
|
$this->Options[$c] = $G_TMP_MENU->Options[$i];
|
||||||
$this->Labels [$c] = $G_TMP_MENU->Labels[$i];
|
$this->Labels[$c] = $G_TMP_MENU->Labels[$i];
|
||||||
$this->Icons [$c] = $G_TMP_MENU->Icons[$i];
|
$this->Icons[$c] = $G_TMP_MENU->Icons[$i];
|
||||||
$this->JS [$c] = $G_TMP_MENU->JS[$i];
|
$this->JS[$c] = $G_TMP_MENU->JS[$i];
|
||||||
$this->Types [$c] = $G_TMP_MENU->Types[$i];
|
$this->Types[$c] = $G_TMP_MENU->Types[$i];
|
||||||
$this->Enabled[$c] = $G_TMP_MENU->Enabled[$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->Classes[$c] = $G_TMP_MENU->Classes[$i];
|
||||||
$this->ElementClass[$c] = $G_TMP_MENU->ElementClass[$i];
|
$this->ElementClass[$c] = $G_TMP_MENU->ElementClass[$i];
|
||||||
$c ++;
|
$c ++;
|
||||||
} else {
|
} else {
|
||||||
if ($i == $this->optionOn) $this->optionOn = -1;
|
if ($i == $this->optionOn)
|
||||||
elseif ($i < $this->optionOn) $this->optionOn--;
|
$this->optionOn = - 1;
|
||||||
elseif ($this->optionOn > 0) $this->optionOn--;//added this line
|
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
|
* @access public
|
||||||
* @return int
|
* @return int
|
||||||
*/
|
*/
|
||||||
function OptionCount()
|
function OptionCount ()
|
||||||
{
|
{
|
||||||
$result = 0;
|
$result = 0;
|
||||||
if( is_array( $this->Options ) )
|
if (is_array( $this->Options )) {
|
||||||
{
|
|
||||||
$result = count( $this->Options );
|
$result = count( $this->Options );
|
||||||
}
|
}
|
||||||
return $result;
|
return $result;
|
||||||
@@ -145,7 +154,7 @@ class Menu
|
|||||||
* @param string $strType type, defualt value ='plugins'
|
* @param string $strType type, defualt value ='plugins'
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function AddOption( $strLabel, $strURL, $strType = "plugins" )
|
function AddOption ($strLabel, $strURL, $strType = "plugins")
|
||||||
{
|
{
|
||||||
$pos = $this->OptionCount();
|
$pos = $this->OptionCount();
|
||||||
$this->Options[$pos] = $strURL;
|
$this->Options[$pos] = $strURL;
|
||||||
@@ -167,19 +176,19 @@ class Menu
|
|||||||
* @param string $strType type, defualt value ='plugins'
|
* @param string $strType type, defualt value ='plugins'
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function AddIdOption( $strId, $strLabel, $strURL, $strType = "plugins" )
|
function AddIdOption ($strId, $strLabel, $strURL, $strType = "plugins")
|
||||||
{
|
{
|
||||||
$pos = $this->OptionCount();
|
$pos = $this->OptionCount();
|
||||||
$this->Options[$pos] = $strURL;
|
$this->Options[$pos] = $strURL;
|
||||||
$this->Labels[$pos] = $strLabel;
|
$this->Labels[$pos] = $strLabel;
|
||||||
$this->Types[$pos] = $strType;
|
$this->Types[$pos] = $strType;
|
||||||
$this->Enabled[$pos] = 1;
|
$this->Enabled[$pos] = 1;
|
||||||
if (is_array ($strId)) {
|
if (is_array( $strId )) {
|
||||||
$this->Id[$pos] = $strId[0];
|
$this->Id[$pos] = $strId[0];
|
||||||
$this->Classes[$pos] = $strId[1];
|
$this->Classes[$pos] = $strId[1];
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
$this->Id[$pos] = $strId;
|
$this->Id[$pos] = $strId;
|
||||||
|
}
|
||||||
unset( $pos );
|
unset( $pos );
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -192,7 +201,7 @@ class Menu
|
|||||||
* @param string $strType type, defualt value ='plugins'
|
* @param string $strType type, defualt value ='plugins'
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function AddRawOption( $strURL = "", $strType = "plugins" )
|
function AddRawOption ($strURL = "", $strType = "plugins")
|
||||||
{
|
{
|
||||||
$pos = $this->OptionCount();
|
$pos = $this->OptionCount();
|
||||||
$this->Options[$pos] = $strURL;
|
$this->Options[$pos] = $strURL;
|
||||||
@@ -215,7 +224,7 @@ class Menu
|
|||||||
* @param string $elementClass default value =''
|
* @param string $elementClass default value =''
|
||||||
* @return void
|
* @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();
|
$pos = $this->OptionCount();
|
||||||
$this->Options[$pos] = $strURL;
|
$this->Options[$pos] = $strURL;
|
||||||
@@ -225,12 +234,12 @@ class Menu
|
|||||||
$this->Types[$pos] = $strType;
|
$this->Types[$pos] = $strType;
|
||||||
$this->Enabled[$pos] = 1;
|
$this->Enabled[$pos] = 1;
|
||||||
$this->ElementClass[$pos] = $elementClass;
|
$this->ElementClass[$pos] = $elementClass;
|
||||||
if (is_array ($strId)) {
|
if (is_array( $strId )) {
|
||||||
$this->Id[$pos] = $strId[0];
|
$this->Id[$pos] = $strId[0];
|
||||||
$this->Classes[$pos] = $strId[1];
|
$this->Classes[$pos] = $strId[1];
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
$this->Id[$pos] = $strId;
|
$this->Id[$pos] = $strId;
|
||||||
|
}
|
||||||
unset( $pos );
|
unset( $pos );
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -242,7 +251,7 @@ class Menu
|
|||||||
* @param string $intPos menu option's position
|
* @param string $intPos menu option's position
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function DisableOptionPos( $intPos )
|
function DisableOptionPos ($intPos)
|
||||||
{
|
{
|
||||||
$this->Enabled[$intPos] = 0;
|
$this->Enabled[$intPos] = 0;
|
||||||
}
|
}
|
||||||
@@ -255,10 +264,11 @@ class Menu
|
|||||||
* @param string $id menu's id
|
* @param string $id menu's id
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function DisableOptionId ( $id )
|
function DisableOptionId ($id)
|
||||||
{
|
{
|
||||||
if ( array_search ($id, $this->Id) )
|
if (array_search( $id, $this->Id )) {
|
||||||
$this->Enabled[ array_search ($id, $this->Id) ] = 0;
|
$this->Enabled[array_search( $id, $this->Id )] = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -269,32 +279,31 @@ class Menu
|
|||||||
* @param string $intPos menu option's position
|
* @param string $intPos menu option's position
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function RenderOption( $intPos )
|
function RenderOption ($intPos)
|
||||||
{
|
{
|
||||||
if ( $this->Enabled[$intPos] != 1)
|
if ($this->Enabled[$intPos] != 1) {
|
||||||
return;
|
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
|
$classname = $this->Class . "Link";
|
||||||
if (defined('SYS_SYS'))
|
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;
|
$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;
|
$target = "/sys/" . SYS_LANG . "/" . SYS_SKIN . "/" . $target;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
$label = $this->Labels[$intPos];
|
$label = $this->Labels[$intPos];
|
||||||
$result = "<a href=\"$target\"";
|
$result = "<a href=\"$target\"";
|
||||||
$result .= " class=\"$classname\">";
|
$result .= " class=\"$classname\">";
|
||||||
$result .= htmlentities( $label , ENT_NOQUOTES , 'utf-8');
|
$result .= htmlentities( $label, ENT_NOQUOTES, 'utf-8' );
|
||||||
$result .= "</a>";
|
$result .= "</a>";
|
||||||
print( $result );
|
print ($result) ;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -310,19 +319,18 @@ class Menu
|
|||||||
* @param string $G_ID_MENU_SELECTED
|
* @param string $G_ID_MENU_SELECTED
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
function generateArrayForTemplate($G_MAIN_MENU,$classOn,$classOff,$G_MENU_SELECTED, $G_ID_MENU_SELECTED ) {
|
function generateArrayForTemplate ($G_MAIN_MENU, $classOn, $classOff, $G_MENU_SELECTED, $G_ID_MENU_SELECTED)
|
||||||
$menus = array();
|
{
|
||||||
|
$menus = array ();
|
||||||
if ($G_MAIN_MENU == null) {
|
if ($G_MAIN_MENU == null) {
|
||||||
return $menus;
|
return $menus;
|
||||||
}
|
}
|
||||||
$this->Load ($G_MAIN_MENU);
|
$this->Load( $G_MAIN_MENU );
|
||||||
$this->optionOn = $G_MENU_SELECTED;
|
$this->optionOn = $G_MENU_SELECTED;
|
||||||
$this->id_optionOn = $G_ID_MENU_SELECTED;
|
$this->id_optionOn = $G_ID_MENU_SELECTED;
|
||||||
//$this->Class = $G_MENU_CLASS;
|
//$this->Class = $G_MENU_CLASS;
|
||||||
if (is_array($this->Options))
|
if (is_array( $this->Options )) {
|
||||||
{
|
for ($ncount = 0; $ncount < $this->OptionCount(); $ncount ++) {
|
||||||
for ($ncount = 0; $ncount < $this->OptionCount(); $ncount++)
|
|
||||||
{
|
|
||||||
$target = $this->Options[$ncount];
|
$target = $this->Options[$ncount];
|
||||||
|
|
||||||
//$aux = $this->Icons[$ncount];
|
//$aux = $this->Icons[$ncount];
|
||||||
@@ -332,48 +340,45 @@ class Menu
|
|||||||
$target = $this->Options[$ncount];
|
$target = $this->Options[$ncount];
|
||||||
}
|
}
|
||||||
if ($this->Types[$ncount] != 'absolute') {
|
if ($this->Types[$ncount] != 'absolute') {
|
||||||
if (defined('SYS_SYS')) {
|
if (defined( 'SYS_SYS' )) {
|
||||||
$target = '/sys' . SYS_TEMP . G::encryptLink('/' . SYS_LANG . '/' . SYS_SKIN . '/' . $this->Options[$ncount]);
|
$target = '/sys' . SYS_TEMP . G::encryptLink( '/' . SYS_LANG . '/' . SYS_SKIN . '/' . $this->Options[$ncount] );
|
||||||
}
|
} else {
|
||||||
else {
|
$target = '/sys/' . G::encryptLink( SYS_LANG . '/' . SYS_SKIN . '/' . $this->Options[$ncount] );
|
||||||
$target = '/sys/' . G::encryptLink(SYS_LANG . '/' . SYS_SKIN . '/' . $this->Options[$ncount]);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$label = $this->Labels[$ncount];
|
$label = $this->Labels[$ncount];
|
||||||
if ($this->id_optionOn != '') {
|
if ($this->id_optionOn != '') {
|
||||||
$onMenu = ($this->Id[$ncount] == $this->id_optionOn ? true : false);
|
$onMenu = ($this->Id[$ncount] == $this->id_optionOn ? true : false);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
$onMenu = ($ncount == $this->optionOn ? true : false);
|
$onMenu = ($ncount == $this->optionOn ? true : false);
|
||||||
}
|
}
|
||||||
$classname = ($onMenu ? $classOn : $classOff);
|
$classname = ($onMenu ? $classOn : $classOff);
|
||||||
$imageLeft = ($onMenu ? "<img src=\"/images/bulletSubMenu.jpg\" />" : '');
|
$imageLeft = ($onMenu ? "<img src=\"/images/bulletSubMenu.jpg\" />" : '');
|
||||||
$onclick = '';
|
$onclick = '';
|
||||||
if ($this->JS[$ncount] !== '' ) {
|
if ($this->JS[$ncount] !== '') {
|
||||||
$onclick = " onclick=\"" . $this->JS[$ncount] . "\"";
|
$onclick = " onclick=\"" . $this->JS[$ncount] . "\"";
|
||||||
}
|
}
|
||||||
$icon = '';
|
$icon = '';
|
||||||
if ($this->Icons[$ncount] !== '' ) {
|
if ($this->Icons[$ncount] !== '') {
|
||||||
$icon = " <a href=\"#\" onclick=\"" . $this->JS[$ncount] . "\" class=\"$classname\">" .
|
$icon = " <a href=\"#\" onclick=\"" . $this->JS[$ncount] . "\" class=\"$classname\">" . "<img src=\"" . $this->Icons[$ncount] . "\" border=\"0\"/></a>";
|
||||||
"<img src=\"". $this->Icons[$ncount] . "\" border=\"0\"/></a>";
|
|
||||||
$icon = $this->Icons[$ncount];
|
$icon = $this->Icons[$ncount];
|
||||||
}
|
}
|
||||||
if ( $this->Classes[$ncount] != '') {
|
if ($this->Classes[$ncount] != '') {
|
||||||
$classname = $this->Classes[$ncount];
|
$classname = $this->Classes[$ncount];
|
||||||
$target = "#";
|
$target = "#";
|
||||||
}
|
}
|
||||||
$idName=$this->Id[$ncount];
|
$idName = $this->Id[$ncount];
|
||||||
|
|
||||||
$elementclass = '';
|
$elementclass = '';
|
||||||
if($this->ElementClass[$ncount] != ''){
|
if ($this->ElementClass[$ncount] != '') {
|
||||||
$elementclass = 'class="'.$this->ElementClass[$ncount].'"';
|
$elementclass = 'class="' . $this->ElementClass[$ncount] . '"';
|
||||||
}
|
}
|
||||||
|
|
||||||
$menus[] = array ( 'id' => $ncount, 'target' => $target, 'label' => $label, 'onMenu' => $onMenu, 'classname' => $classname,
|
$menus[] = array ('id' => $ncount,'target' => $target,'label' => $label,'onMenu' => $onMenu,'classname' => $classname,'imageLeft' => $imageLeft,'onclick' => $onclick,'icon' => $icon,'aux' => $aux,'idName' => $idName,'elementclass' => $elementclass
|
||||||
'imageLeft' => $imageLeft, 'onclick' => $onclick,
|
);
|
||||||
'icon' => $icon, 'aux' => $aux,'idName' => $idName,'elementclass'=>$elementclass);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $menus;
|
return $menus;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* class.objectTemplate.php
|
* class.objectTemplate.php
|
||||||
|
*
|
||||||
* @package gulliver.system
|
* @package gulliver.system
|
||||||
*
|
*
|
||||||
* ProcessMaker Open Source Edition
|
* ProcessMaker Open Source Edition
|
||||||
@@ -26,20 +28,23 @@
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Class objectTemplate
|
* Class objectTemplate
|
||||||
|
*
|
||||||
* @package gulliver.system
|
* @package gulliver.system
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
|
|
||||||
class objectTemplate extends smarty
|
class objectTemplate extends smarty
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function objectTemplate
|
* Function objectTemplate
|
||||||
|
*
|
||||||
* @access public
|
* @access public
|
||||||
* @param object $templateFile
|
* @param object $templateFile
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function objectTemplate( $templateFile )
|
function objectTemplate ($templateFile)
|
||||||
{
|
{
|
||||||
$this->template_dir = PATH_TPL;
|
$this->template_dir = PATH_TPL;
|
||||||
$this->compile_dir = PATH_SMARTY_C;
|
$this->compile_dir = PATH_SMARTY_C;
|
||||||
@@ -51,13 +56,15 @@ class objectTemplate extends smarty
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Function printObject
|
* Function printObject
|
||||||
|
*
|
||||||
* @access public
|
* @access public
|
||||||
* @param object $object
|
* @param object $object
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
function printObject($object)
|
function printObject ($object)
|
||||||
{
|
{
|
||||||
$this->assign($object);
|
$this->assign( $object );
|
||||||
return $this->fetch($this->templateFile);
|
return $this->fetch( $this->templateFile );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,11 +1,12 @@
|
|||||||
<?php
|
<?php
|
||||||
/**
|
/**
|
||||||
* class.testTools.php
|
* class.testTools.php
|
||||||
|
*
|
||||||
* @package gulliver.system
|
* @package gulliver.system
|
||||||
*
|
*
|
||||||
* ProcessMaker Open Source Edition
|
* ProcessMaker Open Source Edition
|
||||||
* Copyright (C) 2004 - 2011 Colosa Inc.
|
* Copyright (C) 2004 - 2011 Colosa Inc.
|
||||||
|
*
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU Affero General Public License as
|
* it under the terms of the GNU Affero General Public License as
|
||||||
@@ -25,12 +26,15 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
*
|
||||||
* @package gulliver.system
|
* @package gulliver.system
|
||||||
**/
|
*
|
||||||
G::LoadSystem ( 'ymlDomain');
|
*/
|
||||||
G::LoadSystem ( 'ymlTestCases');
|
G::LoadSystem( 'ymlDomain' );
|
||||||
G::LoadSystem ( 'unitTest');
|
G::LoadSystem( 'ymlTestCases' );
|
||||||
|
G::LoadSystem( 'unitTest' );
|
||||||
|
|
||||||
class testTools
|
class testTools
|
||||||
{
|
{
|
||||||
|
|
||||||
@@ -45,9 +49,9 @@ class testTools
|
|||||||
*
|
*
|
||||||
* @return none
|
* @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
|
* @return none
|
||||||
*/
|
*/
|
||||||
function importLocalDB( $importFile )
|
function importLocalDB ($importFile)
|
||||||
{
|
{
|
||||||
self::importDB( DB_HOST, DB_USER, DB_PASS, DB_NAME, $importFile );
|
self::importDB( DB_HOST, DB_USER, DB_PASS, DB_NAME, $importFile );
|
||||||
}
|
}
|
||||||
@@ -72,16 +76,16 @@ class testTools
|
|||||||
*
|
*
|
||||||
* @return none
|
* @return none
|
||||||
*/
|
*/
|
||||||
function callMethod( $methodFile, $GET, $POST, $SESSION )
|
function callMethod ($methodFile, $GET, $POST, $SESSION)
|
||||||
{
|
{
|
||||||
//TODO $_SERVER
|
//TODO $_SERVER
|
||||||
self::arrayDelete($_GET);
|
self::arrayDelete( $_GET );
|
||||||
self::arrayDelete($_POST);
|
self::arrayDelete( $_POST );
|
||||||
self::arrayDelete($_SESSION);
|
self::arrayDelete( $_SESSION );
|
||||||
self::arrayAppend($_GET,$GET);
|
self::arrayAppend( $_GET, $GET );
|
||||||
self::arrayAppend($_POST,$POST);
|
self::arrayAppend( $_POST, $POST );
|
||||||
self::arrayAppend($_SESSION,$SESSION);
|
self::arrayAppend( $_SESSION, $SESSION );
|
||||||
include( PATH_CORE . 'methods/' . $methodFile );
|
include (PATH_CORE . 'methods/' . $methodFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -92,9 +96,11 @@ class testTools
|
|||||||
*
|
*
|
||||||
* @return boolean true
|
* @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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -105,9 +111,11 @@ class testTools
|
|||||||
*
|
*
|
||||||
* @return boolean true
|
* @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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -120,11 +128,11 @@ class testTools
|
|||||||
* @return array $Fields
|
* @return array $Fields
|
||||||
*/
|
*/
|
||||||
//@@
|
//@@
|
||||||
function replaceVariables( $Fields, $ExternalVariables = array() )
|
function replaceVariables ($Fields, $ExternalVariables = array())
|
||||||
{
|
{
|
||||||
//TODO: Verify dependencies between fields
|
//TODO: Verify dependencies between fields
|
||||||
foreach($Fields as $key => $field) {
|
foreach ($Fields as $key => $field) {
|
||||||
if (is_string($field)) {
|
if (is_string( $field )) {
|
||||||
$mergedValues = G::array_merges( $Fields, $ExternalVariables );
|
$mergedValues = G::array_merges( $Fields, $ExternalVariables );
|
||||||
$Fields[$key] = G::ReplaceDataField( $field, $mergedValues );
|
$Fields[$key] = G::ReplaceDataField( $field, $mergedValues );
|
||||||
}
|
}
|
||||||
@@ -141,30 +149,32 @@ class testTools
|
|||||||
*
|
*
|
||||||
* @return (boolean | string) ((true | false) | $value)
|
* @return (boolean | string) ((true | false) | $value)
|
||||||
*/
|
*/
|
||||||
function findValue( $value, &$obj )
|
function findValue ($value, &$obj)
|
||||||
{
|
{
|
||||||
if (is_array($obj)) {
|
if (is_array( $obj )) {
|
||||||
foreach($obj as $key => $val ) {
|
foreach ($obj as $key => $val) {
|
||||||
if ($res=self::findValue( $value , $obj[$key] )) {
|
if ($res = self::findValue( $value, $obj[$key] )) {
|
||||||
if ($res==true) return $key;
|
if ($res == true) {
|
||||||
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)
|
|
||||||
return $key;
|
return $key;
|
||||||
else
|
} else {
|
||||||
return $key . '.' . $res;
|
return $key . '.' . $res;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
else {
|
return false;
|
||||||
return $obj==$value;
|
} 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
|
* @return object $result
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function domain($location)
|
function domain ($location)
|
||||||
{
|
{
|
||||||
global $testDomain;
|
global $testDomain;
|
||||||
$result = $testDomain->get($location);
|
$result = $testDomain->get( $location );
|
||||||
if (count($result)==0) trigger_error("'$location' is an empty domain.", E_USER_WARNING);
|
if (count( $result ) == 0) {
|
||||||
|
trigger_error( "'$location' is an empty domain.", E_USER_WARNING );
|
||||||
|
}
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,17 +1,18 @@
|
|||||||
<?php
|
<?php
|
||||||
/**
|
/**
|
||||||
* class.tree.php
|
* class.tree.php
|
||||||
|
*
|
||||||
* @package gulliver.system
|
* @package gulliver.system
|
||||||
*
|
*
|
||||||
* ProcessMaker Open Source Edition
|
* ProcessMaker Open Source Edition
|
||||||
* Copyright (C) 2004 - 2011 Colosa Inc.
|
* Copyright (C) 2004 - 2011 Colosa Inc.
|
||||||
|
*
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU Affero General Public License as
|
* it under the terms of the GNU Affero General Public License as
|
||||||
* published by the Free Software Foundation, either version 3 of the
|
* published by the Free Software Foundation, either version 3 of the
|
||||||
* License, or (at your option) any later version.
|
* License, or (at your option) any later version.
|
||||||
*<2A>
|
* <EFBFBD>
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
@@ -25,11 +26,14 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
*
|
||||||
* @package gulliver.system
|
* @package gulliver.system
|
||||||
*/
|
*/
|
||||||
G::LoadSystem('objectTemplate');
|
G::LoadSystem( 'objectTemplate' );
|
||||||
class Tree extends Xml_Node {
|
|
||||||
|
class Tree extends Xml_Node
|
||||||
|
{
|
||||||
var $template = 'tree.html';
|
var $template = 'tree.html';
|
||||||
var $nodeType = 'base';
|
var $nodeType = 'base';
|
||||||
var $nodeClass = 'treeNode';
|
var $nodeClass = 'treeNode';
|
||||||
@@ -50,23 +54,24 @@
|
|||||||
*
|
*
|
||||||
* @return none
|
* @return none
|
||||||
*/
|
*/
|
||||||
function Tree( $xmlnode = NULL )
|
function Tree ($xmlnode = null)
|
||||||
{
|
{
|
||||||
if (!isset($xmlnode))
|
if (! isset( $xmlnode )) {
|
||||||
return;
|
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') {
|
if (isset( $xmlnode->attributes['nodeType'] )) {
|
||||||
foreach( $xmlnode->attributes as $key => $value ) {
|
$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;
|
$this->{$key} = $value;
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
$this->{$key} = $value;
|
$this->{$key} = $value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -82,10 +87,10 @@
|
|||||||
* @return object(Tree) $newNode
|
* @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));
|
$newNode = new Tree( new Xml_Node( $name, 'open', $label, $attributes ) );
|
||||||
$this->children[] =& $newNode;
|
$this->children[] = & $newNode;
|
||||||
return $newNode;
|
return $newNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -94,23 +99,21 @@
|
|||||||
*
|
*
|
||||||
* @return string '<span>...</span>'
|
* @return string '<span>...</span>'
|
||||||
*/
|
*/
|
||||||
function printPlus()
|
function printPlus ()
|
||||||
{
|
{
|
||||||
$plus = 'none';
|
$plus = 'none';
|
||||||
$minus = 'none';
|
$minus = 'none';
|
||||||
$point = 'none';
|
$point = 'none';
|
||||||
if ($this->showSign) {
|
if ($this->showSign) {
|
||||||
if ((sizeof($this->children)>0) && ($this->contracted)) {
|
if ((sizeof( $this->children ) > 0) && ($this->contracted)) {
|
||||||
$plus = '';
|
$plus = '';
|
||||||
} elseif ((sizeof($this->children)>0) && (!$this->contracted)) {
|
} elseif ((sizeof( $this->children ) > 0) && (! $this->contracted)) {
|
||||||
$minus = '';
|
$minus = '';
|
||||||
} else {
|
} else {
|
||||||
$point = '';
|
$point = '';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return "<span class='treePlus' name='plus' style='display:$plus;'>{$this->plus}</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>";
|
||||||
"<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
|
* @return $this->value
|
||||||
*/
|
*/
|
||||||
function printLabel()
|
function printLabel ()
|
||||||
{
|
{
|
||||||
return $this->value;
|
return $this->value;
|
||||||
}
|
}
|
||||||
@@ -128,13 +131,14 @@
|
|||||||
*
|
*
|
||||||
* @return string $html
|
* @return string $html
|
||||||
*/
|
*/
|
||||||
function printContent()
|
function printContent ()
|
||||||
{
|
{
|
||||||
$html = '';
|
$html = '';
|
||||||
$row = 0;
|
$row = 0;
|
||||||
foreach($this->children as $child) {
|
foreach ($this->children as $child) {
|
||||||
if ($row)
|
if ($row) {
|
||||||
$child->nodeClass = 'treeNodeAlternate';
|
$child->nodeClass = 'treeNodeAlternate';
|
||||||
|
}
|
||||||
$html .= $child->render();
|
$html .= $child->render();
|
||||||
$row = ($row + 1) % 2;
|
$row = ($row + 1) % 2;
|
||||||
}
|
}
|
||||||
@@ -143,11 +147,14 @@
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* render
|
* render
|
||||||
|
*
|
||||||
* @return $obj->printObject( array( 'node' => &$this ) )
|
* @return $obj->printObject( array( 'node' => &$this ) )
|
||||||
*/
|
*/
|
||||||
function render() {
|
function render ()
|
||||||
|
{
|
||||||
$obj = new objectTemplate( $this->template );
|
$obj = new objectTemplate( $this->template );
|
||||||
return $obj->printObject( array( 'node' => &$this ) );
|
return $obj->printObject( array ('node' => &$this
|
||||||
}
|
) );
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,11 +1,13 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* class.unitTest.php
|
* class.unitTest.php
|
||||||
|
*
|
||||||
* @package gulliver.system
|
* @package gulliver.system
|
||||||
*
|
*
|
||||||
* ProcessMaker Open Source Edition
|
* ProcessMaker Open Source Edition
|
||||||
* Copyright (C) 2004 - 2011 Colosa Inc.
|
* Copyright (C) 2004 - 2011 Colosa Inc.
|
||||||
|
*
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU Affero General Public License as
|
* it under the terms of the GNU Affero General Public License as
|
||||||
@@ -25,7 +27,8 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
*
|
||||||
* @package gulliver.system
|
* @package gulliver.system
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -36,37 +39,41 @@ class unitTest
|
|||||||
var $yml;
|
var $yml;
|
||||||
var $domain;
|
var $domain;
|
||||||
var $testLime;
|
var $testLime;
|
||||||
function unitTest( $ymlFile, &$testLime, &$testDomain )
|
|
||||||
|
function unitTest ($ymlFile, &$testLime, &$testDomain)
|
||||||
{
|
{
|
||||||
if (!isset($testDomain)) $testDomain = new ymlDomain();
|
if (! isset( $testDomain )) {
|
||||||
$this->domain =& $testDomain;
|
$testDomain = new ymlDomain();
|
||||||
$this->testLime =& $testLime;
|
}
|
||||||
|
$this->domain = & $testDomain;
|
||||||
|
$this->testLime = & $testLime;
|
||||||
$this->yml = new ymlTestCases( $ymlFile, $this->domain, $this->testLime );
|
$this->yml = new ymlTestCases( $ymlFile, $this->domain, $this->testLime );
|
||||||
}
|
}
|
||||||
//Load a Test (group of unitary tests) defined in the Yml file.
|
//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 );
|
$this->yml->load( $testName, $fields );
|
||||||
}
|
}
|
||||||
//Run one single unit test from the loaded Test
|
//Run one single unit test from the loaded Test
|
||||||
function runSingle( $fields=array() )
|
function runSingle ($fields = array())
|
||||||
{
|
{
|
||||||
return $this->yml->runSingle( $this, $fields );
|
return $this->yml->runSingle( $this, $fields );
|
||||||
}
|
}
|
||||||
//Run a group of unit tests from the loaded Test
|
//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 );
|
return $this->yml->runMultiple( $this, $fields, $count, $start );
|
||||||
}
|
}
|
||||||
//Run all the unit tests from the loaded Test
|
//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.
|
//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;
|
return $result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* class.webResource.php
|
* class.webResource.php
|
||||||
|
*
|
||||||
* @package gulliver.system
|
* @package gulliver.system
|
||||||
*
|
*
|
||||||
* ProcessMaker Open Source Edition
|
* ProcessMaker Open Source Edition
|
||||||
@@ -32,7 +34,8 @@
|
|||||||
* @dependencies: grest.js *
|
* @dependencies: grest.js *
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
*
|
||||||
* @package gulliver.system
|
* @package gulliver.system
|
||||||
*/
|
*/
|
||||||
class WebResource
|
class WebResource
|
||||||
@@ -47,25 +50,26 @@ class WebResource
|
|||||||
*
|
*
|
||||||
* @return none
|
* @return none
|
||||||
*/
|
*/
|
||||||
function WebResource($uri, $post)
|
function WebResource ($uri, $post)
|
||||||
{
|
{
|
||||||
$this->_uri=$uri;
|
$this->_uri = $uri;
|
||||||
if (isset($post['function'])&&$post['function']!='') {
|
if (isset( $post['function'] ) && $post['function'] != '') {
|
||||||
/*Call a 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((urldecode($post['parameters']))); //for %AC
|
||||||
$parameters=G::json_decode(($post['parameters']));
|
$parameters = G::json_decode( ($post['parameters']) );
|
||||||
$paramsRef=array();
|
$paramsRef = array ();
|
||||||
foreach($parameters as $key => $value)
|
foreach ($parameters as $key => $value) {
|
||||||
{
|
if (is_string( $key )) {
|
||||||
if (is_string($key)) $paramsRef[]="\$parameters['".addcslashes($key,'\\\'')."']";
|
$paramsRef[] = "\$parameters['" . addcslashes( $key, '\\\'' ) . "']";
|
||||||
else $paramsRef[]='$parameters['.$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*/
|
/*Print class definition*/
|
||||||
$this->_encode();
|
$this->_encode();
|
||||||
}
|
}
|
||||||
@@ -76,56 +80,52 @@ class WebResource
|
|||||||
*
|
*
|
||||||
* @return none
|
* @return none
|
||||||
*/
|
*/
|
||||||
function _encode()
|
function _encode ()
|
||||||
{
|
{
|
||||||
header('Content-Type: text/json');
|
header( 'Content-Type: text/json' );
|
||||||
$methods=get_class_methods(get_class($this));
|
$methods = get_class_methods( get_class( $this ) );
|
||||||
print('{');
|
print ('{') ;
|
||||||
$first = true;
|
$first = true;
|
||||||
foreach($methods as $method) {
|
foreach ($methods as $method) {
|
||||||
//To avoid PHP version incompatibilities, put the $method name in lowercase
|
//To avoid PHP version incompatibilities, put the $method name in lowercase
|
||||||
$method=strtolower($method);
|
$method = strtolower( $method );
|
||||||
if ((substr($method,0,1)==='_')||
|
if ((substr( $method, 0, 1 ) === '_') || (strcasecmp( $method, 'WebResource' ) == 0) || (strcasecmp( $method, get_class( $this ) ) == 0)) {
|
||||||
(strcasecmp($method,'WebResource')==0)||
|
} elseif (strcasecmp( substr( $method, 0, 3 ), 'js_' ) == 0) {
|
||||||
(strcasecmp($method,get_class($this))==0)
|
if (! $first) {
|
||||||
)
|
print (',') ;
|
||||||
{
|
|
||||||
}
|
}
|
||||||
elseif (strcasecmp(substr($method,0,3),'js_')==0)
|
|
||||||
{
|
|
||||||
if (!$first) print(',');
|
|
||||||
$this->{$method}();
|
$this->{$method}();
|
||||||
$first=false;
|
$first = false;
|
||||||
|
} else {
|
||||||
|
if (! $first) {
|
||||||
|
print (',') ;
|
||||||
}
|
}
|
||||||
else
|
print ($method . ':function(){return __wrCall("' . addslashes( $this->_uri ) . '","' . $method . '",arguments);}') ;
|
||||||
{
|
$first = false;
|
||||||
if (!$first) print(',');
|
|
||||||
print(
|
|
||||||
$method.
|
|
||||||
':function(){return __wrCall("'.
|
|
||||||
addslashes($this->_uri).
|
|
||||||
'","'.$method.'",arguments);}'
|
|
||||||
);
|
|
||||||
$first=false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
print('}');
|
print ('}') ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* end class WebResource */
|
/* end class WebResource */
|
||||||
|
|
||||||
if (!function_exists('json_encode')) {
|
if (! function_exists( 'json_encode' )) {
|
||||||
G::LoadThirdParty('pear/json','class.json');
|
G::LoadThirdParty( 'pear/json', 'class.json' );
|
||||||
function json_encode(&$value) {
|
|
||||||
$json= new Services_JSON;
|
function json_encode (&$value)
|
||||||
return $json->encode($value);
|
{
|
||||||
|
$json = new Services_JSON();
|
||||||
|
return $json->encode( $value );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!function_exists('json_decode')) {
|
if (! function_exists( 'json_decode' )) {
|
||||||
G::LoadThirdParty('pear/json','class.json');
|
G::LoadThirdParty( 'pear/json', 'class.json' );
|
||||||
function json_decode(&$value) {
|
|
||||||
$json= new Services_JSON;
|
function json_decode (&$value)
|
||||||
return $json->decode($value);
|
{
|
||||||
|
$json = new Services_JSON();
|
||||||
|
return $json->decode( $value );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* class.xmlDocument.php
|
* class.xmlDocument.php
|
||||||
|
*
|
||||||
* @package gulliver.system
|
* @package gulliver.system
|
||||||
*
|
*
|
||||||
* ProcessMaker Open Source Edition
|
* ProcessMaker Open Source Edition
|
||||||
@@ -25,6 +27,7 @@
|
|||||||
*/
|
*/
|
||||||
/**
|
/**
|
||||||
* Class Xml_Node
|
* Class Xml_Node
|
||||||
|
*
|
||||||
* @author David S. Callizaya S. <davidsantos@colosa.com>
|
* @author David S. Callizaya S. <davidsantos@colosa.com>
|
||||||
* @package gulliver.system
|
* @package gulliver.system
|
||||||
* @access public
|
* @access public
|
||||||
@@ -34,117 +37,132 @@ class Xml_Node
|
|||||||
var $name = '';
|
var $name = '';
|
||||||
var $type = '';
|
var $type = '';
|
||||||
var $value = ''; //maybe not necesary
|
var $value = ''; //maybe not necesary
|
||||||
var $attributes = array();
|
var $attributes = array ();
|
||||||
var $children = array();
|
var $children = array ();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function Xml_Node
|
* Function Xml_Node
|
||||||
|
*
|
||||||
* @author David S. Callizaya S. <davidsantos@colosa.com>
|
* @author David S. Callizaya S. <davidsantos@colosa.com>
|
||||||
* @access public
|
* @access public
|
||||||
* @parameter string name
|
* @param eter string name
|
||||||
* @parameter string type
|
* @param eter string type
|
||||||
* @parameter string value
|
* @param eter string value
|
||||||
* @parameter string attributes
|
* @param eter string attributes
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
function Xml_Node($name, $type, $value, $attributes = array() )
|
function Xml_Node ($name, $type, $value, $attributes = array())
|
||||||
{
|
{
|
||||||
$this->name = $name;
|
$this->name = $name;
|
||||||
$this->type = $type;
|
$this->type = $type;
|
||||||
$this->value = $value;
|
$this->value = $value;
|
||||||
$this->attributes = $attributes;
|
$this->attributes = $attributes;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function addAttribute
|
* Function addAttribute
|
||||||
|
*
|
||||||
* @author David S. Callizaya S. <davidsantos@colosa.com>
|
* @author David S. Callizaya S. <davidsantos@colosa.com>
|
||||||
* @access public
|
* @access public
|
||||||
* @parameter string name
|
* @param eter string name
|
||||||
* @parameter string value
|
* @param eter string value
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
function addAttribute( $name, $value )
|
function addAttribute ($name, $value)
|
||||||
{
|
{
|
||||||
$this->attributes[$name] = $value;
|
$this->attributes[$name] = $value;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function addChildNode
|
* Function addChildNode
|
||||||
|
*
|
||||||
* @author David S. Callizaya S. <davidsantos@colosa.com>
|
* @author David S. Callizaya S. <davidsantos@colosa.com>
|
||||||
* @access public
|
* @access public
|
||||||
* @parameter string childNode
|
* @param eter string childNode
|
||||||
* @return string
|
* @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';
|
$this->type = 'open';
|
||||||
$childNode->parent = &$this;
|
$childNode->parent = &$this;
|
||||||
$this->children[] = &$childNode;
|
$this->children[] = &$childNode;
|
||||||
return true;
|
return true;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function toTree
|
* Function toTree
|
||||||
|
*
|
||||||
* @author David S. Callizaya S. <davidsantos@colosa.com>
|
* @author David S. Callizaya S. <davidsantos@colosa.com>
|
||||||
* @access public
|
* @access public
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
function toTree()
|
function toTree ()
|
||||||
{
|
{
|
||||||
$arr = new Xml_Node( $this->name, $this->type, $this->value, $this->attributes );
|
$arr = new Xml_Node( $this->name, $this->type, $this->value, $this->attributes );
|
||||||
unset( $arr->parent );
|
unset( $arr->parent );
|
||||||
foreach($this->children as $k => $v) {
|
foreach ($this->children as $k => $v) {
|
||||||
unset($v->parent);
|
unset( $v->parent );
|
||||||
$arr->children[$k]=$v->toTree();
|
$arr->children[$k] = $v->toTree();
|
||||||
}
|
}
|
||||||
return $arr;
|
return $arr;
|
||||||
}
|
}
|
||||||
function toArray( $obj = NULL ) {
|
|
||||||
$arr = array();
|
function toArray ($obj = null)
|
||||||
if ( !isset($obj) ) $obj = $this->toTree();
|
{
|
||||||
foreach($obj as $att => $val ) {
|
$arr = array ();
|
||||||
if (is_array($val) || is_object($val) ) {
|
if (! isset( $obj )) {
|
||||||
$arr[$att] = Xml_Node::toArray($val);
|
$obj = $this->toTree();
|
||||||
|
}
|
||||||
|
foreach ($obj as $att => $val) {
|
||||||
|
if (is_array( $val ) || is_object( $val )) {
|
||||||
|
$arr[$att] = Xml_Node::toArray( $val );
|
||||||
} else {
|
} else {
|
||||||
$arr[$att] = $val;
|
$arr[$att] = $val;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $arr;
|
return $arr;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function &findNode
|
* Function &findNode
|
||||||
|
*
|
||||||
* @author David S. Callizaya S. <davidsantos@colosa.com>
|
* @author David S. Callizaya S. <davidsantos@colosa.com>
|
||||||
* @access public
|
* @access public
|
||||||
* @parameter string xpath
|
* @param eter string xpath
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
function &findNode( $xpath )
|
function &findNode ($xpath)
|
||||||
{
|
{
|
||||||
$n = NULL;
|
$n = null;
|
||||||
$p = explode('/', $xpath);
|
$p = explode( '/', $xpath );
|
||||||
if ( $p[0] === '') {
|
if ($p[0] === '') {
|
||||||
return $this;
|
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) === '@') {
|
} elseif ($p[0] === '..') {
|
||||||
$p[0] = substr($p[0], 1 );
|
array_shift( $p );
|
||||||
if ( isset($this->attributes[$p[0]])) return $this->attributes[$p[0]];
|
$n = & $this->parent->findNode( implode( '/', $p ) );
|
||||||
|
if (isset( $n )) {
|
||||||
|
return $n;
|
||||||
}
|
}
|
||||||
elseif ($p[0] === '..' ) {
|
} else {
|
||||||
array_shift($p);
|
foreach ($this->children as $k => $v) {
|
||||||
$n = & $this->parent->findNode ( implode('/',$p) );
|
if (($v->type !== 'cdata') && ($v->name === $p[0])) {
|
||||||
if (isset($n) ) return $n;
|
if (sizeof( $p ) > 1) {
|
||||||
|
array_shift( $p );
|
||||||
|
$n = & $this->children[$k]->findNode( implode( '/', $p ) );
|
||||||
|
if (isset( $n )) {
|
||||||
|
return $n;
|
||||||
}
|
}
|
||||||
else {
|
} 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 {
|
|
||||||
return $this->children[$k];
|
return $this->children[$k];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -152,21 +170,22 @@ class Xml_Node
|
|||||||
}
|
}
|
||||||
return $n;
|
return $n;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function getXML
|
* Function getXML
|
||||||
* Returns a string of the node in XML notation.
|
* Returns a string of the node in XML notation.
|
||||||
|
*
|
||||||
* @author David S. Callizaya S. <davidsantos@colosa.com>
|
* @author David S. Callizaya S. <davidsantos@colosa.com>
|
||||||
* @access public
|
* @access public
|
||||||
* @parameter string xpath
|
* @param eter string xpath
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
function getXML()
|
function getXML ()
|
||||||
{
|
|
||||||
switch($this->type)
|
|
||||||
{
|
{
|
||||||
|
switch ($this->type) {
|
||||||
case 'open':
|
case 'open':
|
||||||
$xml = '<'.$this->name;
|
$xml = '<' . $this->name;
|
||||||
foreach( $this->attributes as $attib => $value ) {
|
foreach ($this->attributes as $attib => $value) {
|
||||||
$value = htmlspecialchars( $value, ENT_QUOTES, 'utf-8' );
|
$value = htmlspecialchars( $value, ENT_QUOTES, 'utf-8' );
|
||||||
/*if(($attib == "hint")||($attib == "defaultvalue")){
|
/*if(($attib == "hint")||($attib == "defaultvalue")){
|
||||||
$value = str_replace("&", "&", $value);
|
$value = str_replace("&", "&", $value);
|
||||||
@@ -181,38 +200,35 @@ class Xml_Node
|
|||||||
$xml .= ' ' . $attib . '="' . $value . '"';
|
$xml .= ' ' . $attib . '="' . $value . '"';
|
||||||
//check if the htmlentities result value is the euro symbol and
|
//check if the htmlentities result value is the euro symbol and
|
||||||
//replaced by their numeric character representation
|
//replaced by their numeric character representation
|
||||||
if (strpos($xml, '€') !== false) {
|
if (strpos( $xml, '€' ) !== false) {
|
||||||
$xml = str_replace('€', '€', $xml);
|
$xml = str_replace( '€', '€', $xml );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$xml .= '>'.$this->getCDATAValue();
|
$xml .= '>' . $this->getCDATAValue();
|
||||||
foreach( $this->children as $child )
|
foreach ($this->children as $child) {
|
||||||
$xml .= $child->getXML();
|
$xml .= $child->getXML();
|
||||||
$xml .= '</'.$this->name.'>';
|
}
|
||||||
|
$xml .= '</' . $this->name . '>';
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'close':
|
case 'close':
|
||||||
$xml = '</'.$this->name.'>';
|
$xml = '</' . $this->name . '>';
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'cdata':
|
case 'cdata':
|
||||||
$xml = $this->getCDATAValue();
|
$xml = $this->getCDATAValue();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'complete':
|
case 'complete':
|
||||||
|
$xml = '<' . $this->name;
|
||||||
$xml = '<'.$this->name;
|
foreach ($this->attributes as $attib => $value) {
|
||||||
foreach( $this->attributes as $attib => $value ) {
|
$xml .= ' ' . $attib . '="' . htmlentities( $value, ENT_QUOTES, 'utf-8' ) . '"';
|
||||||
$xml .= ' ' . $attib . '="' . htmlentities($value, ENT_QUOTES, 'utf-8' ) . '"';
|
|
||||||
//check if the htmlentities result value is the euro symbol and
|
//check if the htmlentities result value is the euro symbol and
|
||||||
//replaced by their numeric character representation
|
//replaced by their numeric character representation
|
||||||
if (strpos($xml, '€') !== false) {
|
if (strpos( $xml, '€' ) !== false) {
|
||||||
$xml = str_replace('€', '€', $xml);
|
$xml = str_replace( '€', '€', $xml );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ($this->value!=='') {
|
if ($this->value !== '') {
|
||||||
$xml .= '>'.$this->getCDATAValue();
|
$xml .= '>' . $this->getCDATAValue();
|
||||||
$xml .= '</'.$this->name.'>';
|
$xml .= '</' . $this->name . '>';
|
||||||
} else {
|
} else {
|
||||||
$xml .= '/>';
|
$xml .= '/>';
|
||||||
}
|
}
|
||||||
@@ -220,17 +236,21 @@ class Xml_Node
|
|||||||
}
|
}
|
||||||
return $xml;
|
return $xml;
|
||||||
}
|
}
|
||||||
function getCDATAValue()
|
|
||||||
|
function getCDATAValue ()
|
||||||
{
|
{
|
||||||
$cdata = htmlentities( $this->value, ENT_QUOTES, 'utf-8' );
|
$cdata = htmlentities( $this->value, ENT_QUOTES, 'utf-8' );
|
||||||
if ($this->value === $cdata)
|
if ($this->value === $cdata) {
|
||||||
return $this->value;
|
return $this->value;
|
||||||
else
|
} else {
|
||||||
return '<![CDATA[' . $this->value . ']]>';
|
return '<![CDATA[' . $this->value . ']]>';
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class Xml_document
|
* Class Xml_document
|
||||||
|
*
|
||||||
* @author David S. Callizaya S. <davidsantos@colosa.com>
|
* @author David S. Callizaya S. <davidsantos@colosa.com>
|
||||||
* @package gulliver.system
|
* @package gulliver.system
|
||||||
* @access public
|
* @access public
|
||||||
@@ -238,43 +258,46 @@ class Xml_Node
|
|||||||
class Xml_document extends Xml_Node
|
class Xml_document extends Xml_Node
|
||||||
{
|
{
|
||||||
var $currentNode;
|
var $currentNode;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function Xml_document
|
* Function Xml_document
|
||||||
|
*
|
||||||
* @author David S. Callizaya S. <davidsantos@colosa.com>
|
* @author David S. Callizaya S. <davidsantos@colosa.com>
|
||||||
* @access public
|
* @access public
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
function Xml_document()
|
function Xml_document ()
|
||||||
{
|
{
|
||||||
$this->currentNode = &$this;
|
$this->currentNode = &$this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function parseXmlFile
|
* Function parseXmlFile
|
||||||
|
*
|
||||||
* @author David S. Callizaya S. <davidsantos@colosa.com>
|
* @author David S. Callizaya S. <davidsantos@colosa.com>
|
||||||
* @access public
|
* @access public
|
||||||
* @parameter string filename
|
* @param eter string filename
|
||||||
* @parameter string content
|
* @param eter string content
|
||||||
* @return string
|
* @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.
|
{ //$content is a new variable, if it has any value then use it instead of the file content.
|
||||||
if($content==""){
|
if ($content == "") {
|
||||||
if ( !file_exists ($filename) ) {
|
if (! file_exists( $filename )) {
|
||||||
throw ( new Exception ( "failed to open Xmlform File : No such file or directory in $filename " ) );
|
throw (new Exception( "failed to open Xmlform File : No such file or directory in $filename " ));
|
||||||
}
|
}
|
||||||
$data = implode( '', file( $filename) );
|
$data = implode( '', file( $filename ) );
|
||||||
}else{
|
} else {
|
||||||
$data = $content;
|
$data = $content;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$parser = xml_parser_create( 'utf-8' );
|
$parser = xml_parser_create( 'utf-8' );
|
||||||
xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0);
|
xml_parser_set_option( $parser, XML_OPTION_CASE_FOLDING, 0 );
|
||||||
xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 0);
|
xml_parser_set_option( $parser, XML_OPTION_SKIP_WHITE, 0 );
|
||||||
xml_parse_into_struct($parser, $data, $values, $tags);
|
xml_parse_into_struct( $parser, $data, $values, $tags );
|
||||||
if (xml_get_error_code($parser)!== 0) {
|
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));
|
$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 );
|
trigger_error( $msg );
|
||||||
}
|
}
|
||||||
xml_parser_free( $parser );
|
xml_parser_free( $parser );
|
||||||
|
|
||||||
@@ -282,83 +305,77 @@ class Xml_document extends Xml_Node
|
|||||||
$this->type = 'open';
|
$this->type = 'open';
|
||||||
$this->currentNode = &$this;
|
$this->currentNode = &$this;
|
||||||
$m = &$this;
|
$m = &$this;
|
||||||
foreach($values as $k => $v)
|
foreach ($values as $k => $v) {
|
||||||
{
|
switch ($v['type']) {
|
||||||
switch ($v['type'])
|
|
||||||
{
|
|
||||||
case 'open':
|
case 'open':
|
||||||
$this->currentNode->addChildNode ( new Xml_Node ($v['tag'],
|
$this->currentNode->addChildNode( new Xml_Node( $v['tag'], $v['type'], isset( $v['value'] ) ? $v['value'] : '', isset( $v['attributes'] ) ? $v['attributes'] : array () ) );
|
||||||
$v['type'], isset($v['value'])?$v['value'] : '',
|
$this->currentNode = &$this->findNode( $v['tag'] );
|
||||||
isset($v['attributes']) ? $v['attributes']:array()));
|
|
||||||
$this->currentNode = &$this->findNode($v['tag']);
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'close':
|
case 'close':
|
||||||
$this->currentNode=& $this->findNode('..');
|
$this->currentNode = & $this->findNode( '..' );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'cdata':
|
case 'cdata':
|
||||||
$this->currentNode->addChildNode(new Xml_Node('',
|
$this->currentNode->addChildNode( new Xml_Node( '', $v['type'], isset( $v['value'] ) ? $v['value'] : '' ) );
|
||||||
$v['type'], isset($v['value'])?$v['value']:''));
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'complete':
|
case 'complete':
|
||||||
$this->currentNode->addChildNode( new Xml_Node($v['tag'],
|
$this->currentNode->addChildNode( new Xml_Node( $v['tag'], $v['type'], isset( $v['value'] ) ? $v['value'] : '', isset( $v['attributes'] ) ? $v['attributes'] : array () ) );
|
||||||
$v['type'], isset($v['value'])?$v['value']:'',
|
|
||||||
isset($v['attributes'])?$v['attributes']:array()));
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function &findNode
|
* Function &findNode
|
||||||
|
*
|
||||||
* @author David S. Callizaya S. <davidsantos@colosa.com>
|
* @author David S. Callizaya S. <davidsantos@colosa.com>
|
||||||
* @access public
|
* @access public
|
||||||
* @parameter string xpath
|
* @param eter string xpath
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
function &findNode( $xpath )
|
function &findNode ($xpath)
|
||||||
{
|
{
|
||||||
if ( substr( $xpath, 0, 1 ) == '/' ) {
|
if (substr( $xpath, 0, 1 ) == '/') {
|
||||||
return parent::findNode( substr( $xpath,1) );
|
return parent::findNode( substr( $xpath, 1 ) );
|
||||||
}
|
} else {
|
||||||
else {
|
if (isset( $this->currentNode )) {
|
||||||
if ( isset($this->currentNode) ){
|
if ($this->currentNode->name === $this->name) {
|
||||||
if ( $this->currentNode->name === $this->name)
|
|
||||||
return parent::findNode( $xpath );
|
return parent::findNode( $xpath );
|
||||||
else
|
} else {
|
||||||
return $this->currentNode->findNode($xpath);
|
return $this->currentNode->findNode( $xpath );
|
||||||
}
|
}
|
||||||
else {
|
} else {
|
||||||
return $null;
|
return $null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} //function findNode
|
} //function findNode
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function getXML
|
* Function getXML
|
||||||
*
|
*
|
||||||
* @access public
|
* @access public
|
||||||
* @return string $xml
|
* @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();
|
$xml .= $this->children[0]->getXML();
|
||||||
return $xml;
|
return $xml;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function save
|
* Function save
|
||||||
*
|
*
|
||||||
* @access public
|
* @access public
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function save ( $filename )
|
function save ($filename)
|
||||||
{
|
{
|
||||||
$xml = $this->getXML();
|
$xml = $this->getXML();
|
||||||
$fp = fopen( $filename , 'w' );
|
$fp = fopen( $filename, 'w' );
|
||||||
fwrite( $fp , $xml );
|
fwrite( $fp, $xml );
|
||||||
fclose( $fp );/**/
|
fclose( $fp );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* class.xmlformExtension.php
|
* class.xmlformExtension.php
|
||||||
|
*
|
||||||
* @package gulliver.system
|
* @package gulliver.system
|
||||||
*
|
*
|
||||||
* ProcessMaker Open Source Edition
|
* ProcessMaker Open Source Edition
|
||||||
@@ -24,7 +26,8 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
*
|
||||||
* @package gulliver.system
|
* @package gulliver.system
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -38,6 +41,7 @@ class XmlForm_Field_Label extends XmlForm_Field
|
|||||||
* Special class for pagedTable
|
* Special class for pagedTable
|
||||||
* condition: PHP expression whose result defines whether to "mark"
|
* condition: PHP expression whose result defines whether to "mark"
|
||||||
* the following columns (that is if true)
|
* the following columns (that is if true)
|
||||||
|
*
|
||||||
* @package gulliver.system
|
* @package gulliver.system
|
||||||
*/
|
*/
|
||||||
class XmlForm_Field_cellMark extends XmlForm_Field
|
class XmlForm_Field_cellMark extends XmlForm_Field
|
||||||
@@ -60,14 +64,13 @@ class XmlForm_Field_cellMark extends XmlForm_Field
|
|||||||
*
|
*
|
||||||
* @return string $value
|
* @return string $value
|
||||||
*/
|
*/
|
||||||
function tdStyle( $values , $owner )
|
function tdStyle ($values, $owner)
|
||||||
{
|
{
|
||||||
$value = G::replaceDataField( $this->condition, $owner->values );
|
$value = G::replaceDataField( $this->condition, $owner->values );
|
||||||
$value = @eval('return ('.$value.');');
|
$value = @eval( 'return (' . $value . ');' );
|
||||||
$row=$values['row__'];
|
$row = $values['row__'];
|
||||||
$style=((($row % 2)==0) && ($this->styleAlt!=0)) ?
|
$style = ((($row % 2) == 0) && ($this->styleAlt != 0)) ? $this->styleAlt : $this->style;
|
||||||
$this->styleAlt : $this->style;
|
return ($value) ? $style : '';
|
||||||
return ($value)?$style:'';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -78,22 +81,21 @@ class XmlForm_Field_cellMark extends XmlForm_Field
|
|||||||
*
|
*
|
||||||
* @return $value
|
* @return $value
|
||||||
*/
|
*/
|
||||||
function tdClass( $values, $owner )
|
function tdClass ($values, $owner)
|
||||||
{
|
{
|
||||||
$value = G::replaceDataField( $this->condition, $owner->values );
|
$value = G::replaceDataField( $this->condition, $owner->values );
|
||||||
$value = @eval('return ('.$value.');');
|
$value = @eval( 'return (' . $value . ');' );
|
||||||
$row=$values['row__'];
|
$row = $values['row__'];
|
||||||
$style=(($row % 2)==0) ?
|
$style = (($row % 2) == 0) ? $this->classNameAlt : $this->className;
|
||||||
$this->classNameAlt : $this->className;
|
return ($value) ? $style : '';
|
||||||
return ($value)?$style:'';
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* XmlForm_Field_DVEditor
|
* XmlForm_Field_DVEditor
|
||||||
*
|
*
|
||||||
* extends XmlForm_Field
|
* extends XmlForm_Field
|
||||||
|
*
|
||||||
* @package gulliver.system
|
* @package gulliver.system
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@@ -101,7 +103,7 @@ class XmlForm_Field_DVEditor extends XmlForm_Field
|
|||||||
{
|
{
|
||||||
var $toolbarSet = 'toolbar2lines.html';
|
var $toolbarSet = 'toolbar2lines.html';
|
||||||
var $width = '90%';
|
var $width = '90%';
|
||||||
var $height = '200' ;
|
var $height = '200';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* render
|
* render
|
||||||
@@ -111,9 +113,9 @@ class XmlForm_Field_DVEditor extends XmlForm_Field
|
|||||||
*
|
*
|
||||||
* @return string '<div> ... </div>'
|
* @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
|
* @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;
|
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;">
|
* <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>
|
* <en>Search</en>
|
||||||
* </PAGED_TABLE_FAST_SEARCH>
|
* </PAGED_TABLE_FAST_SEARCH>
|
||||||
|
*
|
||||||
* @package gulliver.system
|
* @package gulliver.system
|
||||||
*/
|
*/
|
||||||
class XmlForm_Field_FastSearch extends XmlForm_Field_Text
|
class XmlForm_Field_FastSearch extends XmlForm_Field_Text
|
||||||
@@ -155,3 +158,4 @@ class XmlForm_Field_FastSearch extends XmlForm_Field_Text
|
|||||||
var $colWidth = "180";
|
var $colWidth = "180";
|
||||||
var $label = "@G::LoadTranslation(ID_SEARCH)";
|
var $label = "@G::LoadTranslation(ID_SEARCH)";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user