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:
File diff suppressed because it is too large
Load Diff
@@ -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,16 +182,16 @@ 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;
|
||||||
if (is_null( $errorLevel ))
|
if (is_null( $errorLevel ))
|
||||||
if (isset( $this->errorLevel )) {
|
if (isset( $this->errorLevel )) {
|
||||||
$errorLevel = $this->errorLevel;
|
$errorLevel = $this->errorLevel;
|
||||||
} else {
|
} else {
|
||||||
$errorLevel = DB_ERROR_SHOWALL_AND_STOP; //for fatal errors the default is 3, show detailed and die.
|
$errorLevel = DB_ERROR_SHOWALL_AND_STOP; //for fatal errors the default is 3, show detailed and die.
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($errorLevel == DB_ERROR_SHOW_AND_STOP || $errorLevel == DB_ERROR_SHOW_AND_CONTINUE || $errorLevel == DB_ERROR_SHOWALL_AND_STOP || $errorLevel == DB_ERROR_SHOWALL_AND_CONTINUE) {
|
if ($errorLevel == DB_ERROR_SHOW_AND_STOP || $errorLevel == DB_ERROR_SHOW_AND_CONTINUE || $errorLevel == DB_ERROR_SHOWALL_AND_STOP || $errorLevel == DB_ERROR_SHOWALL_AND_CONTINUE) {
|
||||||
print "<table border=1 style='font-family:Arial' cellspacing=1 cellpadding = 0 width=400 class= 'tableError' >";
|
print "<table border=1 style='font-family:Arial' cellspacing=1 cellpadding = 0 width=400 class= 'tableError' >";
|
||||||
|
|||||||
@@ -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
|
||||||
@@ -13,20 +15,21 @@
|
|||||||
*
|
*
|
||||||
* 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
|
||||||
* GNU Affero General Public License for more details.
|
* GNU Affero General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU Affero General Public License
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*
|
*
|
||||||
* For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
|
* For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
|
||||||
* Coral Gables, FL, 33134, USA, or email info@colosa.com.
|
* Coral Gables, FL, 33134, USA, or email info@colosa.com.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 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>
|
||||||
@@ -34,118 +37,116 @@
|
|||||||
*/
|
*/
|
||||||
class DBRecordSet
|
class DBRecordSet
|
||||||
{
|
{
|
||||||
var $result = null;
|
var $result = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Starts connection to Database using default values
|
* Starts connection to Database using default values
|
||||||
*
|
*
|
||||||
* @author Fernando Ontiveros Lira <fernando@colosa.com>
|
* @author Fernando Ontiveros Lira <fernando@colosa.com>
|
||||||
* @access public
|
* @access public
|
||||||
* @param string $intResult Database recordset default value = false
|
* @param string $intResult Database recordset default value = false
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
|
||||||
function DBRecordSet( $intResult = null )
|
|
||||||
{
|
|
||||||
$this->SetTo( $intResult );
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set conecction to Database
|
|
||||||
*
|
|
||||||
* @author Fernando Ontiveros Lira <fernando@colosa.com>
|
|
||||||
* @access public
|
|
||||||
* @param string $intResult connection string default value = false
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
function SetTo( $intResult = null )
|
|
||||||
{
|
|
||||||
if ( $intResult === null ) {
|
|
||||||
$dberror = PEAR::raiseError(null, DB_ERROR_OBJECT_NOT_DEFINED, null, 'null',
|
|
||||||
"You tried to call to a DBRecordset with an invalid result recordset.",
|
|
||||||
'G_Error', true);
|
|
||||||
DBconnection::logError( $dberror );
|
|
||||||
}
|
|
||||||
if ( $intResult ) {
|
|
||||||
$this->result = $intResult;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Function Free
|
|
||||||
* @author David S. Callizaya S. <davidsantos@colosa.com>
|
|
||||||
* @access public
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
function Free()
|
|
||||||
{
|
|
||||||
if ( $this->result === null ) {
|
|
||||||
$dberror = PEAR::raiseError(null, DB_ERROR_OBJECT_NOT_DEFINED, null, 'null',
|
|
||||||
"You tried to call to a DBRecordset with an invalid result recordset.",
|
|
||||||
'G_Error', true);
|
|
||||||
DBconnection::logError( $dberror );
|
|
||||||
}
|
|
||||||
$this->result->free();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Function Count
|
|
||||||
* @author David S. Callizaya S. <davidsantos@colosa.com>
|
|
||||||
* @access public
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
function Count()
|
|
||||||
{
|
|
||||||
if ( $this->result === null ) {
|
|
||||||
$dberror = PEAR::raiseError(null, DB_ERROR_OBJECT_NOT_DEFINED, null, 'null',
|
|
||||||
"You tried to call to a DBRecordset with an invalid result recordset.",
|
|
||||||
'G_Error', true);
|
|
||||||
DBconnection::logError( $dberror );
|
|
||||||
}
|
|
||||||
return $this->result->numRows();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Function Read
|
|
||||||
* @author David S. Callizaya S. <davidsantos@colosa.com>
|
|
||||||
* @access public
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
function Read()
|
|
||||||
{
|
|
||||||
if ( $this->result === null ) {
|
|
||||||
$dberror = PEAR::raiseError(null, DB_ERROR_OBJECT_NOT_DEFINED, null, 'null',
|
|
||||||
"You tried to call to a DBRecordset with an invalid result recordset.",
|
|
||||||
'G_Error', true);
|
|
||||||
DBconnection::logError( $dberror );
|
|
||||||
}
|
|
||||||
$res = $this->result->fetchRow(DB_FETCHMODE_ASSOC);
|
|
||||||
//for Pgsql databases,
|
|
||||||
//if ( PEAR_DATABASE == "pgsql" && is_array ( $res ) ) { $res = array_change_key_case( $res, CASE_UPPER); }
|
|
||||||
|
|
||||||
/* Comment Code: This block is not required now because
|
|
||||||
* of the the use of the G::sqlEscape() instead of addslashes
|
|
||||||
* funcion over each field in DBTable.
|
|
||||||
* @author David Callizaya
|
|
||||||
*/
|
*/
|
||||||
/*if (is_array ($res) )
|
function DBRecordSet ($intResult = null)
|
||||||
foreach ($res as $key => $val)
|
{
|
||||||
|
$this->SetTo( $intResult );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set conecction to Database
|
||||||
|
*
|
||||||
|
* @author Fernando Ontiveros Lira <fernando@colosa.com>
|
||||||
|
* @access public
|
||||||
|
* @param string $intResult connection string default value = false
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
function SetTo ($intResult = null)
|
||||||
|
{
|
||||||
|
if ($intResult === null) {
|
||||||
|
$dberror = PEAR::raiseError( null, DB_ERROR_OBJECT_NOT_DEFINED, null, 'null', "You tried to call to a DBRecordset with an invalid result recordset.", 'G_Error', true );
|
||||||
|
DBconnection::logError( $dberror );
|
||||||
|
}
|
||||||
|
if ($intResult) {
|
||||||
|
$this->result = $intResult;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function Free
|
||||||
|
*
|
||||||
|
* @author David S. Callizaya S. <davidsantos@colosa.com>
|
||||||
|
* @access public
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
function Free ()
|
||||||
|
{
|
||||||
|
if ($this->result === null) {
|
||||||
|
$dberror = PEAR::raiseError( null, DB_ERROR_OBJECT_NOT_DEFINED, null, 'null', "You tried to call to a DBRecordset with an invalid result recordset.", 'G_Error', true );
|
||||||
|
DBconnection::logError( $dberror );
|
||||||
|
}
|
||||||
|
$this->result->free();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function Count
|
||||||
|
*
|
||||||
|
* @author David S. Callizaya S. <davidsantos@colosa.com>
|
||||||
|
* @access public
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
function Count ()
|
||||||
|
{
|
||||||
|
if ($this->result === null) {
|
||||||
|
$dberror = PEAR::raiseError( null, DB_ERROR_OBJECT_NOT_DEFINED, null, 'null', "You tried to call to a DBRecordset with an invalid result recordset.", 'G_Error', true );
|
||||||
|
DBconnection::logError( $dberror );
|
||||||
|
}
|
||||||
|
return $this->result->numRows();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function Read
|
||||||
|
*
|
||||||
|
* @author David S. Callizaya S. <davidsantos@colosa.com>
|
||||||
|
* @access public
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
function Read ()
|
||||||
|
{
|
||||||
|
if ($this->result === null) {
|
||||||
|
$dberror = PEAR::raiseError( null, DB_ERROR_OBJECT_NOT_DEFINED, null, 'null', "You tried to call to a DBRecordset with an invalid result recordset.", 'G_Error', true );
|
||||||
|
DBconnection::logError( $dberror );
|
||||||
|
}
|
||||||
|
$res = $this->result->fetchRow( DB_FETCHMODE_ASSOC );
|
||||||
|
//for Pgsql databases,
|
||||||
|
//if ( PEAR_DATABASE == "pgsql" && is_array ( $res ) ) { $res = array_change_key_case( $res, CASE_UPPER); }
|
||||||
|
|
||||||
|
|
||||||
|
/* Comment Code: This block is not required now because
|
||||||
|
* of the the use of the G::sqlEscape() instead of addslashes
|
||||||
|
* funcion over each field in DBTable.
|
||||||
|
* @author David Callizaya
|
||||||
|
*/
|
||||||
|
/*if (is_array ($res) )
|
||||||
|
foreach ($res as $key => $val)
|
||||||
$res[$key] = stripslashes ($val); remove the slashes*/
|
$res[$key] = stripslashes ($val); remove the slashes*/
|
||||||
|
|
||||||
return $res;
|
return $res;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function ReadAbsolute
|
* Function ReadAbsolute
|
||||||
* @author David S. Callizaya S. <davidsantos@colosa.com>
|
*
|
||||||
* @access public
|
* @author David S. Callizaya S. <davidsantos@colosa.com>
|
||||||
* @return string
|
* @access public
|
||||||
*/
|
* @return string
|
||||||
function ReadAbsolute()
|
*/
|
||||||
{
|
function ReadAbsolute ()
|
||||||
$res = $this->result->fetchRow(DB_FETCHMODE_ORDERED);
|
{
|
||||||
//for Pgsql databases,
|
$res = $this->result->fetchRow( DB_FETCHMODE_ORDERED );
|
||||||
//if ( PEAR_DATABASE == "pgsql" && is_array ( $res ) ) { $res = array_change_key_case( $res, CASE_UPPER); }
|
//for Pgsql databases,
|
||||||
return $res;
|
//if ( PEAR_DATABASE == "pgsql" && is_array ( $res ) ) { $res = array_change_key_case( $res, CASE_UPPER); }
|
||||||
}
|
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
|
||||||
@@ -13,20 +15,21 @@
|
|||||||
*
|
*
|
||||||
* 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
|
||||||
* GNU Affero General Public License for more details.
|
* GNU Affero General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU Affero General Public License
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*
|
*
|
||||||
* For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
|
* For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
|
||||||
* Coral Gables, FL, 33134, USA, or email info@colosa.com.
|
* Coral Gables, FL, 33134, USA, or email info@colosa.com.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 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,146 +37,151 @@
|
|||||||
*/
|
*/
|
||||||
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
|
*
|
||||||
* @param object $objConnection
|
* @access public
|
||||||
* @param string $strDBName
|
* @param object $objConnection
|
||||||
* @return void
|
* @param string $strDBName
|
||||||
*
|
* @return void
|
||||||
*/
|
*
|
||||||
function DBSession( $objConnection = NULL, $strDBName = '' )
|
*/
|
||||||
{
|
function DBSession ($objConnection = null, $strDBName = '')
|
||||||
if ($strDBName!='') $strDBName = $objConnection->db->_db;
|
|
||||||
$this->setTo( $objConnection, $strDBName );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* It's like a constructor
|
|
||||||
* @author Fernando Ontiveros Lira <fernando@colosa.com>
|
|
||||||
*
|
|
||||||
* @access public
|
|
||||||
* @param object $objConnection
|
|
||||||
* @param string $strDBName
|
|
||||||
* @return void
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
function setTo( $objConnection = NULL, $strDBName = DB_NAME )
|
|
||||||
{
|
|
||||||
if ( $objConnection != NULL )
|
|
||||||
{
|
{
|
||||||
$this->Free();
|
if ($strDBName != '') {
|
||||||
$this->dbc = $objConnection;
|
$strDBName = $objConnection->db->_db;
|
||||||
$this->dbname = $strDBName;
|
}
|
||||||
|
$this->setTo( $objConnection, $strDBName );
|
||||||
//enable utf8 in mysql databases
|
|
||||||
if ( $this->dbc->db->phptype == 'mysql' ) { //utf-8
|
|
||||||
$this->dbc->db->query ( "SET NAMES 'utf8'; " );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* UseDB stablish a database for the connection
|
|
||||||
* @author Fernando Ontiveros Lira <fernando@colosa.com>
|
|
||||||
*
|
|
||||||
* @access public
|
|
||||||
* @param string $strDBName
|
|
||||||
* @return void
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
function UseDB( $strDBName = DB_NAME )
|
|
||||||
{
|
|
||||||
$this->dbname = $strDBName;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Function Execute, to execute a query and send back the recordset.
|
|
||||||
* @access public
|
|
||||||
* @parameter string strQuery
|
|
||||||
* @parameter string debug
|
|
||||||
* @parameter string error
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
function Execute( $strQuery = '', $debug = false, $errorLevel = null )
|
|
||||||
{
|
|
||||||
//BUG::traceRoute();
|
|
||||||
if ($this->dbc == NULL ) {
|
|
||||||
$dberror = PEAR::raiseError(null, DB_ERROR_OBJECT_NOT_DEFINED, null, 'null',
|
|
||||||
'You have tried to call a DBSession function without create an instance of DBConnection',
|
|
||||||
'G_Error', true);
|
|
||||||
DBconnection::logError( $dberror, $errorLevel );
|
|
||||||
return $dberror;
|
|
||||||
};
|
|
||||||
|
|
||||||
if ( $errorLevel === null ) $errorLevel = $this->dbc->errorLevel;
|
|
||||||
|
|
||||||
$this->Free( true );
|
|
||||||
|
|
||||||
if( $debug ) {
|
|
||||||
print( $strQuery . "<br>\n" );
|
|
||||||
}
|
|
||||||
$this->result = $this->dbc->db->query ( $strQuery );
|
|
||||||
if (DB::isError ($this->result)) {
|
|
||||||
$this->dbc->logError( $this->result, $errorLevel );
|
|
||||||
return $this->result;
|
|
||||||
}
|
|
||||||
$dset = new DBRecordSet( $this->result );
|
|
||||||
return $dset;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Function Query, just to execute the query.
|
|
||||||
* @access public
|
|
||||||
* @parameter string strQuery
|
|
||||||
* @parameter string debug
|
|
||||||
* @parameter string error
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
/* function deprecated... by Onti, 30th july 2007
|
|
||||||
function Query( $strQuery = '', $debug = false, $error = '' )
|
|
||||||
{
|
|
||||||
if ( $error == '' && defined('ERROR_STATE') ) {
|
|
||||||
$error = ERROR_STATE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( !defined('ERROR_STATE') ) $error = 4;
|
/**
|
||||||
|
* It's like a constructor
|
||||||
|
*
|
||||||
|
* @author Fernando Ontiveros Lira <fernando@colosa.com>
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
* @param object $objConnection
|
||||||
|
* @param string $strDBName
|
||||||
|
* @return void
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
function setTo ($objConnection = null, $strDBName = DB_NAME)
|
||||||
|
{
|
||||||
|
if ($objConnection != null) {
|
||||||
|
$this->Free();
|
||||||
|
$this->dbc = $objConnection;
|
||||||
|
$this->dbname = $strDBName;
|
||||||
|
|
||||||
if( $debug ) {
|
//enable utf8 in mysql databases
|
||||||
print( $strQuery . "<br>\n" );
|
if ($this->dbc->db->phptype == 'mysql') { //utf-8
|
||||||
|
$this->dbc->db->query( "SET NAMES 'utf8'; " );
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->Free( true );
|
/**
|
||||||
|
* UseDB stablish a database for the connection
|
||||||
$this->result = $this->dbc->db->query ( $strQuery );
|
*
|
||||||
|
* @author Fernando Ontiveros Lira <fernando@colosa.com>
|
||||||
if (DB::isError ($this->result)) {
|
*
|
||||||
$this->dbc->ShowLogError( $this->result->getMessage() , $this->result->userinfo, $error);
|
* @access public
|
||||||
die;
|
* @param string $strDBName
|
||||||
|
* @return void
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
function UseDB ($strDBName = DB_NAME)
|
||||||
|
{
|
||||||
|
$this->dbname = $strDBName;
|
||||||
}
|
}
|
||||||
return;
|
|
||||||
|
|
||||||
}
|
/**
|
||||||
*/
|
* Function Execute, to execute a query and send back the recordset.
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
* @param eter string strQuery
|
||||||
|
* @param eter string debug
|
||||||
|
* @param eter string error
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
function Execute ($strQuery = '', $debug = false, $errorLevel = null)
|
||||||
|
{
|
||||||
|
//BUG::traceRoute();
|
||||||
|
if ($this->dbc == null) {
|
||||||
|
$dberror = PEAR::raiseError( null, DB_ERROR_OBJECT_NOT_DEFINED, null, 'null', 'You have tried to call a DBSession function without create an instance of DBConnection', 'G_Error', true );
|
||||||
|
DBconnection::logError( $dberror, $errorLevel );
|
||||||
|
return $dberror;
|
||||||
|
}
|
||||||
|
;
|
||||||
|
|
||||||
/**
|
if ($errorLevel === null) {
|
||||||
* Function Free
|
$errorLevel = $this->dbc->errorLevel;
|
||||||
* @access public
|
}
|
||||||
* @parameter string debug
|
$this->Free( true );
|
||||||
* @return string
|
|
||||||
*/
|
if ($debug) {
|
||||||
function Free( $debug = false )
|
print ($strQuery . "<br>\n") ;
|
||||||
{
|
}
|
||||||
if ( is_resource($this->result) )
|
$this->result = $this->dbc->db->query( $strQuery );
|
||||||
$this->result->Free();
|
if (DB::isError( $this->result )) {
|
||||||
return;
|
$this->dbc->logError( $this->result, $errorLevel );
|
||||||
}
|
return $this->result;
|
||||||
|
}
|
||||||
|
$dset = new DBRecordSet( $this->result );
|
||||||
|
return $dset;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function Query, just to execute the query.
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
* @param eter string strQuery
|
||||||
|
* @param eter string debug
|
||||||
|
* @param eter string error
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
/* function deprecated... by Onti, 30th july 2007
|
||||||
|
function Query( $strQuery = '', $debug = false, $error = '' )
|
||||||
|
{
|
||||||
|
if ( $error == '' && defined('ERROR_STATE') ) {
|
||||||
|
$error = ERROR_STATE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( !defined('ERROR_STATE') ) $error = 4;
|
||||||
|
|
||||||
|
if( $debug ) {
|
||||||
|
print( $strQuery . "<br>\n" );
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->Free( true );
|
||||||
|
|
||||||
|
$this->result = $this->dbc->db->query ( $strQuery );
|
||||||
|
|
||||||
|
if (DB::isError ($this->result)) {
|
||||||
|
$this->dbc->ShowLogError( $this->result->getMessage() , $this->result->userinfo, $error);
|
||||||
|
die;
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function Free
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
* @param eter string debug
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
function Free ($debug = false)
|
||||||
|
{
|
||||||
|
if (is_resource( $this->result )) {
|
||||||
|
$this->result->Free();
|
||||||
|
}
|
||||||
|
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
|
||||||
@@ -13,11 +15,11 @@
|
|||||||
*
|
*
|
||||||
* 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
|
||||||
* GNU Affero General Public License for more details.
|
* GNU Affero General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU Affero General Public License
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*
|
*
|
||||||
* For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
|
* For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
|
||||||
* Coral Gables, FL, 33134, USA, or email info@colosa.com.
|
* Coral Gables, FL, 33134, USA, or email info@colosa.com.
|
||||||
@@ -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.
|
||||||
@@ -36,393 +39,391 @@
|
|||||||
*/
|
*/
|
||||||
class DBTable
|
class DBTable
|
||||||
{
|
{
|
||||||
var $_dbc;
|
var $_dbc;
|
||||||
var $_dbses;
|
var $_dbses;
|
||||||
var $_dset;
|
var $_dset;
|
||||||
var $table_name;
|
var $table_name;
|
||||||
var $table_keys;
|
var $table_keys;
|
||||||
var $Fields = null;
|
var $Fields = null;
|
||||||
var $is_new;
|
var $is_new;
|
||||||
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>
|
||||||
* @access public
|
* @access public
|
||||||
* @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->_dbses = NULL;
|
|
||||||
$this->SetTo( $objConnection, $strTable, $arrKeys );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Initiate a database conecction using default values
|
|
||||||
*
|
|
||||||
* @author Fernando Ontiveros Lira <fernando@colosa.com>
|
|
||||||
* @access public
|
|
||||||
* @param object $objDBConnection conecction string
|
|
||||||
* @param string $strTable Table name defaultvalue=''
|
|
||||||
* @param array $arrKeys table keys defaultvalue=UID
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
function setTo( $objDBConnection, $strTable = "", $arrKeys = array( 'UID' ) )
|
|
||||||
{
|
|
||||||
|
|
||||||
$this->_dbc = $objDBConnection;
|
|
||||||
if( $this->_dbc != NULL && strcasecmp( get_class( $objDBConnection ) , 'dbconnection' ) == 0 )
|
|
||||||
{
|
{
|
||||||
$this->_dbses = new DBSession( $this->_dbc );
|
$this->_dbc = null;
|
||||||
$this->_dbses->UseDB( DB_NAME );
|
$this->_dbses = null;
|
||||||
|
$this->SetTo( $objConnection, $strTable, $arrKeys );
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
$dberror = PEAR::raiseError(null, DB_ERROR_OBJECT_NOT_DEFINED, null, 'null',
|
|
||||||
"You tried to call to a DBTable function without create an instance of DBConnection",
|
|
||||||
'G_Error', true);
|
|
||||||
//DBconnection::logError( $dberror );
|
|
||||||
return $dberror;
|
|
||||||
}
|
|
||||||
$this->is_new = true;
|
|
||||||
$this->Fields = NULL;
|
|
||||||
$this->table_name = $strTable;
|
|
||||||
if ( is_array ( $arrKeys ) )
|
|
||||||
$this->table_keys = $arrKeys;
|
|
||||||
else
|
|
||||||
$this->table_keys = array ( 0 => $arrKeys );
|
|
||||||
$this->errorLevel = $this->_dbc->errorLevel;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Loads full description of a referenced table in Fields
|
* Initiate a database conecction using default values
|
||||||
*
|
*
|
||||||
* @author Fernando Ontiveros Lira <fernando@colosa.com>
|
* @author Fernando Ontiveros Lira <fernando@colosa.com>
|
||||||
* @access public
|
* @access public
|
||||||
* @return void
|
* @param object $objDBConnection conecction string
|
||||||
*/
|
* @param string $strTable Table name defaultvalue=''
|
||||||
function loadEmpty()
|
* @param array $arrKeys table keys defaultvalue=UID
|
||||||
{
|
* @return void
|
||||||
$stQry = "DESCRIBE `" . $this->table_name. "`";
|
*/
|
||||||
$dset = $this->_dbses->execute( $stQry );
|
function setTo ($objDBConnection, $strTable = "", $arrKeys = array( 'UID' ))
|
||||||
//$dset = new DBRecordSet( $this->_dbses->Result );
|
|
||||||
$nlim = $dset->Count();
|
|
||||||
$this->Fields = NULL;
|
|
||||||
for( $ncount = 0; $ncount < $nlim; $ncount++ )
|
|
||||||
{
|
{
|
||||||
$data = $dset->Read();
|
|
||||||
$fname = $data['Field'];
|
|
||||||
$fval = "";
|
|
||||||
$ftypearr = explode($data['Type'], '(' );
|
|
||||||
$ftype = $ftypearr[0];
|
|
||||||
|
|
||||||
if( $data['Key'] == 'PRI' )
|
$this->_dbc = $objDBConnection;
|
||||||
{
|
if ($this->_dbc != null && strcasecmp( get_class( $objDBConnection ), 'dbconnection' ) == 0) {
|
||||||
if( is_array($this->table_keys) )
|
$this->_dbses = new DBSession( $this->_dbc );
|
||||||
{
|
$this->_dbses->UseDB( DB_NAME );
|
||||||
$this->table_keys[count( $this->table_keys ) - 1] = $fname;
|
} else {
|
||||||
|
$dberror = PEAR::raiseError( null, DB_ERROR_OBJECT_NOT_DEFINED, null, 'null', "You tried to call to a DBTable function without create an instance of DBConnection", 'G_Error', true );
|
||||||
|
//DBconnection::logError( $dberror );
|
||||||
|
return $dberror;
|
||||||
}
|
}
|
||||||
else
|
$this->is_new = true;
|
||||||
{
|
$this->Fields = null;
|
||||||
$this->table_keys[0] = $fname;
|
$this->table_name = $strTable;
|
||||||
|
if (is_array( $arrKeys )) {
|
||||||
|
$this->table_keys = $arrKeys;
|
||||||
|
} else {
|
||||||
|
$this->table_keys = array (0 => $arrKeys
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
$this->errorLevel = $this->_dbc->errorLevel;
|
||||||
|
|
||||||
switch( $ftype )
|
|
||||||
{
|
|
||||||
case 'int':
|
|
||||||
case 'smallint':
|
|
||||||
case 'tinyint':
|
|
||||||
case 'decimal':
|
|
||||||
case 'numeric':
|
|
||||||
case 'double':
|
|
||||||
case 'float':
|
|
||||||
$fval = 0;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->Fields[ $fname ] = $fval;
|
|
||||||
$this->Fields[ $ncount ] = &$this->Fields[ $fname ];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Return specified field on the referenced table
|
|
||||||
*
|
|
||||||
* @author Fernando Ontiveros Lira <fernando@colosa.com>
|
|
||||||
* @access public
|
|
||||||
* @param string $strWhere string which contains conditions
|
|
||||||
* @return strint
|
|
||||||
*/
|
|
||||||
function loadWhere( $strWhere )
|
|
||||||
{
|
|
||||||
$this->Fields = NULL;
|
|
||||||
|
|
||||||
$stQry = "SELECT * FROM `" . $this->table_name . "`";
|
|
||||||
if( $strWhere != "" ) $stQry .= " WHERE " . $strWhere;
|
|
||||||
|
|
||||||
$this->_dset = $this->_dbses->Execute ( $stQry , $this->debug, $this->errorLevel);
|
|
||||||
if (DB::isError ($this->_dset)) {
|
|
||||||
return $this->_dset;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if( $this->_dset->Count() > 0 ){
|
/**
|
||||||
$this->Fields = $this->_dset->Read();
|
* Loads full description of a referenced table in Fields
|
||||||
$this->is_new = false;
|
*
|
||||||
}
|
* @author Fernando Ontiveros Lira <fernando@colosa.com>
|
||||||
else
|
* @access public
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
function loadEmpty ()
|
||||||
{
|
{
|
||||||
$this->Fields = NULL;
|
$stQry = "DESCRIBE `" . $this->table_name . "`";
|
||||||
$this->is_new = true;
|
$dset = $this->_dbses->execute( $stQry );
|
||||||
}
|
//$dset = new DBRecordSet( $this->_dbses->Result );
|
||||||
|
$nlim = $dset->Count();
|
||||||
|
$this->Fields = null;
|
||||||
|
for ($ncount = 0; $ncount < $nlim; $ncount ++) {
|
||||||
|
$data = $dset->Read();
|
||||||
|
$fname = $data['Field'];
|
||||||
|
$fval = "";
|
||||||
|
$ftypearr = explode( $data['Type'], '(' );
|
||||||
|
$ftype = $ftypearr[0];
|
||||||
|
|
||||||
return $this->Fields;
|
if ($data['Key'] == 'PRI') {
|
||||||
}
|
if (is_array( $this->table_keys )) {
|
||||||
|
$this->table_keys[count( $this->table_keys ) - 1] = $fname;
|
||||||
/**
|
} else {
|
||||||
* Return all fields on the referenced table
|
$this->table_keys[0] = $fname;
|
||||||
*
|
}
|
||||||
* @author Fernando Ontiveros Lira <fernando@colosa.com>
|
|
||||||
* @access public
|
|
||||||
* @param array array of arguments key values
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
function load()
|
|
||||||
{
|
|
||||||
// bug::traceRoute();
|
|
||||||
$ncount = 0;
|
|
||||||
$stWhere = "";
|
|
||||||
$arrKeys = func_get_args();
|
|
||||||
if ( isset($arrKeys[0]) && is_array ($arrKeys[0] ) ) {
|
|
||||||
foreach ($this->table_keys as $key=>$val) {
|
|
||||||
if( $stWhere == "" ){
|
|
||||||
$stWhere .= " $val = '" . $arrKeys[0][ $val ] . "' ";
|
|
||||||
}else
|
|
||||||
$stWhere .= " AND $val = '" . $arrKeys[0][ $val ] . "' ";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
foreach( $arrKeys as $val )
|
|
||||||
{
|
|
||||||
if( $stWhere == "" )
|
|
||||||
{
|
|
||||||
$stWhere .= $this->table_keys[$ncount] . "='" . $val . "'";
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$stWhere .= " AND " . $this->table_keys[$ncount] . "='" . $val . "'";
|
|
||||||
}
|
|
||||||
$ncount++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return $this->LoadWhere( $stWhere );
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Function nextvalPGSql
|
|
||||||
* @author David S. Callizaya S. <davidsantos@colosa.com>
|
|
||||||
* @access public
|
|
||||||
* @parameter string seq
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
function nextvalPGSql( $seq )
|
|
||||||
{
|
|
||||||
$stQry = " Select NEXTVAL( '$seq' ) ";
|
|
||||||
$dset = $this->_dbses->Execute( $stQry );
|
|
||||||
$row = $dset->Read();
|
|
||||||
if ( is_array ($row) ) {
|
|
||||||
return $row['NEXTVAL'];
|
|
||||||
}
|
|
||||||
die ("Sequence '$seq' is not exist!!");
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Insert a new row
|
|
||||||
*
|
|
||||||
* @author Fernando Ontiveros Lira <fernando@colosa.com>
|
|
||||||
* @access public
|
|
||||||
* @return boolean
|
|
||||||
|
|
||||||
*/
|
|
||||||
function insert () {
|
|
||||||
$strFields = "";
|
|
||||||
$strValues = "";
|
|
||||||
if( defined('DB_ADAPTER'))
|
|
||||||
$DBEngine = DB_ADAPTER;
|
|
||||||
else
|
|
||||||
$DBEngine = 'mysql';
|
|
||||||
foreach( $this->Fields as $field => $val ) {
|
|
||||||
$strFields .= $field . ",";
|
|
||||||
$iskey = false;
|
|
||||||
if ( isset ( $this->table_keys ) && is_array ( $this->table_keys ) )
|
|
||||||
$iskey = in_array( $field, $this->table_keys ) && strtoupper(substr(trim($val),0,7) ) == "NEXTVAL";
|
|
||||||
|
|
||||||
$dbcType = isset ( $this->_dbc->type ) ? $this->_dbc->type : $DBEngine;
|
|
||||||
// Commented by new format of textarea in javascript
|
|
||||||
if( ! $iskey )
|
|
||||||
$val = "'" . $val . "'";
|
|
||||||
///-- $val = "'" . G::sqlEscape( $val , $dbcType ) . "'";
|
|
||||||
$strValues .= $val .", ";
|
|
||||||
}
|
|
||||||
$strFields = substr( $strFields , 0, strlen($strFields)-1 );
|
|
||||||
$strValues = substr( $strValues , 0, strlen($strValues)-1 );
|
|
||||||
|
|
||||||
$stQry = "INSERT INTO `" . $this->table_name . "` ( " . $strFields . " ) values ( " . $strValues . " ) ";
|
|
||||||
|
|
||||||
$result = $this->_dbses->Execute( $stQry , $this->debug);
|
|
||||||
return $result;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Update an existing row
|
|
||||||
*
|
|
||||||
* @author Fernando Ontiveros Lira <fernando@colosa.com>
|
|
||||||
* @access public
|
|
||||||
* @return boolean
|
|
||||||
*/
|
|
||||||
function update()
|
|
||||||
{
|
|
||||||
$stQry = "";
|
|
||||||
|
|
||||||
$stWhere = '';
|
|
||||||
$remainKeys = array();
|
|
||||||
|
|
||||||
if(defined('DB_ADAPTER'))
|
|
||||||
$DBEngine = DB_ADAPTER;
|
|
||||||
else
|
|
||||||
$DBEngine = 'mysql';
|
|
||||||
|
|
||||||
foreach ( $this->table_keys as $k => $v ) $remainKeys[ $v ] = false;
|
|
||||||
foreach( $this->Fields as $field => $val )
|
|
||||||
{
|
|
||||||
$iskey = false;
|
|
||||||
$iskey = in_array( $field, $this->table_keys );
|
|
||||||
if( $iskey == false ) {
|
|
||||||
$stQry .= $field . "='" . $val . "', ";
|
|
||||||
// Commented by new format of textarea in javascript
|
|
||||||
///-- $stQry .= $field . "='" . G::sqlEscape ( $val, isset( $this->_dbc->type) ? $this->_dbc->type : $DBEngine ) . "', ";
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
if( $stWhere == "" ) {
|
|
||||||
$stWhere .= $field . "='" . G::sqlEscape ( $val, isset( $this->_dbc->type) ? $this->_dbc->type : $DBEngine ) . "'";
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$stWhere .= " AND " . $field . "='" . G::sqlEscape ( $val, isset( $this->_dbc->type) ? $this->_dbc->type : $DBEngine ) . "'";
|
|
||||||
}
|
|
||||||
$remainKeys[ $field ] = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
foreach( $remainKeys as $field => $bool )
|
|
||||||
if ( $bool == false) {
|
|
||||||
if( $stWhere != "" ) $stWhere = " AND ";
|
|
||||||
$stWhere .= $field . "= ''";
|
|
||||||
$remainKeys[ $field ] = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
$stQry = trim( $stQry );
|
|
||||||
$stQry = substr( $stQry , 0, strlen($stQry)-1 ); //to remove the last comma ,
|
|
||||||
if (!$stQry) return;
|
|
||||||
$stQry = "UPDATE `" . $this->table_name . "` SET " . $stQry;
|
|
||||||
$stWhere = trim( $stWhere );
|
|
||||||
if( $stWhere != "" ) $stQry .= " WHERE " . $stWhere;
|
|
||||||
$result = false;
|
|
||||||
|
|
||||||
$result = $this->_dbses->execute( $stQry , $this->debug, $this->errorLevel );
|
|
||||||
$this->is_new = false;
|
|
||||||
return $result;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Save a register in a table
|
|
||||||
*
|
|
||||||
* depending of value of "is_new" inserts or update is do it
|
|
||||||
*
|
|
||||||
* @author Fernando Ontiveros Lira <fernando@colosa.com>
|
|
||||||
* @access public
|
|
||||||
* @return boolean
|
|
||||||
*/
|
|
||||||
function save()
|
|
||||||
{
|
|
||||||
if ( $this->is_new == true )
|
|
||||||
return $this->Insert();
|
|
||||||
else
|
|
||||||
return $this->Update();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Delete an existing row
|
|
||||||
*
|
|
||||||
* @author Fernando Ontiveros Lira <fernando@colosa.com>
|
|
||||||
* @access public
|
|
||||||
* @return boolean
|
|
||||||
*/
|
|
||||||
function delete()
|
|
||||||
{
|
|
||||||
$stQry = "delete from `" . $this->table_name . "` ";
|
|
||||||
|
|
||||||
$stWhere = '';
|
|
||||||
$remainKeys = array();
|
|
||||||
if(defined('DB_ADAPTER'))
|
|
||||||
$DBEngine = DB_ADAPTER;
|
|
||||||
else
|
|
||||||
$DBEngine = 'mysql';
|
|
||||||
foreach ( $this->table_keys as $k => $v ) $remainKeys[ $v ] = false;
|
|
||||||
|
|
||||||
if ( is_array ( $this->Fields ) ) {
|
|
||||||
foreach( $this->Fields as $field => $val )
|
|
||||||
{
|
|
||||||
$iskey = false;
|
|
||||||
$iskey = in_array( $field, $this->table_keys );
|
|
||||||
if( $iskey == true ) {
|
|
||||||
if( $stWhere == "" ) {
|
|
||||||
$stWhere .= $field . "='" . G::sqlEscape ( $val, isset( $this->_dbc->type) ? $this->_dbc->type : $DBEngine ) . "'";
|
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
$stWhere .= " AND " . $field . "='" . G::sqlEscape ( $val, isset( $this->_dbc->type) ? $this->_dbc->type : $DBEngine ) . "'";
|
switch ($ftype) {
|
||||||
|
case 'int':
|
||||||
|
case 'smallint':
|
||||||
|
case 'tinyint':
|
||||||
|
case 'decimal':
|
||||||
|
case 'numeric':
|
||||||
|
case 'double':
|
||||||
|
case 'float':
|
||||||
|
$fval = 0;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
$remainKeys[ $field ] = true;
|
|
||||||
}
|
$this->Fields[$fname] = $fval;
|
||||||
}
|
$this->Fields[$ncount] = &$this->Fields[$fname];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
foreach( $remainKeys as $field => $bool )
|
|
||||||
if ( $bool == false) {
|
|
||||||
if( $stWhere != "" ) $stWhere .= " AND ";
|
|
||||||
$stWhere .= $field . "= ''";
|
|
||||||
$remainKeys[ $field ] = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
$stQry = trim( $stQry );
|
/**
|
||||||
$stWhere = trim( $stWhere );
|
* Return specified field on the referenced table
|
||||||
if ( $stWhere == '' ) {
|
*
|
||||||
$dberror = PEAR::raiseError(null, G_ERROR_WARNING_MESSAGE, null, 'null',
|
* @author Fernando Ontiveros Lira <fernando@colosa.com>
|
||||||
"You tried to call delete method without WHERE clause, if you want to delete all records use dbsession",
|
* @access public
|
||||||
'G_Error', true);
|
* @param string $strWhere string which contains conditions
|
||||||
DBconnection::logError( $dberror, $this->errorLevel );
|
* @return strint
|
||||||
return $dberror;
|
*/
|
||||||
|
function loadWhere ($strWhere)
|
||||||
|
{
|
||||||
|
$this->Fields = null;
|
||||||
|
|
||||||
|
$stQry = "SELECT * FROM `" . $this->table_name . "`";
|
||||||
|
if ($strWhere != "") {
|
||||||
|
$stQry .= " WHERE " . $strWhere;
|
||||||
|
}
|
||||||
|
$this->_dset = $this->_dbses->Execute( $stQry, $this->debug, $this->errorLevel );
|
||||||
|
if (DB::isError( $this->_dset )) {
|
||||||
|
return $this->_dset;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($this->_dset->Count() > 0) {
|
||||||
|
$this->Fields = $this->_dset->Read();
|
||||||
|
$this->is_new = false;
|
||||||
|
} else {
|
||||||
|
$this->Fields = null;
|
||||||
|
$this->is_new = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->Fields;
|
||||||
}
|
}
|
||||||
$stQry .= " WHERE " . $stWhere;
|
|
||||||
|
|
||||||
$result = $this->_dbses->execute( $stQry , $this->debug, $this->errorLevel );
|
/**
|
||||||
$this->is_new = false;
|
* Return all fields on the referenced table
|
||||||
return $result;
|
*
|
||||||
}
|
* @author Fernando Ontiveros Lira <fernando@colosa.com>
|
||||||
|
* @access public
|
||||||
|
* @param array array of arguments key values
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
function load ()
|
||||||
|
{
|
||||||
|
// bug::traceRoute();
|
||||||
|
$ncount = 0;
|
||||||
|
$stWhere = "";
|
||||||
|
$arrKeys = func_get_args();
|
||||||
|
if (isset( $arrKeys[0] ) && is_array( $arrKeys[0] )) {
|
||||||
|
foreach ($this->table_keys as $key => $val) {
|
||||||
|
if ($stWhere == "") {
|
||||||
|
$stWhere .= " $val = '" . $arrKeys[0][$val] . "' ";
|
||||||
|
} else {
|
||||||
|
$stWhere .= " AND $val = '" . $arrKeys[0][$val] . "' ";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
foreach ($arrKeys as $val) {
|
||||||
|
if ($stWhere == "") {
|
||||||
|
$stWhere .= $this->table_keys[$ncount] . "='" . $val . "'";
|
||||||
|
} else {
|
||||||
|
$stWhere .= " AND " . $this->table_keys[$ncount] . "='" . $val . "'";
|
||||||
|
}
|
||||||
|
$ncount ++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $this->LoadWhere( $stWhere );
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Move to next record in a recordset
|
* Function nextvalPGSql
|
||||||
*
|
*
|
||||||
* Move to next record in a recordset, this is useful where the load method have a recordset with many rows
|
* @author David S. Callizaya S. <davidsantos@colosa.com>
|
||||||
*
|
* @access public
|
||||||
* @author Fernando Ontiveros Lira <fernando@colosa.com>
|
* @param eter string seq
|
||||||
* @access public
|
* @return string
|
||||||
* @return boolean
|
*/
|
||||||
*/
|
function nextvalPGSql ($seq)
|
||||||
function next()
|
{
|
||||||
{
|
$stQry = " Select NEXTVAL( '$seq' ) ";
|
||||||
$this->Fields = $this->_dset->read ();
|
$dset = $this->_dbses->Execute( $stQry );
|
||||||
}
|
$row = $dset->Read();
|
||||||
|
if (is_array( $row )) {
|
||||||
|
return $row['NEXTVAL'];
|
||||||
|
}
|
||||||
|
die( "Sequence '$seq' is not exist!!" );
|
||||||
|
return - 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Insert a new row
|
||||||
|
*
|
||||||
|
* @author Fernando Ontiveros Lira <fernando@colosa.com>
|
||||||
|
* @access public
|
||||||
|
* @return boolean
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
function insert ()
|
||||||
|
{
|
||||||
|
$strFields = "";
|
||||||
|
$strValues = "";
|
||||||
|
if (defined( 'DB_ADAPTER' )) {
|
||||||
|
$DBEngine = DB_ADAPTER;
|
||||||
|
} else {
|
||||||
|
$DBEngine = 'mysql';
|
||||||
|
}
|
||||||
|
foreach ($this->Fields as $field => $val) {
|
||||||
|
$strFields .= $field . ",";
|
||||||
|
$iskey = false;
|
||||||
|
if (isset( $this->table_keys ) && is_array( $this->table_keys )) {
|
||||||
|
$iskey = in_array( $field, $this->table_keys ) && strtoupper( substr( trim( $val ), 0, 7 ) ) == "NEXTVAL";
|
||||||
|
}
|
||||||
|
$dbcType = isset( $this->_dbc->type ) ? $this->_dbc->type : $DBEngine;
|
||||||
|
// Commented by new format of textarea in javascript
|
||||||
|
if (! $iskey) {
|
||||||
|
$val = "'" . $val . "'";
|
||||||
|
}
|
||||||
|
///-- $val = "'" . G::sqlEscape( $val , $dbcType ) . "'";
|
||||||
|
$strValues .= $val . ", ";
|
||||||
|
}
|
||||||
|
$strFields = substr( $strFields, 0, strlen( $strFields ) - 1 );
|
||||||
|
$strValues = substr( $strValues, 0, strlen( $strValues ) - 1 );
|
||||||
|
|
||||||
|
$stQry = "INSERT INTO `" . $this->table_name . "` ( " . $strFields . " ) values ( " . $strValues . " ) ";
|
||||||
|
|
||||||
|
$result = $this->_dbses->Execute( $stQry, $this->debug );
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update an existing row
|
||||||
|
*
|
||||||
|
* @author Fernando Ontiveros Lira <fernando@colosa.com>
|
||||||
|
* @access public
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
|
function update ()
|
||||||
|
{
|
||||||
|
$stQry = "";
|
||||||
|
|
||||||
|
$stWhere = '';
|
||||||
|
$remainKeys = array ();
|
||||||
|
|
||||||
|
if (defined( 'DB_ADAPTER' )) {
|
||||||
|
$DBEngine = DB_ADAPTER;
|
||||||
|
} else {
|
||||||
|
$DBEngine = 'mysql';
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($this->table_keys as $k => $v) {
|
||||||
|
$remainKeys[$v] = false;
|
||||||
|
}
|
||||||
|
foreach ($this->Fields as $field => $val) {
|
||||||
|
$iskey = false;
|
||||||
|
$iskey = in_array( $field, $this->table_keys );
|
||||||
|
if ($iskey == false) {
|
||||||
|
$stQry .= $field . "='" . $val . "', ";
|
||||||
|
// Commented by new format of textarea in javascript
|
||||||
|
///-- $stQry .= $field . "='" . G::sqlEscape ( $val, isset( $this->_dbc->type) ? $this->_dbc->type : $DBEngine ) . "', ";
|
||||||
|
} else {
|
||||||
|
if ($stWhere == "") {
|
||||||
|
$stWhere .= $field . "='" . G::sqlEscape( $val, isset( $this->_dbc->type ) ? $this->_dbc->type : $DBEngine ) . "'";
|
||||||
|
} else {
|
||||||
|
$stWhere .= " AND " . $field . "='" . G::sqlEscape( $val, isset( $this->_dbc->type ) ? $this->_dbc->type : $DBEngine ) . "'";
|
||||||
|
}
|
||||||
|
$remainKeys[$field] = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
foreach ($remainKeys as $field => $bool)
|
||||||
|
if ($bool == false) {
|
||||||
|
if ($stWhere != "") {
|
||||||
|
$stWhere = " AND ";
|
||||||
|
}
|
||||||
|
$stWhere .= $field . "= ''";
|
||||||
|
$remainKeys[$field] = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
$stQry = trim( $stQry );
|
||||||
|
$stQry = substr( $stQry, 0, strlen( $stQry ) - 1 ); //to remove the last comma ,
|
||||||
|
if (! $stQry) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$stQry = "UPDATE `" . $this->table_name . "` SET " . $stQry;
|
||||||
|
$stWhere = trim( $stWhere );
|
||||||
|
if ($stWhere != "") {
|
||||||
|
$stQry .= " WHERE " . $stWhere;
|
||||||
|
}
|
||||||
|
$result = false;
|
||||||
|
|
||||||
|
$result = $this->_dbses->execute( $stQry, $this->debug, $this->errorLevel );
|
||||||
|
$this->is_new = false;
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Save a register in a table
|
||||||
|
*
|
||||||
|
* depending of value of "is_new" inserts or update is do it
|
||||||
|
*
|
||||||
|
* @author Fernando Ontiveros Lira <fernando@colosa.com>
|
||||||
|
* @access public
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
|
function save ()
|
||||||
|
{
|
||||||
|
if ($this->is_new == true) {
|
||||||
|
return $this->Insert();
|
||||||
|
} else {
|
||||||
|
return $this->Update();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Delete an existing row
|
||||||
|
*
|
||||||
|
* @author Fernando Ontiveros Lira <fernando@colosa.com>
|
||||||
|
* @access public
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
|
function delete ()
|
||||||
|
{
|
||||||
|
$stQry = "delete from `" . $this->table_name . "` ";
|
||||||
|
|
||||||
|
$stWhere = '';
|
||||||
|
$remainKeys = array ();
|
||||||
|
if (defined( 'DB_ADAPTER' )) {
|
||||||
|
$DBEngine = DB_ADAPTER;
|
||||||
|
} else {
|
||||||
|
$DBEngine = 'mysql';
|
||||||
|
}
|
||||||
|
foreach ($this->table_keys as $k => $v) {
|
||||||
|
$remainKeys[$v] = false;
|
||||||
|
}
|
||||||
|
if (is_array( $this->Fields )) {
|
||||||
|
foreach ($this->Fields as $field => $val) {
|
||||||
|
$iskey = false;
|
||||||
|
$iskey = in_array( $field, $this->table_keys );
|
||||||
|
if ($iskey == true) {
|
||||||
|
if ($stWhere == "") {
|
||||||
|
$stWhere .= $field . "='" . G::sqlEscape( $val, isset( $this->_dbc->type ) ? $this->_dbc->type : $DBEngine ) . "'";
|
||||||
|
} else {
|
||||||
|
$stWhere .= " AND " . $field . "='" . G::sqlEscape( $val, isset( $this->_dbc->type ) ? $this->_dbc->type : $DBEngine ) . "'";
|
||||||
|
}
|
||||||
|
$remainKeys[$field] = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
foreach ($remainKeys as $field => $bool)
|
||||||
|
if ($bool == false) {
|
||||||
|
if ($stWhere != "") {
|
||||||
|
$stWhere .= " AND ";
|
||||||
|
}
|
||||||
|
$stWhere .= $field . "= ''";
|
||||||
|
$remainKeys[$field] = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
$stQry = trim( $stQry );
|
||||||
|
$stWhere = trim( $stWhere );
|
||||||
|
if ($stWhere == '') {
|
||||||
|
$dberror = PEAR::raiseError( null, G_ERROR_WARNING_MESSAGE, null, 'null', "You tried to call delete method without WHERE clause, if you want to delete all records use dbsession", 'G_Error', true );
|
||||||
|
DBconnection::logError( $dberror, $this->errorLevel );
|
||||||
|
return $dberror;
|
||||||
|
}
|
||||||
|
$stQry .= " WHERE " . $stWhere;
|
||||||
|
|
||||||
|
$result = $this->_dbses->execute( $stQry, $this->debug, $this->errorLevel );
|
||||||
|
$this->is_new = false;
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Move to next record in a recordset
|
||||||
|
*
|
||||||
|
* Move to next record in a recordset, this is useful where the load method have a recordset with many rows
|
||||||
|
*
|
||||||
|
* @author Fernando Ontiveros Lira <fernando@colosa.com>
|
||||||
|
* @access public
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
|
function next ()
|
||||||
|
{
|
||||||
|
$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
|
||||||
@@ -13,18 +15,18 @@
|
|||||||
*
|
*
|
||||||
* 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
|
||||||
* GNU Affero General Public License for more details.
|
* GNU Affero General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU Affero General Public License
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*
|
*
|
||||||
* For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
|
* For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
|
||||||
* Coral Gables, FL, 33134, USA, or email info@colosa.com.
|
* Coral Gables, FL, 33134, USA, or email info@colosa.com.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 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,352 +38,372 @@
|
|||||||
|
|
||||||
class i18n_PO
|
class i18n_PO
|
||||||
{
|
{
|
||||||
private $_file = NULL;
|
private $_file = null;
|
||||||
private $_string = '';
|
private $_string = '';
|
||||||
private $_meta;
|
private $_meta;
|
||||||
private $_fp;
|
private $_fp;
|
||||||
private $_fileComments;
|
private $_fileComments;
|
||||||
|
|
||||||
protected $_editingHeader;
|
protected $_editingHeader;
|
||||||
protected $_fileLine;
|
protected $_fileLine;
|
||||||
|
|
||||||
protected $flagEndHeaders;
|
protected $flagEndHeaders;
|
||||||
protected $flagError;
|
protected $flagError;
|
||||||
protected $flagInit;
|
protected $flagInit;
|
||||||
protected $lineNumber;
|
protected $lineNumber;
|
||||||
|
|
||||||
public $translatorComments;
|
public $translatorComments;
|
||||||
public $extractedComments;
|
public $extractedComments;
|
||||||
public $references;
|
public $references;
|
||||||
public $flags;
|
public $flags;
|
||||||
public $previousUntranslatedStrings;
|
public $previousUntranslatedStrings;
|
||||||
|
|
||||||
function __construct($file)
|
function __construct ($file)
|
||||||
{
|
{
|
||||||
$this->file = $file;
|
$this->file = $file;
|
||||||
}
|
|
||||||
|
|
||||||
function buildInit()
|
|
||||||
{
|
|
||||||
$this->_fp = fopen($this->file, 'w');
|
|
||||||
|
|
||||||
if ( ! is_resource($this->_fp) ) {
|
|
||||||
throw new Exception('Could\'t open ' . $this->file . ' file');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// lock PO file exclusively
|
function buildInit ()
|
||||||
if ( ! flock($this->_fp, LOCK_EX) ) {
|
{
|
||||||
fclose($this->_fp);
|
$this->_fp = fopen( $this->file, 'w' );
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->_meta = 'msgid ""';
|
if (! is_resource( $this->_fp )) {
|
||||||
$this->_writeLine($this->_meta);
|
throw new Exception( 'Could\'t open ' . $this->file . ' file' );
|
||||||
$this->_meta = 'msgstr ""';
|
|
||||||
$this->_writeLine($this->_meta);
|
|
||||||
|
|
||||||
$this->_editingHeader = TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
function readInit(){
|
|
||||||
$this->_fp = fopen($this->file, 'r');
|
|
||||||
|
|
||||||
if ( ! is_resource($this->_fp) ) {
|
|
||||||
throw new Exception('Could\'t open ' . $this->file . ' file');
|
|
||||||
}
|
|
||||||
//skipping comments
|
|
||||||
$this->skipCommets();
|
|
||||||
//deaing headers
|
|
||||||
$this->readHeaders();
|
|
||||||
|
|
||||||
$this->translatorComments = Array();
|
|
||||||
$this->extractedComments = Array();
|
|
||||||
$this->references = Array();
|
|
||||||
$this->flags = Array();
|
|
||||||
$this->previousUntranslatedStrings = Array();
|
|
||||||
}
|
|
||||||
|
|
||||||
function addHeader($id, $value)
|
|
||||||
{
|
|
||||||
if( $this->_editingHeader ) {
|
|
||||||
$meta = '"'.trim($id).': '.trim($value).'\n"';
|
|
||||||
$this->_writeLine($meta);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function addTranslatorComment($str)
|
|
||||||
{
|
|
||||||
$this->headerStroke();
|
|
||||||
$comment = '# ' . trim($str);
|
|
||||||
$this->_writeLine($comment);
|
|
||||||
}
|
|
||||||
|
|
||||||
function addExtractedComment($str)
|
|
||||||
{
|
|
||||||
$this->headerStroke();
|
|
||||||
$comment = '#. ' . trim($str);
|
|
||||||
$this->_writeLine($comment);
|
|
||||||
}
|
|
||||||
|
|
||||||
function addReference($str)
|
|
||||||
{
|
|
||||||
$this->headerStroke();
|
|
||||||
$reference = '#: ' . trim($str);
|
|
||||||
$this->_writeLine($reference);
|
|
||||||
}
|
|
||||||
|
|
||||||
function addFlag($str)
|
|
||||||
{
|
|
||||||
$this->headerStroke();
|
|
||||||
$flag = '#, ' . trim($str);
|
|
||||||
$this->_writeLine($flag);
|
|
||||||
}
|
|
||||||
|
|
||||||
function addPreviousUntranslatedString($str)
|
|
||||||
{
|
|
||||||
$this->headerStroke();
|
|
||||||
$str = '#| ' . trim($str);
|
|
||||||
$this->_writeLine($str);
|
|
||||||
}
|
|
||||||
|
|
||||||
function addTranslation($msgid, $msgstr)
|
|
||||||
{
|
|
||||||
$this->headerStroke();
|
|
||||||
$this->_writeLine('msgid "' . $this->prepare($msgid, true) . '"');
|
|
||||||
$this->_writeLine('msgstr "' . $this->prepare($msgstr, true) . '"');
|
|
||||||
$this->_writeLine('');
|
|
||||||
}
|
|
||||||
|
|
||||||
function _writeLine($str)
|
|
||||||
{
|
|
||||||
$this->_write($str . "\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
function _write($str)
|
|
||||||
{
|
|
||||||
fwrite($this->_fp, $str);
|
|
||||||
}
|
|
||||||
|
|
||||||
function prepare($string, $reverse = false)
|
|
||||||
{
|
|
||||||
//$string = str_replace('\"', '"', $string);
|
|
||||||
//$string = stripslashes($string);
|
|
||||||
|
|
||||||
if ($reverse) {
|
|
||||||
$smap = array('"', "\n", "\t", "\r");
|
|
||||||
$rmap = array('\"', '\\n"' . "\n" . '"', '\\t', '\\r');
|
|
||||||
return (string) str_replace($smap, $rmap, $string);
|
|
||||||
} else {
|
|
||||||
$string = preg_replace('/"\s+"/', '', $string);
|
|
||||||
$smap = array('\\n', '\\r', '\\t', '\"');
|
|
||||||
$rmap = array("\n", "\r", "\t", '"');
|
|
||||||
return (string) str_replace($smap, $rmap, $string);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function headerStroke()
|
|
||||||
{
|
|
||||||
if( $this->_editingHeader ) {
|
|
||||||
$this->_editingHeader = FALSE;
|
|
||||||
$this->_writeLine('');;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/** read funtions **/
|
|
||||||
private function skipCommets(){
|
|
||||||
$this->_fileComments = '';
|
|
||||||
do {
|
|
||||||
$lastPos = ftell($this->_fp);
|
|
||||||
$line = fgets($this->_fp);
|
|
||||||
$this->_fileComments .= $line;
|
|
||||||
} while( (substr($line, 0, 1) == '#' || trim($line) == '') && ! feof($this->_fp) );
|
|
||||||
|
|
||||||
fseek($this->_fp, $lastPos);
|
|
||||||
}
|
|
||||||
|
|
||||||
private function readHeaders()
|
|
||||||
{
|
|
||||||
$this->flagEndHeaders = false;
|
|
||||||
$this->flagError = false;
|
|
||||||
$this->flagInit = true;
|
|
||||||
$this->lineNumber = 0;
|
|
||||||
$errMsg = '';
|
|
||||||
|
|
||||||
while( ! $this->flagError && ! $this->flagEndHeaders ) {
|
|
||||||
|
|
||||||
if( $this->flagInit ) { //in first instance
|
|
||||||
$this->flagInit = false; //unset init flag
|
|
||||||
|
|
||||||
//read the first and second line of the file
|
|
||||||
$firstLine = fgets($this->_fp);
|
|
||||||
$secondLine = fgets($this->_fp);
|
|
||||||
|
|
||||||
//verifying the file head
|
|
||||||
if( strpos($firstLine, 'msgid ""') === false || strpos($secondLine, 'msgstr ""') === false ){
|
|
||||||
$this->flagError = true;
|
|
||||||
$errMsg = 'Misplace for firts msgid "" and msgstr "" in the header';
|
|
||||||
}
|
}
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
//getting the new line
|
// lock PO file exclusively
|
||||||
$this->_fileLine = trim(fgets($this->_fp));
|
if (! flock( $this->_fp, LOCK_EX )) {
|
||||||
//set line number
|
fclose( $this->_fp );
|
||||||
$this->lineNumber++;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
//verifying that is not end of file and applying a restriction for to read just the twenty firsts lines
|
$this->_meta = 'msgid ""';
|
||||||
if( trim($this->_fileLine) == '' || ! $this->_fileLine || $this->lineNumber >= 20 ) {
|
$this->_writeLine( $this->_meta );
|
||||||
$this->flagEndHeaders = true; // set ending to read the headers
|
$this->_meta = 'msgstr ""';
|
||||||
continue;
|
$this->_writeLine( $this->_meta );
|
||||||
}
|
|
||||||
//verify if has a valid mask header line
|
|
||||||
preg_match('/^"([a-z0-9\._-]+)\s*:\s*([\W\w]+)\\\n"$/i', $this->_fileLine, $match);
|
|
||||||
|
|
||||||
//for a valid header line the $match size should three
|
$this->_editingHeader = true;
|
||||||
if( sizeof($match) == 3 ) {
|
|
||||||
$key = trim($match[1]); //getting the key of the header
|
|
||||||
$value = trim($match[2]); //getting the value of the header
|
|
||||||
$this->_meta[$key] = $value; //setting a new header
|
|
||||||
} else {
|
|
||||||
$this->flagEndHeaders = true; //otherwise set the ending to read the headers
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}//end looking for headeers
|
|
||||||
|
|
||||||
//verifying the headers data
|
|
||||||
if( ! isset($this->_meta['X-Poedit-Language']) ) {
|
|
||||||
$this->flagError = true;
|
|
||||||
$errMsg = "X-Poedit-Language meta doesn't exist";
|
|
||||||
} else if ( $this->_meta['X-Poedit-Language'] == '' ) {
|
|
||||||
$this->flagError = true;
|
|
||||||
$errMsg = "X-Poedit-Language meta is empty";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//if the country is not present in metadata
|
function readInit ()
|
||||||
if( ! isset($this->_meta['X-Poedit-Country']) ) {
|
{
|
||||||
$this->_meta['X-Poedit-Country'] = '.';
|
$this->_fp = fopen( $this->file, 'r' );
|
||||||
} else if( $this->_meta['X-Poedit-Country'] == '' ) {
|
|
||||||
$this->_meta['X-Poedit-Country'] = '.';
|
if (! is_resource( $this->_fp )) {
|
||||||
|
throw new Exception( 'Could\'t open ' . $this->file . ' file' );
|
||||||
|
}
|
||||||
|
//skipping comments
|
||||||
|
$this->skipCommets();
|
||||||
|
//deaing headers
|
||||||
|
$this->readHeaders();
|
||||||
|
|
||||||
|
$this->translatorComments = Array ();
|
||||||
|
$this->extractedComments = Array ();
|
||||||
|
$this->references = Array ();
|
||||||
|
$this->flags = Array ();
|
||||||
|
$this->previousUntranslatedStrings = Array ();
|
||||||
}
|
}
|
||||||
|
|
||||||
//thowing the exception if is necesary
|
function addHeader ($id, $value)
|
||||||
if( $this->flagError ){
|
{
|
||||||
throw new Exception("This file is not a valid PO file. ($errMsg)");
|
if ($this->_editingHeader) {
|
||||||
}
|
$meta = '"' . trim( $id ) . ': ' . trim( $value ) . '\n"';
|
||||||
}
|
$this->_writeLine( $meta );
|
||||||
|
}
|
||||||
function getHeaders() {
|
|
||||||
return $this->_meta;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getTranslation(){
|
|
||||||
|
|
||||||
$flagReadingComments = true;
|
|
||||||
$this->translatorComments = Array();
|
|
||||||
$this->extractedComments = Array();
|
|
||||||
$this->references = Array();
|
|
||||||
$this->flags = Array();
|
|
||||||
|
|
||||||
//getting the new line
|
|
||||||
while( $flagReadingComments && ! $this->flagError ) {
|
|
||||||
|
|
||||||
$this->_fileLine = trim(fgets($this->_fp));
|
|
||||||
//set line number
|
|
||||||
$this->lineNumber++;
|
|
||||||
|
|
||||||
if( ! $this->_fileLine )
|
|
||||||
return false;
|
|
||||||
|
|
||||||
$prefix = substr($this->_fileLine, 0, 2);
|
|
||||||
|
|
||||||
switch($prefix) {
|
|
||||||
case '# ':
|
|
||||||
$lineItem = str_replace('# ', '', $this->_fileLine);
|
|
||||||
$this->translatorComments[] = $lineItem;
|
|
||||||
break;
|
|
||||||
case '#.':
|
|
||||||
if( substr_count($this->_fileLine, '#. ') == 0 )
|
|
||||||
$this->flagError = true;
|
|
||||||
else {
|
|
||||||
$lineItem = str_replace('#. ', '', $this->_fileLine);
|
|
||||||
$this->extractedComments[] = $lineItem;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case '#:':
|
|
||||||
if( substr_count($this->_fileLine, '#: ') == 0 )
|
|
||||||
$this->flagError = true;
|
|
||||||
else {
|
|
||||||
$lineItem = str_replace('#: ', '', $this->_fileLine);
|
|
||||||
$this->references[] = $lineItem;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case '#,':
|
|
||||||
if( substr_count($this->_fileLine, '#, ') == 0 )
|
|
||||||
$this->flagError = true;
|
|
||||||
else {
|
|
||||||
$lineItem = str_replace('#, ', '', $this->_fileLine);
|
|
||||||
$this->flags[] = $lineItem;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case '#|':
|
|
||||||
if( substr_count($this->_fileLine, '#| ') == 0 )
|
|
||||||
$this->flagError = true;
|
|
||||||
else {
|
|
||||||
$lineItem = str_replace('#| ', '', $this->_fileLine);
|
|
||||||
$this->previousUntranslatedStrings[] = $lineItem;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
$flagReadingComments = false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if( ! $this->_fileLine )
|
function addTranslatorComment ($str)
|
||||||
return false;
|
{
|
||||||
|
$this->headerStroke();
|
||||||
|
$comment = '# ' . trim( $str );
|
||||||
|
$this->_writeLine( $comment );
|
||||||
|
}
|
||||||
|
|
||||||
//Getting the msgid
|
function addExtractedComment ($str)
|
||||||
preg_match('/\s*msgid\s*"(.*)"\s*/s', $this->_fileLine, $match);
|
{
|
||||||
|
$this->headerStroke();
|
||||||
|
$comment = '#. ' . trim( $str );
|
||||||
|
$this->_writeLine( $comment );
|
||||||
|
}
|
||||||
|
|
||||||
if( sizeof($match) != 2 )
|
function addReference ($str)
|
||||||
throw new Exception('Invalid PO file format1');
|
{
|
||||||
|
$this->headerStroke();
|
||||||
|
$reference = '#: ' . trim( $str );
|
||||||
|
$this->_writeLine( $reference );
|
||||||
|
}
|
||||||
|
|
||||||
$msgid = '';
|
function addFlag ($str)
|
||||||
|
{
|
||||||
|
$this->headerStroke();
|
||||||
|
$flag = '#, ' . trim( $str );
|
||||||
|
$this->_writeLine( $flag );
|
||||||
|
}
|
||||||
|
|
||||||
do {
|
function addPreviousUntranslatedString ($str)
|
||||||
//g::pr($match);
|
{
|
||||||
$msgid .= $match[1];
|
$this->headerStroke();
|
||||||
$this->_fileLine = trim(fgets($this->_fp));
|
$str = '#| ' . trim( $str );
|
||||||
preg_match('/^"(.*)"\s*/s', $this->_fileLine, $match);
|
$this->_writeLine( $str );
|
||||||
} while ( sizeof($match) == 2 );
|
}
|
||||||
|
|
||||||
//Getting the msgstr
|
function addTranslation ($msgid, $msgstr)
|
||||||
preg_match('/\s*msgstr\s*"(.*)"\s*/s', $this->_fileLine, $match);
|
{
|
||||||
|
$this->headerStroke();
|
||||||
|
$this->_writeLine( 'msgid "' . $this->prepare( $msgid, true ) . '"' );
|
||||||
|
$this->_writeLine( 'msgstr "' . $this->prepare( $msgstr, true ) . '"' );
|
||||||
|
$this->_writeLine( '' );
|
||||||
|
}
|
||||||
|
|
||||||
if( sizeof($match) != 2 )
|
function _writeLine ($str)
|
||||||
throw new Exception('Invalid PO file format2');
|
{
|
||||||
|
$this->_write( $str . "\n" );
|
||||||
|
}
|
||||||
|
|
||||||
$msgstr = '';
|
function _write ($str)
|
||||||
|
{
|
||||||
|
fwrite( $this->_fp, $str );
|
||||||
|
}
|
||||||
|
|
||||||
do {
|
function prepare ($string, $reverse = false)
|
||||||
//g::pr($match);
|
{
|
||||||
$msgstr .= $match[1] . "\n";
|
//$string = str_replace('\"', '"', $string);
|
||||||
$this->_fileLine = trim(fgets($this->_fp));
|
//$string = stripslashes($string);
|
||||||
preg_match('/^"(.*)"\s*/s', $this->_fileLine, $match);
|
|
||||||
} while ( sizeof($match) == 2 );
|
|
||||||
|
|
||||||
|
|
||||||
/*g::pr($this->translatorComments);
|
if ($reverse) {
|
||||||
g::pr($this->references);
|
$smap = array ('"',"\n","\t","\r"
|
||||||
g::pr($match);
|
);
|
||||||
die;*/
|
$rmap = array ('\"','\\n"' . "\n" . '"','\\t','\\r'
|
||||||
|
);
|
||||||
|
return (string) str_replace( $smap, $rmap, $string );
|
||||||
|
} else {
|
||||||
|
$string = preg_replace( '/"\s+"/', '', $string );
|
||||||
|
$smap = array ('\\n','\\r','\\t','\"'
|
||||||
|
);
|
||||||
|
$rmap = array ("\n","\r","\t",'"'
|
||||||
|
);
|
||||||
|
return (string) str_replace( $smap, $rmap, $string );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return Array('msgid'=>trim($msgid), 'msgstr'=>trim($msgstr));
|
function headerStroke ()
|
||||||
}
|
{
|
||||||
|
if ($this->_editingHeader) {
|
||||||
|
$this->_editingHeader = false;
|
||||||
|
$this->_writeLine( '' );
|
||||||
|
;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//garbage
|
/**
|
||||||
function __destruct()
|
* read funtions *
|
||||||
{
|
*/
|
||||||
if ( $this->_fp )
|
private function skipCommets ()
|
||||||
fclose($this->_fp);
|
{
|
||||||
}
|
$this->_fileComments = '';
|
||||||
|
do {
|
||||||
|
$lastPos = ftell( $this->_fp );
|
||||||
|
$line = fgets( $this->_fp );
|
||||||
|
$this->_fileComments .= $line;
|
||||||
|
} while ((substr( $line, 0, 1 ) == '#' || trim( $line ) == '') && ! feof( $this->_fp ));
|
||||||
|
|
||||||
|
fseek( $this->_fp, $lastPos );
|
||||||
|
}
|
||||||
|
|
||||||
|
private function readHeaders ()
|
||||||
|
{
|
||||||
|
$this->flagEndHeaders = false;
|
||||||
|
$this->flagError = false;
|
||||||
|
$this->flagInit = true;
|
||||||
|
$this->lineNumber = 0;
|
||||||
|
$errMsg = '';
|
||||||
|
|
||||||
|
while (! $this->flagError && ! $this->flagEndHeaders) {
|
||||||
|
|
||||||
|
if ($this->flagInit) { //in first instance
|
||||||
|
$this->flagInit = false; //unset init flag
|
||||||
|
|
||||||
|
|
||||||
|
//read the first and second line of the file
|
||||||
|
$firstLine = fgets( $this->_fp );
|
||||||
|
$secondLine = fgets( $this->_fp );
|
||||||
|
|
||||||
|
//verifying the file head
|
||||||
|
if (strpos( $firstLine, 'msgid ""' ) === false || strpos( $secondLine, 'msgstr ""' ) === false) {
|
||||||
|
$this->flagError = true;
|
||||||
|
$errMsg = 'Misplace for firts msgid "" and msgstr "" in the header';
|
||||||
|
}
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
//getting the new line
|
||||||
|
$this->_fileLine = trim( fgets( $this->_fp ) );
|
||||||
|
//set line number
|
||||||
|
$this->lineNumber ++;
|
||||||
|
|
||||||
|
//verifying that is not end of file and applying a restriction for to read just the twenty firsts lines
|
||||||
|
if (trim( $this->_fileLine ) == '' || ! $this->_fileLine || $this->lineNumber >= 20) {
|
||||||
|
$this->flagEndHeaders = true; // set ending to read the headers
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
//verify if has a valid mask header line
|
||||||
|
preg_match( '/^"([a-z0-9\._-]+)\s*:\s*([\W\w]+)\\\n"$/i', $this->_fileLine, $match );
|
||||||
|
|
||||||
|
//for a valid header line the $match size should three
|
||||||
|
if (sizeof( $match ) == 3) {
|
||||||
|
$key = trim( $match[1] ); //getting the key of the header
|
||||||
|
$value = trim( $match[2] ); //getting the value of the header
|
||||||
|
$this->_meta[$key] = $value; //setting a new header
|
||||||
|
} else {
|
||||||
|
$this->flagEndHeaders = true; //otherwise set the ending to read the headers
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} //end looking for headeers
|
||||||
|
|
||||||
|
|
||||||
|
//verifying the headers data
|
||||||
|
if (! isset( $this->_meta['X-Poedit-Language'] )) {
|
||||||
|
$this->flagError = true;
|
||||||
|
$errMsg = "X-Poedit-Language meta doesn't exist";
|
||||||
|
} else if ($this->_meta['X-Poedit-Language'] == '') {
|
||||||
|
$this->flagError = true;
|
||||||
|
$errMsg = "X-Poedit-Language meta is empty";
|
||||||
|
}
|
||||||
|
|
||||||
|
//if the country is not present in metadata
|
||||||
|
if (! isset( $this->_meta['X-Poedit-Country'] )) {
|
||||||
|
$this->_meta['X-Poedit-Country'] = '.';
|
||||||
|
} else if ($this->_meta['X-Poedit-Country'] == '') {
|
||||||
|
$this->_meta['X-Poedit-Country'] = '.';
|
||||||
|
}
|
||||||
|
|
||||||
|
//thowing the exception if is necesary
|
||||||
|
if ($this->flagError) {
|
||||||
|
throw new Exception( "This file is not a valid PO file. ($errMsg)" );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function getHeaders ()
|
||||||
|
{
|
||||||
|
return $this->_meta;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getTranslation ()
|
||||||
|
{
|
||||||
|
|
||||||
|
$flagReadingComments = true;
|
||||||
|
$this->translatorComments = Array ();
|
||||||
|
$this->extractedComments = Array ();
|
||||||
|
$this->references = Array ();
|
||||||
|
$this->flags = Array ();
|
||||||
|
|
||||||
|
//getting the new line
|
||||||
|
while ($flagReadingComments && ! $this->flagError) {
|
||||||
|
|
||||||
|
$this->_fileLine = trim( fgets( $this->_fp ) );
|
||||||
|
//set line number
|
||||||
|
$this->lineNumber ++;
|
||||||
|
|
||||||
|
if (! $this->_fileLine) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
$prefix = substr( $this->_fileLine, 0, 2 );
|
||||||
|
|
||||||
|
switch ($prefix) {
|
||||||
|
case '# ':
|
||||||
|
$lineItem = str_replace( '# ', '', $this->_fileLine );
|
||||||
|
$this->translatorComments[] = $lineItem;
|
||||||
|
break;
|
||||||
|
case '#.':
|
||||||
|
if (substr_count( $this->_fileLine, '#. ' ) == 0) {
|
||||||
|
$this->flagError = true;
|
||||||
|
} else {
|
||||||
|
$lineItem = str_replace( '#. ', '', $this->_fileLine );
|
||||||
|
$this->extractedComments[] = $lineItem;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case '#:':
|
||||||
|
if (substr_count( $this->_fileLine, '#: ' ) == 0) {
|
||||||
|
$this->flagError = true;
|
||||||
|
} else {
|
||||||
|
$lineItem = str_replace( '#: ', '', $this->_fileLine );
|
||||||
|
$this->references[] = $lineItem;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case '#,':
|
||||||
|
if (substr_count( $this->_fileLine, '#, ' ) == 0) {
|
||||||
|
$this->flagError = true;
|
||||||
|
} else {
|
||||||
|
$lineItem = str_replace( '#, ', '', $this->_fileLine );
|
||||||
|
$this->flags[] = $lineItem;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case '#|':
|
||||||
|
if (substr_count( $this->_fileLine, '#| ' ) == 0) {
|
||||||
|
$this->flagError = true;
|
||||||
|
} else {
|
||||||
|
$lineItem = str_replace( '#| ', '', $this->_fileLine );
|
||||||
|
$this->previousUntranslatedStrings[] = $lineItem;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
$flagReadingComments = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! $this->_fileLine) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Getting the msgid
|
||||||
|
preg_match( '/\s*msgid\s*"(.*)"\s*/s', $this->_fileLine, $match );
|
||||||
|
|
||||||
|
if (sizeof( $match ) != 2) {
|
||||||
|
throw new Exception( 'Invalid PO file format1' );
|
||||||
|
}
|
||||||
|
|
||||||
|
$msgid = '';
|
||||||
|
|
||||||
|
do {
|
||||||
|
//g::pr($match);
|
||||||
|
$msgid .= $match[1];
|
||||||
|
$this->_fileLine = trim( fgets( $this->_fp ) );
|
||||||
|
preg_match( '/^"(.*)"\s*/s', $this->_fileLine, $match );
|
||||||
|
} while (sizeof( $match ) == 2);
|
||||||
|
|
||||||
|
//Getting the msgstr
|
||||||
|
preg_match( '/\s*msgstr\s*"(.*)"\s*/s', $this->_fileLine, $match );
|
||||||
|
|
||||||
|
if (sizeof( $match ) != 2) {
|
||||||
|
throw new Exception( 'Invalid PO file format2' );
|
||||||
|
}
|
||||||
|
|
||||||
|
$msgstr = '';
|
||||||
|
|
||||||
|
do {
|
||||||
|
//g::pr($match);
|
||||||
|
$msgstr .= $match[1] . "\n";
|
||||||
|
$this->_fileLine = trim( fgets( $this->_fp ) );
|
||||||
|
preg_match( '/^"(.*)"\s*/s', $this->_fileLine, $match );
|
||||||
|
} while (sizeof( $match ) == 2);
|
||||||
|
|
||||||
|
/*g::pr($this->translatorComments);
|
||||||
|
g::pr($this->references);
|
||||||
|
g::pr($match);
|
||||||
|
die;*/
|
||||||
|
|
||||||
|
return Array ('msgid' => trim( $msgid ),'msgstr' => trim( $msgstr )
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
//garbage
|
||||||
|
function __destruct ()
|
||||||
|
{
|
||||||
|
if ($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
|
||||||
@@ -13,17 +14,17 @@
|
|||||||
*
|
*
|
||||||
* 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
|
||||||
* GNU Affero General Public License for more details.
|
* GNU Affero General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU Affero General Public License
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*
|
*
|
||||||
* For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
|
* For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
|
||||||
* 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,237 +40,276 @@ 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
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* instanceMailer
|
* instanceMailer
|
||||||
*
|
*
|
||||||
* @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 = "";
|
||||||
$mailer->SMTPAuth = false;
|
$mailer->SMTPAuth = false;
|
||||||
$mailer->Username = "";
|
$mailer->Username = "";
|
||||||
$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;
|
||||||
return $mailer;
|
}
|
||||||
}
|
if (defined( 'MAIL_USERNAME' )) {
|
||||||
|
$mailer->Username = MAIL_USERNAME;
|
||||||
/* ARPA INTERNET TEXT MESSAGES
|
}
|
||||||
* Returns an array with the "name" and "email" of an ARPA type
|
if (defined( 'MAIL_PASSWORD' )) {
|
||||||
* email $address.
|
$mailer->Password = MAIL_PASSWORD;
|
||||||
* @author David Callizaya
|
}
|
||||||
*/
|
if (defined( 'MAIL_TIMEOUT' )) {
|
||||||
function arpaEMAIL($address)
|
$mailer->Timeout = MAIL_TIMEOUT;
|
||||||
{
|
}
|
||||||
$arpa = array();
|
if (defined( 'MAIL_CHARSET' )) {
|
||||||
preg_match("/([^<>]*)(?:\<([^<>]*)\>)?/",$address,$matches);
|
$mailer->CharSet = MAIL_CHARSET;
|
||||||
$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]:'');
|
if (defined( 'MAIL_ENCODING' )) {
|
||||||
$arpa['name'] = ($isEmail)?'':$matches[1];
|
$mailer->Encoding = MAIL_ENCODING;
|
||||||
return $arpa;
|
}
|
||||||
}
|
return $mailer;
|
||||||
|
|
||||||
/**
|
|
||||||
* sendTemplate
|
|
||||||
*
|
|
||||||
* @param string $from default value empty
|
|
||||||
* @param string $target default value default value empty
|
|
||||||
* @param string $cc default value default value empty
|
|
||||||
* @param string $bcc default value default value empty
|
|
||||||
* @param string $subject default value empty
|
|
||||||
* @param array $Fields
|
|
||||||
* @param string $templateFile default value "empty.html"
|
|
||||||
* @param array $attachs
|
|
||||||
* @param boolean $plainText default value false
|
|
||||||
* @param boolean $returnContent default value false
|
|
||||||
*
|
|
||||||
* @return object $content or $result
|
|
||||||
*/
|
|
||||||
function sendTemplate( $from = "", $target = "", $cc = "", $bcc="" ,$subject = "", $Fields = array(), $templateFile = "empty.html", $attachs=array(), $plainText=false, $returnContent = false )
|
|
||||||
{
|
|
||||||
// Read the content of the TemplateFile
|
|
||||||
$fp = fopen(PATH_HTMLMAIL . $templateFile,"r");
|
|
||||||
$content = fread($fp,filesize(PATH_HTMLMAIL . $templateFile));
|
|
||||||
fclose($fp);
|
|
||||||
//Replace the @@Fields with the $Fields array.
|
|
||||||
$content = mailer::replaceFields($Fields,$content);
|
|
||||||
//Compatibility with class.Application
|
|
||||||
if ($attachs==='FALSE')
|
|
||||||
return $content;
|
|
||||||
//Create the alternative body (text only)
|
|
||||||
//$h2t =& new html2text($content);
|
|
||||||
$text = '';//$h2t->get_text();
|
|
||||||
//Prepate el phpmailer
|
|
||||||
$mailer = mailer::instanceMailer();
|
|
||||||
$arpa = mailer::arpaEMAIL($from);
|
|
||||||
$mailer->From = $arpa['email']==''?$mailer->defaultEMail:$arpa['email'];
|
|
||||||
$mailer->FromName = $arpa['name'];
|
|
||||||
$arpa = mailer::arpaEMAIL($target);
|
|
||||||
$mailer->AddAddress($arpa['email'],$arpa['name']);
|
|
||||||
$mailer->AddCC($cc);
|
|
||||||
$mailer->AddBCC($bcc);
|
|
||||||
$mailer->Subject = $subject;
|
|
||||||
if ($plainText)
|
|
||||||
$content = $text;
|
|
||||||
if ($content==='')
|
|
||||||
$content='empty';
|
|
||||||
$mailer->Body = $content;
|
|
||||||
//$mailer->AltBody = $text;
|
|
||||||
$mailer->isHTML(!$plainText);
|
|
||||||
//Attach the required files
|
|
||||||
if (is_array($attachs))
|
|
||||||
if (sizeof($attachs)>0)
|
|
||||||
foreach($attachs as $aFile)
|
|
||||||
$mailer->AddAttachment($aFile,basename($aFile));
|
|
||||||
//Send the e-mail.
|
|
||||||
for($r=1;$r<=4;$r++) {
|
|
||||||
$result = $mailer->Send();
|
|
||||||
if ($result) break;
|
|
||||||
}
|
}
|
||||||
//unset($h2t);
|
|
||||||
if ($result && $returnContent) return $content;
|
|
||||||
return $result;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/* ARPA INTERNET TEXT MESSAGES
|
||||||
* sendHtml
|
* Returns an array with the "name" and "email" of an ARPA type
|
||||||
*
|
* email $address.
|
||||||
* @param string $from default value empty
|
* @author David Callizaya
|
||||||
* @param string $target default value empty
|
*/
|
||||||
* @param string $cc default value empty
|
function arpaEMAIL ($address)
|
||||||
* @param string $bcc default value empty
|
{
|
||||||
* @param string $subject default value empty
|
$arpa = array ();
|
||||||
* @param array $Fields
|
preg_match( "/([^<>]*)(?:\<([^<>]*)\>)?/", $address, $matches );
|
||||||
* @param string $content default value empty
|
$isEmail = preg_match( "/\b[A-Z0-9._%-]+@[A-Z0-9.-]+\.[A-Z]{2,4}\b/i", $matches[1] );
|
||||||
* @param array $attachs default value empty
|
$arpa['email'] = ((isset( $matches[2] )) && ($matches[2] != '')) ? $matches[2] : (($isEmail) ? $matches[1] : '');
|
||||||
* @param string $plainText default false
|
$arpa['name'] = ($isEmail) ? '' : $matches[1];
|
||||||
* @param boolean $returnContent default value false
|
return $arpa;
|
||||||
*
|
|
||||||
* @return object $result
|
|
||||||
*/
|
|
||||||
function sendHtml( $from = "", $target = "", $cc = "", $bcc="" ,$subject = "", $Fields = array(), $content = "", $attachs=array(), $plainText=false, $returnContent = false )
|
|
||||||
{
|
|
||||||
//Replace the @@Fields with the $Fields array.
|
|
||||||
$content = mailer::replaceFields($Fields,$content);
|
|
||||||
//Create the alternative body (text only)
|
|
||||||
//$h2t =& new html2text($content);
|
|
||||||
$text = '';//$h2t->get_text();
|
|
||||||
//Prepate el phpmailer
|
|
||||||
$mailer = mailer::instanceMailer();
|
|
||||||
$arpa = mailer::arpaEMAIL($from);
|
|
||||||
$mailer->From = $arpa['email']==''?$mailer->defaultEMail:$arpa['email'];
|
|
||||||
$mailer->FromName = $arpa['name'];
|
|
||||||
$arpa = mailer::arpaEMAIL($target);
|
|
||||||
$mailer->AddAddress($arpa['email'],$arpa['name']);
|
|
||||||
$mailer->AddCC($cc);
|
|
||||||
$mailer->AddBCC($bcc);
|
|
||||||
$mailer->Subject = $subject;
|
|
||||||
if ($plainText) $content = $text;
|
|
||||||
if ($content==='') $content='empty';
|
|
||||||
$mailer->Body = $content;
|
|
||||||
//$mailer->AltBody = $text;
|
|
||||||
$mailer->isHTML(!$plainText);
|
|
||||||
//Attach the required files
|
|
||||||
if (is_array($attachs))
|
|
||||||
if (sizeof($attachs)>0)
|
|
||||||
foreach($attachs as $aFile)
|
|
||||||
$mailer->AddAttachment($aFile,basename($aFile));
|
|
||||||
//Send the e-mail.
|
|
||||||
for($r=1;$r<=4;$r++) {
|
|
||||||
$result=$mailer->Send();
|
|
||||||
if ($result) break;
|
|
||||||
}
|
}
|
||||||
//unset($h2t);
|
|
||||||
if ($result && $returnContent) return $content;
|
|
||||||
return $result;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* sendText
|
* sendTemplate
|
||||||
*
|
*
|
||||||
* @param string $from default value empty
|
* @param string $from default value empty
|
||||||
* @param string $target default value empty
|
* @param string $target default value default value empty
|
||||||
* @param string $cc default value empty
|
* @param string $cc default value default value empty
|
||||||
* @param string $bcc default value empty
|
* @param string $bcc default value default value empty
|
||||||
* @param string $subject default value empty
|
* @param string $subject default value empty
|
||||||
* @param string $content default value empty
|
* @param array $Fields
|
||||||
* @param array $attachs
|
* @param string $templateFile default value "empty.html"
|
||||||
*
|
* @param array $attachs
|
||||||
* @return object $result
|
* @param boolean $plainText default value false
|
||||||
*/
|
* @param boolean $returnContent default value false
|
||||||
function sendText( $from = "", $target = "", $cc = "", $bcc="" ,$subject = "", $content = "", $attachs=array())
|
*
|
||||||
{
|
* @return object $content or $result
|
||||||
//Prepate el phpmailer
|
*/
|
||||||
$mailer = mailer::instanceMailer();
|
function sendTemplate ($from = "", $target = "", $cc = "", $bcc = "", $subject = "", $Fields = array(), $templateFile = "empty.html", $attachs = array(), $plainText = false, $returnContent = false)
|
||||||
$arpa = mailer::arpaEMAIL($from);
|
{
|
||||||
$mailer->From = $arpa['email']==''?$mailer->defaultEMail:$arpa['email'];
|
// Read the content of the TemplateFile
|
||||||
$mailer->FromName = $arpa['name'];
|
$fp = fopen( PATH_HTMLMAIL . $templateFile, "r" );
|
||||||
$arpa = mailer::arpaEMAIL($target);
|
$content = fread( $fp, filesize( PATH_HTMLMAIL . $templateFile ) );
|
||||||
$mailer->AddAddress($arpa['email'],$arpa['name']);
|
fclose( $fp );
|
||||||
$mailer->AddCC($cc);
|
//Replace the @@Fields with the $Fields array.
|
||||||
$mailer->AddBCC($bcc);
|
$content = mailer::replaceFields( $Fields, $content );
|
||||||
$mailer->Subject = $subject;
|
//Compatibility with class.Application
|
||||||
if ($content==='') $content='empty';
|
if ($attachs === 'FALSE') {
|
||||||
$mailer->Body = $content;
|
return $content;
|
||||||
$mailer->AltBody = $content;
|
}
|
||||||
$mailer->isHTML(false);
|
//Create the alternative body (text only)
|
||||||
//Attach the required files
|
//$h2t =& new html2text($content);
|
||||||
if (sizeof($attachs)>0)
|
$text = ''; //$h2t->get_text();
|
||||||
foreach($attachs as $aFile)
|
//Prepate el phpmailer
|
||||||
$mailer->AddAttachment($aFile,basename($aFile));
|
$mailer = mailer::instanceMailer();
|
||||||
//Send the e-mail.
|
$arpa = mailer::arpaEMAIL( $from );
|
||||||
for($r=1;$r<=4;$r++) {
|
$mailer->From = $arpa['email'] == '' ? $mailer->defaultEMail : $arpa['email'];
|
||||||
$result=$mailer->Send();
|
$mailer->FromName = $arpa['name'];
|
||||||
if ($result) break;
|
$arpa = mailer::arpaEMAIL( $target );
|
||||||
|
$mailer->AddAddress( $arpa['email'], $arpa['name'] );
|
||||||
|
$mailer->AddCC( $cc );
|
||||||
|
$mailer->AddBCC( $bcc );
|
||||||
|
$mailer->Subject = $subject;
|
||||||
|
if ($plainText) {
|
||||||
|
$content = $text;
|
||||||
|
}
|
||||||
|
if ($content === '') {
|
||||||
|
$content = 'empty';
|
||||||
|
}
|
||||||
|
$mailer->Body = $content;
|
||||||
|
//$mailer->AltBody = $text;
|
||||||
|
$mailer->isHTML( ! $plainText );
|
||||||
|
//Attach the required files
|
||||||
|
if (is_array( $attachs ))
|
||||||
|
if (sizeof( $attachs ) > 0)
|
||||||
|
foreach ($attachs as $aFile)
|
||||||
|
$mailer->AddAttachment( $aFile, basename( $aFile ) );
|
||||||
|
//Send the e-mail.
|
||||||
|
for ($r = 1; $r <= 4; $r ++) {
|
||||||
|
$result = $mailer->Send();
|
||||||
|
if ($result) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//unset($h2t);
|
||||||
|
if ($result && $returnContent) {
|
||||||
|
return $content;
|
||||||
|
}
|
||||||
|
return $result;
|
||||||
}
|
}
|
||||||
return $result;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* replaceFields
|
* sendHtml
|
||||||
*
|
*
|
||||||
* @param array $Fields
|
* @param string $from default value empty
|
||||||
* @param string $content default value string empty
|
* @param string $target default value empty
|
||||||
*
|
* @param string $cc default value empty
|
||||||
* @return none
|
* @param string $bcc default value empty
|
||||||
*/
|
* @param string $subject default value empty
|
||||||
function replaceFields($Fields = array(), $content = "")
|
* @param array $Fields
|
||||||
{
|
* @param string $content default value empty
|
||||||
return G::replaceDataField( $content , $Fields );
|
* @param array $attachs default value empty
|
||||||
}
|
* @param string $plainText default false
|
||||||
|
* @param boolean $returnContent default value false
|
||||||
|
*
|
||||||
|
* @return object $result
|
||||||
|
*/
|
||||||
|
function sendHtml ($from = "", $target = "", $cc = "", $bcc = "", $subject = "", $Fields = array(), $content = "", $attachs = array(), $plainText = false, $returnContent = false)
|
||||||
|
{
|
||||||
|
//Replace the @@Fields with the $Fields array.
|
||||||
|
$content = mailer::replaceFields( $Fields, $content );
|
||||||
|
//Create the alternative body (text only)
|
||||||
|
//$h2t =& new html2text($content);
|
||||||
|
$text = ''; //$h2t->get_text();
|
||||||
|
//Prepate el phpmailer
|
||||||
|
$mailer = mailer::instanceMailer();
|
||||||
|
$arpa = mailer::arpaEMAIL( $from );
|
||||||
|
$mailer->From = $arpa['email'] == '' ? $mailer->defaultEMail : $arpa['email'];
|
||||||
|
$mailer->FromName = $arpa['name'];
|
||||||
|
$arpa = mailer::arpaEMAIL( $target );
|
||||||
|
$mailer->AddAddress( $arpa['email'], $arpa['name'] );
|
||||||
|
$mailer->AddCC( $cc );
|
||||||
|
$mailer->AddBCC( $bcc );
|
||||||
|
$mailer->Subject = $subject;
|
||||||
|
if ($plainText) {
|
||||||
|
$content = $text;
|
||||||
|
}
|
||||||
|
if ($content === '') {
|
||||||
|
$content = 'empty';
|
||||||
|
}
|
||||||
|
$mailer->Body = $content;
|
||||||
|
//$mailer->AltBody = $text;
|
||||||
|
$mailer->isHTML( ! $plainText );
|
||||||
|
//Attach the required files
|
||||||
|
if (is_array( $attachs ))
|
||||||
|
if (sizeof( $attachs ) > 0)
|
||||||
|
foreach ($attachs as $aFile)
|
||||||
|
$mailer->AddAttachment( $aFile, basename( $aFile ) );
|
||||||
|
//Send the e-mail.
|
||||||
|
for ($r = 1; $r <= 4; $r ++) {
|
||||||
|
$result = $mailer->Send();
|
||||||
|
if ($result) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//unset($h2t);
|
||||||
|
if ($result && $returnContent) {
|
||||||
|
return $content;
|
||||||
|
}
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* html2text
|
* sendText
|
||||||
*
|
*
|
||||||
* empty
|
* @param string $from default value empty
|
||||||
* @return none
|
* @param string $target default value empty
|
||||||
*/
|
* @param string $cc default value empty
|
||||||
function html2text()
|
* @param string $bcc default value empty
|
||||||
{
|
* @param string $subject default value empty
|
||||||
//$h2t =& new html2text($content);
|
* @param string $content default value empty
|
||||||
//return $h2t->get_text();
|
* @param array $attachs
|
||||||
}
|
*
|
||||||
|
* @return object $result
|
||||||
|
*/
|
||||||
|
function sendText ($from = "", $target = "", $cc = "", $bcc = "", $subject = "", $content = "", $attachs = array())
|
||||||
|
{
|
||||||
|
//Prepate el phpmailer
|
||||||
|
$mailer = mailer::instanceMailer();
|
||||||
|
$arpa = mailer::arpaEMAIL( $from );
|
||||||
|
$mailer->From = $arpa['email'] == '' ? $mailer->defaultEMail : $arpa['email'];
|
||||||
|
$mailer->FromName = $arpa['name'];
|
||||||
|
$arpa = mailer::arpaEMAIL( $target );
|
||||||
|
$mailer->AddAddress( $arpa['email'], $arpa['name'] );
|
||||||
|
$mailer->AddCC( $cc );
|
||||||
|
$mailer->AddBCC( $bcc );
|
||||||
|
$mailer->Subject = $subject;
|
||||||
|
if ($content === '') {
|
||||||
|
$content = 'empty';
|
||||||
|
}
|
||||||
|
$mailer->Body = $content;
|
||||||
|
$mailer->AltBody = $content;
|
||||||
|
$mailer->isHTML( false );
|
||||||
|
//Attach the required files
|
||||||
|
if (sizeof( $attachs ) > 0) {
|
||||||
|
foreach ($attachs as $aFile) {
|
||||||
|
$mailer->AddAttachment( $aFile, basename( $aFile ) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//Send the e-mail.
|
||||||
|
for ($r = 1; $r <= 4; $r ++) {
|
||||||
|
$result = $mailer->Send();
|
||||||
|
if ($result) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* replaceFields
|
||||||
|
*
|
||||||
|
* @param array $Fields
|
||||||
|
* @param string $content default value string empty
|
||||||
|
*
|
||||||
|
* @return none
|
||||||
|
*/
|
||||||
|
function replaceFields ($Fields = array(), $content = "")
|
||||||
|
{
|
||||||
|
return G::replaceDataField( $content, $Fields );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* html2text
|
||||||
|
*
|
||||||
|
* empty
|
||||||
|
*
|
||||||
|
* @return none
|
||||||
|
*/
|
||||||
|
function html2text ()
|
||||||
|
{
|
||||||
|
//$h2t =& new html2text($content);
|
||||||
|
//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
|
||||||
@@ -13,23 +15,27 @@
|
|||||||
*
|
*
|
||||||
* 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
|
||||||
* GNU Affero General Public License for more details.
|
* GNU Affero General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU Affero General Public License
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*
|
*
|
||||||
* For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
|
* For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
|
||||||
* Coral Gables, FL, 33134, USA, or email info@colosa.com.
|
* Coral Gables, FL, 33134, USA, or email info@colosa.com.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
/**
|
/**
|
||||||
|
*
|
||||||
* @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,343 +43,342 @@
|
|||||||
*/
|
*/
|
||||||
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
|
||||||
*
|
*
|
||||||
* @author Fernando Ontiveros Lira <fernando@colosa.com>
|
* @author Fernando Ontiveros Lira <fernando@colosa.com>
|
||||||
* @access public
|
* @access public
|
||||||
* @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";
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Load menu options
|
|
||||||
*
|
|
||||||
* @author Fernando Ontiveros Lira <fernando@colosa.com>
|
|
||||||
* @access public
|
|
||||||
* @param $strMenuName name of menu
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
function Load( $strMenuName )
|
|
||||||
{
|
|
||||||
global $G_TMP_MENU;
|
|
||||||
$G_TMP_MENU = NULL;
|
|
||||||
$G_TMP_MENU = new Menu;
|
|
||||||
$fMenu = G::ExpandPath( "menus" ) . $strMenuName . ".php";
|
|
||||||
|
|
||||||
//if the menu file doesn't exists, then try with the plugins folders
|
|
||||||
if ( !is_file( $fMenu) ) {
|
|
||||||
$aux = explode ( PATH_SEP, $strMenuName );
|
|
||||||
if ( count($aux) == 2 ) {
|
|
||||||
$oPluginRegistry =& PMPluginRegistry::getSingleton();
|
|
||||||
if ( $oPluginRegistry->isRegisteredFolder($aux[0]) )
|
|
||||||
$fMenu = PATH_PLUGINS . $aux[0] . PATH_SEP . $aux[1] . ".php";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if( !is_file( $fMenu ) )
|
|
||||||
return;
|
|
||||||
|
|
||||||
include( $fMenu );
|
|
||||||
//this line will add options to current menu.
|
|
||||||
$oPluginRegistry =& PMPluginRegistry::getSingleton();
|
|
||||||
$oPluginRegistry->getMenus ( $strMenuName );
|
|
||||||
|
|
||||||
//?
|
|
||||||
$c = 0;
|
|
||||||
for ($i = 0; $i < count ($G_TMP_MENU->Options) ; $i++)
|
|
||||||
if ($G_TMP_MENU->Enabled[$i] == 1) {
|
|
||||||
$this->Options[$c] = $G_TMP_MENU->Options[$i];
|
|
||||||
$this->Labels [$c] = $G_TMP_MENU->Labels[$i];
|
|
||||||
$this->Icons [$c] = $G_TMP_MENU->Icons[$i];
|
|
||||||
$this->JS [$c] = $G_TMP_MENU->JS[$i];
|
|
||||||
$this->Types [$c] = $G_TMP_MENU->Types[$i];
|
|
||||||
$this->Enabled[$c] = $G_TMP_MENU->Enabled[$i];
|
|
||||||
$this->Id [$c] = $G_TMP_MENU->Id[$i];
|
|
||||||
$this->Classes[$c] = $G_TMP_MENU->Classes[$i];
|
|
||||||
$this->ElementClass[$c] = $G_TMP_MENU->ElementClass[$i];
|
|
||||||
$c ++;
|
|
||||||
} else {
|
|
||||||
if ($i == $this->optionOn) $this->optionOn = -1;
|
|
||||||
elseif ($i < $this->optionOn) $this->optionOn--;
|
|
||||||
elseif ($this->optionOn > 0) $this->optionOn--;//added this line
|
|
||||||
}
|
|
||||||
$G_TMP_MENU = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Load menu options
|
|
||||||
*
|
|
||||||
* @author Fernando Ontiveros Lira <fernando@colosa.com>
|
|
||||||
* @access public
|
|
||||||
* @return int
|
|
||||||
*/
|
|
||||||
function OptionCount()
|
|
||||||
{
|
|
||||||
$result = 0;
|
|
||||||
if( is_array( $this->Options ) )
|
|
||||||
{
|
{
|
||||||
$result = count( $this->Options );
|
$this->Class = "mnu";
|
||||||
}
|
}
|
||||||
return $result;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add an option to menu
|
* Load menu options
|
||||||
*
|
*
|
||||||
* @author Fernando Ontiveros Lira <fernando@colosa.com>
|
* @author Fernando Ontiveros Lira <fernando@colosa.com>
|
||||||
* @access public
|
* @access public
|
||||||
* @param string $strLabel label to show
|
* @param $strMenuName name of menu
|
||||||
* @param string $strURL link
|
* @return void
|
||||||
* @param string $strType type, defualt value ='plugins'
|
*/
|
||||||
* @return void
|
function Load ($strMenuName)
|
||||||
*/
|
|
||||||
function AddOption( $strLabel, $strURL, $strType = "plugins" )
|
|
||||||
{
|
|
||||||
$pos = $this->OptionCount();
|
|
||||||
$this->Options[$pos] = $strURL;
|
|
||||||
$this->Labels[$pos] = $strLabel;
|
|
||||||
$this->Types[$pos] = $strType;
|
|
||||||
$this->Enabled[$pos] = 1;
|
|
||||||
$this->Id[$pos] = $pos;
|
|
||||||
unset( $pos );
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Add an option to menu by id
|
|
||||||
*
|
|
||||||
* @author Fernando Ontiveros Lira <fernando@colosa.com>
|
|
||||||
* @access public
|
|
||||||
* @param string $strId menu id
|
|
||||||
* @param string $strLabel label to show
|
|
||||||
* @param string $strURL link
|
|
||||||
* @param string $strType type, defualt value ='plugins'
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
function AddIdOption( $strId, $strLabel, $strURL, $strType = "plugins" )
|
|
||||||
{
|
|
||||||
$pos = $this->OptionCount();
|
|
||||||
$this->Options[$pos] = $strURL;
|
|
||||||
$this->Labels[$pos] = $strLabel;
|
|
||||||
$this->Types[$pos] = $strType;
|
|
||||||
$this->Enabled[$pos] = 1;
|
|
||||||
if (is_array ($strId)) {
|
|
||||||
$this->Id[$pos] = $strId[0];
|
|
||||||
$this->Classes[$pos] = $strId[1];
|
|
||||||
}
|
|
||||||
else
|
|
||||||
$this->Id[$pos] = $strId;
|
|
||||||
unset( $pos );
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Add an option to menu
|
|
||||||
*
|
|
||||||
* @author Fernando Ontiveros Lira <fernando@colosa.com>
|
|
||||||
* @access public
|
|
||||||
* @param string $strURL link
|
|
||||||
* @param string $strType type, defualt value ='plugins'
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
function AddRawOption( $strURL = "", $strType = "plugins" )
|
|
||||||
{
|
|
||||||
$pos = $this->OptionCount();
|
|
||||||
$this->Options[$pos] = $strURL;
|
|
||||||
$this->Labels[$pos] = "";
|
|
||||||
$this->Types[$pos] = $strType;
|
|
||||||
$this->Enabled[$pos] = 1;
|
|
||||||
$this->Id[$pos] = $pos;
|
|
||||||
unset( $pos );
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Add an option to menu by id
|
|
||||||
*
|
|
||||||
* @author Fernando Ontiveros Lira <fernando@colosa.com>
|
|
||||||
* @access public
|
|
||||||
* @param string $strId menu id
|
|
||||||
* @param string $strLabel label to show
|
|
||||||
* @param string $strURL link
|
|
||||||
* @param string $strType type, defualt value ='plugins'
|
|
||||||
* @param string $elementClass default value =''
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
function AddIdRawOption( $strId, $strURL = "", $label = "", $icon = "",$js = "", $strType = "plugins",$elementClass = '' )
|
|
||||||
{
|
|
||||||
$pos = $this->OptionCount();
|
|
||||||
$this->Options[$pos] = $strURL;
|
|
||||||
$this->Labels[$pos] = $label;
|
|
||||||
$this->Icons[$pos] = $icon;
|
|
||||||
$this->JS[$pos] = $js;
|
|
||||||
$this->Types[$pos] = $strType;
|
|
||||||
$this->Enabled[$pos] = 1;
|
|
||||||
$this->ElementClass[$pos] = $elementClass;
|
|
||||||
if (is_array ($strId)) {
|
|
||||||
$this->Id[$pos] = $strId[0];
|
|
||||||
$this->Classes[$pos] = $strId[1];
|
|
||||||
}
|
|
||||||
else
|
|
||||||
$this->Id[$pos] = $strId;
|
|
||||||
unset( $pos );
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Disable an menu option by menu's position
|
|
||||||
*
|
|
||||||
* @author Fernando Ontiveros Lira <fernando@colosa.com>
|
|
||||||
* @access public
|
|
||||||
* @param string $intPos menu option's position
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
function DisableOptionPos( $intPos )
|
|
||||||
{
|
|
||||||
$this->Enabled[$intPos] = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Disable an menu's option by id
|
|
||||||
*
|
|
||||||
* @author Fernando Ontiveros Lira <fernando@colosa.com>
|
|
||||||
* @access public
|
|
||||||
* @param string $id menu's id
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
function DisableOptionId ( $id )
|
|
||||||
{
|
|
||||||
if ( array_search ($id, $this->Id) )
|
|
||||||
$this->Enabled[ array_search ($id, $this->Id) ] = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Render an menu's option
|
|
||||||
*
|
|
||||||
* @author Fernando Ontiveros Lira <fernando@colosa.com>
|
|
||||||
* @access public
|
|
||||||
* @param string $intPos menu option's position
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
function RenderOption( $intPos )
|
|
||||||
{
|
|
||||||
if ( $this->Enabled[$intPos] != 1)
|
|
||||||
return;
|
|
||||||
|
|
||||||
$classname = $this->Class . "Link";
|
|
||||||
if ( $this->Classes[$intPos] != "" ) $classname = $this->Classes[$intPos];
|
|
||||||
$target = $this->Options[$intPos];
|
|
||||||
if( $this->Types[$intPos] != "absolute" )
|
|
||||||
{
|
{
|
||||||
if (defined('ENABLE_ENCRYPT')) {
|
global $G_TMP_MENU;
|
||||||
|
$G_TMP_MENU = null;
|
||||||
|
$G_TMP_MENU = new Menu();
|
||||||
|
$fMenu = G::ExpandPath( "menus" ) . $strMenuName . ".php";
|
||||||
|
|
||||||
$target = "/sys" . SYS_SYS . "/" . SYS_LANG . "/" . SYS_SKIN . "/" . $target;
|
//if the menu file doesn't exists, then try with the plugins folders
|
||||||
}
|
if (! is_file( $fMenu )) {
|
||||||
else
|
$aux = explode( PATH_SEP, $strMenuName );
|
||||||
if (defined('SYS_SYS'))
|
if (count( $aux ) == 2) {
|
||||||
$target = "/sys" . SYS_SYS . "/" . SYS_LANG . "/" . SYS_SKIN . "/" . $target;
|
$oPluginRegistry = & PMPluginRegistry::getSingleton();
|
||||||
else
|
if ($oPluginRegistry->isRegisteredFolder( $aux[0] )) {
|
||||||
$target = "/sys/" . SYS_LANG . "/" . SYS_SKIN . "/" . $target;
|
$fMenu = PATH_PLUGINS . $aux[0] . PATH_SEP . $aux[1] . ".php";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! is_file( $fMenu )) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
include ($fMenu);
|
||||||
|
//this line will add options to current menu.
|
||||||
|
$oPluginRegistry = & PMPluginRegistry::getSingleton();
|
||||||
|
$oPluginRegistry->getMenus( $strMenuName );
|
||||||
|
|
||||||
|
//?
|
||||||
|
$c = 0;
|
||||||
|
for ($i = 0; $i < count( $G_TMP_MENU->Options ); $i ++)
|
||||||
|
if ($G_TMP_MENU->Enabled[$i] == 1) {
|
||||||
|
$this->Options[$c] = $G_TMP_MENU->Options[$i];
|
||||||
|
$this->Labels[$c] = $G_TMP_MENU->Labels[$i];
|
||||||
|
$this->Icons[$c] = $G_TMP_MENU->Icons[$i];
|
||||||
|
$this->JS[$c] = $G_TMP_MENU->JS[$i];
|
||||||
|
$this->Types[$c] = $G_TMP_MENU->Types[$i];
|
||||||
|
$this->Enabled[$c] = $G_TMP_MENU->Enabled[$i];
|
||||||
|
$this->Id[$c] = $G_TMP_MENU->Id[$i];
|
||||||
|
$this->Classes[$c] = $G_TMP_MENU->Classes[$i];
|
||||||
|
$this->ElementClass[$c] = $G_TMP_MENU->ElementClass[$i];
|
||||||
|
$c ++;
|
||||||
|
} else {
|
||||||
|
if ($i == $this->optionOn)
|
||||||
|
$this->optionOn = - 1;
|
||||||
|
elseif ($i < $this->optionOn)
|
||||||
|
$this->optionOn --;
|
||||||
|
elseif ($this->optionOn > 0)
|
||||||
|
$this->optionOn --; //added this line
|
||||||
|
}
|
||||||
|
$G_TMP_MENU = null;
|
||||||
}
|
}
|
||||||
$label = $this->Labels[$intPos];
|
|
||||||
$result = "<a href=\"$target\"";
|
|
||||||
$result .= " class=\"$classname\">";
|
|
||||||
$result .= htmlentities( $label , ENT_NOQUOTES , 'utf-8');
|
|
||||||
$result .= "</a>";
|
|
||||||
print( $result );
|
|
||||||
|
|
||||||
}
|
/**
|
||||||
|
* Load menu options
|
||||||
/**
|
*
|
||||||
* to make an array for template
|
* @author Fernando Ontiveros Lira <fernando@colosa.com>
|
||||||
*
|
* @access public
|
||||||
* @author Fernando Ontiveros Lira <fernando@colosa.com>
|
* @return int
|
||||||
* @access public
|
*/
|
||||||
* @param string $G_MAIN_MENU
|
function OptionCount ()
|
||||||
* @param string $classOn
|
|
||||||
* @param string $classOff
|
|
||||||
* @param string $G_MENU_SELECTED
|
|
||||||
* @param string $G_ID_MENU_SELECTED
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
function generateArrayForTemplate($G_MAIN_MENU,$classOn,$classOff,$G_MENU_SELECTED, $G_ID_MENU_SELECTED ) {
|
|
||||||
$menus = array();
|
|
||||||
if ($G_MAIN_MENU == null) {
|
|
||||||
return $menus;
|
|
||||||
}
|
|
||||||
$this->Load ($G_MAIN_MENU);
|
|
||||||
$this->optionOn = $G_MENU_SELECTED;
|
|
||||||
$this->id_optionOn = $G_ID_MENU_SELECTED;
|
|
||||||
//$this->Class = $G_MENU_CLASS;
|
|
||||||
if (is_array($this->Options))
|
|
||||||
{
|
{
|
||||||
for ($ncount = 0; $ncount < $this->OptionCount(); $ncount++)
|
$result = 0;
|
||||||
{
|
if (is_array( $this->Options )) {
|
||||||
$target = $this->Options[$ncount];
|
$result = count( $this->Options );
|
||||||
|
|
||||||
//$aux = $this->Icons[$ncount];
|
|
||||||
$aux = $this->JS[$ncount];
|
|
||||||
if ($this->Types[$ncount] == 'absolute') {
|
|
||||||
//$target = G::encryptLink(str_replace('sys' . SYS_TEMP, SYS_TEMP, $this->Options[$ncount]));
|
|
||||||
$target = $this->Options[$ncount];
|
|
||||||
}
|
}
|
||||||
if ($this->Types[$ncount] != 'absolute') {
|
return $result;
|
||||||
if (defined('SYS_SYS')) {
|
}
|
||||||
$target = '/sys' . SYS_TEMP . G::encryptLink('/' . SYS_LANG . '/' . SYS_SKIN . '/' . $this->Options[$ncount]);
|
|
||||||
}
|
/**
|
||||||
else {
|
* Add an option to menu
|
||||||
$target = '/sys/' . G::encryptLink(SYS_LANG . '/' . SYS_SKIN . '/' . $this->Options[$ncount]);
|
*
|
||||||
}
|
* @author Fernando Ontiveros Lira <fernando@colosa.com>
|
||||||
}
|
* @access public
|
||||||
$label = $this->Labels[$ncount];
|
* @param string $strLabel label to show
|
||||||
if ($this->id_optionOn != '') {
|
* @param string $strURL link
|
||||||
$onMenu = ($this->Id[$ncount] == $this->id_optionOn ? true : false);
|
* @param string $strType type, defualt value ='plugins'
|
||||||
}
|
* @return void
|
||||||
else {
|
*/
|
||||||
$onMenu = ($ncount == $this->optionOn ? true : false);
|
function AddOption ($strLabel, $strURL, $strType = "plugins")
|
||||||
}
|
{
|
||||||
$classname = ($onMenu ? $classOn : $classOff);
|
$pos = $this->OptionCount();
|
||||||
$imageLeft = ($onMenu ? "<img src=\"/images/bulletSubMenu.jpg\" />" : '');
|
$this->Options[$pos] = $strURL;
|
||||||
$onclick = '';
|
$this->Labels[$pos] = $strLabel;
|
||||||
if ($this->JS[$ncount] !== '' ) {
|
$this->Types[$pos] = $strType;
|
||||||
$onclick = " onclick=\"" . $this->JS[$ncount] . "\"";
|
$this->Enabled[$pos] = 1;
|
||||||
}
|
$this->Id[$pos] = $pos;
|
||||||
$icon = '';
|
unset( $pos );
|
||||||
if ($this->Icons[$ncount] !== '' ) {
|
}
|
||||||
$icon = " <a href=\"#\" onclick=\"" . $this->JS[$ncount] . "\" class=\"$classname\">" .
|
|
||||||
"<img src=\"". $this->Icons[$ncount] . "\" border=\"0\"/></a>";
|
/**
|
||||||
$icon = $this->Icons[$ncount];
|
* Add an option to menu by id
|
||||||
}
|
*
|
||||||
if ( $this->Classes[$ncount] != '') {
|
* @author Fernando Ontiveros Lira <fernando@colosa.com>
|
||||||
$classname = $this->Classes[$ncount];
|
* @access public
|
||||||
$target = "#";
|
* @param string $strId menu id
|
||||||
}
|
* @param string $strLabel label to show
|
||||||
$idName=$this->Id[$ncount];
|
* @param string $strURL link
|
||||||
|
* @param string $strType type, defualt value ='plugins'
|
||||||
$elementclass = '';
|
* @return void
|
||||||
if($this->ElementClass[$ncount] != ''){
|
*/
|
||||||
$elementclass = 'class="'.$this->ElementClass[$ncount].'"';
|
function AddIdOption ($strId, $strLabel, $strURL, $strType = "plugins")
|
||||||
}
|
{
|
||||||
|
$pos = $this->OptionCount();
|
||||||
$menus[] = array ( 'id' => $ncount, 'target' => $target, 'label' => $label, 'onMenu' => $onMenu, 'classname' => $classname,
|
$this->Options[$pos] = $strURL;
|
||||||
'imageLeft' => $imageLeft, 'onclick' => $onclick,
|
$this->Labels[$pos] = $strLabel;
|
||||||
'icon' => $icon, 'aux' => $aux,'idName' => $idName,'elementclass'=>$elementclass);
|
$this->Types[$pos] = $strType;
|
||||||
}
|
$this->Enabled[$pos] = 1;
|
||||||
|
if (is_array( $strId )) {
|
||||||
|
$this->Id[$pos] = $strId[0];
|
||||||
|
$this->Classes[$pos] = $strId[1];
|
||||||
|
} else {
|
||||||
|
$this->Id[$pos] = $strId;
|
||||||
|
}
|
||||||
|
unset( $pos );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add an option to menu
|
||||||
|
*
|
||||||
|
* @author Fernando Ontiveros Lira <fernando@colosa.com>
|
||||||
|
* @access public
|
||||||
|
* @param string $strURL link
|
||||||
|
* @param string $strType type, defualt value ='plugins'
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
function AddRawOption ($strURL = "", $strType = "plugins")
|
||||||
|
{
|
||||||
|
$pos = $this->OptionCount();
|
||||||
|
$this->Options[$pos] = $strURL;
|
||||||
|
$this->Labels[$pos] = "";
|
||||||
|
$this->Types[$pos] = $strType;
|
||||||
|
$this->Enabled[$pos] = 1;
|
||||||
|
$this->Id[$pos] = $pos;
|
||||||
|
unset( $pos );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add an option to menu by id
|
||||||
|
*
|
||||||
|
* @author Fernando Ontiveros Lira <fernando@colosa.com>
|
||||||
|
* @access public
|
||||||
|
* @param string $strId menu id
|
||||||
|
* @param string $strLabel label to show
|
||||||
|
* @param string $strURL link
|
||||||
|
* @param string $strType type, defualt value ='plugins'
|
||||||
|
* @param string $elementClass default value =''
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
function AddIdRawOption ($strId, $strURL = "", $label = "", $icon = "", $js = "", $strType = "plugins", $elementClass = '')
|
||||||
|
{
|
||||||
|
$pos = $this->OptionCount();
|
||||||
|
$this->Options[$pos] = $strURL;
|
||||||
|
$this->Labels[$pos] = $label;
|
||||||
|
$this->Icons[$pos] = $icon;
|
||||||
|
$this->JS[$pos] = $js;
|
||||||
|
$this->Types[$pos] = $strType;
|
||||||
|
$this->Enabled[$pos] = 1;
|
||||||
|
$this->ElementClass[$pos] = $elementClass;
|
||||||
|
if (is_array( $strId )) {
|
||||||
|
$this->Id[$pos] = $strId[0];
|
||||||
|
$this->Classes[$pos] = $strId[1];
|
||||||
|
} else {
|
||||||
|
$this->Id[$pos] = $strId;
|
||||||
|
}
|
||||||
|
unset( $pos );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Disable an menu option by menu's position
|
||||||
|
*
|
||||||
|
* @author Fernando Ontiveros Lira <fernando@colosa.com>
|
||||||
|
* @access public
|
||||||
|
* @param string $intPos menu option's position
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
function DisableOptionPos ($intPos)
|
||||||
|
{
|
||||||
|
$this->Enabled[$intPos] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Disable an menu's option by id
|
||||||
|
*
|
||||||
|
* @author Fernando Ontiveros Lira <fernando@colosa.com>
|
||||||
|
* @access public
|
||||||
|
* @param string $id menu's id
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
function DisableOptionId ($id)
|
||||||
|
{
|
||||||
|
if (array_search( $id, $this->Id )) {
|
||||||
|
$this->Enabled[array_search( $id, $this->Id )] = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Render an menu's option
|
||||||
|
*
|
||||||
|
* @author Fernando Ontiveros Lira <fernando@colosa.com>
|
||||||
|
* @access public
|
||||||
|
* @param string $intPos menu option's position
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
function RenderOption ($intPos)
|
||||||
|
{
|
||||||
|
if ($this->Enabled[$intPos] != 1) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$classname = $this->Class . "Link";
|
||||||
|
if ($this->Classes[$intPos] != "") {
|
||||||
|
$classname = $this->Classes[$intPos];
|
||||||
|
}
|
||||||
|
$target = $this->Options[$intPos];
|
||||||
|
if ($this->Types[$intPos] != "absolute") {
|
||||||
|
if (defined( 'ENABLE_ENCRYPT' )) {
|
||||||
|
$target = "/sys" . SYS_SYS . "/" . SYS_LANG . "/" . SYS_SKIN . "/" . $target;
|
||||||
|
} else if (defined( 'SYS_SYS' )) {
|
||||||
|
$target = "/sys" . SYS_SYS . "/" . SYS_LANG . "/" . SYS_SKIN . "/" . $target;
|
||||||
|
} else {
|
||||||
|
$target = "/sys/" . SYS_LANG . "/" . SYS_SKIN . "/" . $target;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$label = $this->Labels[$intPos];
|
||||||
|
$result = "<a href=\"$target\"";
|
||||||
|
$result .= " class=\"$classname\">";
|
||||||
|
$result .= htmlentities( $label, ENT_NOQUOTES, 'utf-8' );
|
||||||
|
$result .= "</a>";
|
||||||
|
print ($result) ;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* to make an array for template
|
||||||
|
*
|
||||||
|
* @author Fernando Ontiveros Lira <fernando@colosa.com>
|
||||||
|
* @access public
|
||||||
|
* @param string $G_MAIN_MENU
|
||||||
|
* @param string $classOn
|
||||||
|
* @param string $classOff
|
||||||
|
* @param string $G_MENU_SELECTED
|
||||||
|
* @param string $G_ID_MENU_SELECTED
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
function generateArrayForTemplate ($G_MAIN_MENU, $classOn, $classOff, $G_MENU_SELECTED, $G_ID_MENU_SELECTED)
|
||||||
|
{
|
||||||
|
$menus = array ();
|
||||||
|
if ($G_MAIN_MENU == null) {
|
||||||
|
return $menus;
|
||||||
|
}
|
||||||
|
$this->Load( $G_MAIN_MENU );
|
||||||
|
$this->optionOn = $G_MENU_SELECTED;
|
||||||
|
$this->id_optionOn = $G_ID_MENU_SELECTED;
|
||||||
|
//$this->Class = $G_MENU_CLASS;
|
||||||
|
if (is_array( $this->Options )) {
|
||||||
|
for ($ncount = 0; $ncount < $this->OptionCount(); $ncount ++) {
|
||||||
|
$target = $this->Options[$ncount];
|
||||||
|
|
||||||
|
//$aux = $this->Icons[$ncount];
|
||||||
|
$aux = $this->JS[$ncount];
|
||||||
|
if ($this->Types[$ncount] == 'absolute') {
|
||||||
|
//$target = G::encryptLink(str_replace('sys' . SYS_TEMP, SYS_TEMP, $this->Options[$ncount]));
|
||||||
|
$target = $this->Options[$ncount];
|
||||||
|
}
|
||||||
|
if ($this->Types[$ncount] != 'absolute') {
|
||||||
|
if (defined( 'SYS_SYS' )) {
|
||||||
|
$target = '/sys' . SYS_TEMP . G::encryptLink( '/' . SYS_LANG . '/' . SYS_SKIN . '/' . $this->Options[$ncount] );
|
||||||
|
} else {
|
||||||
|
$target = '/sys/' . G::encryptLink( SYS_LANG . '/' . SYS_SKIN . '/' . $this->Options[$ncount] );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$label = $this->Labels[$ncount];
|
||||||
|
if ($this->id_optionOn != '') {
|
||||||
|
$onMenu = ($this->Id[$ncount] == $this->id_optionOn ? true : false);
|
||||||
|
} else {
|
||||||
|
$onMenu = ($ncount == $this->optionOn ? true : false);
|
||||||
|
}
|
||||||
|
$classname = ($onMenu ? $classOn : $classOff);
|
||||||
|
$imageLeft = ($onMenu ? "<img src=\"/images/bulletSubMenu.jpg\" />" : '');
|
||||||
|
$onclick = '';
|
||||||
|
if ($this->JS[$ncount] !== '') {
|
||||||
|
$onclick = " onclick=\"" . $this->JS[$ncount] . "\"";
|
||||||
|
}
|
||||||
|
$icon = '';
|
||||||
|
if ($this->Icons[$ncount] !== '') {
|
||||||
|
$icon = " <a href=\"#\" onclick=\"" . $this->JS[$ncount] . "\" class=\"$classname\">" . "<img src=\"" . $this->Icons[$ncount] . "\" border=\"0\"/></a>";
|
||||||
|
$icon = $this->Icons[$ncount];
|
||||||
|
}
|
||||||
|
if ($this->Classes[$ncount] != '') {
|
||||||
|
$classname = $this->Classes[$ncount];
|
||||||
|
$target = "#";
|
||||||
|
}
|
||||||
|
$idName = $this->Id[$ncount];
|
||||||
|
|
||||||
|
$elementclass = '';
|
||||||
|
if ($this->ElementClass[$ncount] != '') {
|
||||||
|
$elementclass = 'class="' . $this->ElementClass[$ncount] . '"';
|
||||||
|
}
|
||||||
|
|
||||||
|
$menus[] = array ('id' => $ncount,'target' => $target,'label' => $label,'onMenu' => $onMenu,'classname' => $classname,'imageLeft' => $imageLeft,'onclick' => $onclick,'icon' => $icon,'aux' => $aux,'idName' => $idName,'elementclass' => $elementclass
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
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
|
||||||
@@ -13,11 +15,11 @@
|
|||||||
*
|
*
|
||||||
* 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
|
||||||
* GNU Affero General Public License for more details.
|
* GNU Affero General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU Affero General Public License
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*
|
*
|
||||||
* For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
|
* For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
|
||||||
* Coral Gables, FL, 33134, USA, or email info@colosa.com.
|
* Coral Gables, FL, 33134, USA, or email info@colosa.com.
|
||||||
@@ -26,38 +28,43 @@
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Class objectTemplate
|
* Class objectTemplate
|
||||||
|
*
|
||||||
* @package gulliver.system
|
* @package gulliver.system
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
|
|
||||||
class objectTemplate extends smarty
|
class objectTemplate extends smarty
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* Function objectTemplate
|
|
||||||
* @access public
|
|
||||||
* @param object $templateFile
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
|
|
||||||
function objectTemplate( $templateFile )
|
/**
|
||||||
{
|
* Function objectTemplate
|
||||||
$this->template_dir = PATH_TPL;
|
*
|
||||||
$this->compile_dir = PATH_SMARTY_C;
|
* @access public
|
||||||
$this->cache_dir = PATH_SMARTY_CACHE;
|
* @param object $templateFile
|
||||||
$this->config_dir = PATH_THIRDPARTY . 'smarty/configs';
|
* @return void
|
||||||
$this->caching = false;
|
*/
|
||||||
$this->templateFile = $templateFile;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
function objectTemplate ($templateFile)
|
||||||
* Function printObject
|
{
|
||||||
* @access public
|
$this->template_dir = PATH_TPL;
|
||||||
* @param object $object
|
$this->compile_dir = PATH_SMARTY_C;
|
||||||
* @return string
|
$this->cache_dir = PATH_SMARTY_CACHE;
|
||||||
*/
|
$this->config_dir = PATH_THIRDPARTY . 'smarty/configs';
|
||||||
function printObject($object)
|
$this->caching = false;
|
||||||
{
|
$this->templateFile = $templateFile;
|
||||||
$this->assign($object);
|
}
|
||||||
return $this->fetch($this->templateFile);
|
|
||||||
}
|
/**
|
||||||
|
* Function printObject
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
* @param object $object
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
function printObject ($object)
|
||||||
|
{
|
||||||
|
$this->assign( $object );
|
||||||
|
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
|
||||||
@@ -14,173 +15,185 @@
|
|||||||
*
|
*
|
||||||
* 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
|
||||||
* GNU Affero General Public License for more details.
|
* GNU Affero General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU Affero General Public License
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*
|
*
|
||||||
* For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
|
* For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
|
||||||
* Coral Gables, FL, 33134, USA, or email info@colosa.com.
|
* Coral Gables, FL, 33134, USA, or email info@colosa.com.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
*
|
||||||
* @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
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* importDB
|
* importDB
|
||||||
*
|
*
|
||||||
* @param string $host
|
* @param string $host
|
||||||
* @param string $user
|
* @param string $user
|
||||||
* @param string $password
|
* @param string $password
|
||||||
* @param string $database
|
* @param string $database
|
||||||
* @param string $importFile
|
* @param string $importFile
|
||||||
*
|
*
|
||||||
* @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" );
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* importLocalDB
|
|
||||||
*
|
|
||||||
* @param string $importFile
|
|
||||||
*
|
|
||||||
* @return none
|
|
||||||
*/
|
|
||||||
function importLocalDB( $importFile )
|
|
||||||
{
|
|
||||||
self::importDB( DB_HOST, DB_USER, DB_PASS, DB_NAME, $importFile );
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* callMethod
|
|
||||||
*
|
|
||||||
* @param string $methodFile
|
|
||||||
* @param string $GET
|
|
||||||
* @param string $POST
|
|
||||||
* @param string $SESSION
|
|
||||||
*
|
|
||||||
* @return none
|
|
||||||
*/
|
|
||||||
function callMethod( $methodFile, $GET, $POST, $SESSION )
|
|
||||||
{
|
|
||||||
//TODO $_SERVER
|
|
||||||
self::arrayDelete($_GET);
|
|
||||||
self::arrayDelete($_POST);
|
|
||||||
self::arrayDelete($_SESSION);
|
|
||||||
self::arrayAppend($_GET,$GET);
|
|
||||||
self::arrayAppend($_POST,$POST);
|
|
||||||
self::arrayAppend($_SESSION,$SESSION);
|
|
||||||
include( PATH_CORE . 'methods/' . $methodFile );
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* arrayAppend
|
|
||||||
*
|
|
||||||
* @param string &$to
|
|
||||||
* @param string $appendFrom
|
|
||||||
*
|
|
||||||
* @return boolean true
|
|
||||||
*/
|
|
||||||
function arrayAppend( &$to , $appendFrom )
|
|
||||||
{
|
|
||||||
foreach($appendFrom as $appendItem) $to[]=$appendItem;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* arrayDelete
|
|
||||||
*
|
|
||||||
* @param array &$array
|
|
||||||
*
|
|
||||||
* @return boolean true
|
|
||||||
*/
|
|
||||||
function arrayDelete( &$array )
|
|
||||||
{
|
|
||||||
foreach($array as $key => $value) unset($array[$key]);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* replaceVariables
|
|
||||||
*
|
|
||||||
* @param string $Fields
|
|
||||||
* @param array $ExternalVariables
|
|
||||||
*
|
|
||||||
* @return array $Fields
|
|
||||||
*/
|
|
||||||
//@@
|
|
||||||
function replaceVariables( $Fields, $ExternalVariables = array() )
|
|
||||||
{
|
|
||||||
//TODO: Verify dependencies between fields
|
|
||||||
foreach($Fields as $key => $field) {
|
|
||||||
if (is_string($field)) {
|
|
||||||
$mergedValues = G::array_merges( $Fields, $ExternalVariables );
|
|
||||||
$Fields[$key] = G::ReplaceDataField( $field, $mergedValues );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return $Fields;
|
|
||||||
}
|
|
||||||
|
|
||||||
// EXTRA TOOLS
|
/**
|
||||||
/**
|
* importLocalDB
|
||||||
* findValue
|
*
|
||||||
*
|
* @param string $importFile
|
||||||
* @param string $value
|
*
|
||||||
* @param object &$obj
|
* @return none
|
||||||
*
|
*/
|
||||||
* @return (boolean | string) ((true | false) | $value)
|
function importLocalDB ($importFile)
|
||||||
*/
|
{
|
||||||
function findValue( $value, &$obj )
|
self::importDB( DB_HOST, DB_USER, DB_PASS, DB_NAME, $importFile );
|
||||||
{
|
}
|
||||||
if (is_array($obj)) {
|
|
||||||
foreach($obj as $key => $val ) {
|
/**
|
||||||
if ($res=self::findValue( $value , $obj[$key] )) {
|
* callMethod
|
||||||
if ($res==true) return $key;
|
*
|
||||||
else return $key . '.' . $res;
|
* @param string $methodFile
|
||||||
|
* @param string $GET
|
||||||
|
* @param string $POST
|
||||||
|
* @param string $SESSION
|
||||||
|
*
|
||||||
|
* @return none
|
||||||
|
*/
|
||||||
|
function callMethod ($methodFile, $GET, $POST, $SESSION)
|
||||||
|
{
|
||||||
|
//TODO $_SERVER
|
||||||
|
self::arrayDelete( $_GET );
|
||||||
|
self::arrayDelete( $_POST );
|
||||||
|
self::arrayDelete( $_SESSION );
|
||||||
|
self::arrayAppend( $_GET, $GET );
|
||||||
|
self::arrayAppend( $_POST, $POST );
|
||||||
|
self::arrayAppend( $_SESSION, $SESSION );
|
||||||
|
include (PATH_CORE . 'methods/' . $methodFile);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* arrayAppend
|
||||||
|
*
|
||||||
|
* @param string &$to
|
||||||
|
* @param string $appendFrom
|
||||||
|
*
|
||||||
|
* @return boolean true
|
||||||
|
*/
|
||||||
|
function arrayAppend (&$to, $appendFrom)
|
||||||
|
{
|
||||||
|
foreach ($appendFrom as $appendItem) {
|
||||||
|
$to[] = $appendItem;
|
||||||
}
|
}
|
||||||
}
|
return true;
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
elseif (is_object($obj)) {
|
|
||||||
foreach($obj as $key => $val ) {
|
/**
|
||||||
if ($res=self::findValue( $value , $obj->$key )) {
|
* arrayDelete
|
||||||
if ($res==true)
|
*
|
||||||
return $key;
|
* @param array &$array
|
||||||
else
|
*
|
||||||
return $key . '.' . $res;
|
* @return boolean true
|
||||||
|
*/
|
||||||
|
function arrayDelete (&$array)
|
||||||
|
{
|
||||||
|
foreach ($array as $key => $value) {
|
||||||
|
unset( $array[$key] );
|
||||||
}
|
}
|
||||||
}
|
return true;
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
return $obj==$value;
|
/**
|
||||||
|
* replaceVariables
|
||||||
|
*
|
||||||
|
* @param string $Fields
|
||||||
|
* @param array $ExternalVariables
|
||||||
|
*
|
||||||
|
* @return array $Fields
|
||||||
|
*/
|
||||||
|
//@@
|
||||||
|
function replaceVariables ($Fields, $ExternalVariables = array())
|
||||||
|
{
|
||||||
|
//TODO: Verify dependencies between fields
|
||||||
|
foreach ($Fields as $key => $field) {
|
||||||
|
if (is_string( $field )) {
|
||||||
|
$mergedValues = G::array_merges( $Fields, $ExternalVariables );
|
||||||
|
$Fields[$key] = G::ReplaceDataField( $field, $mergedValues );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $Fields;
|
||||||
|
}
|
||||||
|
|
||||||
|
// EXTRA TOOLS
|
||||||
|
/**
|
||||||
|
* findValue
|
||||||
|
*
|
||||||
|
* @param string $value
|
||||||
|
* @param object &$obj
|
||||||
|
*
|
||||||
|
* @return (boolean | string) ((true | false) | $value)
|
||||||
|
*/
|
||||||
|
function findValue ($value, &$obj)
|
||||||
|
{
|
||||||
|
if (is_array( $obj )) {
|
||||||
|
foreach ($obj as $key => $val) {
|
||||||
|
if ($res = self::findValue( $value, $obj[$key] )) {
|
||||||
|
if ($res == true) {
|
||||||
|
return $key;
|
||||||
|
} else {
|
||||||
|
return $key . '.' . $res;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
} elseif (is_object( $obj )) {
|
||||||
|
foreach ($obj as $key => $val) {
|
||||||
|
if ($res = self::findValue( $value, $obj->$key )) {
|
||||||
|
if ($res == true) {
|
||||||
|
return $key;
|
||||||
|
} else {
|
||||||
|
return $key . '.' . $res;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
return $obj == $value;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Some extra global functions */
|
/* Some extra global functions */
|
||||||
/**
|
/**
|
||||||
* domain
|
* domain
|
||||||
*
|
*
|
||||||
* @param string $location *
|
* @param string $location *
|
||||||
* @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) {
|
||||||
return $result;
|
trigger_error( "'$location' is an empty domain.", E_USER_WARNING );
|
||||||
|
}
|
||||||
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,92 +1,97 @@
|
|||||||
<?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
|
||||||
* GNU Affero General Public License for more details.
|
* GNU Affero General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU Affero General Public License
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*
|
*
|
||||||
* For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
|
* For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
|
||||||
* Coral Gables, FL, 33134, USA, or email info@colosa.com.
|
* Coral Gables, FL, 33134, USA, or email info@colosa.com.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
*
|
||||||
* @package gulliver.system
|
* @package gulliver.system
|
||||||
*/
|
*/
|
||||||
G::LoadSystem('objectTemplate');
|
G::LoadSystem( 'objectTemplate' );
|
||||||
class Tree extends Xml_Node {
|
|
||||||
var $template = 'tree.html';
|
class Tree extends Xml_Node
|
||||||
var $nodeType = 'base';
|
{
|
||||||
var $nodeClass = 'treeNode';
|
var $template = 'tree.html';
|
||||||
|
var $nodeType = 'base';
|
||||||
|
var $nodeClass = 'treeNode';
|
||||||
var $contentClass = 'treeContent';
|
var $contentClass = 'treeContent';
|
||||||
var $width = '100%';
|
var $width = '100%';
|
||||||
var $contentWidth = '360';
|
var $contentWidth = '360';
|
||||||
var $contracted = false;
|
var $contracted = false;
|
||||||
var $showSign = true;
|
var $showSign = true;
|
||||||
var $isChild = false;
|
var $isChild = false;
|
||||||
var $plus = "<span style='position:absolute; width:16px;height:22px;cursor:pointer;'onclick='tree.expand(this.parentNode);'> </span>";
|
var $plus = "<span style='position:absolute; width:16px;height:22px;cursor:pointer;'onclick='tree.expand(this.parentNode);'> </span>";
|
||||||
var $minus = "<span style='position:absolute; width:16px;height:22px;cursor:pointer' onclick='tree.contract(this.parentNode);'> </span>";
|
var $minus = "<span style='position:absolute; width:16px;height:22px;cursor:pointer' onclick='tree.contract(this.parentNode);'> </span>";
|
||||||
var $point = "<span style='position:absolute; width:5px;height:10px;cursor:pointer;' onclick='tree.select(this.parentNode);'> </span>";
|
var $point = "<span style='position:absolute; width:5px;height:10px;cursor:pointer;' onclick='tree.select(this.parentNode);'> </span>";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tree
|
* Tree
|
||||||
*
|
*
|
||||||
* @param array $xmlnode default value NULL
|
* @param array $xmlnode default value NULL
|
||||||
*
|
*
|
||||||
* @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') {
|
|
||||||
foreach( $xmlnode->attributes as $key => $value ) {
|
|
||||||
$this->{$key} = $value;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else {
|
if (isset( $xmlnode->attributes['nodeType'] )) {
|
||||||
$this->{$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;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$this->{$key} = $value;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* &addChild
|
* &addChild
|
||||||
*
|
*
|
||||||
* @param string $name
|
* @param string $name
|
||||||
* @param string $label
|
* @param string $label
|
||||||
* @param array $attributes
|
* @param array $attributes
|
||||||
*
|
*
|
||||||
* @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>" . "<span class='treeMinus' name='minus' style='display:$minus'>{$this->minus}</span>" . "<span class='treePointer' name='point' style='display:$point'>{$this->point}</span>";
|
||||||
return "<span class='treePlus' name='plus' style='display:$plus;'>{$this->plus}</span>".
|
|
||||||
"<span class='treeMinus' name='minus' style='display:$minus'>{$this->minus}</span>".
|
|
||||||
"<span class='treePointer' name='point' style='display:$point'>{$this->point}</span>";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -118,9 +121,9 @@
|
|||||||
*
|
*
|
||||||
* @return $this->value
|
* @return $this->value
|
||||||
*/
|
*/
|
||||||
function printLabel()
|
function printLabel ()
|
||||||
{
|
{
|
||||||
return $this->value;
|
return $this->value;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -128,26 +131,30 @@
|
|||||||
*
|
*
|
||||||
* @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();
|
}
|
||||||
$row = ($row + 1) % 2;
|
$html .= $child->render();
|
||||||
}
|
$row = ($row + 1) % 2;
|
||||||
return $html;
|
}
|
||||||
|
return $html;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* render
|
* render
|
||||||
|
*
|
||||||
* @return $obj->printObject( array( 'node' => &$this ) )
|
* @return $obj->printObject( array( 'node' => &$this ) )
|
||||||
*/
|
*/
|
||||||
function render() {
|
function render ()
|
||||||
$obj = new objectTemplate( $this->template );
|
{
|
||||||
return $obj->printObject( array( 'node' => &$this ) );
|
$obj = new objectTemplate( $this->template );
|
||||||
|
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
|
||||||
@@ -14,59 +16,64 @@
|
|||||||
*
|
*
|
||||||
* 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
|
||||||
* GNU Affero General Public License for more details.
|
* GNU Affero General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU Affero General Public License
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*
|
*
|
||||||
* For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
|
* For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
|
||||||
* Coral Gables, FL, 33134, USA, or email info@colosa.com.
|
* Coral Gables, FL, 33134, USA, or email info@colosa.com.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @package gulliver.system
|
*
|
||||||
*/
|
* @package gulliver.system
|
||||||
|
*/
|
||||||
|
|
||||||
class unitTest
|
class unitTest
|
||||||
{
|
{
|
||||||
var $dbc;
|
var $dbc;
|
||||||
var $times;
|
var $times;
|
||||||
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();
|
{
|
||||||
$this->domain =& $testDomain;
|
if (! isset( $testDomain )) {
|
||||||
$this->testLime =& $testLime;
|
$testDomain = new ymlDomain();
|
||||||
$this->yml = new ymlTestCases( $ymlFile, $this->domain, $this->testLime );
|
}
|
||||||
}
|
$this->domain = & $testDomain;
|
||||||
//Load a Test (group of unitary tests) defined in the Yml file.
|
$this->testLime = & $testLime;
|
||||||
function load( $testName, $fields=array() )
|
$this->yml = new ymlTestCases( $ymlFile, $this->domain, $this->testLime );
|
||||||
{
|
}
|
||||||
$this->yml->load( $testName, $fields );
|
//Load a Test (group of unitary tests) defined in the Yml file.
|
||||||
}
|
function load ($testName, $fields = array())
|
||||||
//Run one single unit test from the loaded Test
|
{
|
||||||
function runSingle( $fields=array() )
|
$this->yml->load( $testName, $fields );
|
||||||
{
|
}
|
||||||
return $this->yml->runSingle( $this, $fields );
|
//Run one single unit test from the loaded Test
|
||||||
}
|
function runSingle ($fields = array())
|
||||||
//Run a group of unit tests from the loaded Test
|
{
|
||||||
function runMultiple( $fields=array(), $count = -1, $start=0)
|
return $this->yml->runSingle( $this, $fields );
|
||||||
{
|
}
|
||||||
return $this->yml->runMultiple( $this, $fields, $count, $start );
|
//Run a group of unit tests from the loaded Test
|
||||||
}
|
function runMultiple ($fields = array(), $count = -1, $start = 0)
|
||||||
//Run all the unit tests from the loaded Test
|
{
|
||||||
function runAll( $fields=array())
|
return $this->yml->runMultiple( $this, $fields, $count, $start );
|
||||||
{
|
}
|
||||||
return $this->yml->runMultiple( $this, $fields, -1, 0 );
|
//Run all the unit tests from the loaded Test
|
||||||
}
|
function runAll ($fields = array())
|
||||||
//A sample of "Function" to run a unit test.
|
{
|
||||||
function sampleTestFunction( $testCase , &$Fields )
|
return $this->yml->runMultiple( $this, $fields, - 1, 0 );
|
||||||
{
|
}
|
||||||
$result = ($Fields['APP_UID']!='')?"OK":"FALSE";
|
//A sample of "Function" to run a unit test.
|
||||||
return $result;
|
function sampleTestFunction ($testCase, &$Fields)
|
||||||
}
|
{
|
||||||
|
$result = ($Fields['APP_UID'] != '') ? "OK" : "FALSE";
|
||||||
|
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
|
||||||
@@ -13,11 +15,11 @@
|
|||||||
*
|
*
|
||||||
* 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
|
||||||
* GNU Affero General Public License for more details.
|
* GNU Affero General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU Affero General Public License
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*
|
*
|
||||||
* For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
|
* For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
|
||||||
* Coral Gables, FL, 33134, USA, or email info@colosa.com.
|
* Coral Gables, FL, 33134, USA, or email info@colosa.com.
|
||||||
@@ -32,100 +34,98 @@
|
|||||||
* @dependencies: grest.js *
|
* @dependencies: grest.js *
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
*
|
||||||
* @package gulliver.system
|
* @package gulliver.system
|
||||||
*/
|
*/
|
||||||
class WebResource
|
class WebResource
|
||||||
{
|
{
|
||||||
var $_uri;
|
var $_uri;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* WebResource
|
* WebResource
|
||||||
*
|
*
|
||||||
* @param string $uri
|
* @param string $uri
|
||||||
* @param string $post
|
* @param string $post
|
||||||
*
|
*
|
||||||
* @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);
|
$res = eval( 'return ($this->' . $post['function'] . '(' . implode( ',', $paramsRef ) . '));' );
|
||||||
|
$res = G::json_encode( $res );
|
||||||
|
print ($res) ;
|
||||||
|
} else {
|
||||||
|
/*Print class definition*/
|
||||||
|
$this->_encode();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
/*Print class definition*/
|
|
||||||
$this->_encode();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* _encode
|
* _encode
|
||||||
*
|
*
|
||||||
* @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 (',') ;
|
||||||
{
|
}
|
||||||
}
|
$this->{$method}();
|
||||||
elseif (strcasecmp(substr($method,0,3),'js_')==0)
|
$first = false;
|
||||||
{
|
} else {
|
||||||
if (!$first) print(',');
|
if (! $first) {
|
||||||
$this->{$method}();
|
print (',') ;
|
||||||
$first=false;
|
}
|
||||||
}
|
print ($method . ':function(){return __wrCall("' . addslashes( $this->_uri ) . '","' . $method . '",arguments);}') ;
|
||||||
else
|
$first = false;
|
||||||
{
|
}
|
||||||
if (!$first) print(',');
|
}
|
||||||
print(
|
print ('}') ;
|
||||||
$method.
|
|
||||||
':function(){return __wrCall("'.
|
|
||||||
addslashes($this->_uri).
|
|
||||||
'","'.$method.'",arguments);}'
|
|
||||||
);
|
|
||||||
$first=false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
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
|
||||||
@@ -13,11 +15,11 @@
|
|||||||
*
|
*
|
||||||
* 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
|
||||||
* GNU Affero General Public License for more details.
|
* GNU Affero General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU Affero General Public License
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*
|
*
|
||||||
* For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
|
* For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
|
||||||
* Coral Gables, FL, 33134, USA, or email info@colosa.com.
|
* Coral Gables, FL, 33134, USA, or email info@colosa.com.
|
||||||
@@ -25,340 +27,355 @@
|
|||||||
*/
|
*/
|
||||||
/**
|
/**
|
||||||
* 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
|
||||||
*/
|
*/
|
||||||
class Xml_Node
|
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
|
/**
|
||||||
* @author David S. Callizaya S. <davidsantos@colosa.com>
|
* Function Xml_Node
|
||||||
* @access public
|
*
|
||||||
* @parameter string name
|
* @author David S. Callizaya S. <davidsantos@colosa.com>
|
||||||
* @parameter string type
|
* @access public
|
||||||
* @parameter string value
|
* @param eter string name
|
||||||
* @parameter string attributes
|
* @param eter string type
|
||||||
* @return string
|
* @param eter string value
|
||||||
*/
|
* @param eter string attributes
|
||||||
function Xml_Node($name, $type, $value, $attributes = array() )
|
* @return string
|
||||||
{
|
*/
|
||||||
$this->name = $name;
|
function Xml_Node ($name, $type, $value, $attributes = array())
|
||||||
$this->type = $type;
|
|
||||||
$this->value = $value;
|
|
||||||
$this->attributes = $attributes;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Function addAttribute
|
|
||||||
* @author David S. Callizaya S. <davidsantos@colosa.com>
|
|
||||||
* @access public
|
|
||||||
* @parameter string name
|
|
||||||
* @parameter string value
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
function addAttribute( $name, $value )
|
|
||||||
{
|
|
||||||
$this->attributes[$name] = $value;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Function addChildNode
|
|
||||||
* @author David S. Callizaya S. <davidsantos@colosa.com>
|
|
||||||
* @access public
|
|
||||||
* @parameter string childNode
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
function addChildNode( $childNode )
|
|
||||||
{
|
|
||||||
if (is_object($childNode) && strcasecmp( get_class($childNode), 'Xml_Node' ) == 0 ) {
|
|
||||||
$this->type = 'open';
|
|
||||||
$childNode->parent = &$this;
|
|
||||||
$this->children[] = &$childNode;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Function toTree
|
|
||||||
* @author David S. Callizaya S. <davidsantos@colosa.com>
|
|
||||||
* @access public
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
function toTree()
|
|
||||||
{
|
|
||||||
$arr = new Xml_Node( $this->name, $this->type, $this->value, $this->attributes );
|
|
||||||
unset( $arr->parent );
|
|
||||||
foreach($this->children as $k => $v) {
|
|
||||||
unset($v->parent);
|
|
||||||
$arr->children[$k]=$v->toTree();
|
|
||||||
}
|
|
||||||
return $arr;
|
|
||||||
}
|
|
||||||
function toArray( $obj = NULL ) {
|
|
||||||
$arr = array();
|
|
||||||
if ( !isset($obj) ) $obj = $this->toTree();
|
|
||||||
foreach($obj as $att => $val ) {
|
|
||||||
if (is_array($val) || is_object($val) ) {
|
|
||||||
$arr[$att] = Xml_Node::toArray($val);
|
|
||||||
} else {
|
|
||||||
$arr[$att] = $val;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return $arr;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Function &findNode
|
|
||||||
* @author David S. Callizaya S. <davidsantos@colosa.com>
|
|
||||||
* @access public
|
|
||||||
* @parameter string xpath
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
function &findNode( $xpath )
|
|
||||||
{
|
|
||||||
$n = NULL;
|
|
||||||
$p = explode('/', $xpath);
|
|
||||||
if ( $p[0] === '') {
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
elseif ( substr($p[0],0 , 1) === '@') {
|
|
||||||
$p[0] = substr($p[0], 1 );
|
|
||||||
if ( isset($this->attributes[$p[0]])) return $this->attributes[$p[0]];
|
|
||||||
}
|
|
||||||
elseif ($p[0] === '..' ) {
|
|
||||||
array_shift($p);
|
|
||||||
$n = & $this->parent->findNode ( implode('/',$p) );
|
|
||||||
if (isset($n) ) return $n;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
foreach( $this->children as $k => $v) {
|
|
||||||
if ( ($v->type!=='cdata')&&($v->name===$p[0])) {
|
|
||||||
if (sizeof($p)>1) {
|
|
||||||
array_shift($p);
|
|
||||||
$n=& $this->children[$k]->findNode(implode('/',$p));
|
|
||||||
if (isset($n)) return $n;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
return $this->children[$k];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return $n;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Function getXML
|
|
||||||
* Returns a string of the node in XML notation.
|
|
||||||
* @author David S. Callizaya S. <davidsantos@colosa.com>
|
|
||||||
* @access public
|
|
||||||
* @parameter string xpath
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
function getXML()
|
|
||||||
{
|
|
||||||
switch($this->type)
|
|
||||||
{
|
{
|
||||||
case 'open':
|
$this->name = $name;
|
||||||
$xml = '<'.$this->name;
|
$this->type = $type;
|
||||||
foreach( $this->attributes as $attib => $value ) {
|
$this->value = $value;
|
||||||
$value = htmlspecialchars( $value, ENT_QUOTES, 'utf-8' );
|
$this->attributes = $attributes;
|
||||||
/*if(($attib == "hint")||($attib == "defaultvalue")){
|
}
|
||||||
$value = str_replace("&", "&", $value);
|
|
||||||
$value = str_replace("'", "\'", $value);
|
/**
|
||||||
$value = str_replace(">", ">", $value);
|
* Function addAttribute
|
||||||
$value = str_replace("<", "<", $value);
|
*
|
||||||
}
|
* @author David S. Callizaya S. <davidsantos@colosa.com>
|
||||||
//else{
|
* @access public
|
||||||
$value = htmlentities( $value, ENT_QUOTES, 'utf-8' );
|
* @param eter string name
|
||||||
//}
|
* @param eter string value
|
||||||
*/
|
* @return string
|
||||||
$xml .= ' ' . $attib . '="' . $value . '"';
|
*/
|
||||||
//check if the htmlentities result value is the euro symbol and
|
function addAttribute ($name, $value)
|
||||||
//replaced by their numeric character representation
|
{
|
||||||
if (strpos($xml, '€') !== false) {
|
$this->attributes[$name] = $value;
|
||||||
$xml = str_replace('€', '€', $xml);
|
return true;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
$xml .= '>'.$this->getCDATAValue();
|
/**
|
||||||
foreach( $this->children as $child )
|
* Function addChildNode
|
||||||
$xml .= $child->getXML();
|
*
|
||||||
$xml .= '</'.$this->name.'>';
|
* @author David S. Callizaya S. <davidsantos@colosa.com>
|
||||||
break;
|
* @access public
|
||||||
|
* @param eter string childNode
|
||||||
case 'close':
|
* @return string
|
||||||
$xml = '</'.$this->name.'>';
|
*/
|
||||||
break;
|
function addChildNode ($childNode)
|
||||||
|
{
|
||||||
case 'cdata':
|
if (is_object( $childNode ) && strcasecmp( get_class( $childNode ), 'Xml_Node' ) == 0) {
|
||||||
$xml = $this->getCDATAValue();
|
$this->type = 'open';
|
||||||
break;
|
$childNode->parent = &$this;
|
||||||
|
$this->children[] = &$childNode;
|
||||||
case 'complete':
|
return true;
|
||||||
|
} else {
|
||||||
$xml = '<'.$this->name;
|
return false;
|
||||||
foreach( $this->attributes as $attib => $value ) {
|
}
|
||||||
$xml .= ' ' . $attib . '="' . htmlentities($value, ENT_QUOTES, 'utf-8' ) . '"';
|
}
|
||||||
//check if the htmlentities result value is the euro symbol and
|
|
||||||
//replaced by their numeric character representation
|
/**
|
||||||
if (strpos($xml, '€') !== false) {
|
* Function toTree
|
||||||
$xml = str_replace('€', '€', $xml);
|
*
|
||||||
}
|
* @author David S. Callizaya S. <davidsantos@colosa.com>
|
||||||
}
|
* @access public
|
||||||
if ($this->value!=='') {
|
* @return string
|
||||||
$xml .= '>'.$this->getCDATAValue();
|
*/
|
||||||
$xml .= '</'.$this->name.'>';
|
function toTree ()
|
||||||
} else {
|
{
|
||||||
$xml .= '/>';
|
$arr = new Xml_Node( $this->name, $this->type, $this->value, $this->attributes );
|
||||||
}
|
unset( $arr->parent );
|
||||||
break;
|
foreach ($this->children as $k => $v) {
|
||||||
|
unset( $v->parent );
|
||||||
|
$arr->children[$k] = $v->toTree();
|
||||||
|
}
|
||||||
|
return $arr;
|
||||||
|
}
|
||||||
|
|
||||||
|
function toArray ($obj = null)
|
||||||
|
{
|
||||||
|
$arr = array ();
|
||||||
|
if (! isset( $obj )) {
|
||||||
|
$obj = $this->toTree();
|
||||||
|
}
|
||||||
|
foreach ($obj as $att => $val) {
|
||||||
|
if (is_array( $val ) || is_object( $val )) {
|
||||||
|
$arr[$att] = Xml_Node::toArray( $val );
|
||||||
|
} else {
|
||||||
|
$arr[$att] = $val;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $arr;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function &findNode
|
||||||
|
*
|
||||||
|
* @author David S. Callizaya S. <davidsantos@colosa.com>
|
||||||
|
* @access public
|
||||||
|
* @param eter string xpath
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
function &findNode ($xpath)
|
||||||
|
{
|
||||||
|
$n = null;
|
||||||
|
$p = explode( '/', $xpath );
|
||||||
|
if ($p[0] === '') {
|
||||||
|
return $this;
|
||||||
|
} elseif (substr( $p[0], 0, 1 ) === '@') {
|
||||||
|
$p[0] = substr( $p[0], 1 );
|
||||||
|
if (isset( $this->attributes[$p[0]] )) {
|
||||||
|
return $this->attributes[$p[0]];
|
||||||
|
}
|
||||||
|
} elseif ($p[0] === '..') {
|
||||||
|
array_shift( $p );
|
||||||
|
$n = & $this->parent->findNode( implode( '/', $p ) );
|
||||||
|
if (isset( $n )) {
|
||||||
|
return $n;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
foreach ($this->children as $k => $v) {
|
||||||
|
if (($v->type !== 'cdata') && ($v->name === $p[0])) {
|
||||||
|
if (sizeof( $p ) > 1) {
|
||||||
|
array_shift( $p );
|
||||||
|
$n = & $this->children[$k]->findNode( implode( '/', $p ) );
|
||||||
|
if (isset( $n )) {
|
||||||
|
return $n;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return $this->children[$k];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $n;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function getXML
|
||||||
|
* Returns a string of the node in XML notation.
|
||||||
|
*
|
||||||
|
* @author David S. Callizaya S. <davidsantos@colosa.com>
|
||||||
|
* @access public
|
||||||
|
* @param eter string xpath
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
function getXML ()
|
||||||
|
{
|
||||||
|
switch ($this->type) {
|
||||||
|
case 'open':
|
||||||
|
$xml = '<' . $this->name;
|
||||||
|
foreach ($this->attributes as $attib => $value) {
|
||||||
|
$value = htmlspecialchars( $value, ENT_QUOTES, 'utf-8' );
|
||||||
|
/*if(($attib == "hint")||($attib == "defaultvalue")){
|
||||||
|
$value = str_replace("&", "&", $value);
|
||||||
|
$value = str_replace("'", "\'", $value);
|
||||||
|
$value = str_replace(">", ">", $value);
|
||||||
|
$value = str_replace("<", "<", $value);
|
||||||
|
}
|
||||||
|
//else{
|
||||||
|
$value = htmlentities( $value, ENT_QUOTES, 'utf-8' );
|
||||||
|
//}
|
||||||
|
*/
|
||||||
|
$xml .= ' ' . $attib . '="' . $value . '"';
|
||||||
|
//check if the htmlentities result value is the euro symbol and
|
||||||
|
//replaced by their numeric character representation
|
||||||
|
if (strpos( $xml, '€' ) !== false) {
|
||||||
|
$xml = str_replace( '€', '€', $xml );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$xml .= '>' . $this->getCDATAValue();
|
||||||
|
foreach ($this->children as $child) {
|
||||||
|
$xml .= $child->getXML();
|
||||||
|
}
|
||||||
|
$xml .= '</' . $this->name . '>';
|
||||||
|
break;
|
||||||
|
case 'close':
|
||||||
|
$xml = '</' . $this->name . '>';
|
||||||
|
break;
|
||||||
|
case 'cdata':
|
||||||
|
$xml = $this->getCDATAValue();
|
||||||
|
break;
|
||||||
|
case 'complete':
|
||||||
|
$xml = '<' . $this->name;
|
||||||
|
foreach ($this->attributes as $attib => $value) {
|
||||||
|
$xml .= ' ' . $attib . '="' . htmlentities( $value, ENT_QUOTES, 'utf-8' ) . '"';
|
||||||
|
//check if the htmlentities result value is the euro symbol and
|
||||||
|
//replaced by their numeric character representation
|
||||||
|
if (strpos( $xml, '€' ) !== false) {
|
||||||
|
$xml = str_replace( '€', '€', $xml );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ($this->value !== '') {
|
||||||
|
$xml .= '>' . $this->getCDATAValue();
|
||||||
|
$xml .= '</' . $this->name . '>';
|
||||||
|
} else {
|
||||||
|
$xml .= '/>';
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return $xml;
|
||||||
|
}
|
||||||
|
|
||||||
|
function getCDATAValue ()
|
||||||
|
{
|
||||||
|
$cdata = htmlentities( $this->value, ENT_QUOTES, 'utf-8' );
|
||||||
|
if ($this->value === $cdata) {
|
||||||
|
return $this->value;
|
||||||
|
} else {
|
||||||
|
return '<![CDATA[' . $this->value . ']]>';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return $xml;
|
|
||||||
}
|
|
||||||
function getCDATAValue()
|
|
||||||
{
|
|
||||||
$cdata = htmlentities( $this->value, ENT_QUOTES, 'utf-8' );
|
|
||||||
if ($this->value === $cdata)
|
|
||||||
return $this->value;
|
|
||||||
else
|
|
||||||
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
|
||||||
*/
|
*/
|
||||||
class Xml_document extends Xml_Node
|
class Xml_document extends Xml_Node
|
||||||
{
|
{
|
||||||
var $currentNode;
|
var $currentNode;
|
||||||
/**
|
|
||||||
* Function Xml_document
|
|
||||||
* @author David S. Callizaya S. <davidsantos@colosa.com>
|
|
||||||
* @access public
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
function Xml_document()
|
|
||||||
{
|
|
||||||
$this->currentNode = &$this;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Function parseXmlFile
|
|
||||||
* @author David S. Callizaya S. <davidsantos@colosa.com>
|
|
||||||
* @access public
|
|
||||||
* @parameter string filename
|
|
||||||
* @parameter string content
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
function parseXmlFile($filename,$content="")
|
|
||||||
{ //$content is a new variable, if it has any value then use it instead of the file content.
|
|
||||||
if($content==""){
|
|
||||||
if ( !file_exists ($filename) ) {
|
|
||||||
throw ( new Exception ( "failed to open Xmlform File : No such file or directory in $filename " ) );
|
|
||||||
}
|
|
||||||
$data = implode( '', file( $filename) );
|
|
||||||
}else{
|
|
||||||
$data = $content;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
/**
|
||||||
$parser = xml_parser_create( 'utf-8' );
|
* Function Xml_document
|
||||||
xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0);
|
*
|
||||||
xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 0);
|
* @author David S. Callizaya S. <davidsantos@colosa.com>
|
||||||
xml_parse_into_struct($parser, $data, $values, $tags);
|
* @access public
|
||||||
if (xml_get_error_code($parser)!== 0) {
|
* @return string
|
||||||
$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 );
|
function Xml_document ()
|
||||||
}
|
|
||||||
xml_parser_free( $parser );
|
|
||||||
|
|
||||||
$this->name = '#document';
|
|
||||||
$this->type = 'open';
|
|
||||||
$this->currentNode = &$this;
|
|
||||||
$m = &$this;
|
|
||||||
foreach($values as $k => $v)
|
|
||||||
{
|
{
|
||||||
switch ($v['type'])
|
$this->currentNode = &$this;
|
||||||
{
|
|
||||||
case 'open':
|
|
||||||
$this->currentNode->addChildNode ( new Xml_Node ($v['tag'],
|
|
||||||
$v['type'], isset($v['value'])?$v['value'] : '',
|
|
||||||
isset($v['attributes']) ? $v['attributes']:array()));
|
|
||||||
$this->currentNode = &$this->findNode($v['tag']);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'close':
|
|
||||||
$this->currentNode=& $this->findNode('..');
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'cdata':
|
|
||||||
$this->currentNode->addChildNode(new Xml_Node('',
|
|
||||||
$v['type'], isset($v['value'])?$v['value']:''));
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'complete':
|
|
||||||
$this->currentNode->addChildNode( new Xml_Node($v['tag'],
|
|
||||||
$v['type'], isset($v['value'])?$v['value']:'',
|
|
||||||
isset($v['attributes'])?$v['attributes']:array()));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return true;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Function &findNode
|
|
||||||
* @author David S. Callizaya S. <davidsantos@colosa.com>
|
|
||||||
* @access public
|
|
||||||
* @parameter string xpath
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
function &findNode( $xpath )
|
|
||||||
{
|
|
||||||
if ( substr( $xpath, 0, 1 ) == '/' ) {
|
|
||||||
return parent::findNode( substr( $xpath,1) );
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
if ( isset($this->currentNode) ){
|
|
||||||
if ( $this->currentNode->name === $this->name)
|
|
||||||
return parent::findNode( $xpath );
|
|
||||||
else
|
|
||||||
return $this->currentNode->findNode($xpath);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
return $null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} //function findNode
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function getXML
|
* Function parseXmlFile
|
||||||
*
|
*
|
||||||
* @access public
|
* @author David S. Callizaya S. <davidsantos@colosa.com>
|
||||||
* @return string $xml
|
* @access public
|
||||||
*/
|
* @param eter string filename
|
||||||
function getXML()
|
* @param eter string content
|
||||||
{
|
* @return string
|
||||||
$xml = '<?xml version="1.0" encoding="UTF-8"?>'."\n";
|
*/
|
||||||
$xml .= $this->children[0]->getXML();
|
function parseXmlFile ($filename, $content = "")
|
||||||
return $xml;
|
{ //$content is a new variable, if it has any value then use it instead of the file content.
|
||||||
}
|
if ($content == "") {
|
||||||
/**
|
if (! file_exists( $filename )) {
|
||||||
* Function save
|
throw (new Exception( "failed to open Xmlform File : No such file or directory in $filename " ));
|
||||||
*
|
}
|
||||||
* @access public
|
$data = implode( '', file( $filename ) );
|
||||||
* @return void
|
} else {
|
||||||
*/
|
$data = $content;
|
||||||
function save ( $filename )
|
}
|
||||||
{
|
|
||||||
$xml = $this->getXML();
|
$parser = xml_parser_create( 'utf-8' );
|
||||||
$fp = fopen( $filename , 'w' );
|
xml_parser_set_option( $parser, XML_OPTION_CASE_FOLDING, 0 );
|
||||||
fwrite( $fp , $xml );
|
xml_parser_set_option( $parser, XML_OPTION_SKIP_WHITE, 0 );
|
||||||
fclose( $fp );/**/
|
xml_parse_into_struct( $parser, $data, $values, $tags );
|
||||||
}
|
if (xml_get_error_code( $parser ) !== 0) {
|
||||||
|
$msg = sprintf( "XML error in <b>%s</b>: %s at line %d", $filename, xml_error_string( xml_get_error_code( $parser ) ), xml_get_current_line_number( $parser ) );
|
||||||
|
trigger_error( $msg );
|
||||||
|
}
|
||||||
|
xml_parser_free( $parser );
|
||||||
|
|
||||||
|
$this->name = '#document';
|
||||||
|
$this->type = 'open';
|
||||||
|
$this->currentNode = &$this;
|
||||||
|
$m = &$this;
|
||||||
|
foreach ($values as $k => $v) {
|
||||||
|
switch ($v['type']) {
|
||||||
|
case 'open':
|
||||||
|
$this->currentNode->addChildNode( new Xml_Node( $v['tag'], $v['type'], isset( $v['value'] ) ? $v['value'] : '', isset( $v['attributes'] ) ? $v['attributes'] : array () ) );
|
||||||
|
$this->currentNode = &$this->findNode( $v['tag'] );
|
||||||
|
break;
|
||||||
|
case 'close':
|
||||||
|
$this->currentNode = & $this->findNode( '..' );
|
||||||
|
break;
|
||||||
|
case 'cdata':
|
||||||
|
$this->currentNode->addChildNode( new Xml_Node( '', $v['type'], isset( $v['value'] ) ? $v['value'] : '' ) );
|
||||||
|
break;
|
||||||
|
case 'complete':
|
||||||
|
$this->currentNode->addChildNode( new Xml_Node( $v['tag'], $v['type'], isset( $v['value'] ) ? $v['value'] : '', isset( $v['attributes'] ) ? $v['attributes'] : array () ) );
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function &findNode
|
||||||
|
*
|
||||||
|
* @author David S. Callizaya S. <davidsantos@colosa.com>
|
||||||
|
* @access public
|
||||||
|
* @param eter string xpath
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
function &findNode ($xpath)
|
||||||
|
{
|
||||||
|
if (substr( $xpath, 0, 1 ) == '/') {
|
||||||
|
return parent::findNode( substr( $xpath, 1 ) );
|
||||||
|
} else {
|
||||||
|
if (isset( $this->currentNode )) {
|
||||||
|
if ($this->currentNode->name === $this->name) {
|
||||||
|
return parent::findNode( $xpath );
|
||||||
|
} else {
|
||||||
|
return $this->currentNode->findNode( $xpath );
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return $null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} //function findNode
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function getXML
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
* @return string $xml
|
||||||
|
*/
|
||||||
|
function getXML ()
|
||||||
|
{
|
||||||
|
$xml = '<?xml version="1.0" encoding="UTF-8"?>' . "\n";
|
||||||
|
$xml .= $this->children[0]->getXML();
|
||||||
|
return $xml;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function save
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
function save ($filename)
|
||||||
|
{
|
||||||
|
$xml = $this->getXML();
|
||||||
|
$fp = fopen( $filename, 'w' );
|
||||||
|
fwrite( $fp, $xml );
|
||||||
|
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
|
||||||
@@ -13,121 +15,121 @@
|
|||||||
*
|
*
|
||||||
* 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
|
||||||
* GNU Affero General Public License for more details.
|
* GNU Affero General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU Affero General Public License
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*
|
*
|
||||||
* For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
|
* For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
|
||||||
* Coral Gables, FL, 33134, USA, or email info@colosa.com.
|
* Coral Gables, FL, 33134, USA, or email info@colosa.com.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @package gulliver.system
|
*
|
||||||
*/
|
* @package gulliver.system
|
||||||
|
*/
|
||||||
|
|
||||||
class XmlForm_Field_Label extends XmlForm_Field
|
class XmlForm_Field_Label extends XmlForm_Field
|
||||||
{
|
{
|
||||||
var $withoutValue = true;
|
var $withoutValue = true;
|
||||||
var $align = 'left';
|
var $align = 'left';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 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
|
||||||
{
|
{
|
||||||
/* Defines the style of the next tds
|
/* Defines the style of the next tds
|
||||||
of the pagedTable.
|
of the pagedTable.
|
||||||
*/
|
*/
|
||||||
var $showInTable = "0";
|
var $showInTable = "0";
|
||||||
var $style = "";
|
var $style = "";
|
||||||
var $styleAlt = "";
|
var $styleAlt = "";
|
||||||
var $className = "";
|
var $className = "";
|
||||||
var $classNameAlt = "";
|
var $classNameAlt = "";
|
||||||
var $condition = 'false';
|
var $condition = 'false';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* tdStyle
|
* tdStyle
|
||||||
*
|
*
|
||||||
* @param string $values
|
* @param string $values
|
||||||
* @param string $owner
|
* @param string $owner
|
||||||
*
|
*
|
||||||
* @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:'';
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* tdClass
|
* tdClass
|
||||||
*
|
*
|
||||||
* @param string $values
|
* @param string $values
|
||||||
* @param string $owner
|
* @param string $owner
|
||||||
*
|
*
|
||||||
* @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
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
class XmlForm_Field_DVEditor extends XmlForm_Field
|
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
|
||||||
*
|
*
|
||||||
* @param string $value
|
* @param string $value
|
||||||
* @param string $owner default value NULL
|
* @param string $owner default value NULL
|
||||||
*
|
*
|
||||||
* @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>';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* attachEvents
|
* attachEvents
|
||||||
*
|
*
|
||||||
* @param string $element
|
* @param string $element
|
||||||
*
|
*
|
||||||
* @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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -137,21 +139,23 @@ class XmlForm_Field_DVEditor extends XmlForm_Field
|
|||||||
* Use PAGED_TABLE_FAST_SEARCH reserved field, it contains the saved value for each table.
|
* Use PAGED_TABLE_FAST_SEARCH reserved field, it contains the saved value for each table.
|
||||||
* example:
|
* example:
|
||||||
* Ex1.
|
* Ex1.
|
||||||
* <PAGED_TABLE_ID type="private"/>
|
* <PAGED_TABLE_ID type="private"/>
|
||||||
* <PAGED_TABLE_FAST_SEARCH type="FastSearch">
|
* <PAGED_TABLE_FAST_SEARCH type="FastSearch">
|
||||||
* <en>Search</en>
|
* <en>Search</en>
|
||||||
* </PAGED_TABLE_FAST_SEARCH>
|
* </PAGED_TABLE_FAST_SEARCH>
|
||||||
* Ex2 (Using type="text").
|
* Ex2 (Using type="text").
|
||||||
* <PAGED_TABLE_ID type="private"/>
|
* <PAGED_TABLE_ID type="private"/>
|
||||||
* <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
|
||||||
{
|
{
|
||||||
var $onkeypress = "if (event.keyCode===13)@#PAGED_TABLE_ID.doFastSearch(this.value);if (event.keyCode===13)return false;";
|
var $onkeypress = "if (event.keyCode===13)@#PAGED_TABLE_ID.doFastSearch(this.value);if (event.keyCode===13)return false;";
|
||||||
var $colAlign = "right";
|
var $colAlign = "right";
|
||||||
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