diff --git a/build.xml b/build.xml index 42406bf98..072101cde 100644 --- a/build.xml +++ b/build.xml @@ -1,11 +1,14 @@ - + + depends="prepare,phpunit,phpcs-ci,phploc,lint"/> + + @@ -98,6 +101,18 @@ + + + + + + + + + + + + diff --git a/gulliver/js/grid/core/grid.js b/gulliver/js/grid/core/grid.js index 14b42b873..5748a9b55 100755 --- a/gulliver/js/grid/core/grid.js +++ b/gulliver/js/grid/core/grid.js @@ -681,17 +681,20 @@ var G_Grid = function(oForm, sGridName){ } } } + + //Set focus the first element in the grid + for (var i = 0; i < this.aFields.length; i++) { + var fieldName = 'form[' + sGridName + '][' + currentRow + '][' + this.aFields[i].sFieldName + ']'; + if (this.aFields[i].sType != 'file' && this.aFields[i].sType != 'hidden' && document.getElementById(fieldName).focus) { + document.getElementById(fieldName).focus(); + break; + } + } + //Fires OnAddRow Event if (this.onaddrow) { this.onaddrow(currentRow); } - var newInputs = oNewRow.getElementsByTagName('input'); - for (var i = 0; i < newInputs.length; i++) { - if (typeof(newInputs[i]) != 'undefined' && newInputs[i].type != 'hidden') { - newInputs[i].focus(); - break; - } - } }; this.deleteGridRow = function (sRow, bWithoutConfirm) @@ -740,12 +743,12 @@ var G_Grid = function(oForm, sGridName){ for (i = 1; i < oObj.oGrid.rows[iRowAux - 1].cells.length; i++) { var oCell1 = oObj.oGrid.rows[iRowAux - 1].cells[i]; var oCell2 = oObj.oGrid.rows[iRowAux].cells[i]; - + switch (oCell1.innerHTML.replace(/^\s+|\s+$/g, '').substr(0, 6).toLowerCase()){ case ' - * @package gulliver.system - * @access private - */ -class Controller -{ - /** - * @var boolean debug switch for general purpose - */ - public $debug = null; - /** - * @var array - private array to store proxy data - */ - private $__data__ = array(); - - /** - * @var object - private object to store the http request data - */ - private $__request__; - - /** - * @var object - headPublisher object to handle the output - */ - private $headPublisher = null; - - /** - * @var string - response type var. possibles values: json|plain - */ - private $responseType = ''; - - /** - * @var string - layout to pass skinEngine - */ - private $layout = ''; - - /** - * Magic setter method - * - * @param string $name - * @param string $value - */ - public function __set($name, $value) - { - $this->__data__[$name] = $value; - } - - /** - * Magic getter method - * - * @param string $name - * @return string or NULL if the internal var doesn't exist - */ - public function __get($name) - { - if (array_key_exists($name, $this->__data__)) { - return $this->__data__[$name]; - } - - $trace = debug_backtrace(); - trigger_error( - 'Undefined property via __get(): ' . $name . - ' in ' . $trace[0]['file'] . - ' on line ' . $trace[0]['line'], - E_USER_NOTICE); - return null; - } - - /** - * Magic isset method - * @param string $name - */ - public function __isset($name) - { - return isset($this->__data__[$name]); - } - - - /** - * Magic unset method - * @param string $name - */ - public function __unset($name) - { - unset($this->__data__[$name]); - } - - /** - * Set Response type method - * @param string $type contains : json|plain - */ - public function setResponseType($type) - { - $this->responseType = $type; - } - - /** - * call to execute a internal proxy method and handle its exceptions - * @param string $name - */ - public function call($name) - { - try { - $result = $this->$name($this->__request__); - if ($this->responseType == 'json') { - print G::json_encode($result); - } - } catch (Exception $e) { - if ($this->responseType != 'json') { - $result->exception->class = get_class($e); - $result->exception->code = $e->getCode(); - - $template = new TemplatePower(PATH_TEMPLATE . 'controller.exception.tpl'); - $template->prepare(); - $template->assign('controller', (function_exists('get_called_class') ? get_called_class() : 'Controller')); - $template->assign('message', $e->getMessage()); - $template->assign('file', $e->getFile()); - $template->assign('line', $e->getLine()); - $template->assign('trace', $e->getTraceAsString()); - - echo $template->getOutputContent(); - - } else { - $result->success = false; - $result->msg = $e->getMessage(); - switch(get_class($e)) { - case 'Exception': $error = "SYSTEM ERROR"; break; - case 'PMException': $error = "PROCESSMAKER ERROR"; break; - case 'PropelException': $error = "DATABASE ERROR"; break; - case 'UserException': $error = "USER ERROR"; break; - } - $result->error = $error; - - $result->exception->class = get_class($e); - $result->exception->code = $e->getCode(); - print G::json_encode($result); - } - } - } - - /** - * Set the http request data - * @param array $data - */ - public function setHttpRequestData($data) - { - if (!is_object($this->__request__)) { - $this->__request__ = new stdclass(); - } - if( is_array($data) ) { - while( $var = each($data) ) - $this->__request__->$var['key'] = $var['value']; - } else - $this->__request__ = $data; - } - - /** - * Get debug var. method - * @param boolan $val boolean value for debug var. - */ - public function setDebug($val) - { - $this->debug = $val; - } - - /** - * Get debug var. method - */ - public function getDebug() - { - if ($this->debug === null) { - $this->debug = defined('DEBUG') && DEBUG ? true : false; - } - - return $this->debug; - } - - - /*** HeadPublisher Functions Binding ***/ - - /** - * Include a particular extjs library or extension to the main output - * @param string $srcFile path of a extjs library or extension - * @param boolean $debug debug flag to indicate if the js output will be minifield or not - * $debug: true -> the js content will be not minified (readable) - * false -> the js content will be minified - */ - public function includeExtJSLib($srcFile, $debug=false) - { - $this->getHeadPublisher()->usingExtJs($srcFile, ($debug ? $debug : $this->getDebug())); - } - - /** - * Include a javascript file that is using extjs framework to the main output - * @param string $srcFile path of javascrit file to include - * @param boolean $debug debug flag to indicate if the js output will be minifield or not - * $debug: true -> the js content will be not minified (readable) - * false -> the js content will be minified - */ - public function includeExtJS($srcFile, $debug=false) - { - $this->getHeadPublisher()->addExtJsScript($srcFile, ($debug ? $debug : $this->getDebug())); - } - - /** - * Include a Html file to the main output - * @param string $file path of html file to include to the main output - */ - public function setView($file) - { - $this->getHeadPublisher()->addContent($file); - } - - /** - * Set variables to be accesible by javascripts - * @param string $name contains var. name - * @param string $value conatins var. value - */ - public function setJSVar($name, $value) - { - $this->getHeadPublisher()->assign($name, $value); - } - - /** - * Set variables to be accesible by the extjs layout template - * @param string $name contains var. name - * @param string $value conatins var. value - */ - public function setVar($name, $value) - { - $this->getHeadPublisher()->assignVar($name, $value); - } - - /** - * method to get the local getHeadPublisher object - */ - public function getHeadPublisher() - { - if (!is_object($this->headPublisher)) { - $this->headPublisher = headPublisher::getSingleton(); - } - - return $this->headPublisher; - } - - public function setLayout($layout) - { - $this->layout = $layout; - } - - public function render($type='mvc') - { - G::RenderPage('publish', $type, null, $this->layout); - } - - public function header($header) - { - G::header($header); - } - - public function redirect($url) - { - G::header("Location: $url"); - } -} + + * @package gulliver.system + * @access private + */ +class Controller +{ + /** + * + * @var boolean debug switch for general purpose + */ + public $debug = null; + /** + * + * @var array - private array to store proxy data + */ + private $__data__ = array (); + + /** + * + * @var object - private object to store the http request data + */ + private $__request__; + + /** + * + * @var object - headPublisher object to handle the output + */ + private $headPublisher = null; + + /** + * + * @var string - response type var. possibles values: json|plain + */ + private $responseType = ''; + + /** + * + * @var string - layout to pass skinEngine + */ + private $layout = ''; + + /** + * Magic setter method + * + * @param string $name + * @param string $value + */ + public function __set ($name, $value) + { + $this->__data__[$name] = $value; + } + + /** + * Magic getter method + * + * @param string $name + * @return string or NULL if the internal var doesn't exist + */ + public function __get ($name) + { + if (array_key_exists( $name, $this->__data__ )) { + return $this->__data__[$name]; + } + + $trace = debug_backtrace(); + trigger_error( 'Undefined property via __get(): ' . $name . ' in ' . $trace[0]['file'] . ' on line ' . $trace[0]['line'], E_USER_NOTICE ); + return null; + } + + /** + * Magic isset method + * + * @param string $name + */ + public function __isset ($name) + { + return isset( $this->__data__[$name] ); + } + + /** + * Magic unset method + * + * @param string $name + */ + public function __unset ($name) + { + unset( $this->__data__[$name] ); + } + + /** + * Set Response type method + * + * @param string $type contains : json|plain + */ + public function setResponseType ($type) + { + $this->responseType = $type; + } + + /** + * call to execute a internal proxy method and handle its exceptions + * + * @param string $name + */ + public function call ($name) + { + try { + $result = $this->$name( $this->__request__ ); + if ($this->responseType == 'json') { + print G::json_encode( $result ); + } + } catch (Exception $e) { + if ($this->responseType != 'json') { + $result->exception->class = get_class( $e ); + $result->exception->code = $e->getCode(); + + $template = new TemplatePower( PATH_TEMPLATE . 'controller.exception.tpl' ); + $template->prepare(); + $template->assign( 'controller', (function_exists( 'get_called_class' ) ? get_called_class() : 'Controller') ); + $template->assign( 'message', $e->getMessage() ); + $template->assign( 'file', $e->getFile() ); + $template->assign( 'line', $e->getLine() ); + $template->assign( 'trace', $e->getTraceAsString() ); + + echo $template->getOutputContent(); + + } else { + $result->success = false; + $result->msg = $e->getMessage(); + switch (get_class( $e )) { + case 'Exception': + $error = "SYSTEM ERROR"; + break; + case 'PMException': + $error = "PROCESSMAKER ERROR"; + break; + case 'PropelException': + $error = "DATABASE ERROR"; + break; + case 'UserException': + $error = "USER ERROR"; + break; + } + $result->error = $error; + + $result->exception->class = get_class( $e ); + $result->exception->code = $e->getCode(); + print G::json_encode( $result ); + } + } + } + + /** + * Set the http request data + * + * @param array $data + */ + public function setHttpRequestData ($data) + { + if (! is_object( $this->__request__ )) { + $this->__request__ = new stdclass(); + } + if (is_array( $data )) { + while ($var = each( $data )) { + $this->__request__->$var['key'] = $var['value']; + } + } else { + $this->__request__ = $data; + } + } + + /** + * Get debug var. + * method + * + * @param boolan $val boolean value for debug var. + */ + public function setDebug ($val) + { + $this->debug = $val; + } + + /** + * Get debug var. + * method + */ + public function getDebug () + { + if ($this->debug === null) { + $this->debug = defined( 'DEBUG' ) && DEBUG ? true : false; + } + + return $this->debug; + } + + /** + * * HeadPublisher Functions Binding ** + */ + + /** + * Include a particular extjs library or extension to the main output + * + * @param string $srcFile path of a extjs library or extension + * @param boolean $debug debug flag to indicate if the js output will be minifield or not + * $debug: true -> the js content will be not minified (readable) + * false -> the js content will be minified + */ + public function includeExtJSLib ($srcFile, $debug = false) + { + $this->getHeadPublisher()->usingExtJs( $srcFile, ($debug ? $debug : $this->getDebug()) ); + } + + /** + * Include a javascript file that is using extjs framework to the main output + * + * @param string $srcFile path of javascrit file to include + * @param boolean $debug debug flag to indicate if the js output will be minifield or not + * $debug: true -> the js content will be not minified (readable) + * false -> the js content will be minified + */ + public function includeExtJS ($srcFile, $debug = false) + { + $this->getHeadPublisher()->addExtJsScript( $srcFile, ($debug ? $debug : $this->getDebug()) ); + } + + /** + * Include a Html file to the main output + * + * @param string $file path of html file to include to the main output + */ + public function setView ($file) + { + $this->getHeadPublisher()->addContent( $file ); + } + + /** + * Set variables to be accesible by javascripts + * + * @param string $name contains var. name + * @param string $value conatins var. value + */ + public function setJSVar ($name, $value) + { + $this->getHeadPublisher()->assign( $name, $value ); + } + + /** + * Set variables to be accesible by the extjs layout template + * + * @param string $name contains var. name + * @param string $value conatins var. value + */ + public function setVar ($name, $value) + { + $this->getHeadPublisher()->assignVar( $name, $value ); + } + + /** + * method to get the local getHeadPublisher object + */ + public function getHeadPublisher () + { + if (! is_object( $this->headPublisher )) { + $this->headPublisher = headPublisher::getSingleton(); + } + + return $this->headPublisher; + } + + public function setLayout ($layout) + { + $this->layout = $layout; + } + + public function render ($type = 'mvc') + { + G::RenderPage( 'publish', $type, null, $this->layout ); + } + + public function header ($header) + { + G::header( $header ); + } + + public function redirect ($url) + { + G::header( "Location: $url" ); + } +} + diff --git a/gulliver/system/class.database_base.php b/gulliver/system/class.database_base.php index ab82ca68a..577fd1c34 100755 --- a/gulliver/system/class.database_base.php +++ b/gulliver/system/class.database_base.php @@ -1,155 +1,175 @@ -. - * - * For more information, contact Colosa Inc, 2566 Le Jeune Rd., - * Coral Gables, FL, 33134, USA, or email info@colosa.com. - * - */ - -/** - * interface iDatabase - * @package gulliver.system - */ - -interface iDatabase { - public function generateDropTableSQL($sTable); - public function generateCreateTableSQL($sTable, $aColumns); - public function generateDropColumnSQL($sTable, $sColumn); - public function generateAddColumnSQL($sTable, $sColumn, $aParameters); - public function generateChangeColumnSQL($sTable, $sColumn, $aParameters); - public function close(); -} - -/** - * class database_base - * @package gulliver.system - * @access public - */ -class database_base implements iDatabase -{ - protected $sType; - protected $sServer; - protected $sUser; - protected $sPass; - protected $sDataBase; - protected $oConnection; - protected $sQuoteCharacter = ''; - protected $sEndLine = ';'; - - /** - * Function __construct - * @access public - * @param string $sType - * @param string $sServer - * @param string $sUser - * @param string $sPass - * @param string $sDataBase - * @return void - */ - - public function __construct($sType = DB_ADAPTER, $sServer = DB_HOST, $sUser = DB_USER, $sPass = DB_PASS, $sDataBase = DB_NAME) - { - $this->sType = $sType; - $this->sServer = $sServer; - $this->sUser = $sUser; - $this->sPass = $sPass; - $this->sDataBase = $sDataBase; - $this->oConnection = null; - $this->sQuoteCharacter = ''; - } - - /** - * Function generateDropTableSQL - * @access public - * @param string $sTable - * @return string - */ - public function generateDropTableSQL($sTable) - { - $sSQL = 'DROP TABLE IF EXISTS ' . $this->sQuoteCharacter . $sTable . $this->sQuoteCharacter . $this->sEndLine; - return $sSQL; - } - - /** - * Function generateDropTableSQL - * @access public - * @param string $sTable - * @param string $sColumn - * @return void - */ - public function generateCreateTableSQL($sTable, $aColumns) - { - } - - /** - * Function generateDropTableSQL - * @access public - * @param string $sTable - * @param string $sColumn - * @return void - */ - public function generateDropColumnSQL($sTable, $sColumn) - { - } - - /** - * Function generateDropTableSQL - * @access public - * @param string $sTable - * @param string $sColumn - * @param string $aParameters - * @return void - */ - public function generateAddColumnSQL($sTable, $sColumn, $aParameters) - { - } - - /** - * Function generateDropTableSQL - * @access public - * @param string $sTable - * @param string $sColumn - * @param string $aParameters - * @return void - */ - public function generateChangeColumnSQL($sTable, $sColumn, $aParameters) - { - } - - /** - * Function generateDropTableSQL - * @access public - * @param string $sQuery - * @return void - */ - public function executeQuery($sQuery) - { - } - - /** - * Function close - * @access public - * @return void - */ - public function close() - { - } -} \ No newline at end of file +. + * + * For more information, contact Colosa Inc, 2566 Le Jeune Rd., + * Coral Gables, FL, 33134, USA, or email info@colosa.com. + * + */ + +/** + * interface iDatabase + * + * @package gulliver.system + */ + +interface iDatabase +{ + + public function generateDropTableSQL ($sTable); + + public function generateCreateTableSQL ($sTable, $aColumns); + + public function generateDropColumnSQL ($sTable, $sColumn); + + public function generateAddColumnSQL ($sTable, $sColumn, $aParameters); + + public function generateChangeColumnSQL ($sTable, $sColumn, $aParameters); + + public function close (); +} + +/** + * class database_base + * + * @package gulliver.system + * @access public + */ +class database_base implements iDatabase +{ + protected $sType; + protected $sServer; + protected $sUser; + protected $sPass; + protected $sDataBase; + protected $oConnection; + protected $sQuoteCharacter = ''; + protected $sEndLine = ';'; + + /** + * Function __construct + * + * @access public + * @param string $sType + * @param string $sServer + * @param string $sUser + * @param string $sPass + * @param string $sDataBase + * @return void + */ + + public function __construct ($sType = DB_ADAPTER, $sServer = DB_HOST, $sUser = DB_USER, $sPass = DB_PASS, $sDataBase = DB_NAME) + { + $this->sType = $sType; + $this->sServer = $sServer; + $this->sUser = $sUser; + $this->sPass = $sPass; + $this->sDataBase = $sDataBase; + $this->oConnection = null; + $this->sQuoteCharacter = ''; + } + + /** + * Function generateDropTableSQL + * + * @access public + * @param string $sTable + * @return string + */ + public function generateDropTableSQL ($sTable) + { + $sSQL = 'DROP TABLE IF EXISTS ' . $this->sQuoteCharacter . $sTable . $this->sQuoteCharacter . $this->sEndLine; + return $sSQL; + } + + /** + * Function generateDropTableSQL + * + * @access public + * @param string $sTable + * @param string $sColumn + * @return void + */ + public function generateCreateTableSQL ($sTable, $aColumns) + { + } + + /** + * Function generateDropTableSQL + * + * @access public + * @param string $sTable + * @param string $sColumn + * @return void + */ + public function generateDropColumnSQL ($sTable, $sColumn) + { + } + + /** + * Function generateDropTableSQL + * + * @access public + * @param string $sTable + * @param string $sColumn + * @param string $aParameters + * @return void + */ + public function generateAddColumnSQL ($sTable, $sColumn, $aParameters) + { + } + + /** + * Function generateDropTableSQL + * + * @access public + * @param string $sTable + * @param string $sColumn + * @param string $aParameters + * @return void + */ + public function generateChangeColumnSQL ($sTable, $sColumn, $aParameters) + { + } + + /** + * Function generateDropTableSQL + * + * @access public + * @param string $sQuery + * @return void + */ + public function executeQuery ($sQuery) + { + } + + /** + * Function close + * + * @access public + * @return void + */ + public function close () + { + } +} + diff --git a/gulliver/system/class.database_mssql.php b/gulliver/system/class.database_mssql.php index fa12d898e..1d6076d6e 100755 --- a/gulliver/system/class.database_mssql.php +++ b/gulliver/system/class.database_mssql.php @@ -1,592 +1,594 @@ -. - * - * For more information, contact Colosa Inc, 2566 Le Jeune Rd., - * Coral Gables, FL, 33134, USA, or email info@colosa.com. - * - */ - -/** - * @package gulliver.system -*/ - -G::LoadSystem('database_base'); - -class database extends database_base { - - public $iFetchType = MSSQL_ASSOC; - - public function __construct($sType = DB_ADAPTER, $sServer = DB_HOST, $sUser = DB_USER, $sPass = DB_PASS, $sDataBase = DB_NAME) { - $this->sType = $sType; - $this->sServer = $sServer; - $this->sUser = $sUser; - $this->sPass = $sPass; - $this->sDataBase = $sDataBase; - $this->oConnection = @mssql_connect($sServer, $sUser, $sPass) || null; - $this->sQuoteCharacter = ' '; - $this->nullString = 'NULL'; - $this->sQuoteCharacterBegin = '['; - $this->sQuoteCharacterEnd = ']'; - } - - - - public function generateCreateTableSQL($sTable, $aColumns) { - $sKeys = ''; - $sSQL = 'CREATE TABLE ' . $this->sQuoteCharacter . $sTable . $this->sQuoteCharacter . '('; - - foreach ($aColumns as $sColumnName => $aParameters) { - if ($sColumnName != 'INDEXES') { - - if ( $sColumnName != '' && isset($aParameters['Type']) && $aParameters['Type'] != '' ){ - $sSQL .= $this->sQuoteCharacter . $sColumnName . $this->sQuoteCharacter . ' ' . $aParameters['Type']; - - if ( isset($aParameters['Null']) && $aParameters['Null'] == 'YES') { - $sSQL .= ' NULL'; - } else { - $sSQL .= ' NOT NULL'; - } - if ( isset($aParameters['Key']) && $aParameters['Key'] == 'PRI') { - $sKeys .= $this->sQuoteCharacter . $sColumnName . $this->sQuoteCharacter . ','; - } - - if ( isset($aParameters['Default']) && $aParameters['Default'] != '' ) { - $sSQL .= " DEFAULT '" . $aParameters['Default'] . "'"; - } - - $sSQL .= ','; - } - } - } - $sSQL = substr($sSQL, 0, -1); - if ($sKeys != '') { - $sSQL .= ',PRIMARY KEY(' . substr($sKeys, 0, -1) . ')'; - } - $sSQL .= ')' . $this->sEndLine; - - return $sSQL; - } - - public function generateDropTableSQL($sTable) { - return 'DROP TABLE ' . $this->sQuoteCharacter . $sTable . $this->sQuoteCharacter . $this->sEndLine; - } - - public function generateDropColumnSQL($sTable, $sColumn) { - // SQL Server first should remove the restriction before the Elimination of the field - $oConstraint = $this->dropFieldConstraint($sTable, $sColumn); - $sSQL = 'ALTER TABLE ' . $this->sQuoteCharacter . $sTable . $this->sQuoteCharacter . - ' DROP COLUMN ' . $this->sQuoteCharacter . $sColumn . $this->sQuoteCharacter . $this->sEndLine; - return $sSQL; - } - - public function generateAddColumnSQL($sTable, $sColumn, $aParameters) { - if ( isset($aParameters['Type']) && isset($aParameters['Null']) ) { - $sDefault = ""; - $sType = $aParameters['Type']; - $sDataType = $aParameters['Type']; - if(! in_array($sDataType, array("TEXT", "DATE") )) { - $sType = substr($sType, 0, strpos($sType,'(')); - } - switch($sType) { - case 'VARCHAR' : - case 'TEXT' : $sDefault = " DEFAULT '' "; - break; - case 'DATE' : $sDataType = " CHAR(19) "; - $sDefault = " DEFAULT '0000-00-00' "; // The date data type to use char (19) - break; - case 'INT' : - case 'FLOAT' : $sDataType = $sType; - $sDefault = " DEFAULT 0 "; - break; - } - $sSQL = "ALTER TABLE " . $this->sQuoteCharacter . $sTable . $this->sQuoteCharacter . - " ADD " . $this->sQuoteCharacter . $sColumn . $this->sQuoteCharacter . - " " . $aParameters['Type']; - if ($aParameters['Null'] == 'YES') { - $sSQL .= " NULL"; - } - else { - $sSQL .= " NOT NULL " . $sDefault; - - } - } - /*if ($aParameters['Key'] == 'PRI') { +. + * + * For more information, contact Colosa Inc, 2566 Le Jeune Rd., + * Coral Gables, FL, 33134, USA, or email info@colosa.com. + * + */ + +/** + * + * @package gulliver.system + * + */ + +G::LoadSystem( 'database_base' ); + +class database extends database_base +{ + public $iFetchType = MSSQL_ASSOC; + + public function __construct ($sType = DB_ADAPTER, $sServer = DB_HOST, $sUser = DB_USER, $sPass = DB_PASS, $sDataBase = DB_NAME) + { + $this->sType = $sType; + $this->sServer = $sServer; + $this->sUser = $sUser; + $this->sPass = $sPass; + $this->sDataBase = $sDataBase; + $this->oConnection = @mssql_connect( $sServer, $sUser, $sPass ) || null; + $this->sQuoteCharacter = ' '; + $this->nullString = 'NULL'; + $this->sQuoteCharacterBegin = '['; + $this->sQuoteCharacterEnd = ']'; + } + + public function generateCreateTableSQL ($sTable, $aColumns) + { + $sKeys = ''; + $sSQL = 'CREATE TABLE ' . $this->sQuoteCharacter . $sTable . $this->sQuoteCharacter . '('; + + foreach ($aColumns as $sColumnName => $aParameters) { + if ($sColumnName != 'INDEXES') { + + if ($sColumnName != '' && isset( $aParameters['Type'] ) && $aParameters['Type'] != '') { + $sSQL .= $this->sQuoteCharacter . $sColumnName . $this->sQuoteCharacter . ' ' . $aParameters['Type']; + + if (isset( $aParameters['Null'] ) && $aParameters['Null'] == 'YES') { + $sSQL .= ' NULL'; + } else { + $sSQL .= ' NOT NULL'; + } + if (isset( $aParameters['Key'] ) && $aParameters['Key'] == 'PRI') { + $sKeys .= $this->sQuoteCharacter . $sColumnName . $this->sQuoteCharacter . ','; + } + + if (isset( $aParameters['Default'] ) && $aParameters['Default'] != '') { + $sSQL .= " DEFAULT '" . $aParameters['Default'] . "'"; + } + + $sSQL .= ','; + } + } + } + $sSQL = substr( $sSQL, 0, - 1 ); + if ($sKeys != '') { + $sSQL .= ',PRIMARY KEY(' . substr( $sKeys, 0, - 1 ) . ')'; + } + $sSQL .= ')' . $this->sEndLine; + + return $sSQL; + } + + public function generateDropTableSQL ($sTable) + { + return 'DROP TABLE ' . $this->sQuoteCharacter . $sTable . $this->sQuoteCharacter . $this->sEndLine; + } + + public function generateDropColumnSQL ($sTable, $sColumn) + { + // SQL Server first should remove the restriction before the Elimination of the field + $oConstraint = $this->dropFieldConstraint( $sTable, $sColumn ); + $sSQL = 'ALTER TABLE ' . $this->sQuoteCharacter . $sTable . $this->sQuoteCharacter . ' DROP COLUMN ' . $this->sQuoteCharacter . $sColumn . $this->sQuoteCharacter . $this->sEndLine; + return $sSQL; + } + + public function generateAddColumnSQL ($sTable, $sColumn, $aParameters) + { + if (isset( $aParameters['Type'] ) && isset( $aParameters['Null'] )) { + $sDefault = ""; + $sType = $aParameters['Type']; + $sDataType = $aParameters['Type']; + if (! in_array( $sDataType, array ("TEXT","DATE" + ) )) { + $sType = substr( $sType, 0, strpos( $sType, '(' ) ); + } + switch ($sType) { + case 'VARCHAR': + case 'TEXT': + $sDefault = " DEFAULT '' "; + break; + case 'DATE': + $sDataType = " CHAR(19) "; + $sDefault = " DEFAULT '0000-00-00' "; // The date data type to use char (19) + break; + case 'INT': + case 'FLOAT': + $sDataType = $sType; + $sDefault = " DEFAULT 0 "; + break; + } + $sSQL = "ALTER TABLE " . $this->sQuoteCharacter . $sTable . $this->sQuoteCharacter . " ADD " . $this->sQuoteCharacter . $sColumn . $this->sQuoteCharacter . " " . $aParameters['Type']; + if ($aParameters['Null'] == 'YES') { + $sSQL .= " NULL"; + } else { + $sSQL .= " NOT NULL " . $sDefault; + + } + } + /*if ($aParameters['Key'] == 'PRI') { $sKeys .= 'ALTER TABLE ' . $this->sQuoteCharacter . $sTable . $this->sQuoteCharacter . ' ADD PRIMARY KEY (' . $this->sQuoteCharacter . $sColumn . $this->sQuoteCharacter . ')' . $this->sEndLine; - }*/ - if (isset($aParameters['AI'])) { - if ($aParameters['AI'] == 1) { - $sSQL .= ' AUTO_INCREMENT'; - } - else { - if ($aParameters['Default'] != '') { - $sSQL .= " DEFAULT '" . $aParameters['Default'] . "'"; - } - } - } - else { - if (isset($aParameters['Default']) && $aParameters['Default'] != '') { - $sSQL .= " DEFAULT '" . $aParameters['Default'] . "'"; - } - } - $sSQL .= $this->sEndLine; - return $sSQL; - } - - public function generateChangeColumnSQL($sTable, $sColumn, $aParameters, $sColumnNewName = '') { - $sSQL = 'ALTER TABLE ' . $this->sQuoteCharacter . $sTable . $this->sQuoteCharacter . - ' CHANGE COLUMN ' . $this->sQuoteCharacter . ($sColumnNewName != '' ? $sColumnNewName : $sColumn) . $this->sQuoteCharacter . - ' ' . $this->sQuoteCharacter . $sColumn . $this->sQuoteCharacter; - if (isset($aParameters['Type'])) { - $sSQL .= ' ' . $aParameters['Type']; - } - if (isset($aParameters['Null'])) { - if ($aParameters['Null'] == 'YES') { - $sSQL .= ' NULL'; - } - else { - $sSQL .= ' NOT NULL'; - } - } - //if (isset($aParameters['AI'])) { - // if ($aParameters['AI'] == 1) { - // $sSQL .= ' AUTO_INCREMENT'; - // } - // else { - // if (isset($aParameters['Default'])) { - // if ($aParameters['Default'] != '') { - // $sSQL .= " DEFAULT '" . $aParameters['Default'] . "'"; - // } - // } - // } - //} - //else { - if (isset($aParameters['Default'])) { - if ( trim($aParameters['Default'] == '') && $aParameters['Type'] == 'datetime' ) { - //do nothing - } - else - $sSQL .= " DEFAULT '" . $aParameters['Default'] . "'"; - //} - } - if (!isset($aParameters['Default']) && isset($aParameters['Null']) && $aParameters['Null'] == 'YES') { - $sSQL .= " DEFAULT NULL "; - } - //} - $sSQL .= $this->sEndLine; - return $sSQL; - } - - public function generateGetPrimaryKeysSQL($sTable) { - try { - if ($sTable == '') { - throw new Exception('The table name cannot be empty!'); - } - return 'SHOW INDEX FROM ' . $this->sQuoteCharacter . $sTable . $this->sQuoteCharacter . ' WHERE Seq_in_index = 1' . $this->sEndLine; - } - catch (Exception $oException) { - throw $oException; - } - } - - /** - * Get primary key - * @parameter string $sTable - * @return string $sPrimaryKey - */ - public function getPrimaryKey($sTable) - { - try { - $sSQL = " SELECT c.COLUMN_NAME " . - " FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS pk , " . - " INFORMATION_SCHEMA.KEY_COLUMN_USAGE c " . - " WHERE pk.TABLE_NAME = '" . trim($sTable) . "' " . - " AND CONSTRAINT_TYPE = 'PRIMARY KEY' " . - " AND c.TABLE_NAME = pk.TABLE_NAME " . - " AND c.CONSTRAINT_NAME = pk.CONSTRAINT_NAME "; - $oPrimaryKey = $this->executeQuery($sSQL); - $aPrimaryKey = mssql_fetch_array($oPrimaryKey); - mssql_free_result($oPrimaryKey); - return $aPrimaryKey[0]; - } catch (Exception $oException) { - throw $oException; - } - } - - /** - * Get Field Constraint - * @parameter string $sTable - * @parameter string $sField - * @return string $sFieldConstraint - */ - public function getFieldConstraint($sTable, $sField) - { - try { - $sSQL = " select a.name " . - " from sysobjects a " . - " inner join syscolumns b on a.id = b.cdefault " . - " where a.xtype = 'D' " . - " and a.parent_obj = (select id from sysobjects where xtype = 'U' and name = '" . trim($sTable) . "') " . - " and b.name = '" . trim($sField) . "' "; - - $oFieldConstraint = $this->executeQuery($sSQL); - $aFieldConstraint = mssql_fetch_array($oFieldConstraint); - mssql_free_result($oFieldConstraint); - return $aFieldConstraint[0]; - } catch (Exception $oException) { - throw $oException; - } - } - - - /** - * drop Field Constraint - * @parameter string $sTable - * @parameter string $sField - * @return object $oFieldConstraint - */ - public function dropFieldConstraint($sTable, $sField) - { - try { - $sConstraint = $this->getFieldConstraint($sTable, $sField); - $sSQL = "ALTER TABLE " . $sTable . " DROP CONSTRAINT " . $sConstraint . $this->sEndLine ; - $oFieldConstraint = $this->executeQuery($sSQL); - return $oFieldConstraint; - } catch (Exception $oException) { - throw $oException; - } - } - - - public function generateDropPrimaryKeysSQL($sTable) { - try { - if ($sTable == '') { - throw new Exception('The table name cannot be empty!'); - } - $sPrimayKey = $this->getPrimaryKey($sTable); - - return ' ALTER TABLE ' . $sTable . ' DROP CONSTRAINT ' . $sPrimayKey . $this->sEndLine; - } - catch (Exception $oException) { - throw $oException; - } - } - - public function generateAddPrimaryKeysSQL($sTable, $aPrimaryKeys) { - try { - if ($sTable == '') { - throw new Exception('The table name cannot be empty!'); - } - $sSQL = 'ALTER TABLE ' . $this->sQuoteCharacter . $sTable . $this->sQuoteCharacter . - ' ADD PRIMARY KEY ('; - foreach ($aPrimaryKeys as $sKey) { - $sSQL .= $this->sQuoteCharacter . $sKey . $this->sQuoteCharacter . ','; - } - $sSQL = substr($sSQL, 0, -1) . ')' . $this->sEndLine; - return $sSQL; - } - catch (Exception $oException) { - throw $oException; - } - } - - public function generateDropKeySQL($sTable, $sIndexName) { - try { - if ($sTable == '') { - throw new Exception('The table name cannot be empty!'); - } - if ($sIndexName == '') { - throw new Exception('The column name cannot be empty!'); - } - return 'ALTER TABLE ' . $this->sQuoteCharacter . $sTable . $this->sQuoteCharacter . ' DROP INDEX ' . $this->sQuoteCharacter . $sIndexName . $this->sQuoteCharacter . $this->sEndLine; - } - catch (Exception $oException) { - throw $oException; - } - } - - public function generateAddKeysSQL($sTable, $indexName, $aKeys) { - try { - $indexType = 'INDEX'; - if ( $indexName == 'primaryKey' || $indexName == 'PRIMARY' ) { - $indexType = 'PRIMARY'; - $indexName = 'KEY'; - } - $sSQL = 'ALTER TABLE ' . $this->sQuoteCharacter . $sTable . $this->sQuoteCharacter . ' ADD ' . $indexType . ' ' . $indexName . ' ('; - foreach ($aKeys as $sKey) { - $sSQL .= $this->sQuoteCharacter . $sKey . $this->sQuoteCharacter . ', '; - } - $sSQL = substr($sSQL, 0, -2); - $sSQL .= ')' . $this->sEndLine; - return $sSQL; - } - catch (Exception $oException) { - throw $oException; - } - } - - public function generateShowTablesSQL() { - return 'SHOW TABLES' . $this->sEndLine; - } - - public function generateShowTablesLikeSQL($sTable) { - return "SHOW TABLES LIKE '" . $sTable . "'" . $this->sEndLine; - } - - public function generateDescTableSQL($sTable) { - try { - if ($sTable == '') { - throw new Exception('The table name cannot be empty!'); - } - return 'DESC ' . $this->sQuoteCharacter . $sTable . $this->sQuoteCharacter . $this->sEndLine; - } - catch (Exception $oException) { - throw $oException; - } - } - - public function generateTableIndexSQL($sTable) { - return 'SHOW INDEX FROM ' . $this->sQuoteCharacter . $sTable . $this->sQuoteCharacter . " " . $this->sEndLine; - //return 'SHOW INDEX FROM ' . $this->sQuoteCharacter . $sTable . $this->sQuoteCharacter . " WHERE Key_name <> 'PRIMARY'" . $this->sEndLine; - } - - public function isConnected() { - if ( !$this->oConnection ) - return false; - return $this->executeQuery( 'USE ' . $this->sDataBase ); - } - - public function logQuery($sQuery ) { - try { - $found = false; - if ( substr($sQuery,0, 6) == 'SELECT' ) $found = true; - if ( substr($sQuery,0, 4) == 'SHOW' ) $found = true; - if ( substr($sQuery,0, 4) == 'DESC' ) $found = true; - if ( substr($sQuery,0, 4) == 'USE ' ) $found = true; - if ( ! $found ) { - $logFile = PATH_DATA . 'log' . PATH_SEP . 'query.log'; - $fp = fopen ( $logFile, 'a+' ); - fwrite ( $fp, date("Y-m-d H:i:s") . " " . $this->sDataBase . " " . $sQuery . "\n" ); - fclose ( $fp ); - } - } - catch (Exception $oException) { - } - } - - public function executeQuery($sQuery) { - $this->logQuery( $sQuery); - - try { - if ($this->oConnection) { - @mssql_select_db($this->sDataBase); - - return @mssql_query($sQuery); - } - else { - throw new Exception('invalid connection to database ' . $this->sDataBase ); - } - } - catch (Exception $oException) { - $this->logQuery( $oException->getMessage() ); - throw $oException; - } - } - - public function countResults($oDataset) { - return @mssql_num_rows($oDataset); - } - - public function getRegistry($oDataset) { - return @mssql_fetch_array($oDataset, $this->iFetchType); - } - - public function close() { - @mssql_close($this->oConnection); - } - - public function generateInsertSQL($table, $data) { - $fields = array(); - $values = array(); - foreach ($data as $field) { - $fields[] = $field['field']; - if (!is_null($field['value'])) { - switch ($field['type']) { - case 'text': - case 'date': - $values[] = "'" . addslashes($field['value']) . "'"; - break; - case 'int': - default: - $values[] = addslashes($field['value']); - break; - } - } - else { - $values[] = $this->nullString; - } - } - $fields = array_map(array($this, 'putQuotes'), $fields); - $sql = sprintf("INSERT INTO %s (%s) VALUES (%s)", $this->putQuotes($table), implode(', ', $fields), implode(', ', $values)); - return $sql; - } - - public function generateUpdateSQL($table, $keys, $data) { - $fields = array(); - $where = array(); - foreach ($data as $field) { - if (!is_null($field['value'])) { - switch ($field['type']) { - case 'text': - case 'date': - $fields[] = $this->putQuotes($field['field']) . " = '" . addslashes($field['value']) . "'"; - break; - case 'int': - default: - $fields[] = $this->putQuotes($field['field']) . " = " . addslashes($field['value']); - break; - } - } - else { - $values[] = $this->nullString; - } - if (in_array($field['field'], $keys)) { - $where[] = $fields[count($fields) - 1]; - } - } - $sql = sprintf("UPDATE %s SET %s WHERE %s", $this->putQuotes($table), implode(', ', $fields), implode(', ', $where)); - return $sql; - } - - public function generateDeleteSQL($table, $keys, $data) { - $fields = array(); - $where = array(); - foreach ($data as $field) { - if (in_array($field['field'], $keys)) { - if (!is_null($field['value'])) { - switch ($field['type']) { - case 'text': - case 'date': - $where[] = $this->putQuotes($field['field']) . " = '" . addslashes($field['value']) . "'"; - break; - case 'int': - default: - $where[] = $this->putQuotes($field['field']) . " = " . addslashes($field['value']); - break; - } - } - else { - $values[] = $this->nullString; - } - } - } - $sql = sprintf("DELETE FROM %s WHERE %s", $this->putQuotes($table), implode(', ', $where)); - return $sql; - } - - public function generateSelectSQL($table, $keys, $data) { - $fields = array(); - $where = array(); - foreach ($data as $field) { - if (in_array($field['field'], $keys)) { - if (!is_null($field['value'])) { - switch ($field['type']) { - case 'text': - case 'date': - $where[] = $this->putQuotes($field['field']) . " = '" . mysql_real_escape_string($field['value']) . "'"; - break; - case 'int': - default: - $where[] = $this->putQuotes($field['field']) . " = " . mysql_real_escape_string($field['value']); - break; - } - } - else { - $values[] = $this->nullString; - } - } - } - $sql = sprintf("SELECT * FROM %s WHERE %s", $this->putQuotes($table), implode(', ', $where)); - return $sql; - } - - private function putQuotes($element) { - return $this->sQuoteCharacterBegin . $element . $this->sQuoteCharacterEnd; - } - - /*=================================================================================================*/ - /** - * concatString - * Generates a string equivalent to the chosen database. - * - * author Hector Cortez - * date 2010-08-04 - * - * @return string $sConcat - */ - function concatString() - { - $nums = func_num_args(); - $vars = func_get_args(); - $sConcat = ""; - for($i = 0;$i < $nums; $i++) { - if(isset($vars[$i])) { - $sConcat .= $vars[$i]; - if(($i+1) < $nums) - $sConcat .= " + "; - } - } - return $sConcat; - } - - /* + }*/ + if (isset( $aParameters['AI'] )) { + if ($aParameters['AI'] == 1) { + $sSQL .= ' AUTO_INCREMENT'; + } else { + if ($aParameters['Default'] != '') { + $sSQL .= " DEFAULT '" . $aParameters['Default'] . "'"; + } + } + } else { + if (isset( $aParameters['Default'] ) && $aParameters['Default'] != '') { + $sSQL .= " DEFAULT '" . $aParameters['Default'] . "'"; + } + } + $sSQL .= $this->sEndLine; + return $sSQL; + } + + public function generateChangeColumnSQL ($sTable, $sColumn, $aParameters, $sColumnNewName = '') + { + $sSQL = 'ALTER TABLE ' . $this->sQuoteCharacter . $sTable . $this->sQuoteCharacter . ' CHANGE COLUMN ' . $this->sQuoteCharacter . ($sColumnNewName != '' ? $sColumnNewName : $sColumn) . $this->sQuoteCharacter . ' ' . $this->sQuoteCharacter . $sColumn . $this->sQuoteCharacter; + if (isset( $aParameters['Type'] )) { + $sSQL .= ' ' . $aParameters['Type']; + } + if (isset( $aParameters['Null'] )) { + if ($aParameters['Null'] == 'YES') { + $sSQL .= ' NULL'; + } else { + $sSQL .= ' NOT NULL'; + } + } + //if (isset($aParameters['AI'])) { + // if ($aParameters['AI'] == 1) { + // $sSQL .= ' AUTO_INCREMENT'; + // } + // else { + // if (isset($aParameters['Default'])) { + // if ($aParameters['Default'] != '') { + // $sSQL .= " DEFAULT '" . $aParameters['Default'] . "'"; + // } + // } + // } + //} + //else { + if (isset( $aParameters['Default'] )) { + if (trim( $aParameters['Default'] == '' ) && $aParameters['Type'] == 'datetime') { + //do nothing + } else + $sSQL .= " DEFAULT '" . $aParameters['Default'] . "'"; + //} + } + if (! isset( $aParameters['Default'] ) && isset( $aParameters['Null'] ) && $aParameters['Null'] == 'YES') { + $sSQL .= " DEFAULT NULL "; + } + //} + $sSQL .= $this->sEndLine; + return $sSQL; + } + + public function generateGetPrimaryKeysSQL ($sTable) + { + try { + if ($sTable == '') { + throw new Exception( 'The table name cannot be empty!' ); + } + return 'SHOW INDEX FROM ' . $this->sQuoteCharacter . $sTable . $this->sQuoteCharacter . ' WHERE Seq_in_index = 1' . $this->sEndLine; + } catch (Exception $oException) { + throw $oException; + } + } + + /** + * Get primary key + * + * @param eter string $sTable + * @return string $sPrimaryKey + */ + public function getPrimaryKey ($sTable) + { + try { + $sSQL = " SELECT c.COLUMN_NAME " . " FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS pk , " . " INFORMATION_SCHEMA.KEY_COLUMN_USAGE c " . " WHERE pk.TABLE_NAME = '" . trim( $sTable ) . "' " . " AND CONSTRAINT_TYPE = 'PRIMARY KEY' " . " AND c.TABLE_NAME = pk.TABLE_NAME " . " AND c.CONSTRAINT_NAME = pk.CONSTRAINT_NAME "; + $oPrimaryKey = $this->executeQuery( $sSQL ); + $aPrimaryKey = mssql_fetch_array( $oPrimaryKey ); + mssql_free_result( $oPrimaryKey ); + return $aPrimaryKey[0]; + } catch (Exception $oException) { + throw $oException; + } + } + + /** + * Get Field Constraint + * + * @param eter string $sTable + * @param eter string $sField + * @return string $sFieldConstraint + */ + public function getFieldConstraint ($sTable, $sField) + { + try { + $sSQL = " select a.name " . " from sysobjects a " . " inner join syscolumns b on a.id = b.cdefault " . " where a.xtype = 'D' " . " and a.parent_obj = (select id from sysobjects where xtype = 'U' and name = '" . trim( $sTable ) . "') " . " and b.name = '" . trim( $sField ) . "' "; + + $oFieldConstraint = $this->executeQuery( $sSQL ); + $aFieldConstraint = mssql_fetch_array( $oFieldConstraint ); + mssql_free_result( $oFieldConstraint ); + return $aFieldConstraint[0]; + } catch (Exception $oException) { + throw $oException; + } + } + + /** + * drop Field Constraint + * + * @param eter string $sTable + * @param eter string $sField + * @return object $oFieldConstraint + */ + public function dropFieldConstraint ($sTable, $sField) + { + try { + $sConstraint = $this->getFieldConstraint( $sTable, $sField ); + $sSQL = "ALTER TABLE " . $sTable . " DROP CONSTRAINT " . $sConstraint . $this->sEndLine; + $oFieldConstraint = $this->executeQuery( $sSQL ); + return $oFieldConstraint; + } catch (Exception $oException) { + throw $oException; + } + } + + public function generateDropPrimaryKeysSQL ($sTable) + { + try { + if ($sTable == '') { + throw new Exception( 'The table name cannot be empty!' ); + } + $sPrimayKey = $this->getPrimaryKey( $sTable ); + + return ' ALTER TABLE ' . $sTable . ' DROP CONSTRAINT ' . $sPrimayKey . $this->sEndLine; + } catch (Exception $oException) { + throw $oException; + } + } + + public function generateAddPrimaryKeysSQL ($sTable, $aPrimaryKeys) + { + try { + if ($sTable == '') { + throw new Exception( 'The table name cannot be empty!' ); + } + $sSQL = 'ALTER TABLE ' . $this->sQuoteCharacter . $sTable . $this->sQuoteCharacter . ' ADD PRIMARY KEY ('; + foreach ($aPrimaryKeys as $sKey) { + $sSQL .= $this->sQuoteCharacter . $sKey . $this->sQuoteCharacter . ','; + } + $sSQL = substr( $sSQL, 0, - 1 ) . ')' . $this->sEndLine; + return $sSQL; + } catch (Exception $oException) { + throw $oException; + } + } + + public function generateDropKeySQL ($sTable, $sIndexName) + { + try { + if ($sTable == '') { + throw new Exception( 'The table name cannot be empty!' ); + } + if ($sIndexName == '') { + throw new Exception( 'The column name cannot be empty!' ); + } + return 'ALTER TABLE ' . $this->sQuoteCharacter . $sTable . $this->sQuoteCharacter . ' DROP INDEX ' . $this->sQuoteCharacter . $sIndexName . $this->sQuoteCharacter . $this->sEndLine; + } catch (Exception $oException) { + throw $oException; + } + } + + public function generateAddKeysSQL ($sTable, $indexName, $aKeys) + { + try { + $indexType = 'INDEX'; + if ($indexName == 'primaryKey' || $indexName == 'PRIMARY') { + $indexType = 'PRIMARY'; + $indexName = 'KEY'; + } + $sSQL = 'ALTER TABLE ' . $this->sQuoteCharacter . $sTable . $this->sQuoteCharacter . ' ADD ' . $indexType . ' ' . $indexName . ' ('; + foreach ($aKeys as $sKey) { + $sSQL .= $this->sQuoteCharacter . $sKey . $this->sQuoteCharacter . ', '; + } + $sSQL = substr( $sSQL, 0, - 2 ); + $sSQL .= ')' . $this->sEndLine; + return $sSQL; + } catch (Exception $oException) { + throw $oException; + } + } + + public function generateShowTablesSQL () + { + return 'SHOW TABLES' . $this->sEndLine; + } + + public function generateShowTablesLikeSQL ($sTable) + { + return "SHOW TABLES LIKE '" . $sTable . "'" . $this->sEndLine; + } + + public function generateDescTableSQL ($sTable) + { + try { + if ($sTable == '') { + throw new Exception( 'The table name cannot be empty!' ); + } + return 'DESC ' . $this->sQuoteCharacter . $sTable . $this->sQuoteCharacter . $this->sEndLine; + } catch (Exception $oException) { + throw $oException; + } + } + + public function generateTableIndexSQL ($sTable) + { + return 'SHOW INDEX FROM ' . $this->sQuoteCharacter . $sTable . $this->sQuoteCharacter . " " . $this->sEndLine; + //return 'SHOW INDEX FROM ' . $this->sQuoteCharacter . $sTable . $this->sQuoteCharacter . " WHERE Key_name <> 'PRIMARY'" . $this->sEndLine; + } + + public function isConnected () + { + if (! $this->oConnection) + return false; + return $this->executeQuery( 'USE ' . $this->sDataBase ); + } + + public function logQuery ($sQuery) + { + try { + $found = false; + if (substr( $sQuery, 0, 6 ) == 'SELECT') + $found = true; + if (substr( $sQuery, 0, 4 ) == 'SHOW') + $found = true; + if (substr( $sQuery, 0, 4 ) == 'DESC') + $found = true; + if (substr( $sQuery, 0, 4 ) == 'USE ') + $found = true; + if (! $found) { + $logFile = PATH_DATA . 'log' . PATH_SEP . 'query.log'; + $fp = fopen( $logFile, 'a+' ); + fwrite( $fp, date( "Y-m-d H:i:s" ) . " " . $this->sDataBase . " " . $sQuery . "\n" ); + fclose( $fp ); + } + } catch (Exception $oException) { + } + } + + public function executeQuery ($sQuery) + { + $this->logQuery( $sQuery ); + + try { + if ($this->oConnection) { + @mssql_select_db( $this->sDataBase ); + + return @mssql_query( $sQuery ); + } else { + throw new Exception( 'invalid connection to database ' . $this->sDataBase ); + } + } catch (Exception $oException) { + $this->logQuery( $oException->getMessage() ); + throw $oException; + } + } + + public function countResults ($oDataset) + { + return @mssql_num_rows( $oDataset ); + } + + public function getRegistry ($oDataset) + { + return @mssql_fetch_array( $oDataset, $this->iFetchType ); + } + + public function close () + { + @mssql_close( $this->oConnection ); + } + + public function generateInsertSQL ($table, $data) + { + $fields = array (); + $values = array (); + foreach ($data as $field) { + $fields[] = $field['field']; + if (! is_null( $field['value'] )) { + switch ($field['type']) { + case 'text': + case 'date': + $values[] = "'" . addslashes( $field['value'] ) . "'"; + break; + case 'int': + default: + $values[] = addslashes( $field['value'] ); + break; + } + } else { + $values[] = $this->nullString; + } + } + $fields = array_map( array ($this,'putQuotes' + ), $fields ); + $sql = sprintf( "INSERT INTO %s (%s) VALUES (%s)", $this->putQuotes( $table ), implode( ', ', $fields ), implode( ', ', $values ) ); + return $sql; + } + + public function generateUpdateSQL ($table, $keys, $data) + { + $fields = array (); + $where = array (); + foreach ($data as $field) { + if (! is_null( $field['value'] )) { + switch ($field['type']) { + case 'text': + case 'date': + $fields[] = $this->putQuotes( $field['field'] ) . " = '" . addslashes( $field['value'] ) . "'"; + break; + case 'int': + default: + $fields[] = $this->putQuotes( $field['field'] ) . " = " . addslashes( $field['value'] ); + break; + } + } else { + $values[] = $this->nullString; + } + if (in_array( $field['field'], $keys )) { + $where[] = $fields[count( $fields ) - 1]; + } + } + $sql = sprintf( "UPDATE %s SET %s WHERE %s", $this->putQuotes( $table ), implode( ', ', $fields ), implode( ', ', $where ) ); + return $sql; + } + + public function generateDeleteSQL ($table, $keys, $data) + { + $fields = array (); + $where = array (); + foreach ($data as $field) { + if (in_array( $field['field'], $keys )) { + if (! is_null( $field['value'] )) { + switch ($field['type']) { + case 'text': + case 'date': + $where[] = $this->putQuotes( $field['field'] ) . " = '" . addslashes( $field['value'] ) . "'"; + break; + case 'int': + default: + $where[] = $this->putQuotes( $field['field'] ) . " = " . addslashes( $field['value'] ); + break; + } + } else { + $values[] = $this->nullString; + } + } + } + $sql = sprintf( "DELETE FROM %s WHERE %s", $this->putQuotes( $table ), implode( ', ', $where ) ); + return $sql; + } + + public function generateSelectSQL ($table, $keys, $data) + { + $fields = array (); + $where = array (); + foreach ($data as $field) { + if (in_array( $field['field'], $keys )) { + if (! is_null( $field['value'] )) { + switch ($field['type']) { + case 'text': + case 'date': + $where[] = $this->putQuotes( $field['field'] ) . " = '" . mysql_real_escape_string( $field['value'] ) . "'"; + break; + case 'int': + default: + $where[] = $this->putQuotes( $field['field'] ) . " = " . mysql_real_escape_string( $field['value'] ); + break; + } + } else { + $values[] = $this->nullString; + } + } + } + $sql = sprintf( "SELECT * FROM %s WHERE %s", $this->putQuotes( $table ), implode( ', ', $where ) ); + return $sql; + } + + private function putQuotes ($element) + { + return $this->sQuoteCharacterBegin . $element . $this->sQuoteCharacterEnd; + } + + /*=================================================================================================*/ + /** + * concatString + * Generates a string equivalent to the chosen database. + * + * author Hector Cortez + * date 2010-08-04 + * + * @return string $sConcat + */ + function concatString() + { + $nums = func_num_args(); + $vars = func_get_args(); + $sConcat = ""; + for ($i = 0; $i < $nums; $i ++) { + if (isset( $vars[$i] )) { + $sConcat .= $vars[$i]; + if (($i + 1) < $nums) + $sConcat .= " + "; + } + } + return $sConcat; + } + + /* * query functions for class class.case.php * - */ - /** - * concatString - * Generates a string equivalent to the case when - * - * @author Hector Cortez - * date 2010-08-04 - * - * @return string $sCompare - */ - function getCaseWhen($compareValue, $trueResult, $falseResult) - { - $sCompare = " CASE WHEN " . $compareValue . " THEN " . $trueResult . " ELSE " . $falseResult . " END "; - return $sCompare; - } - - /** - * Generates a string equivalent to create table ObjectPermission - * - * class.case.php - * function verifyTable() - * - * @return string $sql - */ - function createTableObjectPermission() - { - $sql = "IF NOT EXISTS (SELECT * FROM sysobjects WHERE name='OBJECT_PERMISSION' AND xtype='U') + */ + /** + * concatString + * Generates a string equivalent to the case when + * + * @author Hector Cortez + * date 2010-08-04 + * + * @return string $sCompare + */ + function getCaseWhen($compareValue, $trueResult, $falseResult) + { + $sCompare = " CASE WHEN " . $compareValue . " THEN " . $trueResult . " ELSE " . $falseResult . " END "; + return $sCompare; + } + + /** + * Generates a string equivalent to create table ObjectPermission + * + * class.case.php + * function verifyTable() + * + * @return string $sql + */ + function createTableObjectPermission() + { + $sql = "IF NOT EXISTS (SELECT * FROM sysobjects WHERE name='OBJECT_PERMISSION' AND xtype='U') CREATE TABLE OBJECT_PERMISSION ( OP_UID varchar(32) NOT NULL, PRO_UID varchar(32) NOT NULL, @@ -598,30 +600,29 @@ class database extends database_base { OP_OBJ_TYPE varchar(15) NOT NULL default 'ANY', OP_OBJ_UID varchar(32) NOT NULL, OP_ACTION varchar(10) NOT NULL default 'VIEW', - CONSTRAINT PK_PRO_UID PRIMARY KEY CLUSTERED (PRO_UID, TAS_UID,USR_UID, OP_TASK_SOURCE, OP_OBJ_UID) )"; - return $sql; - } - - /* + CONSTRAINT PK_PRO_UID PRIMARY KEY CLUSTERED (PRO_UID, TAS_UID,USR_UID, OP_TASK_SOURCE, OP_OBJ_UID) )"; + return $sql; + } + + /* * query functions for class class.report.php * - */ - /** - * Generates a string query - * - * class.report.php - * function generatedReport4() - * - * @return string $sql - */ - function getSelectReport4() - { - - $sqlConcat = " U.USR_LASTNAME + ' ' + USR_FIRSTNAME AS [USER] "; - $sqlGroupBy = " U.USR_LASTNAME + ' ' + USR_FIRSTNAME "; - - $sql = "SELECT " . $sqlConcat . ", " . - " COUNT(*) AS CANTCASES, + */ + /** + * Generates a string query + * + * class.report.php + * function generatedReport4() + * + * @return string $sql + */ + function getSelectReport4() + { + + $sqlConcat = " U.USR_LASTNAME + ' ' + USR_FIRSTNAME AS [USER] "; + $sqlGroupBy = " U.USR_LASTNAME + ' ' + USR_FIRSTNAME "; + + $sql = "SELECT " . $sqlConcat . ", " . " COUNT(*) AS CANTCASES, MIN(AD.DEL_DURATION) AS MIN, MAX(AD.DEL_DURATION) AS MAX, SUM(AD.DEL_DURATION) AS TOTALDUR, @@ -630,27 +631,26 @@ class database extends database_base { LEFT JOIN APP_DELEGATION AS AD ON(A.APP_UID = AD.APP_UID AND AD.DEL_INDEX=1) LEFT JOIN USERS AS U ON(U.USR_UID = A.APP_INIT_USER) WHERE A.APP_UID<>'' - GROUP BY " . $sqlGroupBy; - - return $sql; - - } - - /** - * Generates a string query - * - * class.report.php - * function generatedReport4_filter() - * - * @return string $sql - */ - function getSelectReport4Filter($var) - { - $sqlConcat = " U.USR_LASTNAME + ' ' + USR_FIRSTNAME AS [USER] "; - $sqlGroupBy = " U.USR_LASTNAME + ' ' + USR_FIRSTNAME "; - - $sql = " SELECT " . $sqlConcat . ", " . - " COUNT(*) AS CANTCASES, + GROUP BY " . $sqlGroupBy; + + return $sql; + + } + + /** + * Generates a string query + * + * class.report.php + * function generatedReport4_filter() + * + * @return string $sql + */ + function getSelectReport4Filter($var) + { + $sqlConcat = " U.USR_LASTNAME + ' ' + USR_FIRSTNAME AS [USER] "; + $sqlGroupBy = " U.USR_LASTNAME + ' ' + USR_FIRSTNAME "; + + $sql = " SELECT " . $sqlConcat . ", " . " COUNT(*) AS CANTCASES, MIN(AD.DEL_DURATION) AS MIN, MAX(AD.DEL_DURATION) AS MAX, SUM(AD.DEL_DURATION) AS TOTALDUR, @@ -658,29 +658,28 @@ class database extends database_base { FROM APPLICATION AS A LEFT JOIN APP_DELEGATION AS AD ON(A.APP_UID = AD.APP_UID AND AD.DEL_INDEX=1) LEFT JOIN USERS AS U ON(U.USR_UID = A.APP_INIT_USER) - ".$var." - GROUP BY " . $sqlGroupBy; - - return $sql; - - } - - /** - * Generates a string query - * - * class.report.php - * function generatedReport5() - * - * @return string $sql - */ - function getSelectReport5() - { - - $sqlConcat = " U.USR_LASTNAME + ' ' + USR_FIRSTNAME AS [USER] "; - $sqlGroupBy = " U.USR_LASTNAME + ' ' + USR_FIRSTNAME "; - - $sql = " SELECT " . $sqlConcat . ", " . - " COUNT(*) AS CANTCASES, + " . $var . " + GROUP BY " . $sqlGroupBy; + + return $sql; + + } + + /** + * Generates a string query + * + * class.report.php + * function generatedReport5() + * + * @return string $sql + */ + function getSelectReport5() + { + + $sqlConcat = " U.USR_LASTNAME + ' ' + USR_FIRSTNAME AS [USER] "; + $sqlGroupBy = " U.USR_LASTNAME + ' ' + USR_FIRSTNAME "; + + $sql = " SELECT " . $sqlConcat . ", " . " COUNT(*) AS CANTCASES, MIN(AD.DEL_DURATION) AS MIN, MAX(AD.DEL_DURATION) AS MAX, SUM(AD.DEL_DURATION) AS TOTALDUR, @@ -689,28 +688,27 @@ class database extends database_base { LEFT JOIN PROCESS AS P ON (P.PRO_UID = AD.PRO_UID) LEFT JOIN USERS AS U ON(U.USR_UID = AD.USR_UID) WHERE AD.APP_UID<>'' AND AD.DEL_FINISH_DATE IS NULL - GROUP BY " . $sqlGroupBy; - - return $sql; - - } - - /** - * Generates a string query - * - * class.report.php - * function generatedReport5_filter() - * - * @return string $sql - */ - function getSelectReport5Filter($var) - { - - $sqlConcat = " U.USR_LASTNAME + ' ' + USR_FIRSTNAME AS [USER] "; - $sqlGroupBy = " U.USR_LASTNAME + ' ' + USR_FIRSTNAME "; - - $sql = "SELECT " . $sqlConcat . ", " . - " COUNT(*) AS CANTCASES, + GROUP BY " . $sqlGroupBy; + + return $sql; + + } + + /** + * Generates a string query + * + * class.report.php + * function generatedReport5_filter() + * + * @return string $sql + */ + function getSelectReport5Filter($var) + { + + $sqlConcat = " U.USR_LASTNAME + ' ' + USR_FIRSTNAME AS [USER] "; + $sqlGroupBy = " U.USR_LASTNAME + ' ' + USR_FIRSTNAME "; + + $sql = "SELECT " . $sqlConcat . ", " . " COUNT(*) AS CANTCASES, MIN(AD.DEL_DURATION) AS MIN, MAX(AD.DEL_DURATION) AS MAX, SUM(AD.DEL_DURATION) AS TOTALDUR, @@ -718,50 +716,47 @@ class database extends database_base { FROM APP_DELEGATION AS AD LEFT JOIN PROCESS AS P ON (P.PRO_UID = AD.PRO_UID) LEFT JOIN USERS AS U ON(U.USR_UID = AD.USR_UID) - ".$var." - GROUP BY " . $sqlGroupBy; - - return $sql; - } - - /* - * query functions for class class.net.php - * - */ - function getServerVersion($driver, $dbIP, $dbPort, $dbUser, $dbPasswd, $dbSourcename) - { - - if(strlen(trim($dbIP))<=0) - $dbIP = DB_HOST; - if($link = @mssql_connect($dbIP, $dbUser, $dbPasswd)){ - @mssql_select_db( DB_NAME, $link ); - $oResult = @mssql_query("select substring(@@version, 21, 6) + ' (' + CAST(SERVERPROPERTY ('productlevel') as varchar(10)) + ') ' + CAST(SERVERPROPERTY('productversion') AS VARCHAR(15)) + ' ' + CAST(SERVERPROPERTY ('edition') AS VARCHAR(25)) as version; ", $link); - $aResult = @mssql_fetch_array($oResult); - @mssql_free_result($oResult); - $v = $aResult[0]; - } else { - throw new Exception(@mssql_error($link)); - } - return (isset($v))?$v:'none'; - - } - - + " . $var . " + GROUP BY " . $sqlGroupBy; + + return $sql; + } + /* * query functions for class class.net.php * - */ - function getDropTable($sTableName) - { - $sql = "IF NOT EXISTS (SELECT * FROM sysobjects WHERE name='" . $sTableName . "' AND xtype='U') " . - "DROP TABLE ['" . $sTableName . "']"; - return $sql; - } - - - function getTableDescription($sTableName) - { - $sql = " select column_name as Field, + */ + function getServerVersion($driver, $dbIP, $dbPort, $dbUser, $dbPasswd, $dbSourcename) + { + + if (strlen( trim( $dbIP ) ) <= 0) + $dbIP = DB_HOST; + if ($link = @mssql_connect( $dbIP, $dbUser, $dbPasswd )) { + @mssql_select_db( DB_NAME, $link ); + $oResult = @mssql_query( "select substring(@@version, 21, 6) + ' (' + CAST(SERVERPROPERTY ('productlevel') as varchar(10)) + ') ' + CAST(SERVERPROPERTY('productversion') AS VARCHAR(15)) + ' ' + CAST(SERVERPROPERTY ('edition') AS VARCHAR(25)) as version; ", $link ); + $aResult = @mssql_fetch_array( $oResult ); + @mssql_free_result( $oResult ); + $v = $aResult[0]; + } else { + throw new Exception( @mssql_error( $link ) ); + } + return (isset( $v )) ? $v : 'none'; + + } + + /* + * query functions for class class.net.php + * + */ + function getDropTable($sTableName) + { + $sql = "IF NOT EXISTS (SELECT * FROM sysobjects WHERE name='" . $sTableName . "' AND xtype='U') " . "DROP TABLE ['" . $sTableName . "']"; + return $sql; + } + + function getTableDescription($sTableName) + { + $sql = " select column_name as Field, data_type + ' ' + (case data_type when 'char' @@ -777,56 +772,56 @@ class database extends database_base { when 'No' then 'NO' else 'YES' END) AS AsNull, COLUMN_DEFAULT as [Default] FROM information_schema.columns - WHERE table_name = '" . trim($sTableName) . "'" . - " Order by Ordinal_Position asc "; - return $sql; - } - - function getFieldNull() - { - $fieldName = "AsNull"; - return $fieldName; - } - - function getValidate($validate) - { - $oValidate = true; - return $oValidate; - } - - /** - * Determines whether a table exists - * It is part of class.reportTables.php - */ - function reportTableExist() - { - $bExists = true; - $oConnection = mssql_connect(DB_HOST, DB_USER, DB_PASS); - mssql_select_db(DB_NAME); - $oDataset = mssql_query('SELECT COUNT(*) FROM REPORT_TABLE') || ($bExists = false); - - return $bExists; - } - - /** - * It is part of class.pagedTable.php - */ - function getLimitRenderTable($nCurrentPage, $nRowsPerPage) - { - $sql = ""; - return $sql; - } - - /** - * Determining the existence of a table - */ - function tableExists ($table, $db) { - $sql = "SELECT * FROM sysobjects WHERE name='" . $table . "' AND type='u'"; - $bExists = true; - $oConnection = mssql_connect(DB_HOST, DB_USER, DB_PASS); - mssql_select_db(DB_NAME); - $oDataset = mssql_query($sql) || ($bExists = false); - return $bExists; - } - -} \ No newline at end of file + WHERE table_name = '" . trim( $sTableName ) . "'" . " Order by Ordinal_Position asc "; + return $sql; + } + + function getFieldNull() + { + $fieldName = "AsNull"; + return $fieldName; + } + + function getValidate($validate) + { + $oValidate = true; + return $oValidate; + } + + /** + * Determines whether a table exists + * It is part of class.reportTables.php + */ + function reportTableExist() + { + $bExists = true; + $oConnection = mssql_connect( DB_HOST, DB_USER, DB_PASS ); + mssql_select_db( DB_NAME ); + $oDataset = mssql_query( 'SELECT COUNT(*) FROM REPORT_TABLE' ) || ($bExists = false); + + return $bExists; + } + + /** + * It is part of class.pagedTable.php + */ + function getLimitRenderTable($nCurrentPage, $nRowsPerPage) + { + $sql = ""; + return $sql; + } + + /** + * Determining the existence of a table + */ + function tableExists($table, $db) + { + $sql = "SELECT * FROM sysobjects WHERE name='" . $table . "' AND type='u'"; + $bExists = true; + $oConnection = mssql_connect( DB_HOST, DB_USER, DB_PASS ); + mssql_select_db( DB_NAME ); + $oDataset = mssql_query( $sql ) || ($bExists = false); + return $bExists; + } +} + diff --git a/gulliver/system/class.database_mysql.php b/gulliver/system/class.database_mysql.php index a2f015fa2..75fd83e8c 100755 --- a/gulliver/system/class.database_mysql.php +++ b/gulliver/system/class.database_mysql.php @@ -1,623 +1,655 @@ -. - * - * For more information, contact Colosa Inc, 2566 Le Jeune Rd., - * Coral Gables, FL, 33134, USA, or email info@colosa.com. - * - */ - -/** - * @package gulliver.system -*/ - -G::LoadSystem('database_base'); - -class database extends database_base { - - public $iFetchType = MYSQL_ASSOC; - - /** - * class database constructor - * @param $sType adapter type - * @param $sServer server - * @param $sUser db user - * @param $sPass db user password - * @param $sDataBase Database name - */ - public function __construct($sType = DB_ADAPTER, $sServer = DB_HOST, $sUser = DB_USER, $sPass = DB_PASS, $sDataBase = DB_NAME) { - $this->sType = $sType; - $this->sServer = $sServer; - $this->sUser = $sUser; - $this->sPass = $sPass; - $this->sDataBase = $sDataBase; - $this->oConnection = @mysql_connect($sServer, $sUser, $sPass) || null; - $this->sQuoteCharacter = '`'; - $this->nullString = 'null'; - } - - /** - * generate the sql sentence to create a table - * @param $sTable table name - * @param $aColumns array of columns - * @return $sSql the sql sentence - */ - public function generateCreateTableSQL($sTable, $aColumns) { - $sKeys = ''; - $sSQL = 'CREATE TABLE IF NOT EXISTS ' . $this->sQuoteCharacter . $sTable . $this->sQuoteCharacter . '('; - - foreach ($aColumns as $sColumnName => $aParameters) { - if ($sColumnName != 'INDEXES') { - - if ( $sColumnName != '' && isset($aParameters['Type']) && $aParameters['Type'] != '' ){ - $sSQL .= $this->sQuoteCharacter . $sColumnName . $this->sQuoteCharacter . ' ' . $aParameters['Type']; - - if ( isset($aParameters['Null']) && $aParameters['Null'] == 'YES') { - $sSQL .= ' NULL'; - } else { - $sSQL .= ' NOT NULL'; - } - if ( isset($aParameters['Key']) && $aParameters['Key'] == 'PRI') { - $sKeys .= $this->sQuoteCharacter . $sColumnName . $this->sQuoteCharacter . ','; - } - - if ( isset($aParameters['Default']) && $aParameters['Default'] != '' ) { - $sSQL .= " DEFAULT '" . $aParameters['Default'] . "'"; - } - - $sSQL .= ','; - } - } - } - $sSQL = substr($sSQL, 0, -1); - if ($sKeys != '') { - $sSQL .= ',PRIMARY KEY(' . substr($sKeys, 0, -1) . ')'; - } - $sSQL .= ')' . $this->sEndLine; - - return $sSQL; - } - - /** - * generate a drop table sentence - * @param $sTable table name - * @return sql sentence string - */ - public function generateDropTableSQL($sTable) { - return 'DROP TABLE ' . $this->sQuoteCharacter . $sTable . $this->sQuoteCharacter . $this->sEndLine; - } - - /** - * generate drop column sentence - * @param $sTable table name - * @param $sColumn column name - * @return $sSql sql sentence - */ - public function generateDropColumnSQL($sTable, $sColumn) { - $sSQL = 'ALTER TABLE ' . $this->sQuoteCharacter . $sTable . $this->sQuoteCharacter . - ' DROP COLUMN ' . $this->sQuoteCharacter . $sColumn . $this->sQuoteCharacter . $this->sEndLine; - return $sSQL; - } - - /** - * generate an add column sentence - * @param $sTable table name - * @param $sColumn column name - * @param $aParameters parameters of field like typo or if it can be null - * @return $sSql sql sentence - */ - public function generateAddColumnSQL($sTable, $sColumn, $aParameters) { - if ( isset($aParameters['Type']) && isset($aParameters['Null']) ) { - $sSQL = 'ALTER TABLE ' . $this->sQuoteCharacter . $sTable . $this->sQuoteCharacter . - ' ADD COLUMN ' . $this->sQuoteCharacter . $sColumn . $this->sQuoteCharacter . - ' ' . $aParameters['Type']; - if ($aParameters['Null'] == 'YES') { - $sSQL .= ' NULL'; - } - else { - $sSQL .= ' NOT NULL'; - } - } - /*if ($aParameters['Key'] == 'PRI') { +. + * + * For more information, contact Colosa Inc, 2566 Le Jeune Rd., + * Coral Gables, FL, 33134, USA, or email info@colosa.com. + * + */ + +/** + * + * @package gulliver.system + * + */ + +G::LoadSystem( 'database_base' ); + +class database extends database_base +{ + + public $iFetchType = MYSQL_ASSOC; + + /** + * class database constructor + * + * @param $sType adapter type + * @param $sServer server + * @param $sUser db user + * @param $sPass db user password + * @param $sDataBase Database name + */ + public function __construct ($sType = DB_ADAPTER, $sServer = DB_HOST, $sUser = DB_USER, $sPass = DB_PASS, $sDataBase = DB_NAME) + { + $this->sType = $sType; + $this->sServer = $sServer; + $this->sUser = $sUser; + $this->sPass = $sPass; + $this->sDataBase = $sDataBase; + $this->oConnection = @mysql_connect( $sServer, $sUser, $sPass ) || null; + $this->sQuoteCharacter = '`'; + $this->nullString = 'null'; + } + + /** + * generate the sql sentence to create a table + * + * @param $sTable table name + * @param $aColumns array of columns + * @return $sSql the sql sentence + */ + public function generateCreateTableSQL ($sTable, $aColumns) + { + $sKeys = ''; + $sSQL = 'CREATE TABLE IF NOT EXISTS ' . $this->sQuoteCharacter . $sTable . $this->sQuoteCharacter . '('; + + foreach ($aColumns as $sColumnName => $aParameters) { + if ($sColumnName != 'INDEXES') { + + if ($sColumnName != '' && isset( $aParameters['Type'] ) && $aParameters['Type'] != '') { + $sSQL .= $this->sQuoteCharacter . $sColumnName . $this->sQuoteCharacter . ' ' . $aParameters['Type']; + + if (isset( $aParameters['Null'] ) && $aParameters['Null'] == 'YES') { + $sSQL .= ' NULL'; + } else { + $sSQL .= ' NOT NULL'; + } + if (isset( $aParameters['Key'] ) && $aParameters['Key'] == 'PRI') { + $sKeys .= $this->sQuoteCharacter . $sColumnName . $this->sQuoteCharacter . ','; + } + + if (isset( $aParameters['Default'] ) && $aParameters['Default'] != '') { + $sSQL .= " DEFAULT '" . $aParameters['Default'] . "'"; + } + + $sSQL .= ','; + } + } + } + $sSQL = substr( $sSQL, 0, - 1 ); + if ($sKeys != '') { + $sSQL .= ',PRIMARY KEY(' . substr( $sKeys, 0, - 1 ) . ')'; + } + $sSQL .= ')' . $this->sEndLine; + + return $sSQL; + } + + /** + * generate a drop table sentence + * + * @param $sTable table name + * @return sql sentence string + */ + public function generateDropTableSQL ($sTable) + { + return 'DROP TABLE ' . $this->sQuoteCharacter . $sTable . $this->sQuoteCharacter . $this->sEndLine; + } + + /** + * generate drop column sentence + * + * @param $sTable table name + * @param $sColumn column name + * @return $sSql sql sentence + */ + public function generateDropColumnSQL ($sTable, $sColumn) + { + $sSQL = 'ALTER TABLE ' . $this->sQuoteCharacter . $sTable . $this->sQuoteCharacter . ' DROP COLUMN ' . $this->sQuoteCharacter . $sColumn . $this->sQuoteCharacter . $this->sEndLine; + return $sSQL; + } + + /** + * generate an add column sentence + * + * @param $sTable table name + * @param $sColumn column name + * @param $aParameters parameters of field like typo or if it can be null + * @return $sSql sql sentence + */ + public function generateAddColumnSQL ($sTable, $sColumn, $aParameters) + { + if (isset( $aParameters['Type'] ) && isset( $aParameters['Null'] )) { + $sSQL = 'ALTER TABLE ' . $this->sQuoteCharacter . $sTable . $this->sQuoteCharacter . ' ADD COLUMN ' . $this->sQuoteCharacter . $sColumn . $this->sQuoteCharacter . ' ' . $aParameters['Type']; + if ($aParameters['Null'] == 'YES') { + $sSQL .= ' NULL'; + } else { + $sSQL .= ' NOT NULL'; + } + } + /*if ($aParameters['Key'] == 'PRI') { $sKeys .= 'ALTER TABLE ' . $this->sQuoteCharacter . $sTable . $this->sQuoteCharacter . ' ADD PRIMARY KEY (' . $this->sQuoteCharacter . $sColumn . $this->sQuoteCharacter . ')' . $this->sEndLine; - }*/ - if (isset($aParameters['AI'])) { - if ($aParameters['AI'] == 1) { - $sSQL .= ' AUTO_INCREMENT'; - } - else { - if ($aParameters['Default'] != '') { - $sSQL .= " DEFAULT '" . $aParameters['Default'] . "'"; - } - } - } - else { - if (isset($aParameters['Default'])) { - $sSQL .= " DEFAULT '" . $aParameters['Default'] . "'"; - } - } - $sSQL .= $this->sEndLine; - return $sSQL; - } - - /** - * generate a change column sentence - * @param $sTable table name - * @param $sColumn column name - * @param $aParameters parameters of field like typo or if it can be null - * @param $sColumnNewName column new name - * @return $sSql sql sentence - */ - public function generateChangeColumnSQL($sTable, $sColumn, $aParameters, $sColumnNewName = '') { - $sSQL = 'ALTER TABLE ' . $this->sQuoteCharacter . $sTable . $this->sQuoteCharacter . - ' CHANGE COLUMN ' . $this->sQuoteCharacter . ($sColumnNewName != '' ? $sColumnNewName : $sColumn) . $this->sQuoteCharacter . - ' ' . $this->sQuoteCharacter . $sColumn . $this->sQuoteCharacter; - if (isset($aParameters['Type'])) { - $sSQL .= ' ' . $aParameters['Type']; - } - if (isset($aParameters['Null'])) { - if ($aParameters['Null'] == 'YES') { - $sSQL .= ' NULL'; - } - else { - $sSQL .= ' NOT NULL'; - } - } - //if (isset($aParameters['AI'])) { - // if ($aParameters['AI'] == 1) { - // $sSQL .= ' AUTO_INCREMENT'; - // } - // else { - // if (isset($aParameters['Default'])) { - // if ($aParameters['Default'] != '') { - // $sSQL .= " DEFAULT '" . $aParameters['Default'] . "'"; - // } - // } - // } - //} - //else { - if (isset($aParameters['Default'])) { - if ( trim($aParameters['Default']) == '' && $aParameters['Type'] == 'datetime' ) { - //do nothing - } - else - $sSQL .= " DEFAULT '" . $aParameters['Default'] . "'"; - //} - } - if (!isset($aParameters['Default']) && isset($aParameters['Null']) && $aParameters['Null'] == 'YES') { - $sSQL .= " DEFAULT NULL "; - } - //} - $sSQL .= $this->sEndLine; - return $sSQL; - } - - /** - * Generate and get the primary key in a sentence - * @param $sTable table name - * @return $sSql sql sentence - */ - public function generateGetPrimaryKeysSQL($sTable) { - try { - if ($sTable == '') { - throw new Exception('The table name cannot be empty!'); - } - return 'SHOW INDEX FROM ' . $this->sQuoteCharacter . $sTable . $this->sQuoteCharacter . ' WHERE Seq_in_index = 1' . $this->sEndLine; - } - catch (Exception $oException) { - throw $oException; - } - } - - /** - * generate a sentence to drop the primary key - * @param $sTable table name - * @return sql sentence - */ - public function generateDropPrimaryKeysSQL($sTable) { - try { - if ($sTable == '') { - throw new Exception('The table name cannot be empty!'); - } - return 'ALTER TABLE ' . $this->sQuoteCharacter . $sTable . $this->sQuoteCharacter . ' DROP PRIMARY KEY' . $this->sEndLine; - } - catch (Exception $oException) { - throw $oException; - } - } - - /** - * generate a sentence to add multiple primary keys - * @param $sTable table name - * @param $aPrimaryKeys array of primary keys - * @return sql sentence - */ - public function generateAddPrimaryKeysSQL($sTable, $aPrimaryKeys) { - try { - if ($sTable == '') { - throw new Exception('The table name cannot be empty!'); - } - $sSQL = 'ALTER TABLE ' . $this->sQuoteCharacter . $sTable . $this->sQuoteCharacter . - ' ADD PRIMARY KEY ('; - foreach ($aPrimaryKeys as $sKey) { - $sSQL .= $this->sQuoteCharacter . $sKey . $this->sQuoteCharacter . ','; - } - $sSQL = substr($sSQL, 0, -1) . ')' . $this->sEndLine; - return $sSQL; - } - catch (Exception $oException) { - throw $oException; - } - } - - /** - * generate a sentence to drop an index - * @param $sTable table name - * @param $sIndexName index name - * @return sql sentence - */ - public function generateDropKeySQL($sTable, $sIndexName) { - try { - if ($sTable == '') { - throw new Exception('The table name cannot be empty!'); - } - if ($sIndexName == '') { - throw new Exception('The column name cannot be empty!'); - } - return 'ALTER TABLE ' . $this->sQuoteCharacter . $sTable . $this->sQuoteCharacter . ' DROP INDEX ' . $this->sQuoteCharacter . $sIndexName . $this->sQuoteCharacter . $this->sEndLine; - } - catch (Exception $oException) { - throw $oException; - } - } - - /** - * generate a sentence to add indexes or primary keys - * @param $sTable table name - * @param $indexName index name - * @param $aKeys array of keys - * @return sql sentence - */ - - public function generateAddKeysSQL($sTable, $indexName, $aKeys) { - try { - $indexType = 'INDEX'; - if ( $indexName == 'primaryKey' || $indexName == 'PRIMARY' ) { - $indexType = 'PRIMARY'; - $indexName = 'KEY'; - } - $sSQL = 'ALTER TABLE ' . $this->sQuoteCharacter . $sTable . $this->sQuoteCharacter . ' ADD ' . $indexType . ' ' . $indexName . ' ('; - foreach ($aKeys as $sKey) { - $sSQL .= $this->sQuoteCharacter . $sKey . $this->sQuoteCharacter . ', '; - } - $sSQL = substr($sSQL, 0, -2); - $sSQL .= ')' . $this->sEndLine; - return $sSQL; - } - catch (Exception $oException) { - throw $oException; - } - } - - /** - * generate a sentence to show the tables - * @return sql sentence - */ - public function generateShowTablesSQL() { - return 'SHOW TABLES' . $this->sEndLine; - } - - /** - * generate a sentence to show the tables with a like sentence - * @return sql sentence - */ - public function generateShowTablesLikeSQL($sTable) { - return "SHOW TABLES LIKE '" . $sTable . "'" . $this->sEndLine; - } - - /** - * generate a sentence to show the tables with a like sentence - * @param $sTable table name - * @return sql sentence - */ - public function generateDescTableSQL($sTable) { - try { - if ($sTable == '') { - throw new Exception('The table name cannot be empty!'); - } - return 'DESC ' . $this->sQuoteCharacter . $sTable . $this->sQuoteCharacter . $this->sEndLine; - } - catch (Exception $oException) { - throw $oException; - } - } - - /** - * generate a sentence to show some table indexes - * @param $sTable table name - * @return sql sentence - */ - public function generateTableIndexSQL($sTable) { - return 'SHOW INDEX FROM ' . $this->sQuoteCharacter . $sTable . $this->sQuoteCharacter . " " . $this->sEndLine; - //return 'SHOW INDEX FROM ' . $this->sQuoteCharacter . $sTable . $this->sQuoteCharacter . " WHERE Key_name <> 'PRIMARY'" . $this->sEndLine; - } - - /** - * execute a sentence to check if there is connection - * @return void - */ - public function isConnected() { - if ( !$this->oConnection ) - return false; - return $this->executeQuery( 'USE ' . $this->sDataBase ); - } - - /** - * generate a sentence to show the tables with a like sentence - * @param $sQuery sql query string - * @return void - */ - public function logQuery($sQuery ) { - try { - $found = false; - if ( substr($sQuery,0, 6) == 'SELECT' ) $found = true; - if ( substr($sQuery,0, 4) == 'SHOW' ) $found = true; - if ( substr($sQuery,0, 4) == 'DESC' ) $found = true; - if ( substr($sQuery,0, 4) == 'USE ' ) $found = true; - if ( ! $found ) { - $logDir = PATH_DATA . 'log'; - if (!file_exists($logDir)) - if (!mkdir($logDir)) - return; - $logFile = "$logDir/query.log"; - $fp = fopen ( $logFile, 'a+' ); - if ($fp !== false) { - fwrite ( $fp, date("Y-m-d H:i:s") . " " . $this->sDataBase . " " . $sQuery . "\n" ); - fclose ( $fp ); - } - } - } - catch (Exception $oException) { - } - } - - /** - * execute a sql query - * @param $sQuery table name - * @return void - */ - public function executeQuery($sQuery) { - $this->logQuery( $sQuery); - - try { - if ($this->oConnection) { - @mysql_select_db($this->sDataBase); - - return @mysql_query($sQuery); - } - else { - throw new Exception('invalid connection to database ' . $this->sDataBase ); - } - } - catch (Exception $oException) { - $this->logQuery( $oException->getMessage() ); - throw $oException; - } - } - - /** - * count the rows of a dataset - * @param $oDataset - * @return the number of rows - */ - public function countResults($oDataset) { - return @mysql_num_rows($oDataset); - } - - /** - * count an array of the registry from a dataset - * @param $oDataset - * @return the registry - */ - public function getRegistry($oDataset) { - return @mysql_fetch_array($oDataset, $this->iFetchType); - } - - /** - * close the current connection - * @return void - */ - public function close() { - @mysql_close($this->oConnection); - } - - public function generateInsertSQL($table, $data) { - $fields = array(); - $values = array(); - foreach ($data as $field) { - $fields[] = $field['field']; - if (!is_null($field['value'])) { - switch ($field['type']) { - case 'text': - case 'date': - $values[] = "'" . mysql_real_escape_string($field['value']) . "'"; - break; - case 'int': - default: - $values[] = mysql_real_escape_string($field['value']); - break; - } - } - else { - $values[] = $this->nullString; - } - } - $fields = array_map(array($this, 'putQuotes'), $fields); - $sql = sprintf("INSERT INTO %s (%s) VALUES (%s)", $this->putQuotes($table), implode(', ', $fields), implode(', ', $values)); - return $sql; - } - - public function generateUpdateSQL($table, $keys, $data) { - $fields = array(); - $where = array(); - foreach ($data as $field) { - if (!is_null($field['value'])) { - switch ($field['type']) { - case 'text': - case 'date': - $fields[] = $this->putQuotes($field['field']) . " = '" . mysql_real_escape_string($field['value']) . "'"; - break; - case 'int': - default: - $fields[] = $this->putQuotes($field['field']) . " = " . mysql_real_escape_string($field['value']); - break; - } - } - else { - $values[] = $this->nullString; - } - if (in_array($field['field'], $keys)) { - $where[] = $fields[count($fields) - 1]; - } - } - $sql = sprintf("UPDATE %s SET %s WHERE %s", $this->putQuotes($table), implode(', ', $fields), implode(', ', $where)); - return $sql; - } - - public function generateDeleteSQL($table, $keys, $data) { - $fields = array(); - $where = array(); - foreach ($data as $field) { - if (in_array($field['field'], $keys)) { - if (!is_null($field['value'])) { - switch ($field['type']) { - case 'text': - case 'date': - $where[] = $this->putQuotes($field['field']) . " = '" . mysql_real_escape_string($field['value']) . "'"; - break; - case 'int': - default: - $where[] = $this->putQuotes($field['field']) . " = " . mysql_real_escape_string($field['value']); - break; - } - } - else { - $values[] = $this->nullString; - } - } - } - $sql = sprintf("DELETE FROM %s WHERE %s", $this->putQuotes($table), implode(', ', $where)); - return $sql; - } - - public function generateSelectSQL($table, $keys, $data) { - $fields = array(); - $where = array(); - foreach ($data as $field) { - if (in_array($field['field'], $keys)) { - if (!is_null($field['value'])) { - switch ($field['type']) { - case 'text': - case 'date': - $where[] = $this->putQuotes($field['field']) . " = '" . mysql_real_escape_string($field['value']) . "'"; - break; - case 'int': - default: - $where[] = $this->putQuotes($field['field']) . " = " . mysql_real_escape_string($field['value']); - break; - } - } - else { - $values[] = $this->nullString; - } - } - } - $sql = sprintf("SELECT * FROM %s WHERE %s", $this->putQuotes($table), implode(', ', $where)); - return $sql; - } - - private function putQuotes($element) { - return $this->sQuoteCharacter . $element . $this->sQuoteCharacter; - } - - /*=================================================================================================*/ - /** - * concatString - * Generates a string equivalent to the chosen database. - * - * author Hector Cortez - * date 2010-08-04 - * - * @return string $sConcat - */ - function concatString() - { - $nums = func_num_args(); - $vars = func_get_args(); - - $sConcat = " CONCAT("; - for($i = 0;$i < $nums; $i++) { - if(isset($vars[$i])) { - $sConcat .= $vars[$i]; - if(($i+1) < $nums) - $sConcat .= ", "; - } - } - $sConcat .= ")"; - - return $sConcat; - - } - - /* + }*/ + if (isset( $aParameters['AI'] )) { + if ($aParameters['AI'] == 1) { + $sSQL .= ' AUTO_INCREMENT'; + } else { + if ($aParameters['Default'] != '') { + $sSQL .= " DEFAULT '" . $aParameters['Default'] . "'"; + } + } + } else { + if (isset( $aParameters['Default'] )) { + $sSQL .= " DEFAULT '" . $aParameters['Default'] . "'"; + } + } + $sSQL .= $this->sEndLine; + return $sSQL; + } + + /** + * generate a change column sentence + * + * @param $sTable table name + * @param $sColumn column name + * @param $aParameters parameters of field like typo or if it can be null + * @param $sColumnNewName column new name + * @return $sSql sql sentence + */ + public function generateChangeColumnSQL ($sTable, $sColumn, $aParameters, $sColumnNewName = '') + { + $sSQL = 'ALTER TABLE ' . $this->sQuoteCharacter . $sTable . $this->sQuoteCharacter . ' CHANGE COLUMN ' . $this->sQuoteCharacter . ($sColumnNewName != '' ? $sColumnNewName : $sColumn) . $this->sQuoteCharacter . ' ' . $this->sQuoteCharacter . $sColumn . $this->sQuoteCharacter; + if (isset( $aParameters['Type'] )) { + $sSQL .= ' ' . $aParameters['Type']; + } + if (isset( $aParameters['Null'] )) { + if ($aParameters['Null'] == 'YES') { + $sSQL .= ' NULL'; + } else { + $sSQL .= ' NOT NULL'; + } + } + //if (isset($aParameters['AI'])) { + // if ($aParameters['AI'] == 1) { + // $sSQL .= ' AUTO_INCREMENT'; + // } + // else { + // if (isset($aParameters['Default'])) { + // if ($aParameters['Default'] != '') { + // $sSQL .= " DEFAULT '" . $aParameters['Default'] . "'"; + // } + // } + // } + //} + //else { + if (isset( $aParameters['Default'] )) { + if (trim( $aParameters['Default'] ) == '' && $aParameters['Type'] == 'datetime') { + //do nothing + } else + $sSQL .= " DEFAULT '" . $aParameters['Default'] . "'"; + //} + } + if (! isset( $aParameters['Default'] ) && isset( $aParameters['Null'] ) && $aParameters['Null'] == 'YES') { + $sSQL .= " DEFAULT NULL "; + } + //} + $sSQL .= $this->sEndLine; + return $sSQL; + } + + /** + * Generate and get the primary key in a sentence + * + * @param $sTable table name + * @return $sSql sql sentence + */ + public function generateGetPrimaryKeysSQL ($sTable) + { + try { + if ($sTable == '') { + throw new Exception( 'The table name cannot be empty!' ); + } + return 'SHOW INDEX FROM ' . $this->sQuoteCharacter . $sTable . $this->sQuoteCharacter . ' WHERE Seq_in_index = 1' . $this->sEndLine; + } catch (Exception $oException) { + throw $oException; + } + } + + /** + * generate a sentence to drop the primary key + * + * @param $sTable table name + * @return sql sentence + */ + public function generateDropPrimaryKeysSQL ($sTable) + { + try { + if ($sTable == '') { + throw new Exception( 'The table name cannot be empty!' ); + } + return 'ALTER TABLE ' . $this->sQuoteCharacter . $sTable . $this->sQuoteCharacter . ' DROP PRIMARY KEY' . $this->sEndLine; + } catch (Exception $oException) { + throw $oException; + } + } + + /** + * generate a sentence to add multiple primary keys + * + * @param $sTable table name + * @param $aPrimaryKeys array of primary keys + * @return sql sentence + */ + public function generateAddPrimaryKeysSQL ($sTable, $aPrimaryKeys) + { + try { + if ($sTable == '') { + throw new Exception( 'The table name cannot be empty!' ); + } + $sSQL = 'ALTER TABLE ' . $this->sQuoteCharacter . $sTable . $this->sQuoteCharacter . ' ADD PRIMARY KEY ('; + foreach ($aPrimaryKeys as $sKey) { + $sSQL .= $this->sQuoteCharacter . $sKey . $this->sQuoteCharacter . ','; + } + $sSQL = substr( $sSQL, 0, - 1 ) . ')' . $this->sEndLine; + return $sSQL; + } catch (Exception $oException) { + throw $oException; + } + } + + /** + * generate a sentence to drop an index + * + * @param $sTable table name + * @param $sIndexName index name + * @return sql sentence + */ + public function generateDropKeySQL ($sTable, $sIndexName) + { + try { + if ($sTable == '') { + throw new Exception( 'The table name cannot be empty!' ); + } + if ($sIndexName == '') { + throw new Exception( 'The column name cannot be empty!' ); + } + return 'ALTER TABLE ' . $this->sQuoteCharacter . $sTable . $this->sQuoteCharacter . ' DROP INDEX ' . $this->sQuoteCharacter . $sIndexName . $this->sQuoteCharacter . $this->sEndLine; + } catch (Exception $oException) { + throw $oException; + } + } + + /** + * generate a sentence to add indexes or primary keys + * + * @param $sTable table name + * @param $indexName index name + * @param $aKeys array of keys + * @return sql sentence + */ + + public function generateAddKeysSQL ($sTable, $indexName, $aKeys) + { + try { + $indexType = 'INDEX'; + if ($indexName == 'primaryKey' || $indexName == 'PRIMARY') { + $indexType = 'PRIMARY'; + $indexName = 'KEY'; + } + $sSQL = 'ALTER TABLE ' . $this->sQuoteCharacter . $sTable . $this->sQuoteCharacter . ' ADD ' . $indexType . ' ' . $indexName . ' ('; + foreach ($aKeys as $sKey) { + $sSQL .= $this->sQuoteCharacter . $sKey . $this->sQuoteCharacter . ', '; + } + $sSQL = substr( $sSQL, 0, - 2 ); + $sSQL .= ')' . $this->sEndLine; + return $sSQL; + } catch (Exception $oException) { + throw $oException; + } + } + + /** + * generate a sentence to show the tables + * + * @return sql sentence + */ + public function generateShowTablesSQL () + { + return 'SHOW TABLES' . $this->sEndLine; + } + + /** + * generate a sentence to show the tables with a like sentence + * + * @return sql sentence + */ + public function generateShowTablesLikeSQL ($sTable) + { + return "SHOW TABLES LIKE '" . $sTable . "'" . $this->sEndLine; + } + + /** + * generate a sentence to show the tables with a like sentence + * + * @param $sTable table name + * @return sql sentence + */ + public function generateDescTableSQL ($sTable) + { + try { + if ($sTable == '') { + throw new Exception( 'The table name cannot be empty!' ); + } + return 'DESC ' . $this->sQuoteCharacter . $sTable . $this->sQuoteCharacter . $this->sEndLine; + } catch (Exception $oException) { + throw $oException; + } + } + + /** + * generate a sentence to show some table indexes + * + * @param $sTable table name + * @return sql sentence + */ + public function generateTableIndexSQL ($sTable) + { + return 'SHOW INDEX FROM ' . $this->sQuoteCharacter . $sTable . $this->sQuoteCharacter . " " . $this->sEndLine; + //return 'SHOW INDEX FROM ' . $this->sQuoteCharacter . $sTable . $this->sQuoteCharacter . " WHERE Key_name <> 'PRIMARY'" . $this->sEndLine; + } + + /** + * execute a sentence to check if there is connection + * + * @return void + */ + public function isConnected () + { + if (! $this->oConnection) + return false; + return $this->executeQuery( 'USE ' . $this->sDataBase ); + } + + /** + * generate a sentence to show the tables with a like sentence + * + * @param $sQuery sql query string + * @return void + */ + public function logQuery ($sQuery) + { + try { + $found = false; + if (substr( $sQuery, 0, 6 ) == 'SELECT') + $found = true; + if (substr( $sQuery, 0, 4 ) == 'SHOW') + $found = true; + if (substr( $sQuery, 0, 4 ) == 'DESC') + $found = true; + if (substr( $sQuery, 0, 4 ) == 'USE ') + $found = true; + if (! $found) { + $logDir = PATH_DATA . 'log'; + if (! file_exists( $logDir )) + if (! mkdir( $logDir )) + return; + $logFile = "$logDir/query.log"; + $fp = fopen( $logFile, 'a+' ); + if ($fp !== false) { + fwrite( $fp, date( "Y-m-d H:i:s" ) . " " . $this->sDataBase . " " . $sQuery . "\n" ); + fclose( $fp ); + } + } + } catch (Exception $oException) { + } + } + + /** + * execute a sql query + * + * @param $sQuery table name + * @return void + */ + public function executeQuery ($sQuery) + { + $this->logQuery( $sQuery ); + + try { + if ($this->oConnection) { + @mysql_select_db( $this->sDataBase ); + + return @mysql_query( $sQuery ); + } else { + throw new Exception( 'invalid connection to database ' . $this->sDataBase ); + } + } catch (Exception $oException) { + $this->logQuery( $oException->getMessage() ); + throw $oException; + } + } + + /** + * count the rows of a dataset + * + * @param $oDataset + * @return the number of rows + */ + public function countResults ($oDataset) + { + return @mysql_num_rows( $oDataset ); + } + + /** + * count an array of the registry from a dataset + * + * @param $oDataset + * @return the registry + */ + public function getRegistry ($oDataset) + { + return @mysql_fetch_array( $oDataset, $this->iFetchType ); + } + + /** + * close the current connection + * + * @return void + */ + public function close () + { + @mysql_close( $this->oConnection ); + } + + public function generateInsertSQL ($table, $data) + { + $fields = array (); + $values = array (); + foreach ($data as $field) { + $fields[] = $field['field']; + if (! is_null( $field['value'] )) { + switch ($field['type']) { + case 'text': + case 'date': + $values[] = "'" . mysql_real_escape_string( $field['value'] ) . "'"; + break; + case 'int': + default: + $values[] = mysql_real_escape_string( $field['value'] ); + break; + } + } else { + $values[] = $this->nullString; + } + } + $fields = array_map( array ($this,'putQuotes' + ), $fields ); + $sql = sprintf( "INSERT INTO %s (%s) VALUES (%s)", $this->putQuotes( $table ), implode( ', ', $fields ), implode( ', ', $values ) ); + return $sql; + } + + public function generateUpdateSQL ($table, $keys, $data) + { + $fields = array (); + $where = array (); + foreach ($data as $field) { + if (! is_null( $field['value'] )) { + switch ($field['type']) { + case 'text': + case 'date': + $fields[] = $this->putQuotes( $field['field'] ) . " = '" . mysql_real_escape_string( $field['value'] ) . "'"; + break; + case 'int': + default: + $fields[] = $this->putQuotes( $field['field'] ) . " = " . mysql_real_escape_string( $field['value'] ); + break; + } + } else { + $values[] = $this->nullString; + } + if (in_array( $field['field'], $keys )) { + $where[] = $fields[count( $fields ) - 1]; + } + } + $sql = sprintf( "UPDATE %s SET %s WHERE %s", $this->putQuotes( $table ), implode( ', ', $fields ), implode( ', ', $where ) ); + return $sql; + } + + public function generateDeleteSQL ($table, $keys, $data) + { + $fields = array (); + $where = array (); + foreach ($data as $field) { + if (in_array( $field['field'], $keys )) { + if (! is_null( $field['value'] )) { + switch ($field['type']) { + case 'text': + case 'date': + $where[] = $this->putQuotes( $field['field'] ) . " = '" . mysql_real_escape_string( $field['value'] ) . "'"; + break; + case 'int': + default: + $where[] = $this->putQuotes( $field['field'] ) . " = " . mysql_real_escape_string( $field['value'] ); + break; + } + } else { + $values[] = $this->nullString; + } + } + } + $sql = sprintf( "DELETE FROM %s WHERE %s", $this->putQuotes( $table ), implode( ', ', $where ) ); + return $sql; + } + + public function generateSelectSQL ($table, $keys, $data) + { + $fields = array (); + $where = array (); + foreach ($data as $field) { + if (in_array( $field['field'], $keys )) { + if (! is_null( $field['value'] )) { + switch ($field['type']) { + case 'text': + case 'date': + $where[] = $this->putQuotes( $field['field'] ) . " = '" . mysql_real_escape_string( $field['value'] ) . "'"; + break; + case 'int': + default: + $where[] = $this->putQuotes( $field['field'] ) . " = " . mysql_real_escape_string( $field['value'] ); + break; + } + } else { + $values[] = $this->nullString; + } + } + } + $sql = sprintf( "SELECT * FROM %s WHERE %s", $this->putQuotes( $table ), implode( ', ', $where ) ); + return $sql; + } + + private function putQuotes ($element) + { + return $this->sQuoteCharacter . $element . $this->sQuoteCharacter; + } + + /*=================================================================================================*/ + /** + * concatString + * Generates a string equivalent to the chosen database. + * + * author Hector Cortez + * date 2010-08-04 + * + * @return string $sConcat + */ + function concatString () + { + $nums = func_num_args(); + $vars = func_get_args(); + + $sConcat = " CONCAT("; + for ($i = 0; $i < $nums; $i ++) { + if (isset( $vars[$i] )) { + $sConcat .= $vars[$i]; + if (($i + 1) < $nums) + $sConcat .= ", "; + } + } + $sConcat .= ")"; + + return $sConcat; + + } + + /* * query functions for class class.case.php * - */ - /** - * concatString - * Generates a string equivalent to the case when - * - * author Hector Cortez - * date 2010-08-04 - * - * @return string $sCompare - */ - function getCaseWhen($compareValue, $trueResult, $falseResult) - { - $sCompare = "IF(" . $compareValue . ", " . $trueResult . ", " . $falseResult . ") "; - return $sCompare; - - } - - /** - * Generates a string equivalent to create table ObjectPermission - * - * class.case.php - * function verifyTable() - * - * @return string $sql - */ - function createTableObjectPermission() - { - $sql = "CREATE TABLE IF NOT EXISTS `OBJECT_PERMISSION` ( + */ + /** + * concatString + * Generates a string equivalent to the case when + * + * author Hector Cortez + * date 2010-08-04 + * + * @return string $sCompare + */ + function getCaseWhen ($compareValue, $trueResult, $falseResult) + { + $sCompare = "IF(" . $compareValue . ", " . $trueResult . ", " . $falseResult . ") "; + return $sCompare; + + } + + /** + * Generates a string equivalent to create table ObjectPermission + * + * class.case.php + * function verifyTable() + * + * @return string $sql + */ + function createTableObjectPermission () + { + $sql = "CREATE TABLE IF NOT EXISTS `OBJECT_PERMISSION` ( `OP_UID` varchar(32) NOT NULL, `PRO_UID` varchar(32) NOT NULL, `TAS_UID` varchar(32) NOT NULL, @@ -629,30 +661,29 @@ class database extends database_base { `OP_OBJ_UID` varchar(32) NOT NULL, `OP_ACTION` varchar(10) NOT NULL default 'VIEW', KEY `PRO_UID` (`PRO_UID`,`TAS_UID`,`USR_UID`,`OP_TASK_SOURCE`,`OP_OBJ_UID`) - )ENGINE=MyISAM DEFAULT CHARSET=latin1;"; - return $sql; - } - - /* + )ENGINE=MyISAM DEFAULT CHARSET=latin1;"; + return $sql; + } + + /* * query functions for class class.report.php * - */ - /** - * Generates a string query - * - * class.report.php - * function generatedReport4() - * - * @return string $sql - */ - function getSelectReport4() - { - - $sqlConcat = " CONCAT(U.USR_LASTNAME,' ',USR_FIRSTNAME) AS USER "; - $sqlGroupBy = " USER "; - - $sql = "SELECT " . $sqlConcat . ", " . - " COUNT(*) AS CANTCASES, + */ + /** + * Generates a string query + * + * class.report.php + * function generatedReport4() + * + * @return string $sql + */ + function getSelectReport4 () + { + + $sqlConcat = " CONCAT(U.USR_LASTNAME,' ',USR_FIRSTNAME) AS USER "; + $sqlGroupBy = " USER "; + + $sql = "SELECT " . $sqlConcat . ", " . " COUNT(*) AS CANTCASES, MIN(AD.DEL_DURATION) AS MIN, MAX(AD.DEL_DURATION) AS MAX, SUM(AD.DEL_DURATION) AS TOTALDUR, @@ -661,27 +692,26 @@ class database extends database_base { LEFT JOIN APP_DELEGATION AS AD ON(A.APP_UID = AD.APP_UID AND AD.DEL_INDEX=1) LEFT JOIN USERS AS U ON(U.USR_UID = A.APP_INIT_USER) WHERE A.APP_UID<>'' - GROUP BY " . $sqlGroupBy; - - return $sql; - - } - - /** - * Generates a string query - * - * class.report.php - * function generatedReport4_filter() - * - * @return string $sql - */ - function getSelectReport4Filter($var) - { - $sqlConcat = " CONCAT(U.USR_LASTNAME,' ',USR_FIRSTNAME) AS USER "; - $sqlGroupBy = " USER "; - - $sql = " SELECT " . $sqlConcat . ", " . - " COUNT(*) AS CANTCASES, + GROUP BY " . $sqlGroupBy; + + return $sql; + + } + + /** + * Generates a string query + * + * class.report.php + * function generatedReport4_filter() + * + * @return string $sql + */ + function getSelectReport4Filter ($var) + { + $sqlConcat = " CONCAT(U.USR_LASTNAME,' ',USR_FIRSTNAME) AS USER "; + $sqlGroupBy = " USER "; + + $sql = " SELECT " . $sqlConcat . ", " . " COUNT(*) AS CANTCASES, MIN(AD.DEL_DURATION) AS MIN, MAX(AD.DEL_DURATION) AS MAX, SUM(AD.DEL_DURATION) AS TOTALDUR, @@ -689,28 +719,27 @@ class database extends database_base { FROM APPLICATION AS A LEFT JOIN APP_DELEGATION AS AD ON(A.APP_UID = AD.APP_UID AND AD.DEL_INDEX=1) LEFT JOIN USERS AS U ON(U.USR_UID = A.APP_INIT_USER) - ".$var." - GROUP BY " . $sqlGroupBy; - - return $sql; - - } - - /** - * Generates a string query - * - * class.report.php - * function generatedReport5() - * - * @return string $sql - */ - function getSelectReport5() - { - $sqlConcat = " CONCAT(U.USR_LASTNAME,' ',USR_FIRSTNAME) AS USER "; - $sqlGroupBy = " USER "; - - $sql = " SELECT " . $sqlConcat . ", " . - " COUNT(*) AS CANTCASES, + " . $var . " + GROUP BY " . $sqlGroupBy; + + return $sql; + + } + + /** + * Generates a string query + * + * class.report.php + * function generatedReport5() + * + * @return string $sql + */ + function getSelectReport5 () + { + $sqlConcat = " CONCAT(U.USR_LASTNAME,' ',USR_FIRSTNAME) AS USER "; + $sqlGroupBy = " USER "; + + $sql = " SELECT " . $sqlConcat . ", " . " COUNT(*) AS CANTCASES, MIN(AD.DEL_DURATION) AS MIN, MAX(AD.DEL_DURATION) AS MAX, SUM(AD.DEL_DURATION) AS TOTALDUR, @@ -719,28 +748,27 @@ class database extends database_base { LEFT JOIN PROCESS AS P ON (P.PRO_UID = AD.PRO_UID) LEFT JOIN USERS AS U ON(U.USR_UID = AD.USR_UID) WHERE AD.APP_UID<>'' AND AD.DEL_FINISH_DATE IS NULL - GROUP BY " . $sqlGroupBy; - - return $sql; - - } - - /** - * Generates a string query - * - * class.report.php - * function generatedReport5_filter() - * - * @return string $sql - */ - function getSelectReport5Filter($var) - { - - $sqlConcat = " CONCAT(U.USR_LASTNAME,' ',USR_FIRSTNAME) AS USER "; - $sqlGroupBy = " USER "; - - $sql = "SELECT " . $sqlConcat . ", " . - " COUNT(*) AS CANTCASES, + GROUP BY " . $sqlGroupBy; + + return $sql; + + } + + /** + * Generates a string query + * + * class.report.php + * function generatedReport5_filter() + * + * @return string $sql + */ + function getSelectReport5Filter ($var) + { + + $sqlConcat = " CONCAT(U.USR_LASTNAME,' ',USR_FIRSTNAME) AS USER "; + $sqlGroupBy = " USER "; + + $sql = "SELECT " . $sqlConcat . ", " . " COUNT(*) AS CANTCASES, MIN(AD.DEL_DURATION) AS MIN, MAX(AD.DEL_DURATION) AS MAX, SUM(AD.DEL_DURATION) AS TOTALDUR, @@ -748,107 +776,106 @@ class database extends database_base { FROM APP_DELEGATION AS AD LEFT JOIN PROCESS AS P ON (P.PRO_UID = AD.PRO_UID) LEFT JOIN USERS AS U ON(U.USR_UID = AD.USR_UID) - ".$var." - GROUP BY " . $sqlGroupBy; - - return $sql; - } - - /* + " . $var . " + GROUP BY " . $sqlGroupBy; + + return $sql; + } + + /* * query functions for class class.net.php * - */ - function getServerVersion($driver, $dbIP, $dbPort, $dbUser, $dbPasswd, $dbSourcename) - { - - if($link = @mysql_connect($dbIP, $dbUser, $dbPasswd)){ - $v = @mysql_get_server_info(); - } else { - throw new Exception(@mysql_error($link)); - } - return (isset($v))?$v:'none'; - - } - - + */ + function getServerVersion ($driver, $dbIP, $dbPort, $dbUser, $dbPasswd, $dbSourcename) + { + + if ($link = @mysql_connect( $dbIP, $dbUser, $dbPasswd )) { + $v = @mysql_get_server_info(); + } else { + throw new Exception( @mysql_error( $link ) ); + } + return (isset( $v )) ? $v : 'none'; + + } + /* * query functions for class class.net.php, class.reportTables.php * - */ - function getDropTable($sTableName) - { - $sql = 'DROP TABLE IF EXISTS `' . $sTableName . '`'; - return $sql; - } - - - function getTableDescription($sTableName) - { - $sql = "DESC ".$sTableName; - return $sql; - } - - function getFieldNull() - { - $fieldName = "Null"; - return $fieldName; - } - - function getValidate($validate) - { - $oValidate = $validate; - return $oValidate; - } - - /** - * Determines whether a table exists - * It is part of class.reportTables.php - */ - function reportTableExist() - { - $bExists = true; - $oConnection = mysql_connect(DB_HOST, DB_USER, DB_PASS); - mysql_select_db(DB_NAME); - $oDataset = mysql_query('SELECT COUNT(*) FROM REPORT_TABLE') || ($bExists = false); - - return $bExists; - } - - /** - * It is part of class.pagedTable.php - */ - function getLimitRenderTable($nCurrentPage, $nRowsPerPage) - { - $sql = ' LIMIT '.(($nCurrentPage-1)*$nRowsPerPage).', '.$nRowsPerPage; - return $sql; - } - - /** - * Determining the existence of a table - */ - function tableExists($tableName, $database) - { - @mysql_select_db($database); - $tables = array(); - $tablesResult = mysql_query("SHOW TABLES FROM $database;"); - while ($row = @mysql_fetch_row($tablesResult)) $tables[] = $row[0]; - if(in_array($tableName, $tables)) { - return TRUE; - } - return FALSE; - } - -/* - * Determining the existence of a table (Depricated) - */ -// function tableExists ($table, $db) { -// $tables = mysql_list_tables ($db); -// while (list ($temp) = @mysql_fetch_array ($tables)) { -// if ($temp == $table) { -// return TRUE; -// } -// } -// return FALSE; -// } - -} \ No newline at end of file + */ + function getDropTable ($sTableName) + { + $sql = 'DROP TABLE IF EXISTS `' . $sTableName . '`'; + return $sql; + } + + function getTableDescription ($sTableName) + { + $sql = "DESC " . $sTableName; + return $sql; + } + + function getFieldNull () + { + $fieldName = "Null"; + return $fieldName; + } + + function getValidate ($validate) + { + $oValidate = $validate; + return $oValidate; + } + + /** + * Determines whether a table exists + * It is part of class.reportTables.php + */ + function reportTableExist () + { + $bExists = true; + $oConnection = mysql_connect( DB_HOST, DB_USER, DB_PASS ); + mysql_select_db( DB_NAME ); + $oDataset = mysql_query( 'SELECT COUNT(*) FROM REPORT_TABLE' ) || ($bExists = false); + + return $bExists; + } + + /** + * It is part of class.pagedTable.php + */ + function getLimitRenderTable ($nCurrentPage, $nRowsPerPage) + { + $sql = ' LIMIT ' . (($nCurrentPage - 1) * $nRowsPerPage) . ', ' . $nRowsPerPage; + return $sql; + } + + /** + * Determining the existence of a table + */ + function tableExists ($tableName, $database) + { + @mysql_select_db( $database ); + $tables = array (); + $tablesResult = mysql_query( "SHOW TABLES FROM $database;" ); + while ($row = @mysql_fetch_row( $tablesResult )) + $tables[] = $row[0]; + if (in_array( $tableName, $tables )) { + return TRUE; + } + return FALSE; + } + + /* + * Determining the existence of a table (Depricated) + */ + // function tableExists ($table, $db) { + // $tables = mysql_list_tables ($db); + // while (list ($temp) = @mysql_fetch_array ($tables)) { + // if ($temp == $table) { + // return TRUE; + // } + // } + // return FALSE; + // } +} + diff --git a/gulliver/system/class.dbconnection.php b/gulliver/system/class.dbconnection.php index 1875108f0..50b374f93 100755 --- a/gulliver/system/class.dbconnection.php +++ b/gulliver/system/class.dbconnection.php @@ -1,278 +1,295 @@ -. - * - * For more information, contact Colosa Inc, 2566 Le Jeune Rd., - * Coral Gables, FL, 33134, USA, or email info@colosa.com. - * - */ - -/** - * @package gulliver.system -*/ - -require_once ("DB.php"); - -define ( 'DB_ERROR_NO_SHOW_AND_CONTINUE', 0); -define ( 'DB_ERROR_SHOW_AND_STOP', 1); -define ( 'DB_ERROR_SHOW_AND_CONTINUE', 2); -define ( 'DB_ERROR_SHOWALL_AND_STOP', 3); -define ( 'DB_ERROR_SHOWALL_AND_CONTINUE', 4); - - /** - * DBConnection class definition - * It is useful to stablish a connection - * @package gulliver.system - * @author Fernando Ontiveros Lira - * @copyright (C) 2002 by Colosa Development Team. - */ -class DBConnection -{ - var $db; - var $db_error; - var $errorLevel; - var $type; - -/***************************************************************** -/* Error types: -/* -1 Fatal error ( clase no instanced ) -/* -2 Syntax error ( session missing, query malformed, etc ) -/* -3 warning ( when the engine build a dangerous query, i.e delete without where clause ) -/* -/* Error level: -/* 0 don't display any error information and continue. -/* 1 display small box with error information and die. -/* 2 display small box with error information and continue -/* 3 display complete error information and die. -/* 4 display complete error information and continue. -/* -/* Error Structure -/* int error code -/* string error message -/* string error detailed message -/* -/* In all cases, the error will be saved in the apache log file -/* -/* */ - - /** - * Starts DB connection with default values - * @author Fernando Ontiveros Lira - * @access public - * @param const $strServer Host Name - * @param const $strUser User Name - * @param const $strPwd Password - * @param const $strDB Database Name - * @param string $type Connection Type - * @param integer $strPort Used Port - * @param string $errorLevel Error values posibles are: - * @return string - * - */ - function DBConnection( $strServer = DB_HOST, $strUser = DB_USER, $strPwd = DB_PASS, $strDB = DB_NAME , $type = DB_ADAPTER, $strPort = 0, $errorLevel = 2 ) - { - $this->errorLevel = $errorLevel; - if ($type == null ) $type = 'mysql'; - $this->type = $type; - //print "
$type $strServer, $strUser, $strPwd, $strDB
"; - if ( $type == "mysql" ) - $dsn = "mysql://$strUser:$strPwd@$strServer/$strDB"; - if ( $type == "pgsql" ) { - //$dsn = "pgsql://postgres@$strServer/$strDB"; - $prt = ( $strPort == 0 || $strPort == 5432 ? '' : ":$strPort" ); - $dsn = "pgsql://$strUser:$strPwd@$strServer$prt/$strDB"; - } - if ( $type == "odbc" ) - $dsn = "odbc://$strUser:$strPwd@$strServer/$strDB"; - if ( $type == "mssql" ) { - $strServer = substr($strServer, 0, strpos($strServer,':')); - $prt = ( $strPort == 0 || $strPort == 1433 ? '' : ":$strPort" ); - $dsn = "mssql://$strUser:$strPwd@$strServer$prt/$strDB"; - ///--) $dsn = "mssql://$strUser:$strPwd@$strServer/$strDB"; - } - if ( $type == "oracle" ) { - $dsn = "oci8://$strUser:$strPwd@$strServer/$strDB"; - } - $this->db_error = NULL; - if ( $type === 'myxml' ) { - $this->db = XMLDB::connect ( $strServer ); - } else { - $this->db = DB::connect ( $dsn ); - } - if ( DB::isError ($this->db) ) { - $this->db_error = $this->db; - $this->db = NULL; - $this->logError( $this->db_error ); - } - } - - /** - * Close Connection and Generate Log Message - * @author Fernando Ontiveros Lira - * @access public - * @return void - */ - function Reset() - { - if ( $this->db ){ - $this->db->disconnect(); - } - $this->db = NULL; - } - - /** - * Disconnect from Data base - * @author Fernando Ontiveros Lira - * @access public - * @return void - */ - function Free() - { - $this->Reset(); - } - - /** - * Close Connection - * @author Fernando Ontiveros Lira - * @access public - * @return void - */ - function Close() - { - $this->Reset(); - } - - /** - * log Errors - * @author Fernando Ontiveros Lira - * @access public - * @param db_error $obj - * @param string $errorLevel - * @return void - */ - function logError( $obj, $errorLevel = NULL ) - { - global $_SESSION; - global $_SERVER; - if ( is_null( $errorLevel ) ) - if ( isset ( $this->errorLevel) ) - $errorLevel = $this->errorLevel; - else - $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 ) { - print ""; - print ""; - if ($errorLevel == DB_ERROR_SHOWALL_AND_STOP || $errorLevel == DB_ERROR_SHOWALL_AND_CONTINUE ) { - print ""; - } - print "
" . $obj->code . ' '. $obj->message . "
" . $obj->userinfo . "
"; - } - if (defined('DB_ERROR_BACKTRACE') && DB_ERROR_BACKTRACE) { - print "
"; - } - //G::setErrorHandler ( ); - G::customErrorLog ('DB_Error', $obj->code . ' '. $obj->message .'-' . $obj->userinfo, '', ''); - if ($errorLevel == DB_ERROR_SHOW_AND_STOP || $errorLevel == DB_ERROR_SHOWALL_AND_STOP ) { - die; //stop - } - } - - /** - * Get the trace of the current execution (debug_backtrace). - * @author David Callizaya - * @param string $tts - * @param string $limit - * @return string - */ - function traceError( $tts=2 , $limit=-1 ) - { - $trace = debug_backtrace(); - $out=''; - foreach($trace as $step) { - if ($tts>0) { - $tts--; - } else { - $out .= '['.basename($step['file']).': '.$step['line'].'] : ' . $step['function'] .'(' . - DBConnection::printArgs($step['args']). ")\n"; - $limit--; - if ($limit===0) - return $out; - } - } - return $out; - } - - /** - * Print the arguments of a function - * @author David Callizaya - * @param string $args - * @return string - */ - function printArgs( $args ) - { - $out = ''; - if (is_array($args)){ - foreach($args as $arg) { - if ($out!=='') - $out .= ' ,'; - if (is_string($arg)) - $out .= "'".($arg)."'"; - elseif (is_array($arg) ) - $out .= print_r ( $arg ,1 ); - elseif (is_object($arg)) - $out .= get_class($arg);// print_r ( $arg ,1 ); - elseif (!isset($arg)) - $out .= 'NULL'; - else - $out .= sprintf ( "%s" ,$arg ); - } - } else { - if (!isset($args)) - $out = 'NULL'; - else - $out = print_r($args,1); - } - return $out; - } - - /** - * Gets last autoincrement value inserted - * @author Fernando Ontiveros Lira - * @access public - * @return void - */ - function GetLastID() - { - if ( PEAR_DATABASE == "mysql" ){ - return mysql_insert_id(); - } - else { - $dberror = PEAR::raiseError(null, DB_ERROR_FEATURE_NOT_AVAILABLE, null, 'null', - "getLastID with " . PEAR_DATABASE . ' database.', - 'G_Error', true); - DBconnection::logError( $dberror, DB_ERROR_SHOWALL_AND_STOP ); //this error will stop the execution, until we add this feature!! - return $dberror; - } - return mysql_insert_id(); - } -} \ No newline at end of file +. + * + * For more information, contact Colosa Inc, 2566 Le Jeune Rd., + * Coral Gables, FL, 33134, USA, or email info@colosa.com. + * + */ + +/** + * + * @package gulliver.system + * + */ + +require_once ("DB.php"); + +define( 'DB_ERROR_NO_SHOW_AND_CONTINUE', 0 ); +define( 'DB_ERROR_SHOW_AND_STOP', 1 ); +define( 'DB_ERROR_SHOW_AND_CONTINUE', 2 ); +define( 'DB_ERROR_SHOWALL_AND_STOP', 3 ); +define( 'DB_ERROR_SHOWALL_AND_CONTINUE', 4 ); + +/** + * DBConnection class definition + * It is useful to stablish a connection + * + * @package gulliver.system + * @author Fernando Ontiveros Lira + * @copyright (C) 2002 by Colosa Development Team. + */ +class DBConnection +{ + var $db; + var $db_error; + var $errorLevel; + var $type; + + /** + * *************************************************************** + * /* Error types: + * /* -1 Fatal error ( clase no instanced ) + * /* -2 Syntax error ( session missing, query malformed, etc ) + * /* -3 warning ( when the engine build a dangerous query, i.e delete without where clause ) + * /* + * /* Error level: + * /* 0 don't display any error information and continue. + * /* 1 display small box with error information and die. + * /* 2 display small box with error information and continue + * /* 3 display complete error information and die. + * /* 4 display complete error information and continue. + * /* + * /* Error Structure + * /* int error code + * /* string error message + * /* string error detailed message + * /* + * /* In all cases, the error will be saved in the apache log file + * /* + * /* + */ + + /** + * Starts DB connection with default values + * + * @author Fernando Ontiveros Lira + * @access public + * @param const $strServer Host Name + * @param const $strUser User Name + * @param const $strPwd Password + * @param const $strDB Database Name + * @param string $type Connection Type + * @param integer $strPort Used Port + * @param string $errorLevel Error values posibles are: + * @return string + * + */ + function DBConnection ($strServer = DB_HOST, $strUser = DB_USER, $strPwd = DB_PASS, $strDB = DB_NAME, $type = DB_ADAPTER, $strPort = 0, $errorLevel = 2) + { + $this->errorLevel = $errorLevel; + if ($type == null) + $type = 'mysql'; + $this->type = $type; + //print "
$type $strServer, $strUser, $strPwd, $strDB
"; + if ($type == "mysql") + $dsn = "mysql://$strUser:$strPwd@$strServer/$strDB"; + if ($type == "pgsql") { + //$dsn = "pgsql://postgres@$strServer/$strDB"; + $prt = ($strPort == 0 || $strPort == 5432 ? '' : ":$strPort"); + $dsn = "pgsql://$strUser:$strPwd@$strServer$prt/$strDB"; + } + if ($type == "odbc") + $dsn = "odbc://$strUser:$strPwd@$strServer/$strDB"; + if ($type == "mssql") { + $strServer = substr( $strServer, 0, strpos( $strServer, ':' ) ); + $prt = ($strPort == 0 || $strPort == 1433 ? '' : ":$strPort"); + $dsn = "mssql://$strUser:$strPwd@$strServer$prt/$strDB"; + ///--) $dsn = "mssql://$strUser:$strPwd@$strServer/$strDB"; + } + if ($type == "oracle") { + $dsn = "oci8://$strUser:$strPwd@$strServer/$strDB"; + } + $this->db_error = null; + if ($type === 'myxml') { + $this->db = XMLDB::connect( $strServer ); + } else { + $this->db = DB::connect( $dsn ); + } + if (DB::isError( $this->db )) { + $this->db_error = $this->db; + $this->db = null; + $this->logError( $this->db_error ); + } + } + + /** + * Close Connection and Generate Log Message + * + * @author Fernando Ontiveros Lira + * @access public + * @return void + */ + function Reset () + { + if ($this->db) { + $this->db->disconnect(); + } + $this->db = null; + } + + /** + * Disconnect from Data base + * + * @author Fernando Ontiveros Lira + * @access public + * @return void + */ + function Free () + { + $this->Reset(); + } + + /** + * Close Connection + * + * @author Fernando Ontiveros Lira + * @access public + * @return void + */ + function Close () + { + $this->Reset(); + } + + /** + * log Errors + * + * @author Fernando Ontiveros Lira + * @access public + * @param db_error $obj + * @param string $errorLevel + * @return void + */ + function logError ($obj, $errorLevel = NULL) + { + global $_SESSION; + global $_SERVER; + if (is_null( $errorLevel )) + if (isset( $this->errorLevel )) { + $errorLevel = $this->errorLevel; + } else { + $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) { + print ""; + print ""; + if ($errorLevel == DB_ERROR_SHOWALL_AND_STOP || $errorLevel == DB_ERROR_SHOWALL_AND_CONTINUE) { + print ""; + } + print "
" . $obj->code . ' ' . $obj->message . "
" . $obj->userinfo . "
"; + } + if (defined( 'DB_ERROR_BACKTRACE' ) && DB_ERROR_BACKTRACE) { + print "
"; + } + //G::setErrorHandler ( ); + G::customErrorLog( 'DB_Error', $obj->code . ' ' . $obj->message . '-' . $obj->userinfo, '', '' ); + if ($errorLevel == DB_ERROR_SHOW_AND_STOP || $errorLevel == DB_ERROR_SHOWALL_AND_STOP) { + die(); //stop + } + } + + /** + * Get the trace of the current execution (debug_backtrace). + * + * @author David Callizaya + * @param string $tts + * @param string $limit + * @return string + */ + function traceError ($tts = 2, $limit = -1) + { + $trace = debug_backtrace(); + $out = ''; + foreach ($trace as $step) { + if ($tts > 0) { + $tts --; + } else { + $out .= '[' . basename( $step['file'] ) . ': ' . $step['line'] . '] : ' . $step['function'] . '(' . DBConnection::printArgs( $step['args'] ) . ")\n"; + $limit --; + if ($limit === 0) { + return $out; + } + } + } + return $out; + } + + /** + * Print the arguments of a function + * + * @author David Callizaya + * @param string $args + * @return string + */ + function printArgs ($args) + { + $out = ''; + if (is_array( $args )) { + foreach ($args as $arg) { + if ($out !== '') { + $out .= ' ,'; + } + if (is_string( $arg )) { + $out .= "'" . ($arg) . "'"; + } elseif (is_array( $arg )) { + $out .= print_r( $arg, 1 ); + } elseif (is_object( $arg )) { + $out .= get_class( $arg ); // print_r ( $arg ,1 ); + } elseif (! isset( $arg )) { + $out .= 'NULL'; + } else { + $out .= sprintf( "%s", $arg ); + } + } + } else { + if (! isset( $args )) { + $out = 'NULL'; + } else { + $out = print_r( $args, 1 ); + } + } + return $out; + } + + /** + * Gets last autoincrement value inserted + * + * @author Fernando Ontiveros Lira + * @access public + * @return void + */ + function GetLastID () + { + if (PEAR_DATABASE == "mysql") { + return mysql_insert_id(); + } else { + $dberror = PEAR::raiseError( null, DB_ERROR_FEATURE_NOT_AVAILABLE, null, 'null', "getLastID with " . PEAR_DATABASE . ' database.', 'G_Error', true ); + DBconnection::logError( $dberror, DB_ERROR_SHOWALL_AND_STOP ); //this error will stop the execution, until we add this feature!! + return $dberror; + } + return mysql_insert_id(); + } +} + diff --git a/gulliver/system/class.g.php b/gulliver/system/class.g.php old mode 100755 new mode 100644 index 1f979e6a7..57a512acc --- a/gulliver/system/class.g.php +++ b/gulliver/system/class.g.php @@ -30,50 +30,47 @@ class G { - /** * is_https * @return void */ - function is_https() - { - if(isset($_SERVER['HTTPS'])) + function is_https() { - if($_SERVER['HTTPS']=='on') - return true; - else - return false; - } - else - return false; - } - - /** - * Fill array values (recursive) - * @author maborak - * @access public - * @param Array $arr - * @param Void $value - * @param Boolean $recursive - * @return Array - */ - function array_fill_value($arr = Array(),$value = '',$recursive = false) - { - if(is_array($arr)) { - foreach($arr as $key=>$val) { - if(is_array($arr[$key])) { - $arr[$key] = ($recursive===true)?G::array_fill_value($arr[$key],$value,true):$val; + if(isset($_SERVER['HTTPS'])) + { + if($_SERVER['HTTPS']=='on') + return true; + else + return false; + } else { + return false; } - else { - $arr[$key] = $value; - } - } + } + /** + * Fill array values (recursive) + * + * @author maborak + * @access public + * @param Array $arr + * @param Void $value + * @param Boolean $recursive + * @return Array + */ + function array_fill_value ($arr = Array(), $value = '', $recursive = false) + { + if (is_array( $arr )) { + foreach ($arr as $key => $val) { + if (is_array( $arr[$key] )) { + $arr[$key] = ($recursive === true) ? G::array_fill_value( $arr[$key], $value, true ) : $val; + } else { + $arr[$key] = $value; + } + } + } else { + $arr = Array (); + } + return $arr; } - else { - $arr = Array(); - } - return $arr; - } /** * Generate Password Random @@ -82,44 +79,43 @@ class G * @param Int * @return String */ - function generate_password($length = 8) - { - $password = ""; - $possible = "0123456789bcdfghjkmnpqrstvwxyz"; - $i = 0; - while($i<$length) { - $char = substr($possible, mt_rand(0, strlen($possible)-1), 1); - if(!strstr($password, $char)) { - $password .= $char; - $i++; - } - } - return $password; - } - - /** - * Array concat - * array_concat(ArrayToConcat,ArrayOriginal); - * @author maborak - * @access public - * @param Array - * @return Array - */ - function array_concat() - { - $nums = func_num_args(); - $vars = func_get_args(); - $ret = Array(); - for($i = 0;$i < $nums; $i++) + function generate_password($length = 8) { - if(is_array($vars[$i])) { - foreach($vars[$i] as $key=>$value) { - $ret[$key] = $value; + $password = ""; + $possible = "0123456789bcdfghjkmnpqrstvwxyz"; + $i = 0; + while($i<$length) { + $char = substr($possible, mt_rand(0, strlen($possible)-1), 1); + if(!strstr($password, $char)) { + $password .= $char; + $i++; + } } - } + return $password; + } + /** + * Array concat + * array_concat(ArrayToConcat,ArrayOriginal); + * + * @author maborak + * @access public + * @param Array + * @return Array + */ + function array_concat () + { + $nums = func_num_args(); + $vars = func_get_args(); + $ret = Array (); + for ($i = 0; $i < $nums; $i ++) { + if (is_array( $vars[$i] )) { + foreach ($vars[$i] as $key => $value) { + $ret[$key] = $value; + } + } + } + return $ret; } - return $ret; - } /** * Compare Variables @@ -130,19 +126,21 @@ class G * @param void $var1-N * @return Boolean */ - function var_compare($value=true,$varN) - { - $nums = func_num_args(); - if($nums<2){return true;} - $vars = func_get_args(); - $ret = Array(); - for($i=1;$i<$nums;$i++) { - if($vars[$i]!==$value) { - return false; - } + function var_compare ($value = true, $varN) + { + $nums = func_num_args(); + if ($nums < 2) { + return true; + } + $vars = func_get_args(); + $ret = Array (); + for ($i = 1; $i < $nums; $i ++) { + if ($vars[$i] !== $value) { + return false; + } + } + return true; } - return true; - } /** * Emulate variable selector * @author maborak @@ -150,1041 +148,1038 @@ class G * @param void * @return void */ - function var_probe() - { - //return (!$variable)? - $nums = func_num_args(); - $vars = func_get_args(); - for($i=0;$i<$nums;$i++) { - if($vars[$i]) { - return $vars[$i]; - } + function var_probe () + { + //return (!$variable)? + $nums = func_num_args(); + $vars = func_get_args(); + for ($i = 0; $i < $nums; $i ++) { + if ($vars[$i]) { + return $vars[$i]; + } + } + return 1; + } + + /** + * Get the current version of gulliver classes + * + * @author Fernando Ontiveros Lira + * @access public + * @return string + */ + function &getVersion () + { + //majorVersion.minorVersion-SvnRevision + return '3.0-1'; } - return 1; - } - - /** - * Get the current version of gulliver classes - * @author Fernando Ontiveros Lira - * @access public - * @return string - */ - function &getVersion( ) - { - //majorVersion.minorVersion-SvnRevision - return '3.0-1'; - } /** * getIpAddress * @return string $ip */ - function getIpAddress () - { - if (getenv('HTTP_CLIENT_IP')) { - $ip = getenv('HTTP_CLIENT_IP'); - } - elseif(getenv('HTTP_X_FORWARDED_FOR')) { - $ip = getenv('HTTP_X_FORWARDED_FOR'); - } - else { - $ip = getenv('REMOTE_ADDR'); - } - return $ip; - } - - /** - * getMacAddress - * @return string $mac - */ - function getMacAddress() - { - if ( strstr ( getenv ( 'OS' ), 'Windows' ) ) { - $ipconfig = `ipconfig /all`; - preg_match('/[\dA-Z]{2,2}[\:-][\dA-Z]{2,2}[\:-][\dA-Z]{2,2}[\:-][\dA-Z]{2,2}[\:-][\dA-Z]{2,2}[\:-][\dA-Z]{2,2}/i',$ipconfig,$mac); - } else { - $ifconfig = `/sbin/ifconfig`; - preg_match('/[\dA-Z]{2,2}[\:-][\dA-Z]{2,2}[\:-][\dA-Z]{2,2}[\:-][\dA-Z]{2,2}[\:-][\dA-Z]{2,2}[\:-][\dA-Z]{2,2}/i',$ifconfig,$mac); - } - return isset($mac[0])? $mac[0]:'00:00:00:00:00:00'; - } - - /** - * microtime_float - * @return array_sum(explode(' ',microtime())) - */ - /*public static*/ function microtime_float() { - return array_sum(explode(' ',microtime())); - } - /* custom error functions */ - - /** - * &setFatalErrorHandler - * - * @param string $newFatalErrorHandler default value null - * - * @return boolean true - */ + function getIpAddress () + { + if (getenv( 'HTTP_CLIENT_IP' )) { + $ip = getenv( 'HTTP_CLIENT_IP' ); + } elseif (getenv( 'HTTP_X_FORWARDED_FOR' )) { + $ip = getenv( 'HTTP_X_FORWARDED_FOR' ); + } else { + $ip = getenv( 'REMOTE_ADDR' ); + } + return $ip; + } + + /** + * getMacAddress + * + * @return string $mac + */ + function getMacAddress () + { + if (strstr( getenv( 'OS' ), 'Windows' )) { + $ipconfig = `ipconfig /all`; + preg_match( '/[\dA-Z]{2,2}[\:-][\dA-Z]{2,2}[\:-][\dA-Z]{2,2}[\:-][\dA-Z]{2,2}[\:-][\dA-Z]{2,2}[\:-][\dA-Z]{2,2}/i', $ipconfig, $mac ); + } else { + $ifconfig = `/sbin/ifconfig`; + preg_match( '/[\dA-Z]{2,2}[\:-][\dA-Z]{2,2}[\:-][\dA-Z]{2,2}[\:-][\dA-Z]{2,2}[\:-][\dA-Z]{2,2}[\:-][\dA-Z]{2,2}/i', $ifconfig, $mac ); + } + return isset( $mac[0] ) ? $mac[0] : '00:00:00:00:00:00'; + } + + /** + * microtime_float + * + * @return array_sum(explode(' ',microtime())) + */ + /*public static*/ + function microtime_float () + { + return array_sum( explode( ' ', microtime() ) ); + } + /* custom error functions */ + + /** + * &setFatalErrorHandler + * + * @param string $newFatalErrorHandler default value null + * + * @return boolean true + */ /*public static*/ - function &setFatalErrorHandler( $newFatalErrorHandler = null ) - { - if ( isset ( $newFatalErrorHandler ) ) { - set_error_handler( $newFatalErrorHandler ); - } - else { - ob_start( array ( 'G', 'fatalErrorHandler' ) ); - } - return true; - } - - /** - * setErrorHandler - * @param string setErrorHandler - * @param object $newCustomErrorHandler - * - * @return boolean true - */ - /*public static*/ - function setErrorHandler( $newCustomErrorHandler = null ) - { - if ( isset ( $newCustomErrorHandler ) ) { - set_error_handler( $newCustomErrorHandler ); - } - else { - set_error_handler( array("G", "customErrorHandler")); - } - return true; - } - - /** - * fatalErrorHandler - * - * @param string $buffer - * - * @return string $errorBox or $buffer - */ - /*public static*/ function fatalErrorHandler($buffer) { - // The ereg function has been DEPRECATED as of PHP 5.3.0. - // if (ereg("(error:)(.+)(:)(.+)(/","",$regs[2]); - G::customErrorLog('FATAL', $err, '', 0, ''); - $ip_addr = G::getIpAddress(); - $errorBox = "
" . - "" . - "" . - " " . - "
ERROR CAUGHT check log file
IP address: $ip_addr
"; - return $errorBox; - } - return $buffer; - } - - /** - * customErrorHandler - * - * @param string $errno - * @param string $msg - * @param string $file - * @param string $line - * @param string $context - * - * @return void - */ - /*public static*/ - function customErrorHandler ( $errno, $msg, $file, $line, $context) { - switch ($errno) { - case E_ERROR: - case E_USER_ERROR: - $type = "FATAL"; - G::customErrorLog ($type, $msg, $file, $line); - G::verboseError ($type, $errno, $msg, $file, $line, $context); - if (defined ("ERROR_SHOW_SOURCE_CODE") && ERROR_SHOW_SOURCE_CODE) - G::showErrorSource ($type, $msg, $file, $line, "#c00000"); - die (); - break; - case E_WARNING: - case E_USER_WARNING: - $type = "WARNING"; - G::customErrorLog ($type, $msg, $file, $line); - break; - case E_NOTICE: - case E_USER_NOTICE: - $type = "NOTICE"; - if (defined ("ERROR_LOG_NOTICE_ERROR") && ERROR_LOG_NOTICE_ERROR) - G::customErrorLog ($type, $msg, $file, $line); - break; - case E_STRICT: - $type = "STRICT"; //dont show STRICT Errors - //if (defined ("ERROR_LOG_NOTICE_ERROR") && ERROR_LOG_NOTICE_ERROR) - // G::customErrorLog ($type, $msg, $file, $line); - break; - default: - $type = "ERROR ($errno)"; - G::customErrorLog ($type, $msg, $file, $line); - break; - } - - if (defined ("ERROR_SHOW_SOURCE_CODE") && ERROR_SHOW_SOURCE_CODE && $errno <> E_STRICT ) - G::showErrorSource ($type, $msg, $file, $line); - } - - /** - * Function showErrorSource - * @author David S. Callizaya S. - * @access public - * @parameter string type - * @parameter string msg - * @parameter string file - * @parameter string line - * @return string - */ - function showErrorSource($type, $msg, $file, $line) - { - global $__src_array; - $line_offset = 3; - - if (! isset ($__src_array[$file])) - $__src_array[$file] = @file ($file); - - if (!$__src_array[$file]) - return; - - if ($line - $line_offset < 1) - $start = 1; - else - $start = $line - $line_offset; - - if ($line + $line_offset > count ($__src_array[$file])) - $end = count ($__src_array[$file]); - else - $end = $line + $line_offset; - - print ""; + for ($i = $start; $i <= $end; $i ++) { + $str = @highlight_string( "", true ); + + $pos1 = strpos( $str, "<?" ); + $pos2 = strrpos( $str, "?>" ); + + $str = substr( $str, 0, $pos1 ) . substr( $str, $pos1 + 5, $pos2 - ($pos1 + 5) ) . substr( $str, $pos2 + 5 ); + + ($i == $line) ? $bgcolor = "bgcolor=#ffccaa" : $bgcolor = "bgcolor=#ffffff"; + print " + "; + } + + print "
"; - print ""; - print " + function &setFatalErrorHandler ($newFatalErrorHandler = null) + { + if (isset( $newFatalErrorHandler )) { + set_error_handler( $newFatalErrorHandler ); + } else { + ob_start( array ('G','fatalErrorHandler' + ) ); + } + return true; + } + + /** + * setErrorHandler + * + * @param string setErrorHandler + * @param object $newCustomErrorHandler + * + * @return boolean true + */ + /*public static*/ + function setErrorHandler ($newCustomErrorHandler = null) + { + if (isset( $newCustomErrorHandler )) { + set_error_handler( $newCustomErrorHandler ); + } else { + set_error_handler( array ("G","customErrorHandler") ); + } + return true; + } + + /** + * fatalErrorHandler + * + * @param string $buffer + * + * @return string $errorBox or $buffer + */ + /*public static*/ + function fatalErrorHandler ($buffer) + { + // The ereg function has been DEPRECATED as of PHP 5.3.0. + // if (ereg("(error:)(.+)(:)(.+)(/", "", $regs[2] ); + G::customErrorLog( 'FATAL', $err, '', 0, '' ); + $ip_addr = G::getIpAddress(); + $errorBox = "
" . "" . "" . " " . "
ERROR CAUGHT check log file
IP address: $ip_addr
"; + return $errorBox; + } + return $buffer; + } + /** + * customErrorHandler + * + * @param string $errno + * @param string $msg + * @param string $file + * @param string $line + * @param string $context + * + * @return void + */ + /*public static*/ + function customErrorHandler ($errno, $msg, $file, $line, $context) + { + switch ($errno) { + case E_ERROR: + case E_USER_ERROR: + $type = "FATAL"; + G::customErrorLog( $type, $msg, $file, $line ); + G::verboseError( $type, $errno, $msg, $file, $line, $context ); + if (defined( "ERROR_SHOW_SOURCE_CODE" ) && ERROR_SHOW_SOURCE_CODE) + G::showErrorSource( $type, $msg, $file, $line, "#c00000" ); + die(); + break; + case E_WARNING: + case E_USER_WARNING: + $type = "WARNING"; + G::customErrorLog( $type, $msg, $file, $line ); + break; + case E_NOTICE: + case E_USER_NOTICE: + $type = "NOTICE"; + if (defined( "ERROR_LOG_NOTICE_ERROR" ) && ERROR_LOG_NOTICE_ERROR) + G::customErrorLog( $type, $msg, $file, $line ); + break; + case E_STRICT: + $type = "STRICT"; //dont show STRICT Errors + //if (defined ("ERROR_LOG_NOTICE_ERROR") && ERROR_LOG_NOTICE_ERROR) + // G::customErrorLog ($type, $msg, $file, $line); + break; + default: + $type = "ERROR ($errno)"; + G::customErrorLog( $type, $msg, $file, $line ); + break; + } + if (defined( "ERROR_SHOW_SOURCE_CODE" ) && ERROR_SHOW_SOURCE_CODE && $errno != E_STRICT) + G::showErrorSource( $type, $msg, $file, $line ); + } + + /** + * Function showErrorSource + * + * @author David S. Callizaya S. + * @access public + * @param eter string type + * @param eter string msg + * @param eter string file + * @param eter string line + * @return string + */ + function showErrorSource ($type, $msg, $file, $line) + { + global $__src_array; + $line_offset = 3; + + if (! isset( $__src_array[$file] )) + $__src_array[$file] = @file( $file ); + + if (! $__src_array[$file]) + return; + + if ($line - $line_offset < 1) + $start = 1; + else + $start = $line - $line_offset; + + if ($line + $line_offset > count( $__src_array[$file] )) + $end = count( $__src_array[$file] ); + else + $end = $line + $line_offset; + + print "
"; + print ""; + print " - - "; - for ($i = $start; $i <= $end; $i++) { - $str = @highlight_string ("", TRUE); - - $pos1 = strpos ($str,"<?"); - $pos2 = strrpos ($str,"?>"); - - $str = substr ($str, 0, $pos1) . - substr ($str, $pos1+5, $pos2-($pos1+5)) . - substr ($str, $pos2+5); - - ($i == $line) ? $bgcolor = "bgcolor=#ffccaa" : $bgcolor = "bgcolor=#ffffff"; - print " - "; - } - - print "
$type: $msg
File: $file
$i$str

"; - } - - /** - * customErrorLog - * - * @param string $type - * @param string $msg - * @param string $file - * @param string $line - * - * @return void - */ - /*public static*/ - function customErrorLog ($type, $msg, $file, $line) - { - global $HTTP_X_FORWARDED_FOR, $REMOTE_ADDR, $HTTP_USER_AGENT, $REQUEST_URI; - - $ip_addr = G::getIpAddress(); - - if (defined ('APPLICATION_CODE')) - $name = APPLICATION_CODE; - else - $name = "php"; - - if ( $file != '') - $msg .= " in $file:$line "; - - $date = date ( 'Y-m-d H:i:s'); - $REQUEST_URI = getenv ( 'REQUEST_URI' ); - $HTTP_USER_AGENT = getenv ( 'HTTP_USER_AGENT' ); - error_log ("[$date] [$ip_addr] [$name] $type: $msg [$HTTP_USER_AGENT] URI: $REQUEST_URI", 0); - } - - /** - * verboseError - * - * @param string $type - * @param string $errno - * @param string $msg - * @param string $file - * @param string $line - * @param string $context - * - * @return void - */ - /*public static*/ function verboseError ($type, $errno, $msg, $file, $line, $context) { - global $SERVER_ADMIN; - - print "

Error!

"; - print "An error occurred while executing this script. Please +
File: $file
$i$str

"; + } + + /** + * customErrorLog + * + * @param string $type + * @param string $msg + * @param string $file + * @param string $line + * + * @return void + */ + /*public static*/ + function customErrorLog ($type, $msg, $file, $line) + { + global $HTTP_X_FORWARDED_FOR, $REMOTE_ADDR, $HTTP_USER_AGENT, $REQUEST_URI; + + $ip_addr = G::getIpAddress(); + + if (defined( 'APPLICATION_CODE' )) + $name = APPLICATION_CODE; + else + $name = "php"; + + if ($file != '') + $msg .= " in $file:$line "; + + $date = date( 'Y-m-d H:i:s' ); + $REQUEST_URI = getenv( 'REQUEST_URI' ); + $HTTP_USER_AGENT = getenv( 'HTTP_USER_AGENT' ); + error_log( "[$date] [$ip_addr] [$name] $type: $msg [$HTTP_USER_AGENT] URI: $REQUEST_URI", 0 ); + } + + /** + * verboseError + * + * @param string $type + * @param string $errno + * @param string $msg + * @param string $file + * @param string $line + * @param string $context + * + * @return void + */ + /*public static*/ + function verboseError ($type, $errno, $msg, $file, $line, $context) + { + global $SERVER_ADMIN; + + print "

Error!

"; + print "An error occurred while executing this script. Please contact the $SERVER_ADMIN to - report this error."; - print "

"; - print "Here is the information provided by the script:"; - print "


";
-    print "Error type: $type (code: $errno)
"; - print "Error message: $msg
"; - print "Script name and line number of error: $file:$line
"; - print "Variable context when error occurred:
"; - print_r ($context); - print "

"; - } - - /*** Encrypt and decrypt functions ****/ - /** - * Encrypt string - * - * @author Fernando Ontiveros Lira - * @access public - * @param string $string - * @param string $key - * @return string - */ - function encrypt($string, $key) - { - //print $string; - // if ( defined ( 'ENABLE_ENCRYPT' ) && ENABLE_ENCRYPT == 'yes' ) { - if (strpos($string, '|', 0) !== false) return $string; - $result = ''; - for($i = 0; $i'; - $result = base64_encode($result); - $result = str_replace ( '/' , '°' , $result); - $result = str_replace ( '=' , '' , $result); - // } - // else - // $result = $string; - - return $result; - } - - /** - * Decrypt string - * - * @author Fernando Ontiveros Lira - * @access public - * @param string $string - * @param string $key - * @return string - */ - function decrypt($string, $key) { - - // if ( defined ( 'ENABLE_ENCRYPT' ) && ENABLE_ENCRYPT == 'yes' ) { - - //if (strpos($string, '|', 0) !== false) return $string; - $result = ''; - $string = str_replace ( '°', '/' , $string); - $string_jhl = explode("?",$string); - $string = base64_decode($string); - $string = base64_decode($string_jhl[0]); - - for($i=0; $i - * @access public - * @param string $target - * @return void - */ - function lookup($target) - { - //if( eregi("[a-zA-Z]", $target) ) - if( preg_match("[a-zA-Z]", $target) )//Made compatible to PHP 5.3 - $ntarget = gethostbyname($target); - else - $ntarget = gethostbyaddr($target); - return($ntarget); - } - - /*************** path functions *****************/ - - function mk_dir( $strPath, $rights = 0777) - { - $folder_path = array($strPath); - $oldumask = umask(0); - while(!@is_dir(dirname(end($folder_path))) - && dirname(end($folder_path)) != '/' - && dirname(end($folder_path)) != '.' - && dirname(end($folder_path)) != '') - array_push($folder_path, dirname(end($folder_path))); //var_dump($folder_path); die; - - while($parent_folder_path = array_pop($folder_path)) - if(!@is_dir($parent_folder_path)) - if(!@mkdir($parent_folder_path, $rights)) - //trigger_error ("Can't create folder \"$parent_folder_path\".", E_USER_WARNING); - umask($oldumask); - } - - /** - * rm_dir - * - * @param string $dirName - * - * @return void - */ - function rm_dir($dirName) - { - if (!is_writable($dirName)) { - return false; - } - - if (is_dir($dirName)) { - foreach(glob($dirName . '/{,.}*', GLOB_BRACE) as $file) { - if ( $file == $dirName . '/.' || $file == $dirName . '/..') { - continue; - } - if(is_dir($file)) { - G::rm_dir($file); - - if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') { - $dirNameWin = str_replace('/','\\' ,$dirName); - exec('DEL /F /S /Q ' . $dirNameWin . '', $res); - exec('RD /S /Q ' . $dirNameWin . '', $res); - } else { - @rmdir($file); - } - - } - else { - @unlink($file); - } - } - } - else { - @unlink($dirName); - } - } - - /** - * verify path - * - * @author Fernando Ontiveros Lira - * @access public - * @param string $strPath path - * @param boolean $createPath if true this function will create the path - * @return boolean - */ - function verifyPath( $strPath , $createPath = false ) - { - $folder_path = strstr($strPath, '.') ? dirname($strPath) : $strPath; - - if ( file_exists($strPath ) || @is_dir( $strPath )) { - return true; - } - else { - if ( $createPath ) { - //TODO:: Define Environment constants: Devel (0777), Production (0770), ... - G::mk_dir ( $strPath , 0777 ); - } - else - return false; - } - return false; - } - - /** - * Expand the path using the path constants - * - * @author Fernando Ontiveros Lira - * @access public - * @param string $strPath - * @return string - */ - function expandPath( $strPath = '' ) - { - $res = ""; - $res = PATH_CORE; - if( $strPath != "" ) - { - $res .= $strPath . "/"; - } - return $res; - } - - /** - * Load Gulliver Classes - * - * @author Fernando Ontiveros Lira - * @access public - * @param string $strClass - * @return void - */ - function LoadSystem( $strClass ) - { - require_once( PATH_GULLIVER . 'class.' . $strClass . '.php' ); - } - - function LoadSystemExist($strClass) - { - if (file_exists (PATH_GULLIVER . 'class.' . $strClass . '.php') ) - return true; - else - return false; - } - - /** - * Render Page - * - * @author Fernando Ontiveros Lira - * @access public - * @param object $objContent - * @param string $strTemplate - * @param string $strSkin - * @return void - */ - function RenderPage( $strTemplate = "default", $strSkin = SYS_SKIN , $objContent = NULL, $layout='') - { - global $G_CONTENT; - global $G_TEMPLATE; - global $G_SKIN; - global $G_PUBLISH; - - $G_CONTENT = $objContent; - $G_TEMPLATE = $strTemplate; - $G_SKIN = $strSkin; - - try { - $file = G::ExpandPath('skinEngine') . 'skinEngine.php'; - include $file; - $skinEngine = new SkinEngine($G_TEMPLATE, $G_SKIN, $G_CONTENT); - $skinEngine->setLayout($layout); - $skinEngine->dispatch(); - } catch (Exception $e) { - global $G_PUBLISH; - if (is_null($G_PUBLISH)) { - $G_PUBLISH = new Publisher(); - } - if (count($G_PUBLISH->Parts) == 1) { - array_shift($G_PUBLISH->Parts); - } - global $oHeadPublisher; - $leimnudInitString = $oHeadPublisher->leimnudInitString; - $oHeadPublisher->clearScripts(); - $oHeadPublisher->leimnudInitString = $leimnudInitString; - $oHeadPublisher->addScriptFile('/js/maborak/core/maborak.js'); - $G_PUBLISH->AddContent('xmlform', 'xmlform', 'login/showMessage', null, array('MESSAGE' => $e->getMessage())); - if (class_exists('SkinEngine')) { - $skinEngine = new SkinEngine('publish', 'blank', ''); - $skinEngine->dispatch(); - } else { - die($e->getMessage()); - } - } - } - - /** - * Load a skin - * - * @author Fernando Ontiveros Lira - * @access public - * @param string $strSkinName - * @return void - */ - function LoadSkin( $strSkinName ) - { - //print $strSkinName; - //now, we are using the skin, a skin is a file in engine/skin directory - $file = G::ExpandPath( "skins" ) . $strSkinName. ".php"; - //G::pr($file); - if (file_exists ($file) ) { - require_once( $file ); - return; - } - else { - if (file_exists ( PATH_HTML . 'errors/error703.php') ) { - header ( 'location: /errors/error703.php' ); - die; - } - else { - $text = "The Skin $file does not exist, please review the Skin Definition"; - throw ( new Exception ( $text) ); - } - } - - } - - /** - * Include javascript files - * - * @author Fernando Ontiveros Lira - * @access public - * @param string $strInclude - * @return void - */ - function LoadInclude( $strInclude ) - { - $incfile = G::ExpandPath( "includes" ) . 'inc.' . $strInclude . '.php'; - if ( !file_exists( $incfile )) { - $incfile = PATH_GULLIVER_HOME . 'includes' . PATH_SEP . 'inc.' . $strInclude . '.php'; - } - - if ( file_exists( $incfile )) { - require_once( $incfile ); - return true; - } - else { - return false; - } - } - - /** - * Include all model files - * - * @author Fernando Ontiveros Lira - * @access public - * @param string $strInclude - * @return void - */ - function LoadAllModelClasses( ) - { - $baseDir = PATH_CORE . 'classes' . PATH_SEP . 'model'; - if ($handle = opendir( $baseDir )) { - while ( false !== ($file = readdir($handle))) { - if ( strpos($file, '.php',1) && !strpos($file, 'Peer.php',1) ) { - require_once ( $baseDir . PATH_SEP . $file ); - } - } - } - } - - /** - * Include all model plugin files - * - * LoadAllPluginModelClasses - * @author Hugo Loza - * @access public - * @return void - */ - function LoadAllPluginModelClasses(){ - //Get the current Include path, where the plugins directories should be - if ( !defined('PATH_SEPARATOR') ) { - define('PATH_SEPARATOR', ( substr(PHP_OS, 0, 3) == 'WIN' ) ? ';' : ':'); - } - $path=explode(PATH_SEPARATOR,get_include_path()); - - - foreach($path as $possiblePath){ - if(strstr($possiblePath,"plugins")){ - $baseDir = $possiblePath . 'classes' . PATH_SEP . 'model'; - if(file_exists($baseDir)){ - if ($handle = opendir( $baseDir )) { - while ( false !== ($file = readdir($handle))) { - if ( strpos($file, '.php',1) && !strpos($file, 'Peer.php',1) ) { - require_once ( $baseDir . PATH_SEP . $file ); - } - } - } - //Include also the extendGulliverClass that could have some new definitions for fields - if(file_exists($possiblePath . 'classes' . PATH_SEP.'class.extendGulliver.php')){ - include_once $possiblePath . 'classes' . PATH_SEP.'class.extendGulliver.php'; - } - } - } - } - } - - /** - * Load a template - * - * @author Fernando Ontiveros Lira - * @access public - * @param string $strTemplateName - * @return void - */ - function LoadTemplate( $strTemplateName ) - { - if ( $strTemplateName == '' ) return; - $temp = $strTemplateName . ".php"; - $file = G::ExpandPath( 'templates' ) . $temp; - // Check if its a user template - if ( file_exists($file) ) { - //require_once( $file ); - include( $file ); - } else { - // Try to get the global system template - $file = PATH_TEMPLATE . PATH_SEP . $temp; - //require_once( $file ); - if ( file_exists($file) ) - include( $file ); - } - } - - /** - * Function LoadClassRBAC - * @author David S. Callizaya S. - * @access public - * @parameter string strClass - * @return string - */ - function LoadClassRBAC( $strClass ) - { - $classfile = PATH_RBAC . "class.$strClass" . '.php'; - require_once( $classfile ); - } - /** - * If the class is not defined by the aplication, it - * attempt to load the class from gulliver.system - * - * @author Fernando Ontiveros Lira , David S. Callizaya - * @access public - * @param string $strClass - * @return void - */ - function LoadClass( $strClass ) - { - $classfile = G::ExpandPath( "classes" ) . 'class.' . $strClass . '.php'; - if (!file_exists( $classfile )) { - if (file_exists( PATH_GULLIVER . 'class.' . $strClass . '.php' )) - return require_once( PATH_GULLIVER . 'class.' . $strClass . '.php' ); - else - return false; - } else { - return require_once( $classfile ); - } - } - - /** - * Loads a Class. If the class is not defined by the aplication, it - * attempt to load the class from gulliver.system - * - * @author Fernando Ontiveros Lira , David S. Callizaya - * @access public - * @param string $strClass - * @return void - */ - function LoadThirdParty( $sPath , $sFile ) - { - $classfile = PATH_THIRDPARTY . $sPath .'/'. $sFile . - ( (substr($sFile,0,-4)!=='.php')? '.php': '' ); - return require_once( $classfile ); - } - - /** - * Encrypt URL - * - * @author Fernando Ontiveros Lira - * @access public - * @param string $urlLink - * @return string - */ - function encryptlink($url) - { - if ( defined ( 'ENABLE_ENCRYPT' ) && ENABLE_ENCRYPT == 'yes' ) - return urlencode( G::encrypt( $url ,URL_KEY ) ); - else - return $url; - } - - /** - * Parsing the URI - * - * @author Fernando Ontiveros Lira - * @access public - * @param string $urlLink - * @return string - */ - static function parseURI($uri, $isRestRequest = false) - { - //*** process the $_POST with magic_quotes enabled - // The magic_quotes_gpc feature has been DEPRECATED as of PHP 5.3.0. - if (get_magic_quotes_gpc() === 1) { - $_POST = G::strip_slashes($_POST); - } - - $aRequestUri = explode('/', $uri ); - if ($isRestRequest) { - $args = self::parseRestUri($aRequestUri); - } else { - $args = self::parseNormalUri($aRequestUri); - } - - define("SYS_LANG", $args['SYS_LANG']); - define("SYS_SKIN", $args['SYS_SKIN']); - define('SYS_COLLECTION', $args['SYS_COLLECTION']); - define('SYS_TARGET', $args['SYS_TARGET']); - - if ( $args['SYS_COLLECTION'] == 'js2' ) { - print "ERROR"; die; - } - } - - public function parseNormalUri($aRequestUri) - { - if (substr($aRequestUri[1], 0, 3) == 'sys') { - define('SYS_TEMP', substr($aRequestUri[1], 3)); - } else { - define("ENABLE_ENCRYPT", 'yes'); - define('SYS_TEMP', $aRequestUri[1]); - $plain = '/sys' . SYS_TEMP; - - for ($i = 2; $i < count($aRequestUri); $i++) { - $decoded = G::decrypt(urldecode($aRequestUri[$i]), URL_KEY); - if ( $decoded == 'sWì›' ) { - $decoded = $VARS[$i]; //this is for the string "../" - } - $plain .= '/' . $decoded; - } - $_SERVER["REQUEST_URI"] = $plain; - } - - $work = explode('?', $_SERVER["REQUEST_URI"]); - - if (count($work) > 1) { - define('SYS_CURRENT_PARMS', $work[1]); - } else { - define('SYS_CURRENT_PARMS', ''); - } - - define('SYS_CURRENT_URI', $work[0]); - - if (!defined('SYS_CURRENT_PARMS')) { - define('SYS_CURRENT_PARMS', $work[1]); - } - - $preArray = explode('&', SYS_CURRENT_PARMS); - $buffer = explode('.', $work[0]); - - if (count($buffer) == 1) { - $buffer[1]=''; - } - - //request type - define('REQUEST_TYPE', ($buffer[1] != "" ?$buffer[1] : 'html')); - - $toparse = substr($buffer[0], 1, strlen($buffer[0]) - 1); - $uriVars = explode('/', $toparse); - - unset($work); - unset($buffer); - unset($toparse); - array_shift($uriVars); - - $args = array(); - $args['SYS_LANG'] = array_shift($uriVars); - $args['SYS_SKIN'] = array_shift($uriVars); - $args['SYS_COLLECTION'] = array_shift($uriVars); - $args['SYS_TARGET'] = array_shift($uriVars); - - //to enable more than 2 directories...in the methods structure - while (count($uriVars) > 0) { - $args['SYS_TARGET'] .= '/' . array_shift($uriVars); - } - - /* Fix to prevent use uxs skin outside siplified interface, - because that skin is not compatible with others interfaces*/ - if ($args['SYS_SKIN'] == 'uxs' && $args['SYS_COLLECTION'] != 'home' && $args['SYS_COLLECTION'] != 'cases') { - $config = System::getSystemConfiguration(); - $args['SYS_SKIN'] = $config['default_skin']; - } - - return $args; - } - - public function parseRestUri($requestUri) - { - $args = array(); - //$args['SYS_TEMP'] = $requestUri[1]; - define('SYS_TEMP', $requestUri[2]); - $restUri = ''; - - for ($i=3; $i < count($requestUri); $i++) { - $restUri .= '/' . $requestUri[$i]; - } - - $args['SYS_LANG'] = 'en'; // TODO, this can be set from http header - $args['SYS_SKIN'] = ''; - $args['SYS_COLLECTION'] = ''; - $args['SYS_TARGET'] = $restUri; - - return $args; - } - - function strip_slashes($vVar) { - if (is_array($vVar)) { - foreach($vVar as $sKey => $vValue) { - if (is_array($vValue)) { - G::strip_slashes($vVar[$sKey]); - } - else { - $vVar[$sKey] = stripslashes($vVar[$sKey]); - } - } - } - else { - $vVar = stripslashes($vVar); - } - - return $vVar; - } - - /** - * function to calculate the time used to render a page - */ - function logTimeByPage() - { - if (!defined(PATH_DATA)) { - return false; - } - - $serverAddr = $_SERVER['SERVER_ADDR']; - global $startingTime; - $endTime = microtime(true); - $time = $endTime - $startingTime; - $fpt= fopen ( PATH_DATA . 'log/time.log', 'a' ); - fwrite( $fpt, sprintf ( "%s.%03d %15s %s %5.3f %s\n", date('Y-m-d H:i:s'), $time, getenv('REMOTE_ADDR'), substr($serverAddr,-4), $time, $_SERVER['REQUEST_URI'] )); - fclose( $fpt); - } - - /** - * streaming a big JS file with small js files - * - * @author Fernando Ontiveros Lira - * @access public - * @param string $file - * @return string - */ - function streamCSSBigFile( $filename ) - { - header('Content-Type: text/css'); - - //First get Skin info - $filenameParts = explode("-",$filename); - $skinName = $filenameParts[0]; - $skinVariant = "skin"; - - if(isset($filenameParts[1])) { - $skinVariant = strtolower($filenameParts[1]); - } - - if ($skinName == "jscolors") $skinName = "classic"; - if ($skinName == "xmlcolors") $skinName = "classic"; - if ($skinName=="classic") { - $configurationFile = G::ExpandPath( "skinEngine" ).'base'.PATH_SEP.'config.xml'; - } - else { - $configurationFile = PATH_CUSTOM_SKINS . $skinName . PATH_SEP . 'config.xml'; - - if (!is_file($configurationFile)) { - $configurationFile = G::ExpandPath( "skinEngine" ) . $skinName . PATH_SEP . 'config.xml'; - } - } - - //Read Configuration File - $xmlConfiguration = file_get_contents ( $configurationFile ); - $xmlConfigurationObj=G::xmlParser($xmlConfiguration); - $baseSkinDirectory=dirname($configurationFile); - $directorySize=G::getDirectorySize($baseSkinDirectory); - $mtime=$directorySize['maxmtime']; - - - - //if userAgent (BROWSER) is MSIE we need special headers to avoid MSIE behaivor. - //$userAgent = strtolower($_SERVER['HTTP_USER_AGENT']); - - $gmt_mtime = gmdate("D, d M Y H:i:s", $mtime ) . " GMT"; - header('Pragma: cache'); - header('ETag: "' . md5 ($mtime . $filename ) . '"' ); - header("Last-Modified: " . $gmt_mtime ); - header('Cache-Control: public'); - header("Expires: " . gmdate("D, d M Y H:i:s", time () + 30*60*60*24 ) . " GMT"); //1 month - //header("Expires: " . gmdate("D, d M Y H:i:s", time () + 60*60*24 ) . " GMT"); //1 day - tempor - if( isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) ) { - if ($_SERVER['HTTP_IF_MODIFIED_SINCE'] == $gmt_mtime) { - header('HTTP/1.1 304 Not Modified'); - exit(); - } - } - - if ( isset($_SERVER['HTTP_IF_NONE_MATCH'])) { - if ( str_replace('"', '', stripslashes($_SERVER['HTTP_IF_NONE_MATCH'])) == md5( $mtime . $filename)) { - header("HTTP/1.1 304 Not Modified"); - exit(); - } - } - - $outputHeader = "/* Autogenerated CSS file by gulliver framework \n"; - $outputHeader .=" Skin: $filename\n"; - $outputHeader .=" Configuration: $configurationFile\n"; - $mtimeNow = date('U'); - $gmt_mtimeNow = gmdate("D, d M Y H:i:s", $mtimeNow ) . " GMT"; - $outputHeader .=" Date: $gmt_mtimeNow*/\n"; - $output =""; - //Base files - switch(strtolower($skinVariant)){ - case "extjs": - //Base - $baseCSSPath=PATH_SKIN_ENGINE."base". PATH_SEP."baseCss". PATH_SEP; - $output .= file_get_contents ( $baseCSSPath . 'ext-all-notheme.css' ); - //$output .= file_get_contents ( $publicExtPath . 'ext-all.css' ); - - //Classic Skin - $extJsSkin = 'xtheme-gray'; - /*$publicExtPath = PATH_SKIN_ENGINE."base". PATH_SEP."css". PATH_SEP; + report this error."; + print "

"; + print "Here is the information provided by the script:"; + print "


";
+        print "Error type: $type (code: $errno)
"; + print "Error message: $msg
"; + print "Script name and line number of error: $file:$line
"; + print "Variable context when error occurred:
"; + print_r( $context ); + print "

"; + } + + /** + * * Encrypt and decrypt functions *** + */ + /** + * Encrypt string + * + * @author Fernando Ontiveros Lira + * @access public + * @param string $string + * @param string $key + * @return string + */ + function encrypt ($string, $key) + { + //print $string; + // if ( defined ( 'ENABLE_ENCRYPT' ) && ENABLE_ENCRYPT == 'yes' ) { + if (strpos( $string, '|', 0 ) !== false) + return $string; + $result = ''; + for ($i = 0; $i < strlen( $string ); $i ++) { + $char = substr( $string, $i, 1 ); + $keychar = substr( $key, ($i % strlen( $key )) - 1, 1 ); + $char = chr( ord( $char ) + ord( $keychar ) ); + $result .= $char; + } + //echo $result . '
'; + $result = base64_encode( $result ); + $result = str_replace( '/', '°', $result ); + $result = str_replace( '=', '', $result ); + // } + // else + // $result = $string; + return $result; + } + + /** + * Decrypt string + * + * @author Fernando Ontiveros Lira + * @access public + * @param string $string + * @param string $key + * @return string + */ + function decrypt ($string, $key) + { + // if ( defined ( 'ENABLE_ENCRYPT' ) && ENABLE_ENCRYPT == 'yes' ) { + //if (strpos($string, '|', 0) !== false) return $string; + $result = ''; + $string = str_replace( '°', '/', $string ); + $string_jhl = explode( "?", $string ); + $string = base64_decode( $string ); + $string = base64_decode( $string_jhl[0] ); + + for ($i = 0; $i < strlen( $string ); $i ++) { + $char = substr( $string, $i, 1 ); + $keychar = substr( $key, ($i % strlen( $key )) - 1, 1 ); + $char = chr( ord( $char ) - ord( $keychar ) ); + $result .= $char; + } + if (! empty( $string_jhl[1] )) + $result .= '?' . $string_jhl[1]; + // } + // else + // $result = $string; + return $result; + } + + /** + * Look up an IP address direction + * + * @author Fernando Ontiveros Lira + * @access public + * @param string $target + * @return void + */ + function lookup ($target) + { + //if( eregi("[a-zA-Z]", $target) ) + if (preg_match( "[a-zA-Z]", $target )) //Made compatible to PHP 5.3 + $ntarget = gethostbyname( $target ); + else + $ntarget = gethostbyaddr( $target ); + return ($ntarget); + } + + /** + * ************* path functions **************** + */ + function mk_dir ($strPath, $rights = 0777) + { + $folder_path = array ($strPath + ); + $oldumask = umask( 0 ); + while (! @is_dir( dirname( end( $folder_path ) ) ) && dirname( end( $folder_path ) ) != '/' && dirname( end( $folder_path ) ) != '.' && dirname( end( $folder_path ) ) != '') + array_push( $folder_path, dirname( end( $folder_path ) ) ); //var_dump($folder_path); die; + + + while ($parent_folder_path = array_pop( $folder_path )) + if (! @is_dir( $parent_folder_path )) + if (! @mkdir( $parent_folder_path, $rights )) + //trigger_error ("Can't create folder \"$parent_folder_path\".", E_USER_WARNING); + umask( $oldumask ); + } + /** + * rm_dir + * + * @param string $dirName + * + * @return void + */ + function rm_dir ($dirName) + { + if (! is_writable( $dirName )) { + return false; + } + + if (is_dir( $dirName )) { + foreach (glob( $dirName . '/{,.}*', GLOB_BRACE ) as $file) { + if ($file == $dirName . '/.' || $file == $dirName . '/..') { + continue; + } + if (is_dir( $file )) { + G::rm_dir( $file ); + + if (strtoupper( substr( PHP_OS, 0, 3 ) ) === 'WIN') { + $dirNameWin = str_replace( '/', '\\', $dirName ); + exec( 'DEL /F /S /Q ' . $dirNameWin . '', $res ); + exec( 'RD /S /Q ' . $dirNameWin . '', $res ); + } else { + @rmdir( $file ); + } + + } else { + @unlink( $file ); + } + } + } else { + @unlink( $dirName ); + } + } + + /** + * verify path + * + * @author Fernando Ontiveros Lira + * @access public + * @param string $strPath path + * @param boolean $createPath if true this function will create the path + * @return boolean + */ + function verifyPath ($strPath, $createPath = false) + { + $folder_path = strstr( $strPath, '.' ) ? dirname( $strPath ) : $strPath; + + if (file_exists( $strPath ) || @is_dir( $strPath )) { + return true; + } else { + if ($createPath) { + //TODO:: Define Environment constants: Devel (0777), Production (0770), ... + G::mk_dir( $strPath, 0777 ); + } else + return false; + } + return false; + } + + /** + * Expand the path using the path constants + * + * @author Fernando Ontiveros Lira + * @access public + * @param string $strPath + * @return string + */ + function expandPath ($strPath = '') + { + $res = ""; + $res = PATH_CORE; + if ($strPath != "") { + $res .= $strPath . "/"; + } + return $res; + } + + /** + * Load Gulliver Classes + * + * @author Fernando Ontiveros Lira + * @access public + * @param string $strClass + * @return void + */ + function LoadSystem ($strClass) + { + require_once (PATH_GULLIVER . 'class.' . $strClass . '.php'); + } + + function LoadSystemExist ($strClass) + { + if (file_exists( PATH_GULLIVER . 'class.' . $strClass . '.php' )) + return true; + else + return false; + } + + /** + * Render Page + * + * @author Fernando Ontiveros Lira + * @access public + * @param object $objContent + * @param string $strTemplate + * @param string $strSkin + * @return void + */ + function RenderPage ($strTemplate = "default", $strSkin = SYS_SKIN, $objContent = NULL, $layout = '') + { + global $G_CONTENT; + global $G_TEMPLATE; + global $G_SKIN; + global $G_PUBLISH; + + $G_CONTENT = $objContent; + $G_TEMPLATE = $strTemplate; + $G_SKIN = $strSkin; + + try { + $file = G::ExpandPath( 'skinEngine' ) . 'skinEngine.php'; + include $file; + $skinEngine = new SkinEngine( $G_TEMPLATE, $G_SKIN, $G_CONTENT ); + $skinEngine->setLayout( $layout ); + $skinEngine->dispatch(); + } catch (Exception $e) { + global $G_PUBLISH; + if (is_null( $G_PUBLISH )) { + $G_PUBLISH = new Publisher(); + } + if (count( $G_PUBLISH->Parts ) == 1) { + array_shift( $G_PUBLISH->Parts ); + } + global $oHeadPublisher; + $leimnudInitString = $oHeadPublisher->leimnudInitString; + $oHeadPublisher->clearScripts(); + $oHeadPublisher->leimnudInitString = $leimnudInitString; + $oHeadPublisher->addScriptFile( '/js/maborak/core/maborak.js' ); + $G_PUBLISH->AddContent( 'xmlform', 'xmlform', 'login/showMessage', null, array ('MESSAGE' => $e->getMessage() + ) ); + if (class_exists( 'SkinEngine' )) { + $skinEngine = new SkinEngine( 'publish', 'blank', '' ); + $skinEngine->dispatch(); + } else { + die( $e->getMessage() ); + } + } + } + + /** + * Load a skin + * + * @author Fernando Ontiveros Lira + * @access public + * @param string $strSkinName + * @return void + */ + function LoadSkin ($strSkinName) + { + //print $strSkinName; + //now, we are using the skin, a skin is a file in engine/skin directory + $file = G::ExpandPath( "skins" ) . $strSkinName . ".php"; + //G::pr($file); + if (file_exists( $file )) { + require_once ($file); + return; + } else { + if (file_exists( PATH_HTML . 'errors/error703.php' )) { + header( 'location: /errors/error703.php' ); + die(); + } else { + $text = "The Skin $file does not exist, please review the Skin Definition"; + throw (new Exception( $text )); + } + } + + } + + /** + * Include javascript files + * + * @author Fernando Ontiveros Lira + * @access public + * @param string $strInclude + * @return void + */ + function LoadInclude ($strInclude) + { + $incfile = G::ExpandPath( "includes" ) . 'inc.' . $strInclude . '.php'; + if (! file_exists( $incfile )) { + $incfile = PATH_GULLIVER_HOME . 'includes' . PATH_SEP . 'inc.' . $strInclude . '.php'; + } + + if (file_exists( $incfile )) { + require_once ($incfile); + return true; + } else { + return false; + } + } + + /** + * Include all model files + * + * @author Fernando Ontiveros Lira + * @access public + * @param string $strInclude + * @return void + */ + function LoadAllModelClasses () + { + $baseDir = PATH_CORE . 'classes' . PATH_SEP . 'model'; + if ($handle = opendir( $baseDir )) { + while (false !== ($file = readdir( $handle ))) { + if (strpos( $file, '.php', 1 ) && ! strpos( $file, 'Peer.php', 1 )) { + require_once ($baseDir . PATH_SEP . $file); + } + } + } + } + + /** + * Include all model plugin files + * + * LoadAllPluginModelClasses + * + * @author Hugo Loza + * @access public + * @return void + */ + function LoadAllPluginModelClasses () + { + //Get the current Include path, where the plugins directories should be + if (! defined( 'PATH_SEPARATOR' )) { + define( 'PATH_SEPARATOR', (substr( PHP_OS, 0, 3 ) == 'WIN') ? ';' : ':' ); + } + $path = explode( PATH_SEPARATOR, get_include_path() ); + + foreach ($path as $possiblePath) { + if (strstr( $possiblePath, "plugins" )) { + $baseDir = $possiblePath . 'classes' . PATH_SEP . 'model'; + if (file_exists( $baseDir )) { + if ($handle = opendir( $baseDir )) { + while (false !== ($file = readdir( $handle ))) { + if (strpos( $file, '.php', 1 ) && ! strpos( $file, 'Peer.php', 1 )) { + require_once ($baseDir . PATH_SEP . $file); + } + } + } + //Include also the extendGulliverClass that could have some new definitions for fields + if (file_exists( $possiblePath . 'classes' . PATH_SEP . 'class.extendGulliver.php' )) { + include_once $possiblePath . 'classes' . PATH_SEP . 'class.extendGulliver.php'; + } + } + } + } + } + + /** + * Load a template + * + * @author Fernando Ontiveros Lira + * @access public + * @param string $strTemplateName + * @return void + */ + function LoadTemplate ($strTemplateName) + { + if ($strTemplateName == '') + return; + $temp = $strTemplateName . ".php"; + $file = G::ExpandPath( 'templates' ) . $temp; + // Check if its a user template + if (file_exists( $file )) { + //require_once( $file ); + include ($file); + } else { + // Try to get the global system template + $file = PATH_TEMPLATE . PATH_SEP . $temp; + //require_once( $file ); + if (file_exists( $file )) + include ($file); + } + } + + /** + * Function LoadClassRBAC + * + * @author David S. Callizaya S. + * @access public + * @param eter string strClass + * @return string + */ + function LoadClassRBAC ($strClass) + { + $classfile = PATH_RBAC . "class.$strClass" . '.php'; + require_once ($classfile); + } + + /** + * If the class is not defined by the aplication, it + * attempt to load the class from gulliver.system + * + * @author Fernando Ontiveros Lira , David S. Callizaya + * @access public + * @param string $strClass + * @return void + */ + function LoadClass ($strClass) + { + $classfile = G::ExpandPath( "classes" ) . 'class.' . $strClass . '.php'; + if (! file_exists( $classfile )) { + if (file_exists( PATH_GULLIVER . 'class.' . $strClass . '.php' )) + return require_once (PATH_GULLIVER . 'class.' . $strClass . '.php'); + else + return false; + } else { + return require_once ($classfile); + } + } + + /** + * Loads a Class. + * If the class is not defined by the aplication, it + * attempt to load the class from gulliver.system + * + * @author Fernando Ontiveros Lira , David S. Callizaya + * @access public + * @param string $strClass + * @return void + */ + function LoadThirdParty ($sPath, $sFile) + { + $classfile = PATH_THIRDPARTY . $sPath . '/' . $sFile . ((substr( $sFile, 0, - 4 ) !== '.php') ? '.php' : ''); + return require_once ($classfile); + } + + /** + * Encrypt URL + * + * @author Fernando Ontiveros Lira + * @access public + * @param string $urlLink + * @return string + */ + function encryptlink ($url) + { + if (defined( 'ENABLE_ENCRYPT' ) && ENABLE_ENCRYPT == 'yes') + return urlencode( G::encrypt( $url, URL_KEY ) ); + else + return $url; + } + + /** + * Parsing the URI + * + * @author Fernando Ontiveros Lira + * @access public + * @param string $urlLink + * @return string + */ + static function parseURI ($uri, $isRestRequest = false) + { + //*** process the $_POST with magic_quotes enabled + // The magic_quotes_gpc feature has been DEPRECATED as of PHP 5.3.0. + if (get_magic_quotes_gpc() === 1) { + $_POST = G::strip_slashes( $_POST ); + } + + $aRequestUri = explode( '/', $uri ); + if ($isRestRequest) { + $args = self::parseRestUri( $aRequestUri ); + } else { + $args = self::parseNormalUri( $aRequestUri ); + } + + define( "SYS_LANG", $args['SYS_LANG'] ); + define( "SYS_SKIN", $args['SYS_SKIN'] ); + define( 'SYS_COLLECTION', $args['SYS_COLLECTION'] ); + define( 'SYS_TARGET', $args['SYS_TARGET'] ); + + if ($args['SYS_COLLECTION'] == 'js2') { + print "ERROR"; + die(); + } + } + + public function parseNormalUri ($aRequestUri) + { + if (substr( $aRequestUri[1], 0, 3 ) == 'sys') { + define( 'SYS_TEMP', substr( $aRequestUri[1], 3 ) ); + } else { + define( "ENABLE_ENCRYPT", 'yes' ); + define( 'SYS_TEMP', $aRequestUri[1] ); + $plain = '/sys' . SYS_TEMP; + + for ($i = 2; $i < count( $aRequestUri ); $i ++) { + $decoded = G::decrypt( urldecode( $aRequestUri[$i] ), URL_KEY ); + if ($decoded == 'sWì›') { + $decoded = $VARS[$i]; //this is for the string "../" + } + $plain .= '/' . $decoded; + } + $_SERVER["REQUEST_URI"] = $plain; + } + + $work = explode( '?', $_SERVER["REQUEST_URI"] ); + + if (count( $work ) > 1) { + define( 'SYS_CURRENT_PARMS', $work[1] ); + } else { + define( 'SYS_CURRENT_PARMS', '' ); + } + + define( 'SYS_CURRENT_URI', $work[0] ); + + if (! defined( 'SYS_CURRENT_PARMS' )) { + define( 'SYS_CURRENT_PARMS', $work[1] ); + } + + $preArray = explode( '&', SYS_CURRENT_PARMS ); + $buffer = explode( '.', $work[0] ); + + if (count( $buffer ) == 1) { + $buffer[1] = ''; + } + + //request type + define( 'REQUEST_TYPE', ($buffer[1] != "" ? $buffer[1] : 'html') ); + + $toparse = substr( $buffer[0], 1, strlen( $buffer[0] ) - 1 ); + $uriVars = explode( '/', $toparse ); + + unset( $work ); + unset( $buffer ); + unset( $toparse ); + array_shift( $uriVars ); + + $args = array (); + $args['SYS_LANG'] = array_shift( $uriVars ); + $args['SYS_SKIN'] = array_shift( $uriVars ); + $args['SYS_COLLECTION'] = array_shift( $uriVars ); + $args['SYS_TARGET'] = array_shift( $uriVars ); + + //to enable more than 2 directories...in the methods structure + while (count( $uriVars ) > 0) { + $args['SYS_TARGET'] .= '/' . array_shift( $uriVars ); + } + + /* Fix to prevent use uxs skin outside siplified interface, + because that skin is not compatible with others interfaces*/ + if ($args['SYS_SKIN'] == 'uxs' && $args['SYS_COLLECTION'] != 'home' && $args['SYS_COLLECTION'] != 'cases') { + $config = System::getSystemConfiguration(); + $args['SYS_SKIN'] = $config['default_skin']; + } + + return $args; + } + + public function parseRestUri ($requestUri) + { + $args = array (); + //$args['SYS_TEMP'] = $requestUri[1]; + define( 'SYS_TEMP', $requestUri[2] ); + $restUri = ''; + + for ($i = 3; $i < count( $requestUri ); $i ++) { + $restUri .= '/' . $requestUri[$i]; + } + + $args['SYS_LANG'] = 'en'; // TODO, this can be set from http header + $args['SYS_SKIN'] = ''; + $args['SYS_COLLECTION'] = ''; + $args['SYS_TARGET'] = $restUri; + + return $args; + } + + function strip_slashes ($vVar) + { + if (is_array( $vVar )) { + foreach ($vVar as $sKey => $vValue) { + if (is_array( $vValue )) { + G::strip_slashes( $vVar[$sKey] ); + } else { + $vVar[$sKey] = stripslashes( $vVar[$sKey] ); + } + } + } else { + $vVar = stripslashes( $vVar ); + } + + return $vVar; + } + + /** + * function to calculate the time used to render a page + */ + function logTimeByPage () + { + if (! defined( PATH_DATA )) { + return false; + } + + $serverAddr = $_SERVER['SERVER_ADDR']; + global $startingTime; + $endTime = microtime( true ); + $time = $endTime - $startingTime; + $fpt = fopen( PATH_DATA . 'log/time.log', 'a' ); + fwrite( $fpt, sprintf( "%s.%03d %15s %s %5.3f %s\n", date( 'Y-m-d H:i:s' ), $time, getenv( 'REMOTE_ADDR' ), substr( $serverAddr, - 4 ), $time, $_SERVER['REQUEST_URI'] ) ); + fclose( $fpt ); + } + + /** + * streaming a big JS file with small js files + * + * @author Fernando Ontiveros Lira + * @access public + * @param string $file + * @return string + */ + function streamCSSBigFile ($filename) + { + header( 'Content-Type: text/css' ); + + //First get Skin info + $filenameParts = explode( "-", $filename ); + $skinName = $filenameParts[0]; + $skinVariant = "skin"; + + if (isset( $filenameParts[1] )) { + $skinVariant = strtolower( $filenameParts[1] ); + } + + if ($skinName == "jscolors") + $skinName = "classic"; + if ($skinName == "xmlcolors") + $skinName = "classic"; + if ($skinName == "classic") { + $configurationFile = G::ExpandPath( "skinEngine" ) . 'base' . PATH_SEP . 'config.xml'; + } else { + $configurationFile = PATH_CUSTOM_SKINS . $skinName . PATH_SEP . 'config.xml'; + + if (! is_file( $configurationFile )) { + $configurationFile = G::ExpandPath( "skinEngine" ) . $skinName . PATH_SEP . 'config.xml'; + } + } + + //Read Configuration File + $xmlConfiguration = file_get_contents( $configurationFile ); + $xmlConfigurationObj = G::xmlParser( $xmlConfiguration ); + $baseSkinDirectory = dirname( $configurationFile ); + $directorySize = G::getDirectorySize( $baseSkinDirectory ); + $mtime = $directorySize['maxmtime']; + + //if userAgent (BROWSER) is MSIE we need special headers to avoid MSIE behaivor. + //$userAgent = strtolower($_SERVER['HTTP_USER_AGENT']); + + + $gmt_mtime = gmdate( "D, d M Y H:i:s", $mtime ) . " GMT"; + header( 'Pragma: cache' ); + header( 'ETag: "' . md5( $mtime . $filename ) . '"' ); + header( "Last-Modified: " . $gmt_mtime ); + header( 'Cache-Control: public' ); + header( "Expires: " . gmdate( "D, d M Y H:i:s", time() + 30 * 60 * 60 * 24 ) . " GMT" ); //1 month + //header("Expires: " . gmdate("D, d M Y H:i:s", time () + 60*60*24 ) . " GMT"); //1 day - tempor + if (isset( $_SERVER['HTTP_IF_MODIFIED_SINCE'] )) { + if ($_SERVER['HTTP_IF_MODIFIED_SINCE'] == $gmt_mtime) { + header( 'HTTP/1.1 304 Not Modified' ); + exit(); + } + } + + if (isset( $_SERVER['HTTP_IF_NONE_MATCH'] )) { + if (str_replace( '"', '', stripslashes( $_SERVER['HTTP_IF_NONE_MATCH'] ) ) == md5( $mtime . $filename )) { + header( "HTTP/1.1 304 Not Modified" ); + exit(); + } + } + + $outputHeader = "/* Autogenerated CSS file by gulliver framework \n"; + $outputHeader .= " Skin: $filename\n"; + $outputHeader .= " Configuration: $configurationFile\n"; + $mtimeNow = date( 'U' ); + $gmt_mtimeNow = gmdate( "D, d M Y H:i:s", $mtimeNow ) . " GMT"; + $outputHeader .= " Date: $gmt_mtimeNow*/\n"; + $output = ""; + //Base files + switch (strtolower( $skinVariant )) { + case "extjs": + //Base + $baseCSSPath = PATH_SKIN_ENGINE . "base" . PATH_SEP . "baseCss" . PATH_SEP; + $output .= file_get_contents( $baseCSSPath . 'ext-all-notheme.css' ); + //$output .= file_get_contents ( $publicExtPath . 'ext-all.css' ); + + + //Classic Skin + $extJsSkin = 'xtheme-gray'; + /*$publicExtPath = PATH_SKIN_ENGINE."base". PATH_SEP."css". PATH_SEP; $output .= file_get_contents ( $publicExtPath . $extJsSkin . '.css' ); $output .= file_get_contents ( $publicExtPath . 'pmos-' . $extJsSkin . '.css' ); - */ - //adding the extend css for extjs-pmos - //TODO: move this files to pmos-xthem.. - //$cssThemeExtensions = glob(PATH_TPL . "*/css/extjs-extend/{$extJsSkin}.css"); - //foreach($cssThemeExtensions as $cssThemeExtensionFile) - //$helper->addFile($cssThemeExtensionFile); - //$output .= file_get_contents ( $cssThemeExtensionFile ); - // $classicCSSPath=PATH_SKIN_ENGINE."base". PATH_SEP."css". PATH_SEP; - // $output .= file_get_contents ( $classicCSSPath . 'sprite.css' ); - //$output .= file_get_contents ( $classicCSSPath . 'sprite_ie.css' ); - - - break; - default: - - break; - - } - - - - //Get Browser Info - $infoBrowser=G::browser_detection( 'full_assoc'); - $browserName=$infoBrowser['browser_working']; - if(isset($infoBrowser[$browserName.'_data'])){ - if($infoBrowser[$browserName.'_data'][0]!=""){ - $browserName=$infoBrowser[$browserName.'_data'][0]; - } - } + */ + //adding the extend css for extjs-pmos + //TODO: move this files to pmos-xthem.. + //$cssThemeExtensions = glob(PATH_TPL . "*/css/extjs-extend/{$extJsSkin}.css"); + //foreach($cssThemeExtensions as $cssThemeExtensionFile) + //$helper->addFile($cssThemeExtensionFile); + //$output .= file_get_contents ( $cssThemeExtensionFile ); + // $classicCSSPath=PATH_SKIN_ENGINE."base". PATH_SEP."css". PATH_SEP; + // $output .= file_get_contents ( $classicCSSPath . 'sprite.css' ); + //$output .= file_get_contents ( $classicCSSPath . 'sprite_ie.css' ); + + + break; + default: + + break; + + } + + //Get Browser Info + $infoBrowser = G::browser_detection( 'full_assoc' ); + $browserName = $infoBrowser['browser_working']; + if (isset( $infoBrowser[$browserName . '_data'] )) { + if ($infoBrowser[$browserName . '_data'][0] != "") { + $browserName = $infoBrowser[$browserName . '_data'][0]; + } + } //print "

$browserName

"; //G::pr($infoBrowser); @@ -1225,281 +1220,282 @@ class G $output .= file_get_contents ( $baseSkinDirectory . PATH_SEP.'css'.PATH_SEP.$cssFileInfo['__ATTRIBUTES__']['file'] ); } } - } - //Remove comments.. - $regex = array( -"`^([\t\s]+)`ism"=>'', -"`^\/\*(.+?)\*\/`ism"=>"", -"`([\n\A;]+)\/\*(.+?)\*\/`ism"=>"$1", -"`([\n\A;\s]+)//(.+?)[\n\r]`ism"=>"$1\n", -"`(^[\r\n]*|[\r\n]+)[\s\t]*[\r\n]+`ism"=>"\n" -); -$output = preg_replace(array_keys($regex),$regex,$output); -$output = $outputHeader.$output; - - return $output; - } - - /** - * streaming a big JS file with small js files - * - * @author Fernando Ontiveros Lira - * @access public - * @param string $file - * @param boolean $download - * @param string $downloadFileName - * @return string - */ - function streamJSTranslationFile( $filename, $locale = 'en' ) - { - header('Content-Type: text/javascript'); - - if (!G::LoadTranslationObject($locale)) { - header('Cache-Control: no-cache'); - header('Pragma: no-cache'); - return; - } - - global $translation; - - //if userAgent (BROWSER) is MSIE we need special headers to avoid MSIE behaivor. - $userAgent = strtolower($_SERVER['HTTP_USER_AGENT']); - if ( file_exists($filename) ) - $mtime = filemtime($filename); - else - $mtime = date('U'); - $gmt_mtime = gmdate("D, d M Y H:i:s", $mtime ) . " GMT"; - header('Pragma: cache'); - header('ETag: "' . md5 ($mtime . $filename ) . '"' ); - header("Last-Modified: " . $gmt_mtime ); - header('Cache-Control: public'); - header("Expires: " . gmdate("D, d M Y H:i:s", time () + 30*60*60*24 ) . " GMT"); //1 month - if( isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) ) { - if ($_SERVER['HTTP_IF_MODIFIED_SINCE'] == $gmt_mtime) { - header('HTTP/1.1 304 Not Modified'); - exit(); - } - } - - if ( isset($_SERVER['HTTP_IF_NONE_MATCH'])) { - if ( str_replace('"', '', stripslashes($_SERVER['HTTP_IF_NONE_MATCH'])) == md5( $mtime . $filename)) { - header("HTTP/1.1 304 Not Modified"); - exit(); - } - } - - return JSMin::minify ( 'var TRANSLATIONS = ' . G::json_encode($translation) . ';' ); - } - - /** - * streaming a file - * - * @author Fernando Ontiveros Lira - * @access public - * @param string $file - * @param boolean $download - * @param string $downloadFileName - * @return string - */ - function streamFile( $file, $download = false, $downloadFileName = '' ) - { - require_once (PATH_THIRDPARTY . 'jsmin/jsmin.php'); - $folderarray = explode ( '/', $file ); - $typearray = explode ( '.', basename( $file) ); - $typefile = $typearray[ count($typearray) -1 ]; - $filename = $file; - - //trick to generate the translation.language.js file , merging two files and then minified the content. - if ( strtolower ($typefile ) == 'js' && $typearray[0] == 'translation' ) { - $output = G::streamJSTranslationFile ($filename, $typearray[1]); - print $output; - return; - } - - //trick to generate the big css file for ext style . - if ( strtolower ($typefile ) == 'css' && $folderarray[count($folderarray)-2] == 'css' ) { - $output = G::streamCSSBigFile( $typearray[0] ); - print $output; - return; - } - - if ( file_exists ( $filename ) ) { - switch ( strtolower ($typefile ) ) { - case 'swf' : - G::sendHeaders ( $filename , 'application/x-shockwave-flash', $download, $downloadFileName ); break; - case 'js' : - G::sendHeaders ( $filename , 'text/javascript', $download, $downloadFileName ); break; - case 'htm' : - case 'html' : - G::sendHeaders ( $filename , 'text/html', $download, $downloadFileName ); break; - case 'htc' : - G::sendHeaders ( $filename , 'text/plain', $download, $downloadFileName ); break; - case 'json' : - G::sendHeaders ( $filename , 'text/plain', $download, $downloadFileName ); break; - case 'gif' : - G::sendHeaders ( $filename , 'image/gif', $download, $downloadFileName ); break; - case 'png' : - G::sendHeaders ( $filename , 'image/png', $download, $downloadFileName ); break; - case 'jpg' : - G::sendHeaders ( $filename , 'image/jpg', $download, $downloadFileName ); break; - case 'css' : - G::sendHeaders ( $filename , 'text/css', $download, $downloadFileName ); break; - case 'css' : - G::sendHeaders ( $filename , 'text/css', $download, $downloadFileName ); break; - case 'xml' : - G::sendHeaders ( $filename , 'text/xml', $download, $downloadFileName ); break; - case 'txt' : - G::sendHeaders ( $filename , 'text/html', $download, $downloadFileName ); break; - case 'doc' : - case 'pdf' : - case 'pm' : - case 'po' : - G::sendHeaders ( $filename , 'application/octet-stream', $download, $downloadFileName ); break; - case 'php' : - if ($download) { - G::sendHeaders ( $filename , 'text/plain', $download, $downloadFileName ); - } - else { - require_once( $filename ); - return; - } - break; - case 'tar': - G::sendHeaders ( $filename , 'application/x-tar', $download, $downloadFileName ); break; - default : - //throw new Exception ( "Unknown type of file '$file'. " ); - G::sendHeaders ( $filename , 'application/octet-stream', $download, $downloadFileName ); break; - break; - } - } - else { - if( strpos($file, 'gulliver') !== false ){ - list($path, $filename) = explode('gulliver', $file); - } - - $_SESSION['phpFileNotFound'] = $file; - G::header("location: /errors/error404.php?l=".$_SERVER['REQUEST_URI']); - } - - switch ( strtolower($typefile ) ) { - case "js" : - $paths = explode ( '/', $filename); - $jsName = $paths[ count ($paths) -1 ]; - $output = ''; - $pathJs = PATH_GULLIVER_HOME . PATH_SEP . 'js' . PATH_SEP; - switch ( $jsName ) { - case 'draw2d.js' : - $cachePath = PATH_C . 'ExtJs' . PATH_SEP; - $checksum = G::getCheckSum(array( - $pathJs . 'ext/wz_jsgraphics.js', - $pathJs . 'ext/mootools.js', - $pathJs . 'ext/moocanvas.js' - )); - - $cf = $cachePath . "ext-draw2d-cache.$checksum.js"; - $cfStored = G::getCacheFileNameByPattern($cachePath, 'ext-draw2d-cache.*.js'); - //error_log("draw2d.js ".$checksum ."==". $cfStored['checksum']); - if(is_file($cfStored['filename']) && $checksum == $cfStored['checksum']) { - $output = file_get_contents($cf); - } else { - if (is_file($cfStored['filename'])) - @unlink($cfStored['filename']); - - $output .= JSMin::minify ( file_get_contents ( $pathJs . 'ext/wz_jsgraphics.js' ) ); - $output .= JSMin::minify ( file_get_contents ( $pathJs . 'ext/mootools.js' ) ); - $output .= JSMin::minify ( file_get_contents ( $pathJs . 'ext/moocanvas.js' ) ); - $output .= file_get_contents ($pathJs . 'ext/draw2d.js'); //already minified - file_put_contents($cf, $output); - //error_log("draw2d.js writting ".$cf); - } - break; - case 'ext-all.js' : - $cachePath = PATH_C . 'ExtJs' . PATH_SEP; - $checksum = G::getCheckSum(array( - $pathJs . 'ext/pmos-common.js', - $pathJs . 'ext/ux/miframe.js', - $pathJs . 'ext/ux.locationbar/Ext.ux.LocationBar.js', - $pathJs . 'ext/ux.statusbar/ext-statusbar.js', - $pathJs . 'ext/ux.treefilterx/Ext.ux.tree.TreeFilterX.js' - )); - - $cfStored = G::getCacheFileNameByPattern($cachePath, 'ext-all-cache.*.js'); - $cf = PATH_C . 'ExtJs' . PATH_SEP . "ext-all-cache.$checksum.js"; - if(is_file($cfStored['filename']) && $checksum == $cfStored['checksum']) { - $output = file_get_contents($cf); - } else { - if (is_file($cfStored['filename'])) - @unlink($cfStored['filename']); - - $output .= file_get_contents ( $pathJs . 'ext/ext-all.js' ); //already minified - $output .= file_get_contents ( $pathJs . 'ext/ux/ux-all.js' ); //already minified - $output .= JSMin::minify ( file_get_contents ( $pathJs . 'ext/pmos-common.js' ) ); - $output .= JSMin::minify ( file_get_contents ( $pathJs . 'ext/ux/miframe.js' ) ); - $output .= JSMin::minify ( file_get_contents ( $pathJs . 'ext/ux.locationbar/Ext.ux.LocationBar.js' ) ); - $output .= JSMin::minify ( file_get_contents ( $pathJs . 'ext/ux.statusbar/ext-statusbar.js' ) ); - $output .= JSMin::minify ( file_get_contents ( $pathJs . 'ext/ux.treefilterx/Ext.ux.tree.TreeFilterX.js' ) ); - - file_put_contents($cf, $output); - } - break; - - case 'maborak.js' : - $oHeadPublisher =& headPublisher::getSingleton(); - foreach ( $oHeadPublisher->maborakFiles as $fileJS ) { - $output .= JSMin::minify ( file_get_contents ( $fileJS ) ); - //$output .= G::trimSourceCodeFile ($fileJS ); - } - break; - case 'maborak.loader.js': - $oHeadPublisher =& headPublisher::getSingleton(); - foreach ( $oHeadPublisher->maborakLoaderFiles as $fileJS ) { - $output .= JSMin::minify ( file_get_contents ( $fileJS ) ); - //$output .= G::trimSourceCodeFile ($fileJS ); - } - break; - default : - //$output = file_get_contents ( $filename ) ; - $output = JSMin::minify ( file_get_contents ( $filename ) ); - //$output = G::trimSourceCodeFile ($filename ); - } - print $output; - break; - case 'css' : - //$output = JSMin::minify ( file_get_contents ( $filename) ); - print G::trimSourceCodeFile ($filename ); - break; - default : - @readfile($filename); - } - } - - /** - * trimSourceCodeFile - * - * @param string $filename - * - * @return string $output - */ - function trimSourceCodeFile ( $filename ) { - $handle = fopen ($filename, "r"); - $lastChar = ''; - $firstChar = ''; - $content = ''; - $line = ''; - - //no optimizing code - if ($handle) { - while (!feof($handle)) { - //$line = trim( fgets($handle, 16096) ) . "\n" ; - $line = fgets($handle, 16096); - $content .= $line; - } - fclose($handle); - } - return $content; - //end NO optimizing code - //begin optimizing code - /* + } + //Remove comments.. + $regex = array ("`^([\t\s]+)`ism" => '',"`^\/\*(.+?)\*\/`ism" => "","`([\n\A;]+)\/\*(.+?)\*\/`ism" => "$1","`([\n\A;\s]+)//(.+?)[\n\r]`ism" => "$1\n","`(^[\r\n]*|[\r\n]+)[\s\t]*[\r\n]+`ism" => "\n" + ); + $output = preg_replace( array_keys( $regex ), $regex, $output ); + $output = $outputHeader . $output; + + return $output; + } + + /** + * streaming a big JS file with small js files + * + * @author Fernando Ontiveros Lira + * @access public + * @param string $file + * @param boolean $download + * @param string $downloadFileName + * @return string + */ + function streamJSTranslationFile ($filename, $locale = 'en') + { + header( 'Content-Type: text/javascript' ); + + if (! G::LoadTranslationObject( $locale )) { + header( 'Cache-Control: no-cache' ); + header( 'Pragma: no-cache' ); + return; + } + + global $translation; + + //if userAgent (BROWSER) is MSIE we need special headers to avoid MSIE behaivor. + $userAgent = strtolower( $_SERVER['HTTP_USER_AGENT'] ); + if (file_exists( $filename )) + $mtime = filemtime( $filename ); + else + $mtime = date( 'U' ); + $gmt_mtime = gmdate( "D, d M Y H:i:s", $mtime ) . " GMT"; + header( 'Pragma: cache' ); + header( 'ETag: "' . md5( $mtime . $filename ) . '"' ); + header( "Last-Modified: " . $gmt_mtime ); + header( 'Cache-Control: public' ); + header( "Expires: " . gmdate( "D, d M Y H:i:s", time() + 30 * 60 * 60 * 24 ) . " GMT" ); //1 month + if (isset( $_SERVER['HTTP_IF_MODIFIED_SINCE'] )) { + if ($_SERVER['HTTP_IF_MODIFIED_SINCE'] == $gmt_mtime) { + header( 'HTTP/1.1 304 Not Modified' ); + exit(); + } + } + + if (isset( $_SERVER['HTTP_IF_NONE_MATCH'] )) { + if (str_replace( '"', '', stripslashes( $_SERVER['HTTP_IF_NONE_MATCH'] ) ) == md5( $mtime . $filename )) { + header( "HTTP/1.1 304 Not Modified" ); + exit(); + } + } + + return JSMin::minify( 'var TRANSLATIONS = ' . G::json_encode( $translation ) . ';' ); + } + + /** + * streaming a file + * + * @author Fernando Ontiveros Lira + * @access public + * @param string $file + * @param boolean $download + * @param string $downloadFileName + * @return string + */ + function streamFile ($file, $download = false, $downloadFileName = '') + { + require_once (PATH_THIRDPARTY . 'jsmin/jsmin.php'); + $folderarray = explode( '/', $file ); + $typearray = explode( '.', basename( $file ) ); + $typefile = $typearray[count( $typearray ) - 1]; + $filename = $file; + + //trick to generate the translation.language.js file , merging two files and then minified the content. + if (strtolower( $typefile ) == 'js' && $typearray[0] == 'translation') { + $output = G::streamJSTranslationFile( $filename, $typearray[1] ); + print $output; + return; + } + + //trick to generate the big css file for ext style . + if (strtolower( $typefile ) == 'css' && $folderarray[count( $folderarray ) - 2] == 'css') { + $output = G::streamCSSBigFile( $typearray[0] ); + print $output; + return; + } + + if (file_exists( $filename )) { + switch (strtolower( $typefile )) { + case 'swf': + G::sendHeaders( $filename, 'application/x-shockwave-flash', $download, $downloadFileName ); + break; + case 'js': + G::sendHeaders( $filename, 'text/javascript', $download, $downloadFileName ); + break; + case 'htm': + case 'html': + G::sendHeaders( $filename, 'text/html', $download, $downloadFileName ); + break; + case 'htc': + G::sendHeaders( $filename, 'text/plain', $download, $downloadFileName ); + break; + case 'json': + G::sendHeaders( $filename, 'text/plain', $download, $downloadFileName ); + break; + case 'gif': + G::sendHeaders( $filename, 'image/gif', $download, $downloadFileName ); + break; + case 'png': + G::sendHeaders( $filename, 'image/png', $download, $downloadFileName ); + break; + case 'jpg': + G::sendHeaders( $filename, 'image/jpg', $download, $downloadFileName ); + break; + case 'css': + G::sendHeaders( $filename, 'text/css', $download, $downloadFileName ); + break; + case 'css': + G::sendHeaders( $filename, 'text/css', $download, $downloadFileName ); + break; + case 'xml': + G::sendHeaders( $filename, 'text/xml', $download, $downloadFileName ); + break; + case 'txt': + G::sendHeaders( $filename, 'text/html', $download, $downloadFileName ); + break; + case 'doc': + case 'pdf': + case 'pm': + case 'po': + G::sendHeaders( $filename, 'application/octet-stream', $download, $downloadFileName ); + break; + case 'php': + if ($download) { + G::sendHeaders( $filename, 'text/plain', $download, $downloadFileName ); + } else { + require_once ($filename); + return; + } + break; + case 'tar': + G::sendHeaders( $filename, 'application/x-tar', $download, $downloadFileName ); + break; + default: + //throw new Exception ( "Unknown type of file '$file'. " ); + G::sendHeaders( $filename, 'application/octet-stream', $download, $downloadFileName ); + break; + break; + } + } else { + if (strpos( $file, 'gulliver' ) !== false) { + list ($path, $filename) = explode( 'gulliver', $file ); + } + + $_SESSION['phpFileNotFound'] = $file; + G::header( "location: /errors/error404.php?l=" . $_SERVER['REQUEST_URI'] ); + } + + switch (strtolower( $typefile )) { + case "js": + $paths = explode( '/', $filename ); + $jsName = $paths[count( $paths ) - 1]; + $output = ''; + $pathJs = PATH_GULLIVER_HOME . PATH_SEP . 'js' . PATH_SEP; + switch ($jsName) { + case 'draw2d.js': + $cachePath = PATH_C . 'ExtJs' . PATH_SEP; + $checksum = G::getCheckSum( array ($pathJs . 'ext/wz_jsgraphics.js',$pathJs . 'ext/mootools.js',$pathJs . 'ext/moocanvas.js' + ) ); + + $cf = $cachePath . "ext-draw2d-cache.$checksum.js"; + $cfStored = G::getCacheFileNameByPattern( $cachePath, 'ext-draw2d-cache.*.js' ); + //error_log("draw2d.js ".$checksum ."==". $cfStored['checksum']); + if (is_file( $cfStored['filename'] ) && $checksum == $cfStored['checksum']) { + $output = file_get_contents( $cf ); + } else { + if (is_file( $cfStored['filename'] )) + @unlink( $cfStored['filename'] ); + + $output .= JSMin::minify( file_get_contents( $pathJs . 'ext/wz_jsgraphics.js' ) ); + $output .= JSMin::minify( file_get_contents( $pathJs . 'ext/mootools.js' ) ); + $output .= JSMin::minify( file_get_contents( $pathJs . 'ext/moocanvas.js' ) ); + $output .= file_get_contents( $pathJs . 'ext/draw2d.js' ); //already minified + file_put_contents( $cf, $output ); + //error_log("draw2d.js writting ".$cf); + } + break; + case 'ext-all.js': + $cachePath = PATH_C . 'ExtJs' . PATH_SEP; + $checksum = G::getCheckSum( array ($pathJs . 'ext/pmos-common.js',$pathJs . 'ext/ux/miframe.js',$pathJs . 'ext/ux.locationbar/Ext.ux.LocationBar.js',$pathJs . 'ext/ux.statusbar/ext-statusbar.js',$pathJs . 'ext/ux.treefilterx/Ext.ux.tree.TreeFilterX.js' + ) ); + + $cfStored = G::getCacheFileNameByPattern( $cachePath, 'ext-all-cache.*.js' ); + $cf = PATH_C . 'ExtJs' . PATH_SEP . "ext-all-cache.$checksum.js"; + if (is_file( $cfStored['filename'] ) && $checksum == $cfStored['checksum']) { + $output = file_get_contents( $cf ); + } else { + if (is_file( $cfStored['filename'] )) + @unlink( $cfStored['filename'] ); + + $output .= file_get_contents( $pathJs . 'ext/ext-all.js' ); //already minified + $output .= file_get_contents( $pathJs . 'ext/ux/ux-all.js' ); //already minified + $output .= JSMin::minify( file_get_contents( $pathJs . 'ext/pmos-common.js' ) ); + $output .= JSMin::minify( file_get_contents( $pathJs . 'ext/ux/miframe.js' ) ); + $output .= JSMin::minify( file_get_contents( $pathJs . 'ext/ux.locationbar/Ext.ux.LocationBar.js' ) ); + $output .= JSMin::minify( file_get_contents( $pathJs . 'ext/ux.statusbar/ext-statusbar.js' ) ); + $output .= JSMin::minify( file_get_contents( $pathJs . 'ext/ux.treefilterx/Ext.ux.tree.TreeFilterX.js' ) ); + + file_put_contents( $cf, $output ); + } + break; + + case 'maborak.js': + $oHeadPublisher = & headPublisher::getSingleton(); + foreach ($oHeadPublisher->maborakFiles as $fileJS) { + $output .= JSMin::minify( file_get_contents( $fileJS ) ); + //$output .= G::trimSourceCodeFile ($fileJS ); + } + break; + case 'maborak.loader.js': + $oHeadPublisher = & headPublisher::getSingleton(); + foreach ($oHeadPublisher->maborakLoaderFiles as $fileJS) { + $output .= JSMin::minify( file_get_contents( $fileJS ) ); + //$output .= G::trimSourceCodeFile ($fileJS ); + } + break; + default: + //$output = file_get_contents ( $filename ) ; + $output = JSMin::minify( file_get_contents( $filename ) ); + //$output = G::trimSourceCodeFile ($filename ); + } + print $output; + break; + case 'css': + //$output = JSMin::minify ( file_get_contents ( $filename) ); + print G::trimSourceCodeFile( $filename ); + break; + default: + @readfile( $filename ); + } + } + + /** + * trimSourceCodeFile + * + * @param string $filename + * + * @return string $output + */ + function trimSourceCodeFile ($filename) + { + $handle = fopen( $filename, "r" ); + $lastChar = ''; + $firstChar = ''; + $content = ''; + $line = ''; + + //no optimizing code + if ($handle) { + while (! feof( $handle )) { + //$line = trim( fgets($handle, 16096) ) . "\n" ; + $line = fgets( $handle, 16096 ); + $content .= $line; + } + fclose( $handle ); + } + return $content; + //end NO optimizing code + //begin optimizing code + /* if ($handle) { while (!feof($handle)) { $lastChar = ( strlen ( $line ) > 5 ) ? $line[strlen($line)-1] : ''; @@ -1517,465 +1513,493 @@ $output = $outputHeader.$output; } fclose($handle); } - */ - //end optimizing code - - $index = 0; - $output = ''; - while ( $index < strlen ($content) ) { - $car = $content[$index]; - $index++; - if ( $car == '/' && isset($content[$index]) && $content[$index] == '*' ) { - $endComment = false; - $index ++; - while ( $endComment == false && $index < strlen ($content) ) { - if ($content[$index] == '*' && isset($content[$index+1]) && $content[$index+1] == '/' ) { - $endComment = true; $index ++; - } - $index ++; - } - $car = ''; - } - $output .= $car; - } - return $output; - } - - /** - * sendHeaders - * - * @param string $filename - * @param string $contentType default value '' - * @param boolean $download default value false - * @param string $downloadFileName default value '' - * - * @return void - */ - function sendHeaders ( $filename , $contentType = '', $download = false, $downloadFileName = '' ) - { - if ($download) { - if ($downloadFileName == '') { - $aAux = explode('/', $filename); - $downloadFileName = $aAux[count($aAux) - 1]; - } - header('Content-Disposition: attachment; filename="' . $downloadFileName . '"'); - } - header('Content-Type: ' . $contentType); - - //if userAgent (BROWSER) is MSIE we need special headers to avoid MSIE behaivor. - $userAgent = strtolower($_SERVER['HTTP_USER_AGENT']); - if ( preg_match("/msie/i", $userAgent)) { - //if ( ereg("msie", $userAgent)) { - header('Pragma: cache'); - - $mtime = filemtime($filename); - $gmt_mtime = gmdate("D, d M Y H:i:s", $mtime ) . " GMT"; - header('ETag: "' . md5 ($mtime . $filename ) . '"' ); - header("Last-Modified: " . $gmt_mtime ); - header('Cache-Control: public'); - header("Expires: " . gmdate("D, d M Y H:i:s", time () + 60*10 ) . " GMT"); //ten minutes - return; - } - - if (!$download) { - - header('Pragma: cache'); - - if ( file_exists($filename) ) - $mtime = filemtime($filename); - else - $mtime = date('U'); - $gmt_mtime = gmdate("D, d M Y H:i:s", $mtime ) . " GMT"; - header('ETag: "' . md5 ($mtime . $filename ) . '"' ); - header("Last-Modified: " . $gmt_mtime ); - header('Cache-Control: public'); - header("Expires: " . gmdate("D, d M Y H:i:s", time () + 90*60*60*24 ) . " GMT"); - if( isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) ) { - if ($_SERVER['HTTP_IF_MODIFIED_SINCE'] == $gmt_mtime) { - header('HTTP/1.1 304 Not Modified'); - exit(); - } - } - - if (isset($_SERVER['HTTP_IF_NONE_MATCH'])) { - if ( str_replace('"', '', stripslashes($_SERVER['HTTP_IF_NONE_MATCH'])) == md5( $mtime . $filename)) { - header("HTTP/1.1 304 Not Modified"); - exit(); - } - } - } - } - - /** - * Transform a public URL into a local path. - * - * @author David S. Callizaya S. - * @access public - * @param string $url - * @param string $corvertionTable - * @param string $realPath = local path - * @return boolean - */ - function virtualURI( $url , $convertionTable , &$realPath ) - { - foreach($convertionTable as $urlPattern => $localPath ) { - // $urlPattern = addcslashes( $urlPattern , '/'); - $urlPattern = addcslashes( $urlPattern , './'); - $urlPattern = '/^' . str_replace( - array('*','?'), - array('.*','.?'), - $urlPattern) . '$/'; - if (preg_match($urlPattern , $url, $match)) { - if ($localPath === FALSE) { - $realPath = $url; - return false; - } - if ( $localPath != 'jsMethod' ) - $realPath = $localPath . $match[1]; - else - $realPath = $localPath; - return true; - } - } - $realPath = $url; - return false; - } - - /** - * Create an encrypted unique identifier based on $id and the selected scope id. - * - * @author David S. Callizaya S. - * @access public - * @param string $scope - * @param string $id - * @return string - */ - function createUID( $scope, $id ) - { - $e = $scope . $id; - $e=G::encrypt( $e , URL_KEY ); - $e=str_replace(array('+','/','='),array('__','_','___'),base64_encode($e)); - return $e; - } - - /** - * (Create an encrypted unique identificator based on $id and the selected scope id.) ^-1 - * getUIDName - * - * @author David S. Callizaya S. - * @access public - * @param string $id - * @param string $scope - * @return string - */ - function getUIDName( $uid , $scope = '' ) - { - $e=str_replace(array('=','+','/'),array('___','__','_'),$uid); - $e=base64_decode($e); - $e=G::decrypt( $e , URL_KEY ); - $e=substr( $e , strlen($scope) ); - return $e; - } - - /* formatNumber + */ + //end optimizing code + + + $index = 0; + $output = ''; + while ($index < strlen( $content )) { + $car = $content[$index]; + $index ++; + if ($car == '/' && isset( $content[$index] ) && $content[$index] == '*') { + $endComment = false; + $index ++; + while ($endComment == false && $index < strlen( $content )) { + if ($content[$index] == '*' && isset( $content[$index + 1] ) && $content[$index + 1] == '/') { + $endComment = true; + $index ++; + } + $index ++; + } + $car = ''; + } + $output .= $car; + } + return $output; + } + + /** + * sendHeaders + * + * @param string $filename + * @param string $contentType default value '' + * @param boolean $download default value false + * @param string $downloadFileName default value '' + * + * @return void + */ + function sendHeaders ($filename, $contentType = '', $download = false, $downloadFileName = '') + { + if ($download) { + if ($downloadFileName == '') { + $aAux = explode( '/', $filename ); + $downloadFileName = $aAux[count( $aAux ) - 1]; + } + header( 'Content-Disposition: attachment; filename="' . $downloadFileName . '"' ); + } + header( 'Content-Type: ' . $contentType ); + + //if userAgent (BROWSER) is MSIE we need special headers to avoid MSIE behaivor. + $userAgent = strtolower( $_SERVER['HTTP_USER_AGENT'] ); + if (preg_match( "/msie/i", $userAgent )) { + //if ( ereg("msie", $userAgent)) { + header( 'Pragma: cache' ); + + $mtime = filemtime( $filename ); + $gmt_mtime = gmdate( "D, d M Y H:i:s", $mtime ) . " GMT"; + header( 'ETag: "' . md5( $mtime . $filename ) . '"' ); + header( "Last-Modified: " . $gmt_mtime ); + header( 'Cache-Control: public' ); + header( "Expires: " . gmdate( "D, d M Y H:i:s", time() + 60 * 10 ) . " GMT" ); //ten minutes + return; + } + + if (! $download) { + + header( 'Pragma: cache' ); + + if (file_exists( $filename )) + $mtime = filemtime( $filename ); + else + $mtime = date( 'U' ); + $gmt_mtime = gmdate( "D, d M Y H:i:s", $mtime ) . " GMT"; + header( 'ETag: "' . md5( $mtime . $filename ) . '"' ); + header( "Last-Modified: " . $gmt_mtime ); + header( 'Cache-Control: public' ); + header( "Expires: " . gmdate( "D, d M Y H:i:s", time() + 90 * 60 * 60 * 24 ) . " GMT" ); + if (isset( $_SERVER['HTTP_IF_MODIFIED_SINCE'] )) { + if ($_SERVER['HTTP_IF_MODIFIED_SINCE'] == $gmt_mtime) { + header( 'HTTP/1.1 304 Not Modified' ); + exit(); + } + } + + if (isset( $_SERVER['HTTP_IF_NONE_MATCH'] )) { + if (str_replace( '"', '', stripslashes( $_SERVER['HTTP_IF_NONE_MATCH'] ) ) == md5( $mtime . $filename )) { + header( "HTTP/1.1 304 Not Modified" ); + exit(); + } + } + } + } + + /** + * Transform a public URL into a local path. + * + * @author David S. Callizaya S. + * @access public + * @param string $url + * @param string $corvertionTable + * @param string $realPath = local path + * @return boolean + */ + function virtualURI ($url, $convertionTable, &$realPath) + { + foreach ($convertionTable as $urlPattern => $localPath) { + // $urlPattern = addcslashes( $urlPattern , '/'); + $urlPattern = addcslashes( $urlPattern, './' ); + $urlPattern = '/^' . str_replace( array ('*','?' + ), array ('.*','.?' + ), $urlPattern ) . '$/'; + if (preg_match( $urlPattern, $url, $match )) { + if ($localPath === FALSE) { + $realPath = $url; + return false; + } + if ($localPath != 'jsMethod') + $realPath = $localPath . $match[1]; + else + $realPath = $localPath; + return true; + } + } + $realPath = $url; + return false; + } + + /** + * Create an encrypted unique identifier based on $id and the selected scope id. + * + * @author David S. Callizaya S. + * @access public + * @param string $scope + * @param string $id + * @return string + */ + function createUID ($scope, $id) + { + $e = $scope . $id; + $e = G::encrypt( $e, URL_KEY ); + $e = str_replace( array ('+','/','=' + ), array ('__','_','___' + ), base64_encode( $e ) ); + return $e; + } + + /** + * (Create an encrypted unique identificator based on $id and the selected scope id.) ^-1 + * getUIDName + * + * @author David S. Callizaya S. + * @access public + * @param string $id + * @param string $scope + * @return string + */ + function getUIDName ($uid, $scope = '') + { + $e = str_replace( array ('=','+','/' + ), array ('___','__','_' + ), $uid ); + $e = base64_decode( $e ); + $e = G::decrypt( $e, URL_KEY ); + $e = substr( $e, strlen( $scope ) ); + return $e; + } + + /* formatNumber * * @author David Callizaya * @param int/string $num * @return string number - */ - function formatNumber($num, $language='latin') - { - switch($language) - { - default: - $snum=$num; - } - return $snum; - } - - /* Returns a date formatted according to the given format string + */ + function formatNumber ($num, $language = 'latin') + { + switch ($language) { + default: + $snum = $num; + } + return $snum; + } + + /* Returns a date formatted according to the given format string * @author David Callizaya * @param string $format The format of the outputted date string * @param string $datetime Date in the format YYYY-MM-DD HH:MM:SS - */ - function formatDate($datetime, $format='Y-m-d', $lang='') - { - if ($lang==='') $lang=defined(SYS_LANG)?SYS_LANG:'en'; - $aux = explode (' ', $datetime); //para dividir la fecha del dia - $date = explode ('-', isset ( $aux[0] ) ? $aux[0] : '00-00-00' ); //para obtener los dias, el mes, y el año. - $time = explode (':', isset ( $aux[1] ) ? $aux[1] : '00:00:00' ); //para obtener las horas, minutos, segundos. - $date[0] = (int)((isset($date[0]))?$date[0]:'0'); - $date[1] = (int)((isset($date[1]))?$date[1]:'0'); - $date[2] = (int)((isset($date[2]))?$date[2]:'0'); - $time[0] = (int)((isset($time[0]))?$time[0]:'0'); - $time[1] = (int)((isset($time[1]))?$time[1]:'0'); - $time[2] = (int)((isset($time[2]))?$time[2]:'0'); - // Spanish months - $ARR_MONTHS['es'] = array ("Enero","Febrero","Marzo","Abril","Mayo","Junio","Julio","Agosto","Septiembre","Octubre","Noviembre","Diciembre"); - // English months - $ARR_MONTHS['en'] = array("January", "February", "March", "April", "May", "June","July", "August", "September", "October", "November", "December"); - - - // Spanish days - $ARR_WEEKDAYS['es'] = array("Domingo", "Lunes", "Martes", "Miércoles", "Jueves", "Viernes", "Sábado"); - // English days - $ARR_WEEKDAYS['en'] = array("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"); - - - - if ($lang=='fa') - $number='persian'; - else - $number='latin'; - $d = '0'.$date[2];$d=G::formatNumber(substr($d,strlen($d)-2,2),$number); - $j = G::formatNumber($date[2],$number); - $F = isset ( $ARR_MONTHS[$lang][$date[1]-1] ) ? $ARR_MONTHS[$lang][$date[1]-1] : ''; - $m = '0'.$date[1];$m=G::formatNumber(substr($m,strlen($m)-2,2),$number); - $n = G::formatNumber($date[1],$number); - $y = G::formatNumber(substr($date[0],strlen($date[0])-2,2),$number); - $Y = '0000'.$date[0];$Y=G::formatNumber(substr($Y,strlen($Y)-4,4),$number); - $g = ($time[0] % 12);if ($g===0)$g=12; - $G = $time[0]; - $h = '0'.$g;$h=G::formatNumber(substr($h,strlen($h)-2,2),$number); - $H = '0'.$G;$H=G::formatNumber(substr($H,strlen($H)-2,2),$number); - $i = '0'.$time[1];$i=G::formatNumber(substr($i,strlen($i)-2,2),$number); - $s = '0'.$time[2];$s=G::formatNumber(substr($s,strlen($s)-2,2),$number); - $names=array('d','j','F','m','n','y','Y','g','G','h','H','i','s'); - $values=array($d, $j, $F, $m, $n, $y, $Y, $g, $G, $h, $H, $i, $s); - $_formatedDate = str_replace( $names, $values, $format ); - return $_formatedDate; - } - - /** - * getformatedDate - * - * @param date $date - * @param string $format default value 'yyyy-mm-dd', - * @param string $lang default value '' - * - * @return string $ret - */ - function getformatedDate($date, $format = 'yyyy-mm-dd', $lang = '') - { - /******************************************************************************************************** - * if the year is 2008 and the format is yy then -> 08 - * if the year is 2008 and the format is yyyy then -> 2008 - * - * if the month is 05 and the format is mm then -> 05 - * if the month is 05 and the format is m and the month is less than 10 then -> 5 else digit normal - * if the month is 05 and the format is MM or M then -> May - * - * if the day is 5 and the format is dd then -> 05 - * if the day is 5 and the format is d and the day is less than 10 then -> 5 else digit normal - * if the day is 5 and the format is DD or D then -> five - *********************************************************************************************************/ - - //scape the literal - switch($lang) { - case 'es': - $format = str_replace(' de ', '[of]', $format); - break; - } - - //first we must formatted the string - $format = str_replace('yyyy', '{YEAR}', $format); - $format = str_replace('yy', '{year}', $format); - - $format = str_replace('mm', '{YONTH}', $format); - $format = str_replace('m', '{month}', $format); - $format = str_replace('M', '{XONTH}', $format); - - $format = str_replace('dd', '{DAY}', $format); - $format = str_replace('d', '{day}', $format); - - $format = str_replace('h', '{h}', $format); - $format = str_replace('i', '{i}', $format); - $format = str_replace('s', '{s}', $format); - - - if ($lang==='') $lang=defined(SYS_LANG)?SYS_LANG:'en'; - - $aux = explode (' ', $date); //para dividir la fecha del dia - $date = explode ('-', isset ( $aux[0] ) ? $aux[0] : '00-00-00' ); //para obtener los dias, el mes, y el año. - $time = explode (':', isset ( $aux[1] ) ? $aux[1] : '00:00:00' ); //para obtener las horas, minutos, segundos. - - $year = (int)((isset($date[0]))?$date[0]:'0'); //year - $month = (int)((isset($date[1]))?$date[1]:'0'); //month - $day = (int)((isset($date[2]))?$date[2]:'0'); //day - - $h = isset($time[0])? $time[0]: '00'; //hour - $i = isset($time[1])? $time[1]: '00'; //minute - $s = isset($time[2])? $time[2]: '00'; //second - - $MONTHS = Array(); - for($i=1; $i<=12; $i++){ - $MONTHS[$i] = G::LoadTranslation("ID_MONTH_$i", $lang); - } - - $d = (int)$day; - $dd = G::complete_field($day, 2, 1); - - //missing D - - $M = $MONTHS[$month]; - $m = (int)$month; - $mm = G::complete_field($month, 2, 1); - - $yy = substr($year,strlen($year)-2,2); - $yyyy = $year; - - $names = array('{day}', '{DAY}', '{month}', '{YONTH}', '{XONTH}', '{year}', '{YEAR}', '{h}', '{i}', '{s}'); - $values = array($d, $dd, $m, $mm, $M, $yy, $yyyy, $h, $i, $s); - - $ret = str_replace( $names, $values, $format ); - - //recovering the original literal - switch($lang){ - case 'es': - $ret = str_replace('[of]', ' de ', $ret); - break; - } - - return $ret; - } - - /** - * By - * Here's a little wrapper for array_diff - I found myself needing - * to iterate through the edited array, and I didn't need to original keys for anything. - */ - function arrayDiff($array1, $array2) { - if (!is_array($array1)) { - $array1 = (array) $array1; - } - - if (!is_array($array2)) { - $array2 = (array) $array2; - } - - // This wrapper for array_diff rekeys the array returned - $valid_array = array_diff($array1,$array2); - - // reinstantiate $array1 variable - $array1 = array(); - - // loop through the validated array and move elements to $array1 - // this is necessary because the array_diff function returns arrays that retain their original keys - foreach ($valid_array as $valid){ - $array1[] = $valid; - } - return $array1; - } - - /** - * @author Erik Amaru Ortiz - * @name complete_field($string, $lenght, $type={1:number/2:string/3:float}) - */ - function complete_field($campo, $long, $tipo) - { - $campo = trim($campo); - switch($tipo) - { - case 1: //number - $long = $long-strlen($campo); - for($i=1; $i<=$long; $i++) { - $campo = "0".$campo; - } - break; - - case 2: //string - $long = $long-strlen($campo); - for($i=1; $i<=$long; $i++) { - $campo = " ".$campo; - } - break; - - case 3: //float - if($campo!="0") { - $vals = explode(".",$long); - $ints = $vals[0]; - - $decs = $vals[1]; - - $valscampo = explode(".",$campo); - - $intscampo = $valscampo[0]; - $decscampo = $valscampo[1]; - - $ints = $ints - strlen($intscampo); - - for($i=1; $i<=$ints; $i++) { - $intscampo = "0".$intscampo; - } - - //los decimales pueden ser 0 uno o dos - $decs = $decs - strlen($decscampo); - for($i=1; $i<=$decs; $i++) { - $decscampo = $decscampo."0"; - } - - $campo = $intscampo.".".$decscampo; - } else { - $vals = explode(".",$long); - $ints = $vals[0]; - $decs = $vals[1]; - - $campo = ""; - for($i=1; $i<=$ints; $i++) { - $campo = "0".$campo; - } - $campod = ""; - for($i=1; $i<=$decs; $i++) { - $campod = "0".$campod; - } - - $campo = $campo.".".$campod; - } - break; - } - return $campo; - } - - /* Escapes special characters in a string for use in a SQL statement + */ + function formatDate ($datetime, $format = 'Y-m-d', $lang = '') + { + if ($lang === '') + $lang = defined( SYS_LANG ) ? SYS_LANG : 'en'; + $aux = explode( ' ', $datetime ); //para dividir la fecha del dia + $date = explode( '-', isset( $aux[0] ) ? $aux[0] : '00-00-00' ); //para obtener los dias, el mes, y el año. + $time = explode( ':', isset( $aux[1] ) ? $aux[1] : '00:00:00' ); //para obtener las horas, minutos, segundos. + $date[0] = (int) ((isset( $date[0] )) ? $date[0] : '0'); + $date[1] = (int) ((isset( $date[1] )) ? $date[1] : '0'); + $date[2] = (int) ((isset( $date[2] )) ? $date[2] : '0'); + $time[0] = (int) ((isset( $time[0] )) ? $time[0] : '0'); + $time[1] = (int) ((isset( $time[1] )) ? $time[1] : '0'); + $time[2] = (int) ((isset( $time[2] )) ? $time[2] : '0'); + // Spanish months + $ARR_MONTHS['es'] = array ("Enero","Febrero","Marzo","Abril","Mayo","Junio","Julio","Agosto","Septiembre","Octubre","Noviembre","Diciembre" + ); + // English months + $ARR_MONTHS['en'] = array ("January","February","March","April","May","June","July","August","September","October","November","December" + ); + + // Spanish days + $ARR_WEEKDAYS['es'] = array ("Domingo","Lunes","Martes","Miércoles","Jueves","Viernes","Sábado" + ); + // English days + $ARR_WEEKDAYS['en'] = array ("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday" + ); + + if ($lang == 'fa') + $number = 'persian'; + else + $number = 'latin'; + $d = '0' . $date[2]; + $d = G::formatNumber( substr( $d, strlen( $d ) - 2, 2 ), $number ); + $j = G::formatNumber( $date[2], $number ); + $F = isset( $ARR_MONTHS[$lang][$date[1] - 1] ) ? $ARR_MONTHS[$lang][$date[1] - 1] : ''; + $m = '0' . $date[1]; + $m = G::formatNumber( substr( $m, strlen( $m ) - 2, 2 ), $number ); + $n = G::formatNumber( $date[1], $number ); + $y = G::formatNumber( substr( $date[0], strlen( $date[0] ) - 2, 2 ), $number ); + $Y = '0000' . $date[0]; + $Y = G::formatNumber( substr( $Y, strlen( $Y ) - 4, 4 ), $number ); + $g = ($time[0] % 12); + if ($g === 0) + $g = 12; + $G = $time[0]; + $h = '0' . $g; + $h = G::formatNumber( substr( $h, strlen( $h ) - 2, 2 ), $number ); + $H = '0' . $G; + $H = G::formatNumber( substr( $H, strlen( $H ) - 2, 2 ), $number ); + $i = '0' . $time[1]; + $i = G::formatNumber( substr( $i, strlen( $i ) - 2, 2 ), $number ); + $s = '0' . $time[2]; + $s = G::formatNumber( substr( $s, strlen( $s ) - 2, 2 ), $number ); + $names = array ('d','j','F','m','n','y','Y','g','G','h','H','i','s' + ); + $values = array ($d,$j,$F,$m,$n,$y,$Y,$g,$G,$h,$H,$i,$s + ); + $_formatedDate = str_replace( $names, $values, $format ); + return $_formatedDate; + } + + /** + * getformatedDate + * + * @param date $date + * @param string $format default value 'yyyy-mm-dd', + * @param string $lang default value '' + * + * @return string $ret + */ + function getformatedDate ($date, $format = 'yyyy-mm-dd', $lang = '') + { + /** + * ****************************************************************************************************** + * if the year is 2008 and the format is yy then -> 08 + * if the year is 2008 and the format is yyyy then -> 2008 + * + * if the month is 05 and the format is mm then -> 05 + * if the month is 05 and the format is m and the month is less than 10 then -> 5 else digit normal + * if the month is 05 and the format is MM or M then -> May + * + * if the day is 5 and the format is dd then -> 05 + * if the day is 5 and the format is d and the day is less than 10 then -> 5 else digit normal + * if the day is 5 and the format is DD or D then -> five + * ******************************************************************************************************* + */ + + //scape the literal + switch ($lang) { + case 'es': + $format = str_replace( ' de ', '[of]', $format ); + break; + } + + //first we must formatted the string + $format = str_replace( 'yyyy', '{YEAR}', $format ); + $format = str_replace( 'yy', '{year}', $format ); + + $format = str_replace( 'mm', '{YONTH}', $format ); + $format = str_replace( 'm', '{month}', $format ); + $format = str_replace( 'M', '{XONTH}', $format ); + + $format = str_replace( 'dd', '{DAY}', $format ); + $format = str_replace( 'd', '{day}', $format ); + + $format = str_replace( 'h', '{h}', $format ); + $format = str_replace( 'i', '{i}', $format ); + $format = str_replace( 's', '{s}', $format ); + + if ($lang === '') + $lang = defined( SYS_LANG ) ? SYS_LANG : 'en'; + + $aux = explode( ' ', $date ); //para dividir la fecha del dia + $date = explode( '-', isset( $aux[0] ) ? $aux[0] : '00-00-00' ); //para obtener los dias, el mes, y el año. + $time = explode( ':', isset( $aux[1] ) ? $aux[1] : '00:00:00' ); //para obtener las horas, minutos, segundos. + + + $year = (int) ((isset( $date[0] )) ? $date[0] : '0'); //year + $month = (int) ((isset( $date[1] )) ? $date[1] : '0'); //month + $day = (int) ((isset( $date[2] )) ? $date[2] : '0'); //day + + + $h = isset( $time[0] ) ? $time[0] : '00'; //hour + $i = isset( $time[1] ) ? $time[1] : '00'; //minute + $s = isset( $time[2] ) ? $time[2] : '00'; //second + + + $MONTHS = Array (); + for ($i = 1; $i <= 12; $i ++) { + $MONTHS[$i] = G::LoadTranslation( "ID_MONTH_$i", $lang ); + } + + $d = (int) $day; + $dd = G::complete_field( $day, 2, 1 ); + + //missing D + + + $M = $MONTHS[$month]; + $m = (int) $month; + $mm = G::complete_field( $month, 2, 1 ); + + $yy = substr( $year, strlen( $year ) - 2, 2 ); + $yyyy = $year; + + $names = array ('{day}','{DAY}','{month}','{YONTH}','{XONTH}','{year}','{YEAR}','{h}','{i}','{s}' + ); + $values = array ($d,$dd,$m,$mm,$M,$yy,$yyyy,$h,$i,$s + ); + + $ret = str_replace( $names, $values, $format ); + + //recovering the original literal + switch ($lang) { + case 'es': + $ret = str_replace( '[of]', ' de ', $ret ); + break; + } + + return $ret; + } + + /** + * By + * Here's a little wrapper for array_diff - I found myself needing + * to iterate through the edited array, and I didn't need to original keys for anything. + */ + function arrayDiff ($array1, $array2) + { + if (! is_array( $array1 )) { + $array1 = (array) $array1; + } + + if (! is_array( $array2 )) { + $array2 = (array) $array2; + } + + // This wrapper for array_diff rekeys the array returned + $valid_array = array_diff( $array1, $array2 ); + + // reinstantiate $array1 variable + $array1 = array (); + + // loop through the validated array and move elements to $array1 + // this is necessary because the array_diff function returns arrays that retain their original keys + foreach ($valid_array as $valid) { + $array1[] = $valid; + } + return $array1; + } + + /** + * + * @author Erik Amaru Ortiz + * @name complete_field($string, $lenght, $type={1:number/2:string/3:float}) + */ + function complete_field ($campo, $long, $tipo) + { + $campo = trim( $campo ); + switch ($tipo) { + case 1: //number + $long = $long - strlen( $campo ); + for ($i = 1; $i <= $long; $i ++) { + $campo = "0" . $campo; + } + break; + + case 2: //string + $long = $long - strlen( $campo ); + for ($i = 1; $i <= $long; $i ++) { + $campo = " " . $campo; + } + break; + + case 3: //float + if ($campo != "0") { + $vals = explode( ".", $long ); + $ints = $vals[0]; + + $decs = $vals[1]; + + $valscampo = explode( ".", $campo ); + + $intscampo = $valscampo[0]; + $decscampo = $valscampo[1]; + + $ints = $ints - strlen( $intscampo ); + + for ($i = 1; $i <= $ints; $i ++) { + $intscampo = "0" . $intscampo; + } + + //los decimales pueden ser 0 uno o dos + $decs = $decs - strlen( $decscampo ); + for ($i = 1; $i <= $decs; $i ++) { + $decscampo = $decscampo . "0"; + } + + $campo = $intscampo . "." . $decscampo; + } else { + $vals = explode( ".", $long ); + $ints = $vals[0]; + $decs = $vals[1]; + + $campo = ""; + for ($i = 1; $i <= $ints; $i ++) { + $campo = "0" . $campo; + } + $campod = ""; + for ($i = 1; $i <= $decs; $i ++) { + $campod = "0" . $campod; + } + + $campo = $campo . "." . $campod; + } + break; + } + return $campo; + } + + /* Escapes special characters in a string for use in a SQL statement * @author David Callizaya * @param string $sqlString The string to be escaped * @param string $DBEngine Target DBMS - */ - function sqlEscape( $sqlString, $DBEngine = DB_ADAPTER ) - { - $DBEngine = DB_ADAPTER; - switch($DBEngine){ - case 'mysql': - $con = Propel::getConnection('workflow') ; - return mysql_real_escape_string(stripslashes($sqlString), $con->getResource() ); - case 'myxml': - $sqlString = str_replace('"', '""', $sqlString); - return str_replace("'", "''", $sqlString); - //return str_replace(array('"',"'"),array('""',"''"),stripslashes($sqlString)); - default: - return addslashes(stripslashes($sqlString)); - } - } - - /** - * Function MySQLSintaxis - * @access public - * @return Boolean - **/ - function MySQLSintaxis() - { - $DBEngine = DB_ADAPTER; - switch($DBEngine){ - case 'mysql' : - return TRUE; - break; - case 'mssql' : - default: - return FALSE; - break; - } - } - /* Returns a sql string with @@parameters replaced with its values defined + */ + function sqlEscape ($sqlString, $DBEngine = DB_ADAPTER) + { + $DBEngine = DB_ADAPTER; + switch ($DBEngine) { + case 'mysql': + $con = Propel::getConnection( 'workflow' ); + return mysql_real_escape_string( stripslashes( $sqlString ), $con->getResource() ); + case 'myxml': + $sqlString = str_replace( '"', '""', $sqlString ); + return str_replace( "'", "''", $sqlString ); + //return str_replace(array('"',"'"),array('""',"''"),stripslashes($sqlString)); + default: + return addslashes( stripslashes( $sqlString ) ); + } + } + + /** + * Function MySQLSintaxis + * + * @access public + * @return Boolean + * + */ + function MySQLSintaxis () + { + $DBEngine = DB_ADAPTER; + switch ($DBEngine) { + case 'mysql': + return TRUE; + break; + case 'mssql': + default: + return FALSE; + break; + } + } + /* Returns a sql string with @@parameters replaced with its values defined * in array $result using the next notation: * NOTATION: * @@ Quoted parameter acording to the SYSTEM's Database @@ -1986,28 +2010,29 @@ $output = $outputHeader.$output; * @! Evaluate string : Replace the parameters in value and then in the sql string * @fn() Evaluate string with the function "fn" * @author David Callizaya - */ - function replaceDataField( $sqlString, $result, $DBEngine = 'mysql' ) - { - if (!is_array($result)) { - $result = array(); - } - $result = $result + G::getSystemConstants(); - $__textoEval = ""; - $u = 0; - //$count=preg_match_all('/\@(?:([\@\%\#\!Qq])([a-zA-Z\_]\w*)|([a-zA-Z\_][\w\-\>\:]*)\(((?:[^\\\\\)]*(?:[\\\\][\w\W])?)*)\))/',$sqlString,$match,PREG_PATTERN_ORDER | PREG_OFFSET_CAPTURE); - $count = preg_match_all('/\@(?:([\@\%\#\=\!Qq])([a-zA-Z\_]\w*)|([a-zA-Z\_][\w\-\>\:]*)\(((?:[^\\\\\)]*?)*)\))/',$sqlString,$match,PREG_PATTERN_ORDER | PREG_OFFSET_CAPTURE); - if ($count) { - for($r=0;$r<$count;$r++) { - if (!isset($result[$match[2][$r][0]])) - $result[$match[2][$r][0]] = ''; - if (!is_array($result[$match[2][$r][0]])) { - $__textoEval.=substr($sqlString,$u,$match[0][$r][1]-$u); - $u = $match[0][$r][1]+strlen($match[0][$r][0]); - //Mysql quotes scape - if (($match[1][$r][0]=='@')&&(isset($result[$match[2][$r][0]]))) { - $__textoEval.="\"". G::sqlEscape($result[$match[2][$r][0]],$DBEngine) ."\"";continue; - } + */ + function replaceDataField ($sqlString, $result, $DBEngine = 'mysql') + { + if (! is_array( $result )) { + $result = array (); + } + $result = $result + G::getSystemConstants(); + $__textoEval = ""; + $u = 0; + //$count=preg_match_all('/\@(?:([\@\%\#\!Qq])([a-zA-Z\_]\w*)|([a-zA-Z\_][\w\-\>\:]*)\(((?:[^\\\\\)]*(?:[\\\\][\w\W])?)*)\))/',$sqlString,$match,PREG_PATTERN_ORDER | PREG_OFFSET_CAPTURE); + $count = preg_match_all( '/\@(?:([\@\%\#\=\!Qq])([a-zA-Z\_]\w*)|([a-zA-Z\_][\w\-\>\:]*)\(((?:[^\\\\\)]*?)*)\))/', $sqlString, $match, PREG_PATTERN_ORDER | PREG_OFFSET_CAPTURE ); + if ($count) { + for ($r = 0; $r < $count; $r ++) { + if (! isset( $result[$match[2][$r][0]] )) + $result[$match[2][$r][0]] = ''; + if (! is_array( $result[$match[2][$r][0]] )) { + $__textoEval .= substr( $sqlString, $u, $match[0][$r][1] - $u ); + $u = $match[0][$r][1] + strlen( $match[0][$r][0] ); + //Mysql quotes scape + if (($match[1][$r][0] == '@') && (isset( $result[$match[2][$r][0]] ))) { + $__textoEval .= "\"" . G::sqlEscape( $result[$match[2][$r][0]], $DBEngine ) . "\""; + continue; + } //URL encode if (($match[1][$r][0]=='%')&&(isset($result[$match[2][$r][0]]))) { $__textoEval.=urlencode($result[$match[2][$r][0]]);continue; @@ -2112,849 +2137,862 @@ $output = $outputHeader.$output; $sContent = G::replaceDataField($sContent, $aFields); return $sContent; - } - - - /* Load strings from a XMLFile. + } + + /* Load strings from a XMLFile. * @author David Callizaya * @parameter $languageFile An xml language file. * @parameter $languageId (es|en|...). * @parameter $forceParse Force to read and parse the xml file. - */ - function loadLanguageFile ( $filename , $languageId = '', $forceParse = false ) - { - global $arrayXmlMessages; - if ($languageId==='') $languageId = defined('SYS_LANG') ? SYS_LANG : 'en'; - $languageFile = basename( $filename , '.xml' ); - $cacheFile = substr( $filename , 0 ,-3 ) . $languageId; - if (($forceParse) || (!file_exists($cacheFile)) || - ( filemtime($filename) > filemtime($cacheFile)) - //|| ( filemtime(__FILE__) > filemtime($cacheFile)) - ) { - $languageDocument = new Xml_document(); - $languageDocument->parseXmlFile( $filename ); - if (!is_array($arrayXmlMessages)) $arrayXmlMessages = array(); - $arrayXmlMessages[ $languageFile ] = array(); - for($r=0 ; $r < sizeof($languageDocument->children[0]->children) ; $r++ ) { - $n = $languageDocument->children[0]->children[$r]->findNode($languageId); - if ($n) { - $k = $languageDocument->children[0]->children[$r]->name; - $arrayXmlMessages[ $languageFile ][ $k ] = $n->value; - } - } - $f = fopen( $cacheFile , 'w'); - fwrite( $f , "" ); - fclose( $f ); - } else { - require( $cacheFile ); - } - } - /* Funcion auxiliar Temporal: + */ + function loadLanguageFile ($filename, $languageId = '', $forceParse = false) + { + global $arrayXmlMessages; + if ($languageId === '') + $languageId = defined( 'SYS_LANG' ) ? SYS_LANG : 'en'; + $languageFile = basename( $filename, '.xml' ); + $cacheFile = substr( $filename, 0, - 3 ) . $languageId; + if (($forceParse) || (! file_exists( $cacheFile )) || (filemtime( $filename ) > filemtime( $cacheFile ))) + //|| ( filemtime(__FILE__) > filemtime($cacheFile)) + { + $languageDocument = new Xml_document(); + $languageDocument->parseXmlFile( $filename ); + if (! is_array( $arrayXmlMessages )) + $arrayXmlMessages = array (); + $arrayXmlMessages[$languageFile] = array (); + for ($r = 0; $r < sizeof( $languageDocument->children[0]->children ); $r ++) { + $n = $languageDocument->children[0]->children[$r]->findNode( $languageId ); + if ($n) { + $k = $languageDocument->children[0]->children[$r]->name; + $arrayXmlMessages[$languageFile][$k] = $n->value; + } + } + $f = fopen( $cacheFile, 'w' ); + fwrite( $f, "" ); + fclose( $f ); + } else { + require ($cacheFile); + } + } + /* Funcion auxiliar Temporal: * Registra en la base de datos los labels xml usados en el sistema * @author David Callizaya - */ - function registerLabel( $id , $label ) - { - return 1; - $dbc = new DBConnection(); - $ses = new DBSession($dbc); - $ses->Execute(G::replaceDataField( - 'REPLACE INTO `TRANSLATION` (`TRN_CATEGORY`, `TRN_ID`, `TRN_LANG`, `TRN_VALUE`) VALUES - ("LABEL", @@ID, "'.SYS_LANG.'", @@LABEL);',array('ID'=>$id,'LABEL'=>($label !== null ? $label : '')))); - } - /** - * Function LoadMenuXml - * @author David S. Callizaya S. - * @access public - * @parameter string msgID - * @return string - */ - function LoadMenuXml( $msgID ) - { - global $arrayXmlMessages; - if (!isset($arrayXmlMessages['menus'])) - G::loadLanguageFile( G::ExpandPath('content') . 'languages/menus.xml' ); - G::registerLabel($msgID,$arrayXmlMessages['menus'][$msgID]); - return $arrayXmlMessages['menus'][$msgID]; - } - /** - * Function SendMessageXml - * @author David S. Callizaya S. - * @access public - * @parameter string msgID - * @parameter string strType - * @parameter string file - * @return string - */ - function SendMessageXml( $msgID, $strType , $file="labels") - { - global $arrayXmlMessages; - if (!isset($arrayXmlMessages[$file])) - G::loadLanguageFile( G::ExpandPath('content') . 'languages/' . $file . '.xml' ); - $_SESSION['G_MESSAGE_TYPE'] = $strType; - G::registerLabel($msgID,$arrayXmlMessages[$file][$msgID]); - $_SESSION['G_MESSAGE'] = nl2br ($arrayXmlMessages[$file][$msgID]); - } - - /** - * SendTemporalMessage - * - * @param string $msgID - * @param string $strType - * @param string $sType default value 'LABEL' - * @param date $time default value null - * @param integer $width default value null - * @param string $customLabels default value null - * - * @return void - */ - function SendTemporalMessage($msgID, $strType, $sType='LABEL', $time=null, $width=null, $customLabels= null) - { - if( isset($width) ){ - $_SESSION['G_MESSAGE_WIDTH'] = $width; - } - if( isset($time) ){ - $_SESSION['G_MESSAGE_TIME'] = $time; - } - switch(strtolower($sType)){ - case 'label': - case 'labels': - $_SESSION['G_MESSAGE_TYPE'] = $strType; - $_SESSION['G_MESSAGE'] = nl2br(G::LoadTranslation($msgID)); - break; - case 'string': - $_SESSION['G_MESSAGE_TYPE'] = $strType; - $_SESSION['G_MESSAGE'] = nl2br($msgID); - break; - } - if ( $customLabels != null ) { - $message = $_SESSION['G_MESSAGE']; - foreach ( $customLabels as $key=>$val ) { - $message = str_replace ( '{' . nl2br($key) . '}' , nl2br($val), $message ); - } - $_SESSION['G_MESSAGE'] = $message; - } - } - - /** - * SendMessage - * - * @param string $msgID - * @param string $strType - * @param string $file default value "labels" - * - * @return void - */ - function SendMessage( $msgID, $strType , $file="labels") - { - global $arrayXmlMessages; - $_SESSION['G_MESSAGE_TYPE'] = $strType; - $_SESSION['G_MESSAGE'] = nl2br (G::LoadTranslation($msgID)); - } - - /** - * SendMessageText - * Just put the $text in the message text - * - * @param string $text - * @param string $strType - * - * @return void - */ - function SendMessageText( $text, $strType) - { - global $arrayXmlMessages; - $_SESSION['G_MESSAGE_TYPE'] = $strType; - $_SESSION['G_MESSAGE'] = nl2br ( $text ); - } - - /** - * Render message from XML file - * - * @author Fernando Ontiveros Lira - * @access public - * @param string $msgID - * @return void - */ - function LoadMessage( $msgID, $file = "messages" ) - { - global $_SESSION; - global $arrayXmlMessages; - - if ( !is_array ($arrayXmlMessages) ) - $arrayXmlMessages = G::LoadArrayFile( G::ExpandPath( 'content' ) . $file . "." . SYS_LANG ); - - $aux = $arrayXmlMessages[$msgID]; - $msg = ""; - for ($i = 0; $i < strlen($aux); $i++) { - if ( $aux[$i] == "$") { - $token = ""; $i++; - while ($i < strlen ($aux) && $aux[$i]!=" " && $aux[$i]!="." && $aux[$i]!="'" && $aux[$i]!='"') - $token.= $aux[$i++]; - eval ( "\$msg.= \$_SESSION['".$token."'] ; "); - $msg .= $aux[$i]; - } - else - $msg = $msg . $aux[$i]; - } - return $msg; - } - /** - * Function LoadXmlLabel - * @author David S. Callizaya S. - * @access public - * @parameter string file - * @parameter string msgID - * @return string - */ - function LoadXmlLabel( $msgID , $file = 'labels' ) - { - return 'xxxxxx'; - global $arrayXmlMessages; - if (!isset($arrayXmlMessages[$file])) - G::loadLanguageFile( G::ExpandPath('content') . 'languages/' . $file . '.xml' ); - G::registerLabel($msgID,$arrayXmlMessages[$file][$msgID]); - return $arrayXmlMessages[$file][$msgID]; - } - /** - * Function LoadMessageXml - * @author David S. Callizaya S. - * @access public - * @parameter string msgID - * @parameter string file - * @return string - */ - function LoadMessageXml( $msgID , $file ='labels' ) - { - global $arrayXmlMessages; - if ( !isset($arrayXmlMessages[$file]) ) - G::loadLanguageFile( G::ExpandPath('content') . 'languages/' . $file . '.xml' ); - if ( isset($arrayXmlMessages[$file][$msgID]) ) { - G::registerLabel( $msgID, $arrayXmlMessages[$file][$msgID] ); - return $arrayXmlMessages[$file][$msgID]; - } - else { - G::registerLabel($msgID,''); - return NULL; - } - } - /** - * Function LoadTranslationObject - * It generates a global Translation variable that will be used in all the system. Per script - * @author Hugo Loza. - * @access public - * @parameter string lang - * @return void - */ - function LoadTranslationObject($lang = SYS_LANG){ - $defaultTranslations = Array(); - $foreignTranslations = Array(); - - //if the default translations table doesn't exist we can't proceed - if( ! is_file(PATH_LANGUAGECONT . 'translation.en') ) - return NULL; - - //load the translations table - require_once ( PATH_LANGUAGECONT . 'translation.en' ); - $defaultTranslations = $translation; - - //if some foreign language was requested and its translation file exists - if( $lang != 'en' && file_exists(PATH_LANGUAGECONT . 'translation.' . $lang) ){ - require_once ( PATH_LANGUAGECONT . 'translation.' . $lang ); //load the foreign translations table - $foreignTranslations = $translation; - } - - global $translation; - if( defined("SHOW_UNTRANSLATED_AS_TAG") && SHOW_UNTRANSLATED_AS_TAG != 0 ) - $translation = $foreignTranslations; - else - $translation = array_merge($defaultTranslations, $foreignTranslations); - - return true; - } - - /** - * Function LoadTranslation - * @author Aldo Mauricio Veliz Valenzuela. - * @access public - * @parameter string msgID - * @parameter string file - * @parameter array data // erik: associative array within data input to replace for formatted string i.e "any messsage {replaced_label} that contains a replace label" - * @return string - */ - function LoadTranslation($msgID, $lang = SYS_LANG, $data = null) - { - global $translation; - - // if the second parameter $lang is an array does mean it was especified to use as data - if (is_array($lang)) { - $data = $lang; - $lang = SYS_LANG; - } - - if ( isset ( $translation[$msgID] ) ){ - $translationString = preg_replace("[\n|\r|\n\r]", ' ', $translation[$msgID]); - - if( isset($data) && is_array($data) ) { - foreach($data as $label=>$value) { - $translationString = str_replace('{'.$label.'}', $value, $translationString); - } - } - - return $translationString; - } else { - if( defined("UNTRANSLATED_MARK") ) { - $untranslatedMark = strip_tags(UNTRANSLATED_MARK); - } else { - $untranslatedMark = "**"; - } - return $untranslatedMark . $msgID . $untranslatedMark; - } - - } - - /** - * Function getTranslations - * @author Erik Amaru O. - * @access public - * @parameter array msgIDs - * @parameter string file - * @return string - */ - function getTranslations($msgIDs , $lang = SYS_LANG) - { - if ( ! is_array($msgIDs) ) return null; - - $translations = Array(); - foreach( $msgIDs as $mID ) { - $translations[$mID] = self::LoadTranslation($mID , $lang); - } - - return $translations; - } - /** - * Load an array File Content - * - * @author Fernando Ontiveros Lira - * @access public - * @param string $strFile - * @return void - */ - function LoadArrayFile( $strFile = '' ) - { - $res = NULL; - if ( $strFile != '' ) - { - $src = file( $strFile ); - if( is_array( $src ) ) - { - foreach( $src as $key => $val ) - { - $res[$key] = trim( $val ); - } - } - } - unset( $src ); - return $res; - } - - /** - * Expand an uri based in the current URI - * - * @author Fernando Ontiveros Lira - * @access public - * @param string $methodPage the method directory and the page - * @return the expanded uri, later, will encryt the uri... - */ - function expandUri ( $methodPage ) { - $uri = explode ( '/', getenv ( 'REQUEST_URI' ) ); - $sw = 0; - $newUri = ''; - if ( !defined ( 'SYS_SKIN' ) ) { - for ( $i = 0; $i < count( $uri) ; $i++ ) { - if ( $sw == 0 ) $newUri .= $uri[ $i ] . PATH_SEP ; - if ( $uri[ $i ] == SYS_SKIN ) $sw = 1; - } - } - else { - for ( $i =0; $i < 4 ; $i++ ) { - if ( $sw == 0 ) $newUri .= $uri[ $i ] . PATH_SEP ; - if ( $uri[ $i ] == SYS_SKIN ) $sw = 1; - } - } - $newUri .= $methodPage; - return $newUri; - } - - /** - * Forces login for generic applications - * - * @author Fernando Ontiveros Lira - * @access public - * @param string $userid - * @param string $permission - * @param string $urlNoAccess - * @return void - */ - function genericForceLogin( $permission , $urlNoAccess, $urlLogin = 'login/login' ) { - global $RBAC; - - //the session is expired, go to login page, - //the login page is login/login.html - if ( ! isset ( $_SESSION ) ) { - header ( 'location: ' . G::expandUri ( $urlLogin ) ); - die (); - } - - //$permission is an array, we'll verify all permission to allow access. - if ( is_array($permission) ) - $aux = $permission; - else - $aux[0] = $permission; - - $sw = 0; - for ($i = 0; $i < count ($aux); $i++ ) { - $res = $RBAC->userCanAccess($aux[$i]); - if ($res == 1) $sw = 1; - } - - //you don't have access to this page - if ($sw == 0) { - header ( 'location: ' . G::expandUri ( $urlNoAccess ) ); - die; - } - } - - /** - * capitalize - * - * @param string $string - * - * @return string $string - */ - function capitalize($string) - { - return ucfirst($string); - } - - /** - * toUpper - * - * @param string $sText - * - * @return string strtoupper($sText) - */ - function toUpper($sText) - { - return strtoupper($sText); - } - - /** - * toLower - * - * @param string $sText - * @return string strtolower($sText) - */ - function toLower($sText) - { - return strtolower($sText); - } - - /** - * http_build_query - * - * @param string $formdata, - * @param string $numeric_prefix default value null, - * @param string $key default value null - * - * @return array $res - */ - function http_build_query( $formdata, $numeric_prefix = null, $key = null ) - { - $res = array(); - foreach ((array)$formdata as $k=>$v) { - $tmp_key = rawurlencode(is_int($k) ? $numeric_prefix.$k : $k); - if ($key) $tmp_key = $key.'['.$tmp_key.']'; - if ( is_array($v) || is_object($v) ) { - $res[] = G::http_build_query($v, null /* or $numeric_prefix if you want to add numeric_prefix to all indexes in array*/, $tmp_key); - } else { - $res[] = $tmp_key."=".rawurlencode($v); - } - /* + */ + function registerLabel ($id, $label) + { + return 1; + $dbc = new DBConnection(); + $ses = new DBSession( $dbc ); + $ses->Execute( G::replaceDataField( 'REPLACE INTO `TRANSLATION` (`TRN_CATEGORY`, `TRN_ID`, `TRN_LANG`, `TRN_VALUE`) VALUES + ("LABEL", @@ID, "' . SYS_LANG . '", @@LABEL);', array ('ID' => $id,'LABEL' => ($label !== null ? $label : '') + ) ) ); + } + + /** + * Function LoadMenuXml + * + * @author David S. Callizaya S. + * @access public + * @param eter string msgID + * @return string + */ + function LoadMenuXml ($msgID) + { + global $arrayXmlMessages; + if (! isset( $arrayXmlMessages['menus'] )) + G::loadLanguageFile( G::ExpandPath( 'content' ) . 'languages/menus.xml' ); + G::registerLabel( $msgID, $arrayXmlMessages['menus'][$msgID] ); + return $arrayXmlMessages['menus'][$msgID]; + } + + /** + * Function SendMessageXml + * + * @author David S. Callizaya S. + * @access public + * @param eter string msgID + * @param eter string strType + * @param eter string file + * @return string + */ + function SendMessageXml ($msgID, $strType, $file = "labels") + { + global $arrayXmlMessages; + if (! isset( $arrayXmlMessages[$file] )) + G::loadLanguageFile( G::ExpandPath( 'content' ) . 'languages/' . $file . '.xml' ); + $_SESSION['G_MESSAGE_TYPE'] = $strType; + G::registerLabel( $msgID, $arrayXmlMessages[$file][$msgID] ); + $_SESSION['G_MESSAGE'] = nl2br( $arrayXmlMessages[$file][$msgID] ); + } + + /** + * SendTemporalMessage + * + * @param string $msgID + * @param string $strType + * @param string $sType default value 'LABEL' + * @param date $time default value null + * @param integer $width default value null + * @param string $customLabels default value null + * + * @return void + */ + function SendTemporalMessage ($msgID, $strType, $sType = 'LABEL', $time = null, $width = null, $customLabels = null) + { + if (isset( $width )) { + $_SESSION['G_MESSAGE_WIDTH'] = $width; + } + if (isset( $time )) { + $_SESSION['G_MESSAGE_TIME'] = $time; + } + switch (strtolower( $sType )) { + case 'label': + case 'labels': + $_SESSION['G_MESSAGE_TYPE'] = $strType; + $_SESSION['G_MESSAGE'] = nl2br( G::LoadTranslation( $msgID ) ); + break; + case 'string': + $_SESSION['G_MESSAGE_TYPE'] = $strType; + $_SESSION['G_MESSAGE'] = nl2br( $msgID ); + break; + } + if ($customLabels != null) { + $message = $_SESSION['G_MESSAGE']; + foreach ($customLabels as $key => $val) { + $message = str_replace( '{' . nl2br( $key ) . '}', nl2br( $val ), $message ); + } + $_SESSION['G_MESSAGE'] = $message; + } + } + + /** + * SendMessage + * + * @param string $msgID + * @param string $strType + * @param string $file default value "labels" + * + * @return void + */ + function SendMessage ($msgID, $strType, $file = "labels") + { + global $arrayXmlMessages; + $_SESSION['G_MESSAGE_TYPE'] = $strType; + $_SESSION['G_MESSAGE'] = nl2br( G::LoadTranslation( $msgID ) ); + } + + /** + * SendMessageText + * Just put the $text in the message text + * + * @param string $text + * @param string $strType + * + * @return void + */ + function SendMessageText ($text, $strType) + { + global $arrayXmlMessages; + $_SESSION['G_MESSAGE_TYPE'] = $strType; + $_SESSION['G_MESSAGE'] = nl2br( $text ); + } + + /** + * Render message from XML file + * + * @author Fernando Ontiveros Lira + * @access public + * @param string $msgID + * @return void + */ + function LoadMessage ($msgID, $file = "messages") + { + global $_SESSION; + global $arrayXmlMessages; + + if (! is_array( $arrayXmlMessages )) + $arrayXmlMessages = G::LoadArrayFile( G::ExpandPath( 'content' ) . $file . "." . SYS_LANG ); + + $aux = $arrayXmlMessages[$msgID]; + $msg = ""; + for ($i = 0; $i < strlen( $aux ); $i ++) { + if ($aux[$i] == "$") { + $token = ""; + $i ++; + while ($i < strlen( $aux ) && $aux[$i] != " " && $aux[$i] != "." && $aux[$i] != "'" && $aux[$i] != '"') + $token .= $aux[$i ++]; + eval( "\$msg.= \$_SESSION['" . $token . "'] ; " ); + $msg .= $aux[$i]; + } else + $msg = $msg . $aux[$i]; + } + return $msg; + } + + /** + * Function LoadXmlLabel + * + * @author David S. Callizaya S. + * @access public + * @param eter string file + * @param eter string msgID + * @return string + */ + function LoadXmlLabel ($msgID, $file = 'labels') + { + return 'xxxxxx'; + global $arrayXmlMessages; + if (! isset( $arrayXmlMessages[$file] )) + G::loadLanguageFile( G::ExpandPath( 'content' ) . 'languages/' . $file . '.xml' ); + G::registerLabel( $msgID, $arrayXmlMessages[$file][$msgID] ); + return $arrayXmlMessages[$file][$msgID]; + } + + /** + * Function LoadMessageXml + * + * @author David S. Callizaya S. + * @access public + * @param eter string msgID + * @param eter string file + * @return string + */ + function LoadMessageXml ($msgID, $file = 'labels') + { + global $arrayXmlMessages; + if (! isset( $arrayXmlMessages[$file] )) + G::loadLanguageFile( G::ExpandPath( 'content' ) . 'languages/' . $file . '.xml' ); + if (isset( $arrayXmlMessages[$file][$msgID] )) { + G::registerLabel( $msgID, $arrayXmlMessages[$file][$msgID] ); + return $arrayXmlMessages[$file][$msgID]; + } else { + G::registerLabel( $msgID, '' ); + return NULL; + } + } + + /** + * Function LoadTranslationObject + * It generates a global Translation variable that will be used in all the system. + * Per script + * + * @author Hugo Loza. + * @access public + * @param eter string lang + * @return void + */ + function LoadTranslationObject ($lang = SYS_LANG) + { + $defaultTranslations = Array (); + $foreignTranslations = Array (); + + //if the default translations table doesn't exist we can't proceed + if (! is_file( PATH_LANGUAGECONT . 'translation.en' )) + return NULL; + + //load the translations table + require_once (PATH_LANGUAGECONT . 'translation.en'); + $defaultTranslations = $translation; + + //if some foreign language was requested and its translation file exists + if ($lang != 'en' && file_exists( PATH_LANGUAGECONT . 'translation.' . $lang )) { + require_once (PATH_LANGUAGECONT . 'translation.' . $lang); //load the foreign translations table + $foreignTranslations = $translation; + } + + global $translation; + if (defined( "SHOW_UNTRANSLATED_AS_TAG" ) && SHOW_UNTRANSLATED_AS_TAG != 0) + $translation = $foreignTranslations; + else + $translation = array_merge( $defaultTranslations, $foreignTranslations ); + + return true; + } + + /** + * Function LoadTranslation + * + * @author Aldo Mauricio Veliz Valenzuela. + * @access public + * @param eter string msgID + * @param eter string file + * @param eter array data // erik: associative array within data input to replace for formatted string i.e "any messsage {replaced_label} that contains a replace label" + * @return string + */ + function LoadTranslation ($msgID, $lang = SYS_LANG, $data = null) + { + global $translation; + + // if the second parameter $lang is an array does mean it was especified to use as data + if (is_array( $lang )) { + $data = $lang; + $lang = SYS_LANG; + } + + if (isset( $translation[$msgID] )) { + $translationString = preg_replace( "[\n|\r|\n\r]", ' ', $translation[$msgID] ); + + if (isset( $data ) && is_array( $data )) { + foreach ($data as $label => $value) { + $translationString = str_replace( '{' . $label . '}', $value, $translationString ); + } + } + + return $translationString; + } else { + if (defined( "UNTRANSLATED_MARK" )) { + $untranslatedMark = strip_tags( UNTRANSLATED_MARK ); + } else { + $untranslatedMark = "**"; + } + return $untranslatedMark . $msgID . $untranslatedMark; + } + + } + + /** + * Function getTranslations + * + * @author Erik Amaru O. + * @access public + * @param eter array msgIDs + * @param eter string file + * @return string + */ + function getTranslations ($msgIDs, $lang = SYS_LANG) + { + if (! is_array( $msgIDs )) + return null; + + $translations = Array (); + foreach ($msgIDs as $mID) { + $translations[$mID] = self::LoadTranslation( $mID, $lang ); + } + + return $translations; + } + + /** + * Load an array File Content + * + * @author Fernando Ontiveros Lira + * @access public + * @param string $strFile + * @return void + */ + function LoadArrayFile ($strFile = '') + { + $res = NULL; + if ($strFile != '') { + $src = file( $strFile ); + if (is_array( $src )) { + foreach ($src as $key => $val) { + $res[$key] = trim( $val ); + } + } + } + unset( $src ); + return $res; + } + + /** + * Expand an uri based in the current URI + * + * @author Fernando Ontiveros Lira + * @access public + * @param string $methodPage the method directory and the page + * @return the expanded uri, later, will encryt the uri... + */ + function expandUri ($methodPage) + { + $uri = explode( '/', getenv( 'REQUEST_URI' ) ); + $sw = 0; + $newUri = ''; + if (! defined( 'SYS_SKIN' )) { + for ($i = 0; $i < count( $uri ); $i ++) { + if ($sw == 0) + $newUri .= $uri[$i] . PATH_SEP; + if ($uri[$i] == SYS_SKIN) + $sw = 1; + } + } else { + for ($i = 0; $i < 4; $i ++) { + if ($sw == 0) + $newUri .= $uri[$i] . PATH_SEP; + if ($uri[$i] == SYS_SKIN) + $sw = 1; + } + } + $newUri .= $methodPage; + return $newUri; + } + + /** + * Forces login for generic applications + * + * @author Fernando Ontiveros Lira + * @access public + * @param string $userid + * @param string $permission + * @param string $urlNoAccess + * @return void + */ + function genericForceLogin ($permission, $urlNoAccess, $urlLogin = 'login/login') + { + global $RBAC; + + //the session is expired, go to login page, + //the login page is login/login.html + if (! isset( $_SESSION )) { + header( 'location: ' . G::expandUri( $urlLogin ) ); + die(); + } + + //$permission is an array, we'll verify all permission to allow access. + if (is_array( $permission )) + $aux = $permission; + else + $aux[0] = $permission; + + $sw = 0; + for ($i = 0; $i < count( $aux ); $i ++) { + $res = $RBAC->userCanAccess( $aux[$i] ); + if ($res == 1) + $sw = 1; + } + + //you don't have access to this page + if ($sw == 0) { + header( 'location: ' . G::expandUri( $urlNoAccess ) ); + die(); + } + } + + /** + * capitalize + * + * @param string $string + * + * @return string $string + */ + function capitalize ($string) + { + return ucfirst( $string ); + } + + /** + * toUpper + * + * @param string $sText + * + * @return string strtoupper($sText) + */ + function toUpper ($sText) + { + return strtoupper( $sText ); + } + + /** + * toLower + * + * @param string $sText + * @return string strtolower($sText) + */ + function toLower ($sText) + { + return strtolower( $sText ); + } + + /** + * http_build_query + * + * @param string $formdata, + * @param string $numeric_prefix default value null, + * @param string $key default value null + * + * @return array $res + */ + function http_build_query ($formdata, $numeric_prefix = null, $key = null) + { + $res = array (); + foreach ((array) $formdata as $k => $v) { + $tmp_key = rawurlencode( is_int( $k ) ? $numeric_prefix . $k : $k ); + if ($key) + $tmp_key = $key . '[' . $tmp_key . ']'; + if (is_array( $v ) || is_object( $v )) { + $res[] = G::http_build_query( $v, null /* or $numeric_prefix if you want to add numeric_prefix to all indexes in array*/, $tmp_key ); + } else { + $res[] = $tmp_key . "=" . rawurlencode( $v ); + } + /* If you want, you can write this as one string: $res[] = ( ( is_array($v) || is_object($v) ) ? G::http_build_query($v, null, $tmp_key) : $tmp_key."=".urlencode($v) ); - */ + */ + } + $separator = ini_get( 'arg_separator.output' ); + return implode( $separator, $res ); + } + + /** + * Redirect URL + * + * @author Fernando Ontiveros Lira + * @access public + * @param string $parameter + * @return string + */ + function header ($parameter) + { + if (defined( 'ENABLE_ENCRYPT' ) && (ENABLE_ENCRYPT == 'yes') && (substr( $parameter, 0, 9 ) == 'location:')) { + $url = G::encryptUrl( substr( $parameter, 10 ), URL_KEY ); + header( 'location:' . $url ); + } else + header( $parameter ); + return; + } + + /** + * + * @author Fernando Ontiveros Lira + * @access public + * @param string $permission + * @param string $urlNoAccess + * @return void + */ + function forceLogin ($permission = "", $urlNoAccess = "") + { + global $RBAC; + + if (isset( $_SESSION['USER_LOGGED'] ) && $_SESSION['USER_LOGGED'] == '') { + $sys = (ENABLE_ENCRYPT == 'yes' ? SYS_SYS : "sys" . SYS_SYS); + $lang = (ENABLE_ENCRYPT == 'yes' ? G::encrypt( urldecode( SYS_LANG ), URL_KEY ) : SYS_LANG); + $skin = (ENABLE_ENCRYPT == 'yes' ? G::encrypt( urldecode( SYS_SKIN ), URL_KEY ) : SYS_SKIN); + $login = (ENABLE_ENCRYPT == 'yes' ? G::encrypt( urldecode( 'login' ), URL_KEY ) : 'login'); + $loginhtml = (ENABLE_ENCRYPT == 'yes' ? G::encrypt( urldecode( 'login.html' ), URL_KEY ) : 'login.html'); + $direction = "/$sys/$lang/$skin/$login/$loginhtml"; + die(); + header( "location: $direction" ); + die(); + return; + } + + $Connection = new DBConnection(); + $ses = new DBSession( $Connection ); + $stQry = "SELECT LOG_STATUS FROM LOGIN WHERE LOG_SID = '" . session_id() . "'"; + $dset = $ses->Execute( $stQry ); + $row = $dset->read(); + $sessionPc = defined( 'SESSION_PC' ) ? SESSION_PC : ''; + $sessionBrowser = defined( 'SESSION_BROWSER' ) ? SESSION_BROWSER : ''; + if (($sessionPc == "1") or ($sessionBrowser == "1")) + if ($row['LOG_STATUS'] == 'X') { + $sys = (ENABLE_ENCRYPT == 'yes' ? SYS_SYS : "sys" . SYS_SYS); + $lang = (ENABLE_ENCRYPT == 'yes' ? G::encrypt( urldecode( SYS_LANG ), URL_KEY ) : SYS_LANG); + $skin = (ENABLE_ENCRYPT == 'yes' ? G::encrypt( urldecode( SYS_SKIN ), URL_KEY ) : SYS_SKIN); + $login = (ENABLE_ENCRYPT == 'yes' ? G::encrypt( urldecode( 'login' ), URL_KEY ) : 'login'); + $loginhtml = (ENABLE_ENCRYPT == 'yes' ? G::encrypt( urldecode( 'login.html' ), URL_KEY ) : 'login.html'); + $direction = "/$sys/$lang/$skin/$login/$loginhtml"; + G::SendMessageXml( 'ID_CLOSE_SESSION', "warning" ); + header( "location: $direction" ); + die(); + return; + } + + if (defined( 'SIN_COMPATIBILIDAD_RBAC' ) and SIN_COMPATIBILIDAD_RBAC == 1) + return; + + if ($permission == "") { + return; + } + + if (is_array( $permission )) + $aux = $permission; + else + $aux[0] = $permission; + + $sw = 0; + for ($i = 0; $i < count( $aux ); $i ++) { + $res = $RBAC->userCanAccess( $aux[$i] ); + if ($res == 1) + $sw = 1; + //print " $aux[$i] $res $sw
"; + } + + if ($sw == 0 && $urlNoAccess != "") { + $aux = explode( '/', $urlNoAccess ); + $sys = (ENABLE_ENCRYPT == 'yes' ? SYS_SYS : "/sys" . SYS_LANG); + $lang = (ENABLE_ENCRYPT == 'yes' ? G::encrypt( urldecode( SYS_LANG ), URL_KEY ) : SYS_LANG); + $skin = (ENABLE_ENCRYPT == 'yes' ? G::encrypt( urldecode( SYS_SKIN ), URL_KEY ) : SYS_SKIN); + $login = (ENABLE_ENCRYPT == 'yes' ? G::encrypt( urldecode( $aux[0] ), URL_KEY ) : $aux[0]); + $loginhtml = (ENABLE_ENCRYPT == 'yes' ? G::encrypt( urldecode( $aux[1] ), URL_KEY ) : $aux[1]); + //header ("location: /$sys/$lang/$skin/$login/$loginhtml"); + header( "location: /fluid/mNE/o9A/mNGm1aLiop3V4qU/dtij4J°gmaLPwKDU3qNn2qXanw" ); + die(); + } + + if ($sw == 0) { + header( "location: /fluid/mNE/o9A/mNGm1aLiop3V4qU/dtij4J°gmaLPwKDU3qNn2qXanw" ); + //header ( "location: /sys/" . SYS_LANG . "/" . SYS_SKIN . "/login/noViewPage.html" ); + die(); + } + } + + /** + * Add slashes to a string + * + * @author Fernando Ontiveros Lira + * @access public + * @param string $val_old + * @return string + */ + function add_slashes ($val_old) + { + + if (! is_string( $val_old )) + $val_old = "$val_old"; + + $tamano_cadena = strlen( $val_old ); + $contador_cadena = 0; + $new_val = ""; + + for ($contador_cadena = 0; $contador_cadena < $tamano_cadena; $contador_cadena ++) { + $car = $val_old[$contador_cadena]; + + if ($car != chr( 34 ) && $car != chr( 39 ) && $car != chr( 92 )) { + $new_val .= $car; + } else { + if ($car2 != chr( 92 )) { + //print " xmlvar: $new_val -- $car -- $car2
"; + $new_val .= chr( 92 ) . $car; + } else + $new_val .= $car; + } + } + return $new_val; + } + + /** + * Upload a file and then copy to path+ nameToSave + * + * @author Mauricio Veliz + * @access public + * @param string $file + * @param string $path + * @param string $nameToSave + * @param integer $permission + * @return void + */ + function uploadFile ($file, $path, $nameToSave, $permission = 0666) + { + try { + if ($file == '') { + throw new Exception( 'The filename is empty!' ); + } + if (filesize( $file ) > ((((ini_get( 'upload_max_filesize' ) + 0)) * 1024) * 1024)) { + throw new Exception( 'The size of upload file exceeds the allowed by the server!' ); + } + $oldumask = umask( 0 ); + if (! is_dir( $path )) { + G::verifyPath( $path, true ); + } + move_uploaded_file( $file, $path . "/" . $nameToSave ); + chmod( $path . "/" . $nameToSave, $permission ); + umask( $oldumask ); + } catch (Exception $oException) { + throw $oException; + } + } + + /** + * resizeImage + * + * @param string $path, + * @param string $resWidth + * @param string $resHeight + * @param string $saveTo default value null + * + * @return void + */ + function resizeImage ($path, $resWidth, $resHeight, $saveTo = null) + { + $imageInfo = @getimagesize( $path ); + + if (! $imageInfo) + throw new Exception( "Could not get image information" ); + + list ($width, $height) = $imageInfo; + $percentHeight = $resHeight / $height; + $percentWidth = $resWidth / $width; + $percent = ($percentWidth < $percentHeight) ? $percentWidth : $percentHeight; + $resWidth = $width * $percent; + $resHeight = $height * $percent; + + // Resample + $image_p = imagecreatetruecolor( $resWidth, $resHeight ); + imagealphablending( $image_p, false ); + imagesavealpha( $image_p, true ); + + $background = imagecolorallocate( $image_p, 0, 0, 0 ); + ImageColorTransparent( $image_p, $background ); // make the new temp image all transparent + + + //Assume 3 channels if we can't find that information + if (! array_key_exists( "channels", $imageInfo )) + $imageInfo["channels"] = 3; + $memoryNeeded = Round( ($imageInfo[0] * $imageInfo[1] * $imageInfo['bits'] * $imageInfo['channels'] + Pow( 2, 16 )) * 1.95 ) / (1024 * 1024); + if ($memoryNeeded < 80) + $memoryNeeded = 80; + ini_set( 'memory_limit', intval( $memoryNeeded ) . 'M' ); + + $functions = array (IMAGETYPE_GIF => array ('imagecreatefromgif','imagegif' + ),IMAGETYPE_JPEG => array ('imagecreatefromjpeg','imagejpeg'),IMAGETYPE_PNG => array ('imagecreatefrompng','imagepng')); + + if (! array_key_exists( $imageInfo[2], $functions )) + throw new Exception( "Image format not supported" ); + + list ($inputFn, $outputFn) = $functions[$imageInfo[2]]; + + $image = $inputFn( $path ); + imagecopyresampled( $image_p, $image, 0, 0, 0, 0, $resWidth, $resHeight, $width, $height ); + $outputFn( $image_p, $saveTo ); + + chmod( $saveTo, 0666 ); + } + + /** + * Merge 2 arrays + * + * @author Fernando Ontiveros Lira + * @access public + * @return array + */ + function array_merges () + { + $array = array (); + $arrays = & func_get_args(); + foreach ($arrays as $array_i) { + if (is_array( $array_i )) { + G::array_merge_2( $array, $array_i ); + } + } + return $array; + } + + /** + * Merge 2 arrays + * + * @author Fernando Ontiveros Lira + * @access public + * @param string $array + * @param string $array_i + * @return array + */ + function array_merge_2 (&$array, &$array_i) + { + foreach ($array_i as $k => $v) { + if (is_array( $v )) { + if (! isset( $array[$k] )) { + $array[$k] = array (); + } + G::array_merge_2( $array[$k], $v ); + } else { + if (isset( $array[$k] ) && is_array( $array[$k] )) { + $array[$k][0] = $v; + } else { + if (isset( $array ) && ! is_array( $array )) { + $temp = $array; + $array = array (); + $array[0] = $temp; + } + $array[$k] = $v; + } + } + } + } + + /** + * Generate random number + * + * @author Fernando Ontiveros Lira + * @access public + * @return int + */ + function generateUniqueID () + { + do { + $sUID = str_replace( '.', '0', uniqid( rand( 0, 999999999 ), true ) ); + } while (strlen( $sUID ) != 32); + return $sUID; + //return strtoupper(substr(uniqid(rand(0, 9), false),0,14)); + } + + /** + * Generate a numeric or alphanumeric code + * + * @author Julio Cesar Laura Avendaíž¼juliocesar@colosa.com> + * @access public + * @return string + */ + function generateCode ($iDigits = 4, $sType = 'NUMERIC') + { + if (($iDigits < 4) || ($iDigits > 50)) { + $iDigits = 4; + } + if (($sType != 'NUMERIC') && ($sType != 'ALPHA') && ($sType != 'ALPHANUMERIC')) { + $sType = 'NUMERIC'; + } + $aValidCharacters = array ('0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z' + ); + switch ($sType) { + case 'NUMERIC': + $iMin = 0; + $iMax = 9; + break; + case 'ALPHA': + $iMin = 10; + $iMax = 35; + break; + case 'ALPHANUMERIC': + $iMin = 0; + $iMax = 35; + break; + } + $sCode = ''; + for ($i = 0; $i < $iDigits; $i ++) { + $sCode .= $aValidCharacters[rand( $iMin, $iMax )]; + } + return $sCode; + } + + /** + * Verify if the input string is a valid UID + * + * @author David Callizaya + * @access public + * @return int + */ + function verifyUniqueID ($uid) + { + return (bool) preg_match( '/^[0-9A-Za-z]{14,}/', $uid ); + } + + /** + * is_utf8 + * + * @param string $string + * + * @return string utf8_encode() + */ + function is_utf8 ($string) + { + if (is_array( $string )) { + $enc = implode( '', $string ); + return @! ((ord( $enc[0] ) != 239) && (ord( $enc[1] ) != 187) && (ord( $enc[2] ) != 191)); + } else { + return (utf8_encode( utf8_decode( $string ) ) == $string); + } } - $separator = ini_get('arg_separator.output'); - return implode($separator, $res); - } - /** - * Redirect URL - * - * @author Fernando Ontiveros Lira - * @access public - * @param string $parameter - * @return string - */ - function header( $parameter ) { - if ( defined ('ENABLE_ENCRYPT' ) && (ENABLE_ENCRYPT == 'yes') && (substr ( $parameter, 0, 9) == 'location:')) { - $url = G::encryptUrl ( substr( $parameter, 10) , URL_KEY ); - header ( 'location:' . $url ); - } - else - header ( $parameter ); - return ; - } - - /** - * - * @author Fernando Ontiveros Lira - * @access public - * @param string $permission - * @param string $urlNoAccess - * @return void - */ - function forceLogin( $permission = "", $urlNoAccess = "" ) { - global $RBAC; - - if ( isset( $_SESSION['USER_LOGGED'] ) && $_SESSION['USER_LOGGED'] == '' ) { - $sys = (ENABLE_ENCRYPT=='yes'?SYS_SYS :"sys".SYS_SYS); - $lang = (ENABLE_ENCRYPT=='yes'?G::encrypt ( urldecode(SYS_LANG) , URL_KEY ):SYS_LANG); - $skin = (ENABLE_ENCRYPT=='yes'?G::encrypt ( urldecode(SYS_SKIN) , URL_KEY ):SYS_SKIN); - $login = (ENABLE_ENCRYPT=='yes'?G::encrypt ( urldecode('login') , URL_KEY ):'login'); - $loginhtml = (ENABLE_ENCRYPT=='yes'?G::encrypt ( urldecode('login.html') , URL_KEY ):'login.html'); - $direction = "/$sys/$lang/$skin/$login/$loginhtml"; - die; - header ("location: $direction"); - die; - return; - } - - $Connection = new DBConnection; - $ses = new DBSession($Connection); - $stQry = "SELECT LOG_STATUS FROM LOGIN WHERE LOG_SID = '" . session_id() . "'"; - $dset = $ses->Execute ( $stQry ); - $row = $dset->read(); - $sessionPc = defined ( 'SESSION_PC' ) ? SESSION_PC : '' ; - $sessionBrowser = defined ( 'SESSION_BROWSER' ) ? SESSION_BROWSER : '' ; - if (($sessionPc == "1" ) or ( $sessionBrowser == "1")) - if($row['LOG_STATUS'] == 'X'){ - $sys = (ENABLE_ENCRYPT=='yes'?SYS_SYS :"sys".SYS_SYS); - $lang = (ENABLE_ENCRYPT=='yes'?G::encrypt ( urldecode(SYS_LANG) , URL_KEY ):SYS_LANG); - $skin = (ENABLE_ENCRYPT=='yes'?G::encrypt ( urldecode(SYS_SKIN) , URL_KEY ):SYS_SKIN); - $login = (ENABLE_ENCRYPT=='yes'?G::encrypt ( urldecode('login') , URL_KEY ):'login'); - $loginhtml = (ENABLE_ENCRYPT=='yes'?G::encrypt ( urldecode('login.html') , URL_KEY ):'login.html'); - $direction = "/$sys/$lang/$skin/$login/$loginhtml"; - G::SendMessageXml ('ID_CLOSE_SESSION', "warning"); - header ("location: $direction"); - die; - return; - } - - if ( defined( 'SIN_COMPATIBILIDAD_RBAC') and SIN_COMPATIBILIDAD_RBAC == 1 ) - return; - - if ( $permission == "" ) { - return; - } - - if ( is_array($permission) ) - $aux = $permission; - else - $aux[0] = $permission; - - - $sw = 0; - for ($i = 0; $i < count ($aux); $i++ ) { - $res = $RBAC->userCanAccess($aux[$i]); - if ($res == 1) $sw = 1; - //print " $aux[$i] $res $sw
"; - } - - if ($sw == 0 && $urlNoAccess != "") { - $aux = explode ( '/', $urlNoAccess ); - $sys = (ENABLE_ENCRYPT=='yes'?SYS_SYS :"/sys".SYS_LANG); - $lang = (ENABLE_ENCRYPT=='yes'?G::encrypt ( urldecode(SYS_LANG) , URL_KEY ):SYS_LANG); - $skin = (ENABLE_ENCRYPT=='yes'?G::encrypt ( urldecode(SYS_SKIN) , URL_KEY ):SYS_SKIN); - $login = (ENABLE_ENCRYPT=='yes'?G::encrypt ( urldecode($aux[0]) , URL_KEY ):$aux[0]); - $loginhtml = (ENABLE_ENCRYPT=='yes'?G::encrypt ( urldecode($aux[1]) , URL_KEY ):$aux[1]); - //header ("location: /$sys/$lang/$skin/$login/$loginhtml"); - header ("location: /fluid/mNE/o9A/mNGm1aLiop3V4qU/dtij4J°gmaLPwKDU3qNn2qXanw"); - die; - } - - - if ($sw == 0) { - header ("location: /fluid/mNE/o9A/mNGm1aLiop3V4qU/dtij4J°gmaLPwKDU3qNn2qXanw"); - //header ( "location: /sys/" . SYS_LANG . "/" . SYS_SKIN . "/login/noViewPage.html" ); - die; - } - } - /** - * Add slashes to a string - * - * @author Fernando Ontiveros Lira - * @access public - * @param string $val_old - * @return string - */ - function add_slashes($val_old) { - - if (!is_string ($val_old)) $val_old ="$val_old"; - - $tamano_cadena = strlen ($val_old); - $contador_cadena = 0; - $new_val = ""; - - for ($contador_cadena=0; $contador_cadena< $tamano_cadena; $contador_cadena ++) - { - $car = $val_old[$contador_cadena]; - - if ( $car != chr(34) && $car != chr(39) && $car != chr(92)) - { - $new_val .= $car; - } - else - { - if ($car2 != chr (92) ) - { - //print " xmlvar: $new_val -- $car -- $car2
"; - $new_val .= chr(92) . $car; - } - else - $new_val .= $car; - } - } - return $new_val; - } - /** - * Upload a file and then copy to path+ nameToSave - * - * @author Mauricio Veliz - * @access public - * @param string $file - * @param string $path - * @param string $nameToSave - * @param integer $permission - * @return void - */ - function uploadFile($file, $path ,$nameToSave, $permission = 0666) - { - try { - if ($file == '') { - throw new Exception('The filename is empty!'); - } - if (filesize($file) > ((((ini_get('upload_max_filesize') + 0)) * 1024) * 1024)) { - throw new Exception('The size of upload file exceeds the allowed by the server!'); - } - $oldumask = umask(0); - if (!is_dir($path)) { - G::verifyPath($path, true); - } - move_uploaded_file($file , $path . "/" . $nameToSave); - chmod($path . "/" . $nameToSave , $permission); - umask($oldumask); - } - catch (Exception $oException) { - throw $oException; - } - } - - /** - * resizeImage - * - * @param string $path, - * @param string $resWidth - * @param string $resHeight - * @param string $saveTo default value null - * - * @return void - */ - function resizeImage($path, $resWidth, $resHeight, $saveTo=null) - { - $imageInfo = @getimagesize($path); - - if (!$imageInfo) - throw new Exception("Could not get image information"); - - list($width, $height) = $imageInfo; - $percentHeight = $resHeight / $height; - $percentWidth = $resWidth / $width; - $percent = ($percentWidth < $percentHeight) ? $percentWidth : $percentHeight; - $resWidth = $width * $percent; - $resHeight = $height * $percent; - - // Resample - $image_p = imagecreatetruecolor($resWidth, $resHeight); - imagealphablending($image_p, false); - imagesavealpha($image_p, true); - - $background = imagecolorallocate($image_p, 0, 0, 0); - ImageColorTransparent($image_p, $background); // make the new temp image all transparent - - //Assume 3 channels if we can't find that information - if (!array_key_exists("channels", $imageInfo)) - $imageInfo["channels"] = 3; - $memoryNeeded = Round( ($imageInfo[0] * $imageInfo[1] * $imageInfo['bits'] * $imageInfo['channels'] + Pow(2, 16)) * 1.95) / (1024*1024); - if ( $memoryNeeded < 80 ) $memoryNeeded = 80; - ini_set('memory_limit', intval($memoryNeeded) . 'M'); - - $functions = array( - IMAGETYPE_GIF => array('imagecreatefromgif', 'imagegif'), - IMAGETYPE_JPEG => array('imagecreatefromjpeg', 'imagejpeg'), - IMAGETYPE_PNG => array('imagecreatefrompng', 'imagepng'), - ); - - if (!array_key_exists($imageInfo[2], $functions)) - throw new Exception("Image format not supported"); - - list($inputFn, $outputFn) = $functions[$imageInfo[2]]; - - $image = $inputFn($path); - imagecopyresampled($image_p, $image, 0, 0, 0, 0, $resWidth, $resHeight, $width, $height); - $outputFn($image_p, $saveTo); - - chmod($saveTo, 0666); - } - - /** - * Merge 2 arrays - * - * @author Fernando Ontiveros Lira - * @access public - * @return array - */ - function array_merges() { - $array = array(); - $arrays =& func_get_args(); - foreach ($arrays as $array_i) { - if (is_array($array_i)) { - G::array_merge_2($array, $array_i); - } - } - return $array; - } - - /** - * Merge 2 arrays - * - * @author Fernando Ontiveros Lira - * @access public - * @param string $array - * @param string $array_i - * @return array - */ - function array_merge_2(&$array, &$array_i) { - foreach ($array_i as $k => $v) { - if (is_array($v)) { - if (!isset($array[$k])) { - $array[$k] = array(); - } - G::array_merge_2($array[$k], $v); - } else { - if (isset($array[$k]) && is_array($array[$k])) { - $array[$k][0] = $v; - } else { - if (isset($array) && !is_array($array)) { - $temp = $array; - $array = array(); - $array[0] = $temp; - } - $array[$k] = $v; - } - } - } - } - - /** - * Generate random number - * - * @author Fernando Ontiveros Lira - * @access public - * @return int - */ - function generateUniqueID() { - do { - $sUID = str_replace('.', '0', uniqid(rand(0, 999999999), true)); - } while (strlen($sUID) != 32); - return $sUID; - //return strtoupper(substr(uniqid(rand(0, 9), false),0,14)); - } - - - /** - * Generate a numeric or alphanumeric code - * - * @author Julio Cesar Laura Avendaힼjuliocesar@colosa.com> - * @access public - * @return string - */ - function generateCode($iDigits = 4, $sType = 'NUMERIC') { - if (($iDigits < 4) || ($iDigits > 50)) { - $iDigits = 4; - } - if (($sType != 'NUMERIC') && ($sType != 'ALPHA') && ($sType != 'ALPHANUMERIC')) { - $sType = 'NUMERIC'; - } - $aValidCharacters = array('0', '1', '2', '3', '4', '5', '6', '7', '8', '9', - 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', - 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', - 'U', 'V', 'W', 'X', 'Y', 'Z'); - switch ($sType) { - case 'NUMERIC': - $iMin = 0; - $iMax = 9; - break; - case 'ALPHA': - $iMin = 10; - $iMax = 35; - break; - case 'ALPHANUMERIC': - $iMin = 0; - $iMax = 35; - break; - } - $sCode = ''; - for ($i = 0; $i < $iDigits; $i++) { - $sCode .= $aValidCharacters[rand($iMin, $iMax)]; - } - return $sCode; - } - - /** - * Verify if the input string is a valid UID - * - * @author David Callizaya - * @access public - * @return int - */ - function verifyUniqueID( $uid ) { - return (bool) preg_match('/^[0-9A-Za-z]{14,}/',$uid); - } - - /** - * is_utf8 - * - * @param string $string - * - * @return string utf8_encode() - */ - function is_utf8($string) - { - if (is_array($string)) - { - $enc = implode('', $string); - return @!((ord($enc[0]) != 239) && (ord($enc[1]) != 187) && (ord($enc[2]) != 191)); - } - else - { - return (utf8_encode(utf8_decode($string)) == $string); - } - } /** @@ -3041,335 +3079,345 @@ $output = $outputHeader.$output; function capitalizeWords( $text ) { return ucwords($text); - } - - /** - * unhtmlentities - * - * @param string $string - * - * @return string substring - */ - function unhtmlentities ($string) - { - $trans_tbl = get_html_translation_table (HTML_ENTITIES); - foreach($trans_tbl as $k => $v) - { - $ttr[$v] = utf8_encode($k); - } - return strtr ($string, $ttr); - } - - /*************************************** init ********************************************** + } + + /** + * unhtmlentities + * + * @param string $string + * + * @return string substring + */ + function unhtmlentities ($string) + { + $trans_tbl = get_html_translation_table( HTML_ENTITIES ); + foreach ($trans_tbl as $k => $v) { + $ttr[$v] = utf8_encode( $k ); + } + return strtr( $string, $ttr ); + } + + /** + * ************************************* init ********************************************** + * Xml parse collection functions + * Returns a associative array within the xml structure and data + * + * @author Erik Amaru Ortiz + */ + function xmlParser (&$string) + { + $parser = xml_parser_create(); + xml_parser_set_option( $parser, XML_OPTION_CASE_FOLDING, 0 ); + xml_parse_into_struct( $parser, $string, $vals, $index ); + + $mnary = array (); + $ary = &$mnary; + foreach ($vals as $r) { + $t = $r['tag']; + if ($r['type'] == 'open') { + if (isset( $ary[$t] )) { + if (isset( $ary[$t][0] )) + $ary[$t][] = array (); + else + $ary[$t] = array ($ary[$t],array () + ); + $cv = &$ary[$t][count( $ary[$t] ) - 1]; + } else + $cv = &$ary[$t]; + if (isset( $r['attributes'] )) { + foreach ($r['attributes'] as $k => $v) + $cv['__ATTRIBUTES__'][$k] = $v; + } + // note by gustavo cruz gustavo[at]colosa[dot]com + // minor adjustments to validate if an open node have a value attribute. + // for example a dropdown has many childs, but also can have a value attribute. + if (isset( $r['value'] ) && trim( $r['value'] ) != '') { + $cv['__VALUE__'] = $r['value']; + } + // end added code + $cv['__CONTENT__'] = array (); + $cv['__CONTENT__']['_p'] = &$ary; + $ary = &$cv['__CONTENT__']; + + } elseif ($r['type'] == 'complete') { + if (isset( $ary[$t] )) { // same as open + if (isset( $ary[$t][0] )) + $ary[$t][] = array (); + else + $ary[$t] = array ($ary[$t],array () + ); + $cv = &$ary[$t][count( $ary[$t] ) - 1]; + } else + $cv = &$ary[$t]; + if (isset( $r['attributes'] )) { + foreach ($r['attributes'] as $k => $v) + $cv['__ATTRIBUTES__'][$k] = $v; + } + $cv['__VALUE__'] = (isset( $r['value'] ) ? $r['value'] : ''); + + } elseif ($r['type'] == 'close') { + $ary = &$ary['_p']; + } + } + + self::_del_p( $mnary ); + + $obj_resp->code = xml_get_error_code( $parser ); + $obj_resp->message = xml_error_string( $obj_resp->code ); + $obj_resp->result = $mnary; + xml_parser_free( $parser ); + + return $obj_resp; + } + + /** + * _del_p + * + * @param string &$ary + * + * @return void + */ + // _Internal: Remove recursion in result array + function _del_p (&$ary) + { + foreach ($ary as $k => $v) { + if ($k === '_p') + unset( $ary[$k] ); + elseif (is_array( $ary[$k] )) + self::_del_p( $ary[$k] ); + } + } + + /** + * ary2xml + * + * Array to XML + * + * @param string $cary + * @param string $d=0 + * @param string $forcetag default value '' + * + * @return void + */ + // Array to XML + function ary2xml ($cary, $d = 0, $forcetag = '') + { + $res = array (); + foreach ($cary as $tag => $r) { + if (isset( $r[0] )) { + $res[] = self::ary2xml( $r, $d, $tag ); + } else { + if ($forcetag) + $tag = $forcetag; + $sp = str_repeat( "\t", $d ); + $res[] = "$sp<$tag"; + if (isset( $r['_a'] )) { + foreach ($r['_a'] as $at => $av) + $res[] = " $at=\"$av\""; + } + $res[] = ">" . ((isset( $r['_c'] )) ? "\n" : ''); + if (isset( $r['_c'] )) + $res[] = ary2xml( $r['_c'], $d + 1 ); + elseif (isset( $r['_v'] )) + $res[] = $r['_v']; + $res[] = (isset( $r['_c'] ) ? $sp : '') . "\n"; + } + + } + return implode( '', $res ); + } + + /** + * ins2ary + * + * Insert element into array + * + * @param string &$ary + * @param string $element + * @param string $pos + * + * @return void + */ + // Insert element into array + function ins2ary (&$ary, $element, $pos) + { + $ar1 = array_slice( $ary, 0, $pos ); + $ar1[] = $element; + $ary = array_merge( $ar1, array_slice( $ary, $pos ) ); + } + + /* * Xml parse collection functions - * Returns a associative array within the xml structure and data - * - * @author Erik Amaru Ortiz - */ - function xmlParser(&$string) { - $parser = xml_parser_create(); - xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0); - xml_parse_into_struct($parser, $string, $vals, $index); - - $mnary = array(); - $ary =&$mnary; - foreach ($vals as $r) { - $t=$r['tag']; - if ($r['type']=='open') { - if (isset($ary[$t])) { - if (isset($ary[$t][0])) - $ary[$t][]=array(); - else - $ary[$t]=array($ary[$t], array()); - $cv=&$ary[$t][count($ary[$t])-1]; - } else $cv=&$ary[$t]; - if (isset($r['attributes'])) { - foreach ($r['attributes'] as $k=>$v) $cv['__ATTRIBUTES__'][$k]=$v; - } - // note by gustavo cruz gustavo[at]colosa[dot]com - // minor adjustments to validate if an open node have a value attribute. - // for example a dropdown has many childs, but also can have a value attribute. - if (isset($r['value']) && trim($r['value'])!=''){ - $cv['__VALUE__'] = $r['value']; - } - // end added code - $cv['__CONTENT__'] = array(); - $cv['__CONTENT__']['_p'] =&$ary; - $ary =&$cv['__CONTENT__']; - - } elseif ($r['type']=='complete') { - if (isset($ary[$t])) { // same as open - if (isset($ary[$t][0])) $ary[$t][]=array(); - else $ary[$t]=array($ary[$t], array()); - $cv=&$ary[$t][count($ary[$t])-1]; - } else $cv=&$ary[$t]; - if (isset($r['attributes'])) { - foreach ($r['attributes'] as $k=>$v) $cv['__ATTRIBUTES__'][$k]=$v; - } - $cv['__VALUE__']=(isset($r['value']) ? $r['value'] : ''); - - } elseif ($r['type']=='close') { - $ary=&$ary['_p']; - } + *************************************** end **********************************************/ + + /** + * evalJScript + * + * @param string $c + * + * @return void + */ + function evalJScript ($c) + { + print ("") ; + } + + /** + * Inflects a string with accented characters and other characteres not suitable for file names, by defaul replace with undescore + * + * @author Erik Amaru Ortiz + * @param (string) string to convert + * @param (string) character for replace + * @param (array) additional characteres map + * + */ + function inflect ($string, $replacement = '_', $map = array()) + { + if (is_array( $replacement )) { + $map = $replacement; + $replacement = '_'; + } + + $quotedReplacement = preg_quote( $replacement, '/' ); + + $default = array ('/à|á|å|â/' => 'a','/è|é|ê|ẽ|ë/' => 'e','/ì|í|î/' => 'i','/ò|ó|ô|ø/' => 'o','/ù|ú|ů|û/' => 'u','/ç/' => 'c','/ñ/' => 'n','/ä|æ/' => 'ae','/ö/' => 'oe','/ü/' => 'ue','/Ä/' => 'Ae','/Ü/' => 'Ue','/Ö/' => 'Oe','/ß/' => 'ss','/\.|\,|\:|\-|\\|\//' => " ",'/\\s+/' => $replacement + ); + + $map = array_merge( $default, $map ); + return preg_replace( array_keys( $map ), array_values( $map ), $string ); + } + + /** + * pr + * + * @param string $var + * + * @return void + */ + function pr ($var) + { + print ("
") ;
+        print_r( $var );
+        print ("
") ; + } + + /** + * dump + * + * @param string $var + * + * @return void + */ + function dump ($var) + { + print ("
") ;
+        var_dump( $var );
+        print ("
") ; + } + + /** + * stripCDATA + * + * @param string $string + * + * @return string str_replace + */ + function stripCDATA ($string) + { + preg_match_all( '//is', $string, $matches ); + return str_replace( $matches[0], $matches[1], $string ); + } + + /** + * Get the temporal directory path on differents O.S. + * i.e. /temp -> linux, C:/Temp -> win + * + * @author + */ + function sys_get_temp_dir () + { + if (! function_exists( 'sys_get_temp_dir' )) { + // Based on http://www.phpit.net/ + // article/creating-zip-tar-archives-dynamically-php/2/ + // Try to get from environment variable + if (! empty( $_ENV['TMP'] )) { + return realpath( $_ENV['TMP'] ); + } else if (! empty( $_ENV['TMPDIR'] )) { + return realpath( $_ENV['TMPDIR'] ); + } else if (! empty( $_ENV['TEMP'] )) { + return realpath( $_ENV['TEMP'] ); + } else { // Detect by creating a temporary file + // Try to use system's temporary directory + // as random name shouldn't exist + $temp_file = tempnam( md5( uniqid( rand(), TRUE ) ), '' ); + if ($temp_file) { + $temp_dir = realpath( dirname( $temp_file ) ); + unlink( $temp_file ); + return $temp_dir; + } else { + return FALSE; + } + } + } else { + return sys_get_temp_dir(); + } + } + + /** + * Get the content of a compose pmos web service response + * Returns an array when has a valid reponse, if the response is invalid returns an object containing a status_code and message properties. + * + * @author + */ + function PMWSCompositeResponse ($oResp, $prop) + { + $Resp = new stdClass(); + + if (is_object( $oResp ) && isset( $oResp->{$prop} )) { + $list = $oResp->{$prop}; + + if (is_object( $list )) { + $aList[0] = $list; + } else { + $aList = $list; + } + + $result = true; + if (is_array( $aList )) { + foreach ($aList as $item) { + if (! isset( $item->guid )) { + $result = false; + break; + } + } + } else { + $Resp->status_code = - 1; + $Resp->message = "Bad respose type for ({$prop})"; + } + + if ($result) { + //verifing if the response has a composite response into a guid value of the first row. + $tmp = explode( ' ', trim( $aList[0]->guid ) ); + if (sizeof( $tmp ) >= 2) { //the guid can't has a space, so this should be a ws response + $Resp->status_code = $tmp[0]; + $Resp->message = substr( $aList[0]->guid, strpos( $aList[0]->guid, ' ' ) + 1 ); + } else { + return $aList; + } + + } else { + $Resp->status_code = - 2; + $Resp->message = "Bad respose, the response has not a uniform struct."; + } + } else if (is_object( $oResp )) { + return Array (); + } else { + $Resp->status_code = - 1; + $Resp->message = "1 Bad respose type for ({$prop})"; + } + return $Resp; } - self::_del_p($mnary); - - $obj_resp->code = xml_get_error_code($parser); - $obj_resp->message = xml_error_string($obj_resp->code); - $obj_resp->result = $mnary; - xml_parser_free($parser); - - return $obj_resp; - } - - /** - * _del_p - * - * @param string &$ary - * - * @return void - */ - // _Internal: Remove recursion in result array - function _del_p(&$ary) { - foreach ($ary as $k=>$v) { - if ($k==='_p') unset($ary[$k]); - elseif (is_array($ary[$k])) self::_del_p($ary[$k]); - } - } - - /** - * ary2xml - * - * Array to XML - * - * @param string $cary - * @param string $d=0 - * @param string $forcetag default value '' - * - * @return void - */ - // Array to XML - function ary2xml($cary, $d=0, $forcetag='') { - $res = array(); - foreach ($cary as $tag=>$r) { - if (isset($r[0])) { - $res[]=self::ary2xml($r, $d, $tag); - } else { - if ($forcetag) $tag=$forcetag; - $sp = str_repeat("\t", $d); - $res[] = "$sp<$tag"; - if (isset($r['_a'])) {foreach ($r['_a'] as $at=>$av) $res[]=" $at=\"$av\"";} - $res[] = ">".((isset($r['_c'])) ? "\n" : ''); - if (isset($r['_c'])) $res[]=ary2xml($r['_c'], $d+1); - elseif (isset($r['_v'])) $res[]=$r['_v']; - $res[] = (isset($r['_c']) ? $sp : '')."\n"; - } - - } - return implode('', $res); - } - - /** - * ins2ary - * - * Insert element into array - * - * @param string &$ary - * @param string $element - * @param string $pos - * - * @return void - */ - // Insert element into array - function ins2ary(&$ary, $element, $pos) - { - $ar1=array_slice($ary, 0, $pos); $ar1[]=$element; - $ary=array_merge($ar1, array_slice($ary, $pos)); - } - - /* - * Xml parse collection functions - *************************************** end **********************************************/ - - - /** - * evalJScript - * - * @param string $c - * - * @return void - */ - function evalJScript($c){ - print(""); - } - - - /** - * Inflects a string with accented characters and other characteres not suitable for file names, by defaul replace with undescore - * - * @author Erik Amaru Ortiz - * @param (string) string to convert - * @param (string) character for replace - * @param (array) additional characteres map - * - */ - function inflect($string, $replacement = '_', $map = array()) { - if (is_array($replacement)) { - $map = $replacement; - $replacement = '_'; - } - - $quotedReplacement = preg_quote($replacement, '/'); - - $default = array( - '/à|á|å|â/' => 'a', - '/è|é|ê|ẽ|ë/' => 'e', - '/ì|í|î/' => 'i', - '/ò|ó|ô|ø/' => 'o', - '/ù|ú|ů|û/' => 'u', - '/ç/' => 'c', - '/ñ/' => 'n', - '/ä|æ/' => 'ae', - '/ö/' => 'oe', - '/ü/' => 'ue', - '/Ä/' => 'Ae', - '/Ü/' => 'Ue', - '/Ö/' => 'Oe', - '/ß/' => 'ss', - '/\.|\,|\:|\-|\\|\//' => " ", - '/\\s+/' => $replacement - ); - - $map = array_merge($default, $map); - return preg_replace(array_keys($map), array_values($map), $string); - } - - /** - * pr - * - * @param string $var - * - * @return void - */ - function pr($var) - { - print("
");
-    print_r($var);
-    print("
"); - } - - /** - * dump - * - * @param string $var - * - * @return void - */ - function dump($var){ - print("
");
-    var_dump($var);
-    print("
"); - } - - /** - * stripCDATA - * - * @param string $string - * - * @return string str_replace - */ - function stripCDATA($string){ - preg_match_all('//is', $string, $matches); - return str_replace($matches[0], $matches[1], $string); - } - - /** - * Get the temporal directory path on differents O.S. i.e. /temp -> linux, C:/Temp -> win - * @author - */ - function sys_get_temp_dir() { - if ( !function_exists('sys_get_temp_dir') ){ - // Based on http://www.phpit.net/ - // article/creating-zip-tar-archives-dynamically-php/2/ - // Try to get from environment variable - if ( !empty($_ENV['TMP']) ){ - return realpath( $_ENV['TMP'] ); - } else if ( !empty($_ENV['TMPDIR']) ){ - return realpath( $_ENV['TMPDIR'] ); - } else if ( !empty($_ENV['TEMP']) ){ - return realpath( $_ENV['TEMP'] ); - } else {// Detect by creating a temporary file - // Try to use system's temporary directory - // as random name shouldn't exist - $temp_file = tempnam( md5(uniqid(rand(), TRUE)), '' ); - if ( $temp_file ){ - $temp_dir = realpath( dirname($temp_file) ); - unlink( $temp_file ); - return $temp_dir; - } else { - return FALSE; - } - } - } else { - return sys_get_temp_dir(); - } - } - - /** - * Get the content of a compose pmos web service response - * Returns an array when has a valid reponse, if the response is invalid returns an object containing a status_code and message properties. - * - * @author - */ - function PMWSCompositeResponse($oResp, $prop) { - $Resp = new stdClass(); - - if( is_object($oResp) && isset($oResp->{$prop}) ){ - $list = $oResp->{$prop}; - - if( is_object($list) ){ - $aList[0] = $list; - } else { - $aList = $list; - } - - $result = true; - if( is_array($aList) ){ - foreach($aList as $item){ - if( !isset($item->guid) ){ - $result = false; - break; - } - } - } else { - $Resp->status_code = -1; - $Resp->message = "Bad respose type for ({$prop})"; - } - - if( $result ){ - //verifing if the response has a composite response into a guid value of the first row. - $tmp = explode(' ', trim($aList[0]->guid)); - if( sizeof($tmp) >= 2 ){ //the guid can't has a space, so this should be a ws response - $Resp->status_code = $tmp[0]; - $Resp->message = substr($aList[0]->guid, strpos($aList[0]->guid, ' ') + 1); - } else { - return $aList; - } - - } else { - $Resp->status_code = -2; - $Resp->message = "Bad respose, the response has not a uniform struct."; - } - } else if( is_object($oResp) ){ - return Array(); - } else { - $Resp->status_code = -1; - $Resp->message = "1 Bad respose type for ({$prop})"; - } - return $Resp; - } - /** * Validate and emai address in complete forms, * @@ -4737,871 +4785,685 @@ function get_mobile_data( $pv_browser_user_agent ) return $a_mobile_data; } - function getBrowser() - { - $u_agent = $_SERVER['HTTP_USER_AGENT']; - $bname = 'Unknown'; - $platform = 'Unknown'; - $version= ""; - - //First get the platform? - if (preg_match('/linux/i', $u_agent)) { - $platform = 'linux'; - } - elseif (preg_match('/macintosh|mac os x/i', $u_agent)) { - $platform = 'mac'; - } - elseif (preg_match('/windows|win32/i', $u_agent)) { - $platform = 'windows'; - } - - // Next get the name of the useragent yes seperately and for good reason - if(preg_match('/MSIE/i',$u_agent) && !preg_match('/Opera/i',$u_agent)) - { - $bname = 'Internet Explorer'; - $ub = "MSIE"; - } - elseif(preg_match('/Firefox/i',$u_agent)) - { - $bname = 'Mozilla Firefox'; - $ub = "Firefox"; - } - elseif(preg_match('/Chrome/i',$u_agent)) - { - $bname = 'Google Chrome'; - $ub = "Chrome"; - } - elseif(preg_match('/Safari/i',$u_agent)) - { - $bname = 'Apple Safari'; - $ub = "Safari"; - } - elseif(preg_match('/Opera/i',$u_agent)) - { - $bname = 'Opera'; - $ub = "Opera"; - } - elseif(preg_match('/Netscape/i',$u_agent)) - { - $bname = 'Netscape'; - $ub = "Netscape"; - } - - // finally get the correct version number - $known = array('Version', $ub, 'other'); - $pattern = '#(?P' . join('|', $known) . ')[/ ]+(?P[0-9.|a-zA-Z.]*)#'; - @preg_match_all($pattern, $u_agent, $matches); - - // see how many we have - $i = count($matches['browser']); - if ($i != 1) { - //we will have two since we are not using 'other' argument yet - //see if version is before or after the name - if (strripos($u_agent,"Version") < strripos($u_agent,$ub)){ - $version= $matches['version'][0]; - } - else { - $version= $matches['version'][1]; - } - } - else { - $version= $matches['version'][0]; - } - - // check if we have a number - if ($version==null || $version=="") {$version="?";} - - return array( - 'userAgent' => $u_agent, - 'name' => strtolower($ub), - 'longName' => $bname, - 'version' => $version, - 'platform' => $platform, - 'pattern' => $pattern - ); - } - - - -// track total script execution time -function script_time() -{ - static $script_time; - $elapsed_time = ''; - /* + function getBrowser () + { + $u_agent = $_SERVER['HTTP_USER_AGENT']; + $bname = 'Unknown'; + $platform = 'Unknown'; + $version = ""; + + //First get the platform? + if (preg_match( '/linux/i', $u_agent )) { + $platform = 'linux'; + } elseif (preg_match( '/macintosh|mac os x/i', $u_agent )) { + $platform = 'mac'; + } elseif (preg_match( '/windows|win32/i', $u_agent )) { + $platform = 'windows'; + } + + // Next get the name of the useragent yes seperately and for good reason + if (preg_match( '/MSIE/i', $u_agent ) && ! preg_match( '/Opera/i', $u_agent )) { + $bname = 'Internet Explorer'; + $ub = "MSIE"; + } elseif (preg_match( '/Firefox/i', $u_agent )) { + $bname = 'Mozilla Firefox'; + $ub = "Firefox"; + } elseif (preg_match( '/Chrome/i', $u_agent )) { + $bname = 'Google Chrome'; + $ub = "Chrome"; + } elseif (preg_match( '/Safari/i', $u_agent )) { + $bname = 'Apple Safari'; + $ub = "Safari"; + } elseif (preg_match( '/Opera/i', $u_agent )) { + $bname = 'Opera'; + $ub = "Opera"; + } elseif (preg_match( '/Netscape/i', $u_agent )) { + $bname = 'Netscape'; + $ub = "Netscape"; + } + + // finally get the correct version number + $known = array ('Version',$ub,'other' + ); + $pattern = '#(?P' . join( '|', $known ) . ')[/ ]+(?P[0-9.|a-zA-Z.]*)#'; + @preg_match_all( $pattern, $u_agent, $matches ); + + // see how many we have + $i = count( $matches['browser'] ); + if ($i != 1) { + //we will have two since we are not using 'other' argument yet + //see if version is before or after the name + if (strripos( $u_agent, "Version" ) < strripos( $u_agent, $ub )) { + $version = $matches['version'][0]; + } else { + $version = $matches['version'][1]; + } + } else { + $version = $matches['version'][0]; + } + + // check if we have a number + if ($version == null || $version == "") { + $version = "?"; + } + + return array ('userAgent' => $u_agent,'name' => strtolower( $ub ),'longName' => $bname,'version' => $version,'platform' => $platform,'pattern' => $pattern + ); + } + + // track total script execution time + function script_time () + { + static $script_time; + $elapsed_time = ''; + /* note that microtime(true) requires php 5 or greater for microtime(true) - */ - if ( sprintf("%01.1f", phpversion() ) >= 5 ) { - if ( is_null( $script_time) ) { - $script_time = microtime(true); - } - else { - // note: (string)$var is same as strval($var) - // $elapsed_time = (string)( microtime(true) - $script_time ); - $elapsed_time = ( microtime(true) - $script_time ); - $elapsed_time = sprintf("%01.8f", $elapsed_time ); - $script_time = NULL; // can't unset a static variable - return $elapsed_time; - } - } -} -function getDirectorySize($path,$maxmtime=0) -{ - $totalsize = 0; - $totalcount = 0; - $dircount = 0; - if ($handle = opendir ($path)) - { - while (false !== ($file = readdir($handle))) - { - $nextpath = $path . '/' . $file; - if ($file != '.' && $file != '..' && !is_link ($nextpath) && $file != '.svn') - { - if (is_dir ($nextpath)) - { - $dircount++; - $result = G::getDirectorySize($nextpath,$maxmtime); - $totalsize += $result['size']; - $totalcount += $result['count']; - $dircount += $result['dircount']; - $maxmtime=$result['maxmtime']>$maxmtime?$result['maxmtime']:$maxmtime; - } - elseif (is_file ($nextpath)) - { - $totalsize += filesize ($nextpath); - $totalcount++; - - - $mtime = filemtime($nextpath); - if($mtime>$maxmtime) $maxmtime=$mtime; - - - } - } - } - } - closedir ($handle); - $total['size'] = $totalsize; - $total['count'] = $totalcount; - $total['dircount'] = $dircount; - $total['maxmtime'] = $maxmtime; - - return $total; -} - - /** - * Get checksum from multiple files - * @author erik amaru ortiz - */ - function getCacheFileNameByPattern($path, $pattern) - { - if ($file = glob($path . $pattern)) - preg_match('/[a-f0-9]{32}/', $file[0], $match); - else - $file[0] = ''; - return array('filename'=>$file[0], 'checksum'=>(isset($match[0])? $match[0]: '')); - } - - - /** - * Get checksum from multiple files - * @author erik amaru ortiz - */ - function getCheckSum($files) - { - G::LoadClass('system'); - $key = System::getVersion(); - - if (!is_array($files)) { - $tmp = $files; - $files = array(); - $files[0] = $tmp; - } - - $checkSum = ''; - foreach ($files as $file) { - if (is_file($file)) - $checkSum .= md5_file($file); - } - return md5($checkSum.$key); - } - - /** - * parse_ini_string - Define parse_ini_string if it doesn't exist. - Does accept lines starting with ; as comments - Does not accept comments after values - */ - function parse_ini_string($string){ - if( function_exists('parse_ini_string') ) { - return parse_ini_string($string); - } - else { - $array = Array(); - $lines = explode("\n", $string ); - - foreach( $lines as $line ) { - $statement = preg_match( "/^(?!;)(?P[\w+\.\-]+?)\s*=\s*(?P.+?)\s*$/", $line, $match ); - if( $statement ) { - $key = $match[ 'key' ]; - $value = $match[ 'value' ]; - - //Remove quote - if( preg_match( "/^\".*\"$/", $value ) || preg_match( "/^'.*'$/", $value ) ) { - $value = mb_substr( $value, 1, mb_strlen( $value ) - 2 ); - } - - $array[ $key ] = $value; - } - } - return $array; - } - } - - /** - * disableEnableINIvariable - disable or enable a variable in ini file, this is useful for editing the env.ini file - automatically get the value, and change to inverse value, I mean from true to false and viceversa - */ - function disableEnableINIvariable( $inifile, $variable ) { - $enabled = 'false'; - if ( file_exists($inifile ) ) { - $fp = fopen( $inifile, 'r' ); - $line = fgets($fp); - $found = false; - $buffer = null; - - while ( !feof($fp) ) { - $config = G::parse_ini_string($line); - if ( isset($config[$variable] )) { - $enabled = $config[$variable]; - $buffer .= sprintf("%s = %d \n", $variable, 1- $enabled ); - $found = true; - } - else { - $buffer .= trim($line) . "\n"; - } - $line = fgets($fp); - } - fclose($fp); - if ( !$found ) $buffer .= sprintf("\n%s = 1 \n", $variable ); - - @file_put_contents( $inifile, $buffer); - } - else { - $contents = file_put_contents($inifile, sprintf("\n%s = 1\n", $variable)); - } - } - - /** - * set a variable in ini file - */ - function setINIvariable( $inifile, $variable, $value ) { - if ( file_exists($inifile ) ) { - $fp = fopen( $inifile, 'r' ); - $line = fgets($fp); - $found = false; - $buffer = null; - - while ( !feof($fp) ) { - $config = G::parse_ini_string($line); - if ( isset($config[$variable] )) { - $enabled = $config[$variable]; - $buffer .= sprintf("%s = %s \n", $variable, $value ); - $found = true; - } - else { - $buffer .= trim($line) . "\n"; - } - $line = fgets($fp); - } - fclose($fp); - if ( !$found ) $buffer .= sprintf("\n%s = %s \n", $variable, $value ); - - file_put_contents( $inifile, $buffer); - } - else { - $contents = file_put_contents($inifile, sprintf("\n%s = $s\n", $variable, $value)); - } - } - - function write_php_ini($file, $array) - { - $res = array(); - foreach($array as $key => $val) - { - if(is_array($val)) - { - $res[] = "[$key]"; - foreach($val as $skey => $sval) $res[] = "$skey = ".(is_numeric($sval) ? $sval : '"'.$sval.'"'); - } - else $res[] = "$key = ".(is_numeric($val) ? $val : '"'.$val.'"'); - } - file_put_contents($file, implode("\r\n", $res)); - } - - - /** - * verify if all files & directories passed by param. are writable - * @author Erik Amaru Ortiz - * @param $resources array a list of files to verify write access - */ - function verifyWriteAccess($resources) - { - $noWritable = array(); - foreach ($resources as $i => $resource) { - if (!is_writable($resource)) { - $noWritable[] = $resource; - } - } - - if (count($noWritable) > 0) { - $e = new Exception("Write access not allowed for ProcessMaker resources"); - $e->files = $noWritable; - throw $e; - } - } - - /** - * render a smarty template - * @author Erik Amaru Ortiz - * @param $template string containing the template filename on /gulliver/templates/ directory - * @param $data associative array containig the template data - */ - function renderTemplate($template, $data=array()) - { - if (!defined('PATH_THIRDPARTY')) { - throw new Exception('System constant (PATH_THIRDPARTY) is not defined!'); - } - - require_once PATH_THIRDPARTY . 'smarty/libs/Smarty.class.php'; - $fInfo = pathinfo($template); - - $tplExists = true; - - // file has absolute path - if (substr($template, 0, 1) != PATH_SEP) { - $template = PATH_TEMPLATE . $template; - } - - // fix for template that have dot in its name but is not a valid extension - if (isset($fInfo['extension']) && ($fInfo['extension'] != 'tpl' || $fInfo['extension'] != 'html')) { - unset($fInfo['extension']); - } - - if (!isset($fInfo['extension'])) { - if (file_exists($template . '.tpl')) { - $template .= '.tpl'; - } - else if (file_exists($template . '.html')) { - $template .= '.html'; - } - else { - $tplExists = false; - } - } - else { - if (!file_exists($template)) { - $tplExists = false; - } - } - - if (!$tplExists) { - throw new Exception("Template: $template, doesn't exist!"); - } - - $smarty = new Smarty(); - $smarty->compile_dir = G::sys_get_temp_dir(); - $smarty->cache_dir = G::sys_get_temp_dir(); - $smarty->config_dir = PATH_THIRDPARTY . 'smarty/configs'; - - $smarty->template_dir = PATH_TEMPLATE; - $smarty->force_compile = true; - - foreach ($data as $key => $value) { - $smarty->assign($key, $value); - } - - $smarty->display($template); - } - - /** - * parse a smarty template and return teh result as string - * @author Erik Amaru Ortiz - * @param $template string containing the template filename on /gulliver/templates/ directory - * @param $data associative array containig the template data - * @return $content string containing the parsed template content - */ - function parseTemplate($template, $data=array()) - { - $content = ''; - - ob_start(); - G::renderTemplate($template, $data); - $content = ob_get_contents(); - ob_get_clean(); - - return $content; - } - - /** - * Update a ini file passing a array values, this function don't remove the original comments - * @author Erik Amaru Ortiz - * @licence GPL v2 (http://www.gnu.org/licenses/gpl-2.0.html) - * - * @param $file string containing the ini file to update - * @param $array associative array containing the config data - */ - function update_php_ini($file, $array) - { - $iniLines = array(); - $iniContent = array(); - - if (file_exists($file) && !is_writable($file)) { - throw new Exception("File $file, is not writable."); - } - - if (file_exists($file)) { - $iniContent = file($file); - } - - foreach ($iniContent as $line) { - $line = trim($line); - $lineParts = explode(';', $line); - $setting = G::parse_ini_string($lineParts[0]); - - if (is_array($setting) && count($setting) > 0) { - list($key, ) = array_keys($setting); - - if (isset($array[$key])) { - $value = $array[$key]; - $line = "$key = ".(is_numeric($value) ? $value : '"'.$value.'"'); - $line .= isset($lineParts[1]) ? ' ;' . $lineParts[1] : ''; - unset($array[$key]); - - $lastComment = array_pop($iniLines); - if (strpos($lastComment, "Setting $key") === false) { - $iniLines[] = $lastComment; - } - - $iniLines[] = ";Setting $key - Updated by System on " . date('D d M, Y H:i:s'); - } - } - $iniLines[] = $line; - } - - // inserting new values - foreach ($array as $key => $value) { - $line = "$key = ".(is_numeric($value) ? $value : '"'.$value.'"'); - $iniLines[] = ''; - $iniLines[] = ";Setting $key - Created by System on " . date('D d M, Y H:i:s'); - $iniLines[] = $line; - } - - $content = implode("\r\n", $iniLines); - - if (@file_put_contents($file, $content) === false) { - throw new Exception("G::update_php_ini() -> can't update file: $file"); - } - } - - /** - * recursive file & directories write permission detect - * @author Erik Amaru Ortiz - * @licence GPL v2 (http://www.gnu.org/licenses/gpl-2.0.html) - * - * @param $path string of directory or file to verify recursively - * @param $noWritableFiles (alternative) array passed by reference to store all no-writable files - * @return bool true if all files inside a directory path are writable, false in another case - */ - function is_writable_r($path, &$noWritableFiles = array()) - { - if (is_writable($path)){ - if (!is_dir($path)) - return true; - - $list = glob(rtrim($path, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR .'*'); - - $sw = true; - foreach ($list as $f) { - if (!G::is_writable_r($f, $noWritableFiles)) { - $sw = false; - } - } - - return $sw; - } - else { - if (!in_array($path, $noWritableFiles)) - $noWritableFiles[] = $path; - - return false; - } - } - - /** - * This method allow dispatch rest services using 'Restler' thirdparty library - * - * @author Erik Amaru Ortiz - */ - public function dispatchRestService($uri, $config, $apiClassesPath = '') - { - require_once 'restler/restler.php'; - - $rest = new Restler(); - $rest->setSupportedFormats('JsonFormat', 'XmlFormat'); - + */ + if (sprintf( "%01.1f", phpversion() ) >= 5) { + if (is_null( $script_time )) { + $script_time = microtime( true ); + } else { + // note: (string)$var is same as strval($var) + // $elapsed_time = (string)( microtime(true) - $script_time ); + $elapsed_time = (microtime( true ) - $script_time); + $elapsed_time = sprintf( "%01.8f", $elapsed_time ); + $script_time = NULL; // can't unset a static variable + return $elapsed_time; + } + } + } + + function getDirectorySize ($path, $maxmtime = 0) + { + $totalsize = 0; + $totalcount = 0; + $dircount = 0; + if ($handle = opendir( $path )) { + while (false !== ($file = readdir( $handle ))) { + $nextpath = $path . '/' . $file; + if ($file != '.' && $file != '..' && ! is_link( $nextpath ) && $file != '.svn') { + if (is_dir( $nextpath )) { + $dircount ++; + $result = G::getDirectorySize( $nextpath, $maxmtime ); + $totalsize += $result['size']; + $totalcount += $result['count']; + $dircount += $result['dircount']; + $maxmtime = $result['maxmtime'] > $maxmtime ? $result['maxmtime'] : $maxmtime; + } elseif (is_file( $nextpath )) { + $totalsize += filesize( $nextpath ); + $totalcount ++; + + $mtime = filemtime( $nextpath ); + if ($mtime > $maxmtime) + $maxmtime = $mtime; + + } + } + } + } + closedir( $handle ); + $total['size'] = $totalsize; + $total['count'] = $totalcount; + $total['dircount'] = $dircount; + $total['maxmtime'] = $maxmtime; + + return $total; + } + + /** + * Get checksum from multiple files + * + * @author erik amaru ortiz + */ + function getCacheFileNameByPattern ($path, $pattern) + { + if ($file = glob( $path . $pattern )) + preg_match( '/[a-f0-9]{32}/', $file[0], $match ); + else + $file[0] = ''; + return array ('filename' => $file[0],'checksum' => (isset( $match[0] ) ? $match[0] : '') + ); + } + + /** + * Get checksum from multiple files + * + * @author erik amaru ortiz + */ + function getCheckSum ($files) + { + G::LoadClass( 'system' ); + $key = System::getVersion(); + + if (! is_array( $files )) { + $tmp = $files; + $files = array (); + $files[0] = $tmp; + } + + $checkSum = ''; + foreach ($files as $file) { + if (is_file( $file )) + $checkSum .= md5_file( $file ); + } + return md5( $checkSum . $key ); + } + + /** + * parse_ini_string + * Define parse_ini_string if it doesn't exist. + * Does accept lines starting with ; as comments + * Does not accept comments after values + */ + function parse_ini_string ($string) + { + if (function_exists( 'parse_ini_string' )) { + return parse_ini_string( $string ); + } else { + $array = Array (); + $lines = explode( "\n", $string ); + + foreach ($lines as $line) { + $statement = preg_match( "/^(?!;)(?P[\w+\.\-]+?)\s*=\s*(?P.+?)\s*$/", $line, $match ); + if ($statement) { + $key = $match['key']; + $value = $match['value']; + + //Remove quote + if (preg_match( "/^\".*\"$/", $value ) || preg_match( "/^'.*'$/", $value )) { + $value = mb_substr( $value, 1, mb_strlen( $value ) - 2 ); + } + + $array[$key] = $value; + } + } + return $array; + } + } + + /** + * disableEnableINIvariable + * disable or enable a variable in ini file, this is useful for editing the env.ini file + * automatically get the value, and change to inverse value, I mean from true to false and viceversa + */ + function disableEnableINIvariable ($inifile, $variable) + { + $enabled = 'false'; + if (file_exists( $inifile )) { + $fp = fopen( $inifile, 'r' ); + $line = fgets( $fp ); + $found = false; + $buffer = null; + + while (! feof( $fp )) { + $config = G::parse_ini_string( $line ); + if (isset( $config[$variable] )) { + $enabled = $config[$variable]; + $buffer .= sprintf( "%s = %d \n", $variable, 1 - $enabled ); + $found = true; + } else { + $buffer .= trim( $line ) . "\n"; + } + $line = fgets( $fp ); + } + fclose( $fp ); + if (! $found) + $buffer .= sprintf( "\n%s = 1 \n", $variable ); + + @file_put_contents( $inifile, $buffer ); + } else { + $contents = file_put_contents( $inifile, sprintf( "\n%s = 1\n", $variable ) ); + } + } + + /** + * set a variable in ini file + */ + function setINIvariable ($inifile, $variable, $value) + { + if (file_exists( $inifile )) { + $fp = fopen( $inifile, 'r' ); + $line = fgets( $fp ); + $found = false; + $buffer = null; + + while (! feof( $fp )) { + $config = G::parse_ini_string( $line ); + if (isset( $config[$variable] )) { + $enabled = $config[$variable]; + $buffer .= sprintf( "%s = %s \n", $variable, $value ); + $found = true; + } else { + $buffer .= trim( $line ) . "\n"; + } + $line = fgets( $fp ); + } + fclose( $fp ); + if (! $found) + $buffer .= sprintf( "\n%s = %s \n", $variable, $value ); + + file_put_contents( $inifile, $buffer ); + } else { + $contents = file_put_contents( $inifile, sprintf( "\n%s = $s\n", $variable, $value ) ); + } + } + + function write_php_ini ($file, $array) + { + $res = array (); + foreach ($array as $key => $val) { + if (is_array( $val )) { + $res[] = "[$key]"; + foreach ($val as $skey => $sval) + $res[] = "$skey = " . (is_numeric( $sval ) ? $sval : '"' . $sval . '"'); + } else + $res[] = "$key = " . (is_numeric( $val ) ? $val : '"' . $val . '"'); + } + file_put_contents( $file, implode( "\r\n", $res ) ); + } + + /** + * verify if all files & directories passed by param. + * are writable + * + * @author Erik Amaru Ortiz + * @param $resources array a list of files to verify write access + */ + function verifyWriteAccess ($resources) + { + $noWritable = array (); + foreach ($resources as $i => $resource) { + if (! is_writable( $resource )) { + $noWritable[] = $resource; + } + } + + if (count( $noWritable ) > 0) { + $e = new Exception( "Write access not allowed for ProcessMaker resources" ); + $e->files = $noWritable; + throw $e; + } + } + + /** + * render a smarty template + * + * @author Erik Amaru Ortiz + * @param $template string containing the template filename on /gulliver/templates/ directory + * @param $data associative array containig the template data + */ + function renderTemplate ($template, $data = array()) + { + if (! defined( 'PATH_THIRDPARTY' )) { + throw new Exception( 'System constant (PATH_THIRDPARTY) is not defined!' ); + } + + require_once PATH_THIRDPARTY . 'smarty/libs/Smarty.class.php'; + $fInfo = pathinfo( $template ); + + $tplExists = true; + + // file has absolute path + if (substr( $template, 0, 1 ) != PATH_SEP) { + $template = PATH_TEMPLATE . $template; + } + + // fix for template that have dot in its name but is not a valid extension + if (isset( $fInfo['extension'] ) && ($fInfo['extension'] != 'tpl' || $fInfo['extension'] != 'html')) { + unset( $fInfo['extension'] ); + } + + if (! isset( $fInfo['extension'] )) { + if (file_exists( $template . '.tpl' )) { + $template .= '.tpl'; + } else if (file_exists( $template . '.html' )) { + $template .= '.html'; + } else { + $tplExists = false; + } + } else { + if (! file_exists( $template )) { + $tplExists = false; + } + } + + if (! $tplExists) { + throw new Exception( "Template: $template, doesn't exist!" ); + } + + $smarty = new Smarty(); + $smarty->compile_dir = G::sys_get_temp_dir(); + $smarty->cache_dir = G::sys_get_temp_dir(); + $smarty->config_dir = PATH_THIRDPARTY . 'smarty/configs'; + + $smarty->template_dir = PATH_TEMPLATE; + $smarty->force_compile = true; + + foreach ($data as $key => $value) { + $smarty->assign( $key, $value ); + } + + $smarty->display( $template ); + } + + /** + * parse a smarty template and return teh result as string + * + * @author Erik Amaru Ortiz + * @param $template string containing the template filename on /gulliver/templates/ directory + * @param $data associative array containig the template data + * @return $content string containing the parsed template content + */ + function parseTemplate ($template, $data = array()) + { + $content = ''; + + ob_start(); + G::renderTemplate( $template, $data ); + $content = ob_get_contents(); + ob_get_clean(); + + return $content; + } + + /** + * Update a ini file passing a array values, this function don't remove the original comments + * + * @author Erik Amaru Ortiz + * @licence GPL v2 (http://www.gnu.org/licenses/gpl-2.0.html) + * + * @param $file string containing the ini file to update + * @param $array associative array containing the config data + */ + function update_php_ini ($file, $array) + { + $iniLines = array (); + $iniContent = array (); + + if (file_exists( $file ) && ! is_writable( $file )) { + throw new Exception( "File $file, is not writable." ); + } + + if (file_exists( $file )) { + $iniContent = file( $file ); + } + + foreach ($iniContent as $line) { + $line = trim( $line ); + $lineParts = explode( ';', $line ); + $setting = G::parse_ini_string( $lineParts[0] ); + + if (is_array( $setting ) && count( $setting ) > 0) { + list ($key, ) = array_keys( $setting ); + + if (isset( $array[$key] )) { + $value = $array[$key]; + $line = "$key = " . (is_numeric( $value ) ? $value : '"' . $value . '"'); + $line .= isset( $lineParts[1] ) ? ' ;' . $lineParts[1] : ''; + unset( $array[$key] ); + + $lastComment = array_pop( $iniLines ); + if (strpos( $lastComment, "Setting $key" ) === false) { + $iniLines[] = $lastComment; + } + + $iniLines[] = ";Setting $key - Updated by System on " . date( 'D d M, Y H:i:s' ); + } + } + $iniLines[] = $line; + } + + // inserting new values + foreach ($array as $key => $value) { + $line = "$key = " . (is_numeric( $value ) ? $value : '"' . $value . '"'); + $iniLines[] = ''; + $iniLines[] = ";Setting $key - Created by System on " . date( 'D d M, Y H:i:s' ); + $iniLines[] = $line; + } + + $content = implode( "\r\n", $iniLines ); + + if (@file_put_contents( $file, $content ) === false) { + throw new Exception( "G::update_php_ini() -> can't update file: $file" ); + } + } + + /** + * recursive file & directories write permission detect + * + * @author Erik Amaru Ortiz + * @licence GPL v2 (http://www.gnu.org/licenses/gpl-2.0.html) + * + * @param $path string of directory or file to verify recursively + * @param $noWritableFiles (alternative) array passed by reference to store all no-writable files + * @return bool true if all files inside a directory path are writable, false in another case + */ + function is_writable_r ($path, &$noWritableFiles = array()) + { + if (is_writable( $path )) { + if (! is_dir( $path )) { + return true; + } + $list = glob( rtrim( $path, DIRECTORY_SEPARATOR ) . DIRECTORY_SEPARATOR . '*' ); + + $sw = true; + foreach ($list as $f) { + if (! G::is_writable_r( $f, $noWritableFiles )) { + $sw = false; + } + } + + return $sw; + } else { + if (! in_array( $path, $noWritableFiles )) { + $noWritableFiles[] = $path; + } + return false; + } + } + + /** + * This method allow dispatch rest services using 'Restler' thirdparty library + * + * @author Erik Amaru Ortiz + */ + public function dispatchRestService ($uri, $config, $apiClassesPath = '') + { + require_once 'restler/restler.php'; + + $rest = new Restler(); + $rest->setSupportedFormats( 'JsonFormat', 'XmlFormat' ); // getting all services class - $restClasses = array(); - $restClassesList = G::rglob('*', 0, PATH_CORE . 'services/'); - foreach ($restClassesList as $classFile) { - if (substr($classFile, -4) === '.php') { - $restClasses[str_replace('.php', '', basename($classFile))] = $classFile; - } - } - - if (! empty($apiClassesPath)) { - $pluginRestClasses = array(); - $restClassesList = G::rglob('*', 0, $apiClassesPath . 'services/'); - foreach ($restClassesList as $classFile) { - if (substr($classFile, -4) === '.php') { - $pluginRestClasses[str_replace('.php', '', basename($classFile))] = $classFile; - } - } - $restClasses = array_merge($restClasses, $pluginRestClasses); - } - - + $restClasses = array (); + $restClassesList = G::rglob( '*', 0, PATH_CORE . 'services/' ); + foreach ($restClassesList as $classFile) { + if (substr( $classFile, - 4 ) === '.php') { + $restClasses[str_replace( '.php', '', basename( $classFile ) )] = $classFile; + } + } + if (! empty( $apiClassesPath )) { + $pluginRestClasses = array (); + $restClassesList = G::rglob( '*', 0, $apiClassesPath . 'services/' ); + foreach ($restClassesList as $classFile) { + if (substr( $classFile, - 4 ) === '.php') { + $pluginRestClasses[str_replace( '.php', '', basename( $classFile ) )] = $classFile; + } + } + $restClasses = array_merge( $restClasses, $pluginRestClasses ); + } // hook to get rest api classes from plugins - if (class_exists('PMPluginRegistry')) { - $pluginRegistry = & PMPluginRegistry::getSingleton(); - $pluginClasses = $pluginRegistry->getRegisteredRestClassFiles(); - $restClasses = array_merge($restClasses, $pluginClasses); - } - - foreach ($restClasses as $key => $classFile) { - if ( !file_exists($classFile) ) { - unset($restClasses[$key]); - continue; - } + if (class_exists( 'PMPluginRegistry' )) { + $pluginRegistry = & PMPluginRegistry::getSingleton(); + $pluginClasses = $pluginRegistry->getRegisteredRestClassFiles(); + $restClasses = array_merge( $restClasses, $pluginClasses ); + } + foreach ($restClasses as $key => $classFile) { + if (! file_exists( $classFile )) { + unset( $restClasses[$key] ); + continue; + } //load the file, and check if exist the class inside it. - require_once $classFile; - $namespace = 'Services_Rest_'; - $className = str_replace('.php', '', basename($classFile)); - + require_once $classFile; + $namespace = 'Services_Rest_'; + $className = str_replace( '.php', '', basename( $classFile ) ); + // if the core class does not exists try resolve the for a plugin - if (! class_exists($namespace . $className)) { - $namespace = 'Plugin_Services_Rest_'; - + if (! class_exists( $namespace . $className )) { + $namespace = 'Plugin_Services_Rest_'; // Couldn't resolve the class name, just skipp it - if (! class_exists($namespace . $className)) { - unset($restClasses[$key]); - continue; - } - } + if (! class_exists( $namespace . $className )) { + unset( $restClasses[$key] ); + continue; + } + } // verify if there is an auth class implementing 'iAuthenticate' - $classNameAuth = $namespace . $className; - $reflClass = new ReflectionClass($classNameAuth); + $classNameAuth = $namespace . $className; + $reflClass = new ReflectionClass( $classNameAuth ); // that wasn't from plugin - if ($reflClass->implementsInterface('iAuthenticate') && $namespace != 'Plugin_Services_Rest_') { + if ($reflClass->implementsInterface( 'iAuthenticate' ) && $namespace != 'Plugin_Services_Rest_') { // auth class found, set as restler authentication class handler - $rest->addAuthenticationClass($classNameAuth); - } else { + $rest->addAuthenticationClass( $classNameAuth ); + } else { // add api class - $rest->addAPIClass($classNameAuth); - } - } + $rest->addAPIClass( $classNameAuth ); + } + } //end foreach rest class - // resolving the class for current request - $uriPart = explode('/', $uri); - $requestedClass = ''; - - if (isset($uriPart[1])) { - $requestedClass = ucfirst($uriPart[1]); - } - if (class_exists('Services_Rest_' . $requestedClass)) { - $namespace = 'Services_Rest_'; - } elseif (class_exists('Plugin_Services_Rest_' . $requestedClass)) { - $namespace = 'Plugin_Services_Rest_'; - } else { - $namespace = ''; - } + $uriPart = explode( '/', $uri ); + $requestedClass = ''; + if (isset( $uriPart[1] )) { + $requestedClass = ucfirst( $uriPart[1] ); + } + if (class_exists( 'Services_Rest_' . $requestedClass )) { + $namespace = 'Services_Rest_'; + } elseif (class_exists( 'Plugin_Services_Rest_' . $requestedClass )) { + $namespace = 'Plugin_Services_Rest_'; + } else { + $namespace = ''; + } // end resolv. - // Send additional headers (if exists) configured on rest-config.ini - if (array_key_exists('HEADERS', $config)) { - foreach ($config['HEADERS'] as $name => $value) { - header("$name: $value"); + if (array_key_exists( 'HEADERS', $config )) { + foreach ($config['HEADERS'] as $name => $value) { + header( "$name: $value" ); } } - // to handle a request with "OPTIONS" method - if (! empty($namespace) && $_SERVER['REQUEST_METHOD'] === 'OPTIONS') { - $reflClass = new ReflectionClass($namespace . $requestedClass); - + if (! empty( $namespace ) && $_SERVER['REQUEST_METHOD'] === 'OPTIONS') { + $reflClass = new ReflectionClass( $namespace . $requestedClass ); // if the rest class has not a "options" method - if (! $reflClass->hasMethod('options')) { - header('Access-Control-Allow-Methods: GET, POST, PUT, DELETE, OPTIONS, HEADERS'); - header('Access-Control-Allow-Headers: authorization, content-type'); - header("Access-Control-Allow-Credentials", "false"); - header('Access-Control-Max-Age: 60'); - exit(); + if (! $reflClass->hasMethod( 'options' )) { + header( 'Access-Control-Allow-Methods: GET, POST, PUT, DELETE, OPTIONS, HEADERS' ); + header( 'Access-Control-Allow-Headers: authorization, content-type' ); + header( "Access-Control-Allow-Credentials", "false" ); + header( 'Access-Control-Max-Age: 60' ); + exit(); } } - // override global REQUEST_URI to pass to Restler library - $_SERVER['REQUEST_URI'] = '/' . strtolower($namespace) . ltrim($uri, '/'); - + $_SERVER['REQUEST_URI'] = '/' . strtolower( $namespace ) . ltrim( $uri, '/' ); // handle the rest request - $rest->handle(); - } - - public function reservedWordsSql() - { + $rest->handle(); + } + + public function reservedWordsSql () + { //Reserved words SQL - $reservedWordsSql = array( - "ACCESSIBLE", "ACTION", "ADD", "ALL", "ALTER", - "ANALYZE", "AND", "ANY", "AS", "ASC", - "ASENSITIVE", "AUTHORIZATION", "BACKUP", "BEFORE", "BEGIN", - "BETWEEN", "BIGINT", "BINARY", "BIT", "BLOB", - "BOTH", "BREAK", "BROWSE", "BULK", "BY", - "CALL", "CASCADE", "CASE", "CHANGE", "CHAR", - "CHARACTER", "CHECK", "CHECKPOINT", "CLOSE", "CLUSTERED", - "COALESCE", "COLLATE", "COLUMN", "COMMIT", "COMPUTE", - "CONDITION", "CONSTRAINT", "CONTAINS", "CONTAINSTABLE", "CONTINUE", - "CONVERT", "CREATE", "CROSS", "CURRENT", "CURRENT_DATE", - "CURRENT_TIME", "CURRENT_TIMESTAMP", "CURRENT_USER", "CURSOR", "DATABASE", - "DATABASES", "DATE", "DAY_HOUR", "DAY_MICROSECOND", "DAY_MINUTE", - "DAY_SECOND", "DBCC", "DEALLOCATE", "DEC", "DECIMAL", - "DECLARE", "DEFAULT", "DELAYED", "DELETE", "DENY", - "DESC", "DESCRIBE", "DETERMINISTIC", "DISK", "DISTINCT", - "DISTINCTROW", "DISTRIBUTED", "DIV", "DOUBLE", "DROP", - "DUAL", "DUMMY", "DUMP", "EACH", "ELSE", - "ELSEIF", "ENCLOSED", "END", "ENUM", "ERRLVL", - "ESCAPE", "ESCAPED", "EXCEPT", "EXEC", "EXECUTE", - "EXISTS", "EXIT", "EXPLAIN", "FALSE", "FETCH", - "FILE", "FILLFACTOR", "FLOAT", "FLOAT4", "FLOAT8", - "FOR", "FORCE", "FOREIGN", "FREETEXT", "FREETEXTTABLE", - "FROM", "FULL", "FULLTEXT", "FUNCTION", "GENERAL", - "GOTO", "GRANT", "GROUP", "HAVING", "HIGH_PRIORITY", - "HOLDLOCK", "HOUR_MICROSECOND", "HOUR_MINUTE", "HOUR_SECOND", "IDENTITY", - "IDENTITYCOL", "IDENTITY_INSERT", "IF", "IGNORE", "IGNORE_SERVER_IDS", - "IN", "INDEX", "INFILE", "INNER", "INOUT", - "INSENSITIVE", "INSERT", "INT", "INT1", "INT2", - "INT3", "INT4", "INT8", "INTEGER", "INTERSECT", - "INTERVAL", "INTO", "IS", "ITERATE", "JOIN", - "KEY", "KEYS", "KILL", "LEADING", "LEAVE", - "LEFT", "LIKE", "LIMIT", "LINEAR", "LINENO", - "LINES", "LOAD", "LOCALTIME", "LOCALTIMESTAMP", "LOCK", - "LONG", "LONGBLOB", "LONGTEXT", "LOOP", "LOW_PRIORITY", - "MASTER_HEARTBEAT_PERIOD", "MASTER_SSL_VERIFY_SERVER_CERT", "MATCH", "MAXVALUE", "MEDIUMBLOB", - "MEDIUMINT", "MEDIUMTEXT", "MIDDLEINT", "MINUTE_MICROSECOND", "MINUTE_SECOND", - "MOD", "MODIFIES", "NATIONAL", "NATURAL", "NO", - "NOCHECK", "NONCLUSTERED", "NOT", "NO_WRITE_TO_BINLOG", "NULL", - "NULLIF", "NUMERIC", "OF", "OFF", "OFFSETS", - "ON", "OPEN", "OPENDATASOURCE", "OPENQUERY", "OPENROWSET", - "OPENXML", "OPTIMIZE", "OPTION", "OPTIONALLY", "OR", - "ORDER", "OUT", "OUTER", "OUTFILE", "OVER", - "PERCENT", "PLAN", "PRECISION", "PRIMARY", "PRINT", - "PROC", "PROCEDURE", "PUBLIC", "PURGE", "RAISERROR", - "RANGE", "READ", "READS", "READTEXT", "READ_WRITE", - "REAL", "RECONFIGURE", "REFERENCES", "REGEXP", "RELEASE", - "RENAME", "REPEAT", "REPLACE", "REPLICATION", "REQUIRE", - "RESIGNAL", "RESTORE", "RESTRICT", "RETURN", "REVOKE", - "RIGHT", "RLIKE", "ROLLBACK", "ROWCOUNT", "ROWGUIDCOL", - "RULE", "SAVE", "SCHEMA", "SCHEMAS", "SECOND_MICROSECOND", - "SELECT", "SENSITIVE", "SEPARATOR", "SESSION_USER", "SET", - "SETUSER", "SHOW", "SHUTDOWN", "SIGNAL", "SLOW", - "SMALLINT", "SOME", "SPATIAL", "SPECIFIC", "SQL", - "SQLEXCEPTION", "SQLSTATE", "SQLWARNING", "SQL_BIG_RESULT", "SQL_CALC_FOUND_ROWS", - "SQL_SMALL_RESULT", "SSL", "STARTING", "STATISTICS", "STRAIGHT_JOIN", - "SYSTEM_USER", "TABLE", "TERMINATED", "TEXT", "TEXTSIZE", - "THEN", "TIME", "TIMESTAMP", "TINYBLOB", "TINYINT", - "TINYTEXT", "TO", "TOP", "TRAILING", "TRAN", - "TRANSACTION", "TRIGGER", "TRUE", "TRUNCATE", "TSEQUAL", - "UNDO", "UNION", "UNIQUE", "UNLOCK", "UNSIGNED", - "UPDATE", "UPDATETEXT", "USAGE", "USE", "USER", - "USING", "UTC_DATE", "UTC_TIME", "UTC_TIMESTAMP", "VALUES", - "VARBINARY", "VARCHAR", "VARCHARACTER", "VARYING", "VIEW", - "WAITFOR", "WHEN", "WHERE", "WHILE", "WITH", - "WRITE", "WRITETEXT", "XOR", "YEAR_MONTH", "ZEROFILL" - ); - - return $reservedWordsSql; - } - - /* Friendly functions. - /** - * isWinOs - * - * @return true if the 3 first letters of PHP_OS got 'WIN', otherwise false. - */ - function isWinOs() - { - return strtoupper(substr(PHP_OS, 0, 3)) == "WIN"; - } - - /** - * isNTOs - * - * @return true if PHP_OS is 'WINNT', otherwise false. - */ - function isNTOs() - { - return PHP_OS == "WINNT"; - } - - /** - * isLinuxOs - * - * @return true if PHP_OS (upper text) got 'LINUX', otherwise false. - */ - function isLinuxOs() - { - return strtoupper(PHP_OS) == "LINUX"; - } - - /** - * getDirSize - * - * @path of the directory that want to check. smaller than getDirectorySize function. - */ - function getDirSize($path) - { - $io = popen('/usr/bin/du -sb '.$path, 'r'); - $size = intval(fgets($io,80)); - pclose($io); - return $size; - } - - /** - * getMinText, Used with longer size labels to minimize them, don't like it but works. - * - * @text Contains the text to be cut according to $maxTextLenght - * @maxTextLength got the max length of the text. - * return the min text plus '...' - */ - function getMinText ($text,$maxTextLenght) - { - $points = "..."; - $lengthPoints = strlen($points); - if(strlen($text) > $maxTextLenght){ - $text = substr($text,0,$maxTextLenght - $lengthPoints) . $points; - } - return $text;//TODO: perhaps it shouls return an array to don't loose the original string text - } - - /** - * isPMUnderUpdating, Used to set a file flag tio check if PM is upgrading. - * - * @setFlag Contains the flag to set or unset the temporary file: - * 0 to delete the temporary file flag - * 1 to set the temporary file flag. - * 2 or bigger to check if the temporary file exists. - * return true if the file exists, otherwise false. - */ - function isPMUnderUpdating($setFlag = 2) - { - $fileCheck = PATH_DATA."UPDATE.dat"; - if($setFlag == 0){ - if (file_exists($fileCheck)){ - unlink ($fileCheck); - } - } - else if($setFlag == 1){ - $fp = fopen($fileCheck,'w'); - $line = fputs($fp,"true"); - } - //checking temporary file - if($setFlag >= 1){ - if ( file_exists($fileCheck)){ - return true; - } - } - return false; - } + $reservedWordsSql = array ("ACCESSIBLE","ACTION","ADD","ALL","ALTER","ANALYZE","AND","ANY","AS","ASC","ASENSITIVE","AUTHORIZATION","BACKUP","BEFORE","BEGIN","BETWEEN","BIGINT","BINARY","BIT","BLOB","BOTH","BREAK","BROWSE","BULK","BY","CALL","CASCADE","CASE","CHANGE","CHAR","CHARACTER","CHECK","CHECKPOINT","CLOSE","CLUSTERED","COALESCE","COLLATE","COLUMN","COMMIT","COMPUTE","CONDITION","CONSTRAINT","CONTAINS","CONTAINSTABLE","CONTINUE","CONVERT","CREATE","CROSS","CURRENT","CURRENT_DATE","CURRENT_TIME","CURRENT_TIMESTAMP","CURRENT_USER","CURSOR","DATABASE","DATABASES","DATE","DAY_HOUR","DAY_MICROSECOND","DAY_MINUTE","DAY_SECOND","DBCC","DEALLOCATE","DEC","DECIMAL","DECLARE","DEFAULT","DELAYED","DELETE","DENY","DESC","DESCRIBE","DETERMINISTIC","DISK","DISTINCT","DISTINCTROW", + "DISTRIBUTED","DIV","DOUBLE","DROP","DUAL","DUMMY","DUMP","EACH","ELSE","ELSEIF","ENCLOSED","END","ENUM","ERRLVL","ESCAPE","ESCAPED","EXCEPT","EXEC","EXECUTE","EXISTS","EXIT","EXPLAIN","FALSE","FETCH","FILE","FILLFACTOR","FLOAT","FLOAT4","FLOAT8","FOR","FORCE","FOREIGN","FREETEXT","FREETEXTTABLE","FROM","FULL","FULLTEXT","FUNCTION","GENERAL","GOTO","GRANT","GROUP","HAVING","HIGH_PRIORITY","HOLDLOCK","HOUR_MICROSECOND","HOUR_MINUTE","HOUR_SECOND","IDENTITY","IDENTITYCOL","IDENTITY_INSERT","IF","IGNORE","IGNORE_SERVER_IDS","IN","INDEX","INFILE","INNER","INOUT","INSENSITIVE","INSERT","INT","INT1","INT2","INT3","INT4","INT8","INTEGER","INTERSECT","INTERVAL","INTO","IS","ITERATE","JOIN","KEY","KEYS","KILL","LEADING","LEAVE","LEFT","LIKE","LIMIT","LINEAR","LINENO","LINES", + "LOAD","LOCALTIME","LOCALTIMESTAMP","LOCK","LONG","LONGBLOB","LONGTEXT","LOOP","LOW_PRIORITY","MASTER_HEARTBEAT_PERIOD","MASTER_SSL_VERIFY_SERVER_CERT","MATCH","MAXVALUE","MEDIUMBLOB","MEDIUMINT","MEDIUMTEXT","MIDDLEINT","MINUTE_MICROSECOND","MINUTE_SECOND","MOD","MODIFIES","NATIONAL","NATURAL","NO","NOCHECK","NONCLUSTERED","NOT","NO_WRITE_TO_BINLOG","NULL","NULLIF","NUMERIC","OF","OFF","OFFSETS","ON","OPEN","OPENDATASOURCE","OPENQUERY","OPENROWSET","OPENXML","OPTIMIZE","OPTION","OPTIONALLY","OR","ORDER","OUT","OUTER","OUTFILE","OVER","PERCENT","PLAN","PRECISION","PRIMARY","PRINT","PROC","PROCEDURE","PUBLIC","PURGE","RAISERROR","RANGE","READ","READS","READTEXT","READ_WRITE","REAL","RECONFIGURE","REFERENCES","REGEXP","RELEASE","RENAME","REPEAT","REPLACE", + "REPLICATION","REQUIRE","RESIGNAL","RESTORE","RESTRICT","RETURN","REVOKE","RIGHT","RLIKE","ROLLBACK","ROWCOUNT","ROWGUIDCOL","RULE","SAVE","SCHEMA","SCHEMAS","SECOND_MICROSECOND","SELECT","SENSITIVE","SEPARATOR","SESSION_USER","SET","SETUSER","SHOW","SHUTDOWN","SIGNAL","SLOW","SMALLINT","SOME","SPATIAL","SPECIFIC","SQL","SQLEXCEPTION","SQLSTATE","SQLWARNING","SQL_BIG_RESULT","SQL_CALC_FOUND_ROWS","SQL_SMALL_RESULT","SSL","STARTING","STATISTICS","STRAIGHT_JOIN","SYSTEM_USER","TABLE","TERMINATED","TEXT","TEXTSIZE","THEN","TIME","TIMESTAMP","TINYBLOB","TINYINT","TINYTEXT","TO","TOP","TRAILING","TRAN","TRANSACTION","TRIGGER","TRUE","TRUNCATE","TSEQUAL","UNDO","UNION","UNIQUE","UNLOCK","UNSIGNED","UPDATE","UPDATETEXT","USAGE","USE","USER","USING","UTC_DATE","UTC_TIME", + "UTC_TIMESTAMP","VALUES","VARBINARY","VARCHAR","VARCHARACTER","VARYING","VIEW","WAITFOR","WHEN","WHERE","WHILE","WITH","WRITE","WRITETEXT","XOR","YEAR_MONTH","ZEROFILL"); + return $reservedWordsSql; + } +} + +/** + * eprint + * + * @param string $s default value '' + * @param string $c default value null + * + * @return void + */ +function eprint ($s = "", $c = null) +{ + if (G::isHttpRequest()) { + if (isset( $c )) { + echo "
$s
"; + } else { + echo "
$s
"; + } + } else { + if (isset( $c )) { + switch ($c) { + case 'green': + printf( "\033[0;35;32m$s\033[0m" ); + return; + case 'red': + printf( "\033[0;35;31m$s\033[0m" ); + return; + case 'blue': + printf( "\033[0;35;34m$s\033[0m" ); + return; + default: + print "$s"; + } + } else { + print "$s"; + } + } +} + +/** + * println + * + * @param string $s + * + * @return eprintln($s) + */ +function println ($s) +{ + return eprintln( $s ); +} + +/** + * eprintln + * + * @param string $s + * @param string $c + * + * @return void + */ +function eprintln ($s = "", $c = null) +{ + if (G::isHttpRequest()) { + if (isset( $c )) { + echo "
$s
"; + } else { + echo "
$s
"; + } + } else { + if (isset( $c ) && (PHP_OS != 'WINNT')) { + switch ($c) { + case 'green': + printf( "\033[0;35;32m$s\033[0m\n" ); + return; + case 'red': + printf( "\033[0;35;31m$s\033[0m\n" ); + return; + case 'blue': + printf( "\033[0;35;34m$s\033[0m\n" ); + return; + } + } + print "$s\n"; + } +} + +function __ ($msgID, $lang = SYS_LANG, $data = null) +{ + return G::LoadTranslation( $msgID, $lang, $data ); } -/** - * eprint - * - * @param string $s default value '' - * @param string $c default value null - * - * @return void - */ -function eprint($s = "", $c = null){ - if( G::isHttpRequest() ){ - if(isset($c)){ - echo "
$s
"; - } else - echo "
$s
"; - } else { - if(isset($c)){ - switch($c){ - case 'green': - printf("\033[0;35;32m$s\033[0m"); - return; - case 'red': - printf("\033[0;35;31m$s\033[0m"); - return; - case 'blue': - printf("\033[0;35;34m$s\033[0m"); - return; - default: print "$s"; - } - } else - print "$s"; - } -} - -/** - * println - * - * @param string $s - * - * @return eprintln($s) - */ -function println($s){ - return eprintln($s); -} - -/** - * eprintln - * - * @param string $s - * @param string $c - * - * @return void - */ -function eprintln($s="", $c=null){ - if( G::isHttpRequest() ){ - if(isset($c)){ - echo "
$s
"; - } else - echo "
$s
"; - } else { - if(isset($c) && (PHP_OS != 'WINNT')){ - switch($c){ - case 'green': - printf("\033[0;35;32m$s\033[0m\n"); - return; - case 'red': - printf("\033[0;35;31m$s\033[0m\n"); - return; - case 'blue': - printf("\033[0;35;34m$s\033[0m\n"); - return; - } - } - print "$s\n"; - } - - -} - -function __($msgID , $lang = SYS_LANG, $data = null) -{ - return G::LoadTranslation($msgID, $lang, $data); -} diff --git a/gulliver/system/class.headPublisher.php b/gulliver/system/class.headPublisher.php old mode 100755 new mode 100644 index 699fc2fae..b857d5788 --- a/gulliver/system/class.headPublisher.php +++ b/gulliver/system/class.headPublisher.php @@ -1,6 +1,8 @@ . + * along with this program. If not, see . * * For more information, contact Colosa Inc, 2566 Le Jeune Rd., * Coral Gables, FL, 33134, USA, or email info@colosa.com. @@ -25,634 +27,675 @@ */ /** * Class headPublisher + * * @author David S. Callizaya S. * @package gulliver.system * @access public */ -class headPublisher { - private static $instance = NULL; - var $maborakFiles = array (); - var $maborakLoaderFiles = array (); - var $scriptFiles = array (); - var $leimnudLoad = array (); +class headPublisher +{ + private static $instance = null; + var $maborakFiles = array (); + var $maborakLoaderFiles = array (); + var $scriptFiles = array (); + var $leimnudLoad = array (); - /* extJsSkin init coreLoad flag*/ - var $extJsInit = 'false'; + /* extJsSkin init coreLoad flag*/ + var $extJsInit = 'false'; - /* extJsSkin store the current skin for the ExtJs*/ - var $extJsSkin = ''; + /* extJsSkin store the current skin for the ExtJs*/ + var $extJsSkin = ''; - /* extJsScript Array, to store the file to be include */ - var $extJsScript = array (); + /* extJsScript Array, to store the file to be include */ + var $extJsScript = array (); - /* extJsLibrary Array, to store extended ExtJs lybraries */ - var $extJsLibrary = array (); + /* extJsLibrary Array, to store extended ExtJs lybraries */ + var $extJsLibrary = array (); - /* extJsContent Array, to store the file to be include in the skin content */ - var $extJsContent = array (); + /* extJsContent Array, to store the file to be include in the skin content */ + var $extJsContent = array (); - /* extVariable array, to store the variables generated in PHP, and used in JavaScript */ - var $extVariable = array (); + /* extVariable array, to store the variables generated in PHP, and used in JavaScript */ + var $extVariable = array (); - /* variable array, to store the variables generated in PHP, and used in JavaScript */ - var $vars = array (); + /* variable array, to store the variables generated in PHP, and used in JavaScript */ + var $vars = array (); - /* tplVariable array, to store the variables for template power */ - var $tplVariable = array (); + /* tplVariable array, to store the variables for template power */ + var $tplVariable = array (); - var $leimnudInitString = ' var leimnud = new maborak(); + var $leimnudInitString = ' var leimnud = new maborak(); leimnud.make({ zip:true, inGulliver:true, modules :"dom,abbr,rpc,drag,drop,app,panel,fx,grid,xmlform,validator,dashboard", files :"" });'; - var $headerScript = ' + var $headerScript = ' try{ leimnud.exec(leimnud.fix.memoryLeak); if(leimnud.browser.isIphone){ leimnud.iphone.make(); } }catch(e){}'; - var $disableHeaderScripts = false; - var $title = ''; + var $disableHeaderScripts = false; + var $title = ''; - /** - * Function headPublisher - * @author David S. Callizaya S. - * @access public - * @return string - */ + /** + * Function headPublisher + * + * @author David S. Callizaya S. + * @access public + * @return string + */ - public function __construct() { - $this->addScriptFile ( "/js/maborak/core/maborak.js" ); - } - - function &getSingleton() { - if (self::$instance == NULL) { - self::$instance = new headPublisher ( ); + public function __construct () + { + $this->addScriptFile( "/js/maborak/core/maborak.js" ); } - return self::$instance; - } - /** - * Function setTitle - * @author David S. Callizaya S. - * @access public - * @parameter string url - * @parameter string LoadType - * @return string - */ - function setTitle($title) { - $this->title = $title; - } + function &getSingleton () + { + if (self::$instance == null) { + self::$instance = new headPublisher(); + } + return self::$instance; + } - /** - * Function addMaborakFile - * @access public - * @parameter string filename - * @parameter string loader; false -> maborak files, true maborak.loader - * @return string - */ - function addMaborakFile($filename, $loader = false) { - if ($loader) - $this->maborakLoaderFiles [] = $filename; - else - $this->maborakFiles [] = $filename; - } + /** + * Function setTitle + * + * @author David S. Callizaya S. + * @access public + * @param eter string url + * @param eter string LoadType + * @return string + */ + function setTitle ($title) + { + $this->title = $title; + } - /** - * Function addScriptFile - * @author David S. Callizaya S. - * @access public - * @parameter string url - * @parameter string LoadType - * @return string - */ - function addScriptFile($url, $LoadType = 1) { - if ($LoadType == 1) - $this->scriptFiles [$url] = $url; - if ($LoadType == 2) - $this->leimnudLoad [$url] = $url; - } + /** + * Function addMaborakFile + * + * @access public + * @param eter string filename + * @param eter string loader; false -> maborak files, true maborak.loader + * @return string + */ + function addMaborakFile ($filename, $loader = false) + { + if ($loader) { + $this->maborakLoaderFiles[] = $filename; + } else { + $this->maborakFiles[] = $filename; + } + } - /** - * Function addInstanceModule - * @author David S. Callizaya S. - * @access public - * @parameter string instance - * @parameter string module - * @return string - */ + /** + * Function addScriptFile + * + * @author David S. Callizaya S. + * @access public + * @param eter string url + * @param eter string LoadType + * @return string + */ + function addScriptFile ($url, $LoadType = 1) + { + if ($LoadType == 1) { + $this->scriptFiles[$url] = $url; + } + if ($LoadType == 2) { + $this->leimnudLoad[$url] = $url; + } + } - function addInstanceModule($instance, $module) { - $this->headerScript .= "leimnud.Package.Load('" . $module . "',{Instance:" . $instance . ",Type:'module'});\n"; - } + /** + * Function addInstanceModule + * + * @author David S. Callizaya S. + * @access public + * @param eter string instance + * @param eter string module + * @return string + */ - /** - * Function addClassModule - * @author David S. Callizaya S. - * @access public - * @parameter string class - * @parameter string module - * @return string - */ - function addClassModule($class, $module) { - $this->headerScript .= "leimnud.Package.Load('" . $module . "',{Class:" . $class . ",Type:'module'});\n"; - } + function addInstanceModule ($instance, $module) + { + $this->headerScript .= "leimnud.Package.Load('" . $module . "',{Instance:" . $instance . ",Type:'module'});\n"; + } - /** - * Function addScriptCode - * @author David S. Callizaya S. - * @access public - * @parameter string script - * @return string - */ - function addScriptCode($script) { - $this->headerScript .= $script; - } + /** + * Function addClassModule + * + * @author David S. Callizaya S. + * @access public + * @param eter string class + * @param eter string module + * @return string + */ + function addClassModule ($class, $module) + { + $this->headerScript .= "leimnud.Package.Load('" . $module . "',{Class:" . $class . ",Type:'module'});\n"; + } - /** - * Function printHeader - * @author David S. Callizaya S. - * @access public - * @return string - */ - function printHeader() { - $jslabel = 'labels/en.js'; - if (defined ( 'SYS_LANG' )) { - $jslabel = 'labels' . PATH_SEP . SYS_LANG . '.js'; - if (! file_exists ( PATH_CORE . 'js' . PATH_SEP . $jslabel )) + /** + * Function addScriptCode + * + * @author David S. Callizaya S. + * @access public + * @param eter string script + * @return string + */ + function addScriptCode ($script) + { + $this->headerScript .= $script; + } + + /** + * Function printHeader + * + * @author David S. Callizaya S. + * @access public + * @return string + */ + function printHeader () + { $jslabel = 'labels/en.js'; - } - if (file_exists ( PATH_CORE . 'js' . PATH_SEP . $jslabel )) { - $this->addScriptFile ( '/jscore/' . $jslabel, 1 ); - } - if ($this->disableHeaderScripts) - return ''; - - // available js-calendar languages array - $availableJsCalendarLang = array('ca', 'cn', 'cz', 'de', 'en', 'es', 'fr', 'it', 'jp', 'nl', 'pl', 'pt', 'ro', 'ru', 'sv'); - - // get the system language without locale - $sysLang = explode('-', SYS_LANG); - $sysLang = $sysLang[0]; - - // verify if the requested lang by the system is supported by js-calendar library, if not set english by default - $sysLang = in_array($sysLang, $availableJsCalendarLang) ? $sysLang : 'en'; - - $this->addScriptFile ( "/js/widgets/js-calendar/unicode-letter.js" ); - $this->addScriptFile ( "/js/widgets/js-calendar/lang/".$sysLang.".js" ); - - $head = ''; - $head .= '' . $this->title . "\n"; - foreach ( $this->scriptFiles as $file ) - $head .= "\n"; - $head .= "\n"; - return $head; - } - - /** - * Function printRawHeader - * Its prupose is to load el HEADs initialization javascript - * into a single SCRIPT tag, it is usefull when it is needed - * to load a page by leimnud floating panel of by another ajax - * method. (See also RAW skin) - * - * @author David S. Callizaya S. - * @access public - * @return string - */ - function printRawHeader() { - $jslabel = '/jscore/labels/en.js'; - if (defined ( 'SYS_LANG' )) { - $jslabel1 = 'labels' . PATH_SEP . SYS_LANG . '.js'; - if (! file_exists ( PATH_CORE . 'js' . PATH_SEP . $jslabel1 )) - $jslabel = '/jscore/labels/en.js'; - } - $head = ''; - //$head .= "\n"; - return $head; - } - - /** - * Function clearScripts - * Its prupose is to clear all the scripts of the header. - * - * @author David S. Callizaya S. - * @access public - * @return string - */ - function clearScripts() { - $this->scriptFiles = array (); - $this->leimnudLoad = array (); - $this->leimnudInitString = ''; - $this->headerScript = ''; - } - - /** - * Function includeExtJs - * with this function we are using the ExtJs library, this library is not compatible with - * previous libraries, for that reason oHeadPublisher will clear previous libraries like maborak - * we need to check if we need the language file - * this function returns the header needed to render a page using ExtJs - * - * @author Fernando Ontiveros - * @access public - * @return string - */ - function includeExtJs() { - $this->clearScripts (); - $head = ''; - $head .= " \n"; - $head .= " \n"; - $aux = explode('-', strtolower(SYS_LANG)); - if (($aux[0] != 'en') && file_exists(PATH_GULLIVER_HOME . 'js' . PATH_SEP . 'ext' . PATH_SEP . 'locale' . PATH_SEP . 'ext-lang-' . $aux[0] . '.js')) { - $head .= " \n"; - } - - // enabled for particular use - $head .= $this->getExtJsLibraries(); - - // $head .= " \n"; - $head .= " \n"; - - if (! isset ( $this->extJsSkin ) || $this->extJsSkin == '') { - $this->extJsSkin = 'xtheme-gray'; - //$this->extJsSkin = 'gtheme'; - } - - //$head .= $this->getExtJsStylesheets(); - $head .= $this->getExtJsScripts(); - $head .= $this->getExtJsVariablesScript(); - - $oServerConf =& serverConf::getSingleton(); - if ($oServerConf->isRtl(SYS_LANG)) { - $head .= " \n"; - } - - return $head; - } - - function getExtJsStylesheets($skinName){ - $script = " \n"; - $script .= " \n"; -/* - $script .= " \n"; - $script .= " \n"; - - // - - //new interactive css decorator - $script .= " \n"; - $script .= " \n"; -*/ - // Load external/plugin css - // NOTE is necesary to move this to decorator server - if(class_exists('PMPluginRegistry')){ - $oPluginRegistry = & PMPluginRegistry::getSingleton (); - $registeredCss=$oPluginRegistry->getRegisteredCss(); - foreach($registeredCss as $cssFile){ - $script .= " \n"; - } - } - - return $script; - } - - function getExtJsScripts(){ - $script = ''; - if (isset ( $this->extJsScript ) && is_array ( $this->extJsScript )) { - foreach ( $this->extJsScript as $key => $file ) { - $script .= " \n"; - } - } - return $script; - } - - function getExtJsVariablesScript(){ - $script = ''; - - if (count ( $this->extVariable ) > 0) { - $script = "\n"; - } - - return $script; - } - - function getExtJsLibraries() - { - $script = ''; - if (isset ( $this->extJsLibrary ) && is_array ( $this->extJsLibrary )) { - foreach ( $this->extJsLibrary as $file ) { - $script .= " \n"; - } - } - return $script; - } - - /** - * add a ExtJS extended library - * - * @author Erik A. Ortiz - * @access public - * @param (String) http js path library - * @return none - */ - function usingExtJs($library) { - if (! is_string ( $library )) { - throw new Exception ( 'headPublisher::usingExt->ERROR - the parameter should be a js path string' ); - } - array_push ( $this->extJsLibrary, $library ); - } - - /** - * Function setExtSkin - * with this function we are using the ExtJs library, this library is not compatible with - * previous libraries, for that reason oHeadPublisher will clear previous libraries like maborak - * we need to check if we need the language file - * - * @author Fernando Ontiveros - * @access public - * @return string - */ - function setExtSkin($skin) { - $this->extJsSkin = $skin; - } - - /** - * Function addExtJsScript - * adding a javascript file .js - * add a js file in the extension Javascript Array, - * later, when we use the includeExtJs function, all the files in this array will be included in the output - * if the second argument is true, the file will not be minified, this is useful for debug purposes. - * - * Feature added - - * - Hook to find javascript registered from plugins and load them - * - * @author Fernando Ontiveros - * @author Erik Amaru Ortiz - * @access public - * @return string - */ - function addExtJsScript($filename, $debug = false, $isExternal=false) { - - $sPath = PATH_TPL; - //if the template file doesn't exists, then try with the plugins folders - - - if (! is_file ( $sPath . $filename . ".js" )) { - $aux = explode ( PATH_SEP, $filename ); - //check if G_PLUGIN_CLASS is defined, because publisher can be called without an environment - if (count ( $aux ) == 2 && defined ( 'G_PLUGIN_CLASS' )) { - $oPluginRegistry = & PMPluginRegistry::getSingleton (); - if ($oPluginRegistry->isRegisteredFolder ( $aux [0] )) { - $sPath = PATH_PLUGINS; - } - } - } - - if (!$isExternal) - $jsFilename = $sPath . $filename . '.js'; - else - $jsFilename = $filename . '.js'; - - if (! file_exists ( $jsFilename )) { - return; - } - - $mtime = filemtime ( $jsFilename ); - G::mk_dir ( PATH_C . 'ExtJs' ); - if ($debug) { - $cacheName = str_replace ( '/', '_', $filename ); - $cacheFilename = PATH_C . 'ExtJs' . PATH_SEP . $cacheName . '.js'; - file_put_contents ( $cacheFilename, file_get_contents ( $jsFilename ) ); - } - else { - $cacheName = md5 ( $mtime . $jsFilename ); - $cacheFilename = PATH_C . 'ExtJs' . PATH_SEP . $cacheName . '.js'; - - if (! file_exists ( $cacheFilename )) { - require_once (PATH_THIRDPARTY . 'jsmin/jsmin.php'); - $content = JSMin::minify ( file_get_contents ( $jsFilename ) ); - file_put_contents ( $cacheFilename, $content ); - } - } - - - $this->extJsScript [] = '/extjs/' . $cacheName; - - //hook for registered javascripts from plugins - if ( class_exists( 'PMPluginRegistry' ) ) { - $oPluginRegistry = & PMPluginRegistry::getSingleton(); - $pluginJavascripts = $oPluginRegistry->getRegisteredJavascriptBy($filename); - } - else - $pluginJavascripts = array(); - - if (count($pluginJavascripts) > 0) { - if ($debug) { - foreach ($pluginJavascripts as $pluginJsFile) { - $jsPluginCacheName = ''; - if (substr($pluginJsFile, -3) != '.js') { - $pluginJsFile .= '.js'; - } - - if (file_exists(PATH_PLUGINS . $pluginJsFile)) { - $jsPluginCacheName = str_replace ( '/', '_', str_replace('.js', '', $pluginJsFile) ); - $cacheFilename = PATH_C . 'ExtJs' . PATH_SEP . $jsPluginCacheName.".js"; - file_put_contents ( $cacheFilename, file_get_contents ( PATH_PLUGINS . $pluginJsFile ) ); - } - if ($jsPluginCacheName != '') { - $this->extJsScript [] = '/extjs/' . $jsPluginCacheName; - } - } - } - else { - foreach ($pluginJavascripts as $pluginJsFile) { - $jsPluginCacheName = ''; - if (substr($pluginJsFile, -3) !== '.js') { - $pluginJsFile .= '.js'; - } - if (file_exists(PATH_PLUGINS . $pluginJsFile)) { - $mtime = filemtime ( PATH_PLUGINS . $pluginJsFile ); - $jsPluginCacheName = md5 ( $mtime . $pluginJsFile ); - $cacheFilename = PATH_C . 'ExtJs' . PATH_SEP . $jsPluginCacheName . '.js'; - - if (! file_exists ( $cacheFilename )) { - require_once (PATH_THIRDPARTY . 'jsmin/jsmin.php'); - $content = JSMin::minify ( file_get_contents ( PATH_PLUGINS . $pluginJsFile ) ); - file_put_contents ( $cacheFilename, $content ); + if (defined( 'SYS_LANG' )) { + $jslabel = 'labels' . PATH_SEP . SYS_LANG . '.js'; + if (! file_exists( PATH_CORE . 'js' . PATH_SEP . $jslabel )) { + $jslabel = 'labels/en.js'; } - } - if ($jsPluginCacheName != '') { - $this->extJsScript [] = '/extjs/' . $jsPluginCacheName; - } } - } + if (file_exists( PATH_CORE . 'js' . PATH_SEP . $jslabel )) { + $this->addScriptFile( '/jscore/' . $jslabel, 1 ); + } + if ($this->disableHeaderScripts) { + return ''; + } + + // available js-calendar languages array + $availableJsCalendarLang = array ('ca','cn','cz','de','en','es','fr','it','jp','nl','pl','pt','ro','ru','sv'); + + // get the system language without locale + $sysLang = explode( '-', SYS_LANG ); + $sysLang = $sysLang[0]; + + // verify if the requested lang by the system is supported by js-calendar library, if not set english by default + $sysLang = in_array( $sysLang, $availableJsCalendarLang ) ? $sysLang : 'en'; + + $this->addScriptFile( "/js/widgets/js-calendar/unicode-letter.js" ); + $this->addScriptFile( "/js/widgets/js-calendar/lang/" . $sysLang . ".js" ); + + $head = ''; + $head .= '' . $this->title . "\n"; + foreach ($this->scriptFiles as $file) { + $head .= "\n"; + } + $head .= "\n"; + return $head; } - //end hook for registered javascripts from plugins - } + /** + * Function printRawHeader + * Its prupose is to load el HEADs initialization javascript + * into a single SCRIPT tag, it is usefull when it is needed + * to load a page by leimnud floating panel of by another ajax + * method. (See also RAW skin) + * + * @author David S. Callizaya S. + * @access public + * @return string + */ + function printRawHeader () + { + $jslabel = '/jscore/labels/en.js'; + if (defined( 'SYS_LANG' )) { + $jslabel1 = 'labels' . PATH_SEP . SYS_LANG . '.js'; + if (! file_exists( PATH_CORE . 'js' . PATH_SEP . $jslabel1 )) { + $jslabel = '/jscore/labels/en.js'; + } + } + $head = ''; + //$head .= "\n"; + return $head; + } - /** - * Function AddContent - * adding a html file .html. - * the main idea for this function, is to be a replacement to homonymous function in Publisher class. - * with this function you are adding Content to the output, the class HeadPublisher will maintain a list of - * files to render in the body of the output page - * - * @author Fernando Ontiveros - * @access public - * @return string - */ - function AddContent($templateHtml) { - $this->extJsContent [] = $templateHtml; - } + /** + * Function clearScripts + * Its prupose is to clear all the scripts of the header. + * + * @author David S. Callizaya S. + * @access public + * @return string + */ + function clearScripts () + { + $this->scriptFiles = array (); + $this->leimnudLoad = array (); + $this->leimnudInitString = ''; + $this->headerScript = ''; + } - function getContent() { - return $this->extJsContent; - } + /** + * Function includeExtJs + * with this function we are using the ExtJs library, this library is not compatible with + * previous libraries, for that reason oHeadPublisher will clear previous libraries like maborak + * we need to check if we need the language file + * this function returns the header needed to render a page using ExtJs + * + * @author Fernando Ontiveros + * @access public + * @return string + */ + function includeExtJs () + { + $this->clearScripts(); + $head = ''; + $head .= " \n"; + $head .= " \n"; + $aux = explode( '-', strtolower( SYS_LANG ) ); + if (($aux[0] != 'en') && file_exists( PATH_GULLIVER_HOME . 'js' . PATH_SEP . 'ext' . PATH_SEP . 'locale' . PATH_SEP . 'ext-lang-' . $aux[0] . '.js' )) { + $head .= " \n"; + } - /** - * Function assign - * assign a STRING value to a JS variable - * use this function to send from PHP variables to be used in JavaScript - * - * @author Fernando Ontiveros - * @access public - * @return string - */ - function Assign($variable, $value) { - $this->extVariable [] = array ('name' => $variable, 'value' => $value, 'type' => 'string' ); - } + // enabled for particular use + $head .= $this->getExtJsLibraries(); - function AssignVar($name, $value) { - $this->vars [$name] = $value; - } + // $head .= " \n"; + $head .= " \n"; - function getVars() { - return $this->vars; - } + if (! isset( $this->extJsSkin ) || $this->extJsSkin == '') { + $this->extJsSkin = 'xtheme-gray'; + //$this->extJsSkin = 'gtheme'; + } + //$head .= $this->getExtJsStylesheets(); + $head .= $this->getExtJsScripts(); + $head .= $this->getExtJsVariablesScript(); + $oServerConf = & serverConf::getSingleton(); + if ($oServerConf->isRtl( SYS_LANG )) { + $head .= " \n"; + } - /** - * Function assignNumber - * assign a Number value to a JS variable - * use this function to send from PHP variables to be used in JavaScript - * - * @author Fernando Ontiveros - * @access public - * @return string - */ - function AssignNumber($variable, $value) { - $this->extVariable [] = array ('name' => $variable, 'value' => $value, 'type' => 'number' ); - } - /** - * Function renderExtJs - * this function returns the content rendered using ExtJs - * extJsContent have an array, and we iterate this array to draw the content - * - * @author Fernando Ontiveros - * @access public - * @return string - */ - function renderExtJs() { - $body = ''; - if (isset ( $this->extJsContent ) && is_array ( $this->extJsContent )) { - foreach ( $this->extJsContent as $key => $file ) { + return $head; + } + + function getExtJsStylesheets ($skinName) + { + $script = " \n"; + $script .= " \n"; + /* + $script .= " \n"; + $script .= " \n"; + + // + + //new interactive css decorator + $script .= " \n"; + $script .= " \n"; + */ + // Load external/plugin css + // NOTE is necesary to move this to decorator server + if (class_exists( 'PMPluginRegistry' )) { + $oPluginRegistry = & PMPluginRegistry::getSingleton(); + $registeredCss = $oPluginRegistry->getRegisteredCss(); + foreach ($registeredCss as $cssFile) { + $script .= " \n"; + } + } + return $script; + } + + function getExtJsScripts () + { + $script = ''; + if (isset( $this->extJsScript ) && is_array( $this->extJsScript )) { + foreach ($this->extJsScript as $key => $file) { + $script .= " \n"; + } + } + return $script; + } + + function getExtJsVariablesScript () + { + $script = ''; + if (count( $this->extVariable ) > 0) { + $script = "\n"; + } + return $script; + } + + function getExtJsLibraries () + { + $script = ''; + if (isset( $this->extJsLibrary ) && is_array( $this->extJsLibrary )) { + foreach ($this->extJsLibrary as $file) { + $script .= " \n"; + } + } + return $script; + } + + /** + * add a ExtJS extended library + * + * @author Erik A. Ortiz + * @access public + * @param (String) http js path library + * @return none + */ + function usingExtJs ($library) + { + if (! is_string( $library )) { + throw new Exception( 'headPublisher::usingExt->ERROR - the parameter should be a js path string' ); + } + array_push( $this->extJsLibrary, $library ); + } + + /** + * Function setExtSkin + * with this function we are using the ExtJs library, this library is not compatible with + * previous libraries, for that reason oHeadPublisher will clear previous libraries like maborak + * we need to check if we need the language file + * + * @author Fernando Ontiveros + * @access public + * @return string + */ + function setExtSkin ($skin) + { + $this->extJsSkin = $skin; + } + + /** + * Function addExtJsScript + * adding a javascript file . + * js + * add a js file in the extension Javascript Array, + * later, when we use the includeExtJs function, all the files in this array will be included in the output + * if the second argument is true, the file will not be minified, this is useful for debug purposes. + * + * Feature added - + * - Hook to find javascript registered from plugins and load them + * + * @author Fernando Ontiveros + * @author Erik Amaru Ortiz + * @access public + * @return string + */ + function addExtJsScript ($filename, $debug = false, $isExternal = false) + { $sPath = PATH_TPL; //if the template file doesn't exists, then try with the plugins folders - if (! is_file ( $sPath . $file . ".html" )) { - $aux = explode ( PATH_SEP, $file ); - //check if G_PLUGIN_CLASS is defined, because publisher can be called without an environment - if (count ( $aux ) == 2 && defined ( 'G_PLUGIN_CLASS' )) { - $oPluginRegistry = & PMPluginRegistry::getSingleton (); - if ($oPluginRegistry->isRegisteredFolder ( $aux [0] )) { - $sPath = PATH_PLUGINS; + + + if (! is_file( $sPath . $filename . ".js" )) { + $aux = explode( PATH_SEP, $filename ); + //check if G_PLUGIN_CLASS is defined, because publisher can be called without an environment + if (count( $aux ) == 2 && defined( 'G_PLUGIN_CLASS' )) { + $oPluginRegistry = & PMPluginRegistry::getSingleton(); + if ($oPluginRegistry->isRegisteredFolder( $aux[0] )) { + $sPath = PATH_PLUGINS; + } } - } } - $template = new TemplatePower ( $sPath . $file . '.html' ); - $template->prepare (); - - foreach ($this->getVars() as $k => $v) { - $template->assign($k, $v); + if (! $isExternal) { + $jsFilename = $sPath . $filename . '.js'; + } else { + $jsFilename = $filename . '.js'; } - $body .= $template->getOutputContent (); - } - } - return $body; - } + if (! file_exists( $jsFilename )) { + return; + } - function stripCodeQuotes($sJson){ - $fields = array( "editor", "renderer" ); - foreach ($fields as $field) { - $pattern = '/"('.$field.')":"[a-zA-Z.()]*"/'; -// echo $pattern."
"; - preg_match ($pattern,$sJson,$matches); -// var_dump ($matches); -// echo "
"; - if (!empty($matches)){ - $rendererMatch = $matches[0]; - $replaceBy = explode(":", $matches[0]); - $replaceBy[1] = str_replace('"','',$replaceBy[1]); - $tmpString = implode(":",$replaceBy); - $sJson = str_replace($rendererMatch, $tmpString, $sJson); -// var_dump ($sJson); -// echo "
"; - } - } - return $sJson; - } + $mtime = filemtime( $jsFilename ); + G::mk_dir( PATH_C . 'ExtJs' ); + if ($debug) { + $cacheName = str_replace( '/', '_', $filename ); + $cacheFilename = PATH_C . 'ExtJs' . PATH_SEP . $cacheName . '.js'; + file_put_contents( $cacheFilename, file_get_contents( $jsFilename ) ); + } else { + $cacheName = md5( $mtime . $jsFilename ); + $cacheFilename = PATH_C . 'ExtJs' . PATH_SEP . $cacheName . '.js'; - /** - * Function disableHeaderScripts - * this function sets disableHeaderScripts to true - * to avoid print scripts into the header - * - * @author Enrique Ponce de Leom - * @access public - * @return string - */ - function disableHeaderScripts(){ - $this->disableHeaderScripts = true; - } + if (! file_exists( $cacheFilename )) { + require_once (PATH_THIRDPARTY . 'jsmin/jsmin.php'); + $content = JSMin::minify( file_get_contents( $jsFilename ) ); + file_put_contents( $cacheFilename, $content ); + } + } + + $this->extJsScript[] = '/extjs/' . $cacheName; + + //hook for registered javascripts from plugins + if (class_exists( 'PMPluginRegistry' )) { + $oPluginRegistry = & PMPluginRegistry::getSingleton(); + $pluginJavascripts = $oPluginRegistry->getRegisteredJavascriptBy( $filename ); + } else { + $pluginJavascripts = array (); + } + + if (count( $pluginJavascripts ) > 0) { + if ($debug) { + foreach ($pluginJavascripts as $pluginJsFile) { + $jsPluginCacheName = ''; + if (substr( $pluginJsFile, - 3 ) != '.js') { + $pluginJsFile .= '.js'; + } + + if (file_exists( PATH_PLUGINS . $pluginJsFile )) { + $jsPluginCacheName = str_replace( '/', '_', str_replace( '.js', '', $pluginJsFile ) ); + $cacheFilename = PATH_C . 'ExtJs' . PATH_SEP . $jsPluginCacheName . ".js"; + file_put_contents( $cacheFilename, file_get_contents( PATH_PLUGINS . $pluginJsFile ) ); + } + if ($jsPluginCacheName != '') { + $this->extJsScript[] = '/extjs/' . $jsPluginCacheName; + } + } + } else { + foreach ($pluginJavascripts as $pluginJsFile) { + $jsPluginCacheName = ''; + if (substr( $pluginJsFile, - 3 ) !== '.js') { + $pluginJsFile .= '.js'; + } + if (file_exists( PATH_PLUGINS . $pluginJsFile )) { + $mtime = filemtime( PATH_PLUGINS . $pluginJsFile ); + $jsPluginCacheName = md5( $mtime . $pluginJsFile ); + $cacheFilename = PATH_C . 'ExtJs' . PATH_SEP . $jsPluginCacheName . '.js'; + + if (! file_exists( $cacheFilename )) { + require_once (PATH_THIRDPARTY . 'jsmin/jsmin.php'); + $content = JSMin::minify( file_get_contents( PATH_PLUGINS . $pluginJsFile ) ); + file_put_contents( $cacheFilename, $content ); + } + } + if ($jsPluginCacheName != '') { + $this->extJsScript[] = '/extjs/' . $jsPluginCacheName; + } + } + } + } + //end hook for registered javascripts from plugins + } + + /** + * Function AddContent + * adding a html file . + * html. + * the main idea for this function, is to be a replacement to homonymous function in Publisher class. + * with this function you are adding Content to the output, the class HeadPublisher will maintain a list of + * files to render in the body of the output page + * + * @author Fernando Ontiveros + * @access public + * @return string + */ + function AddContent ($templateHtml) + { + $this->extJsContent[] = $templateHtml; + } + + function getContent () + { + return $this->extJsContent; + } + + /** + * Function assign + * assign a STRING value to a JS variable + * use this function to send from PHP variables to be used in JavaScript + * + * @author Fernando Ontiveros + * @access public + * @return string + */ + function Assign ($variable, $value) + { + $this->extVariable[] = array ('name' => $variable,'value' => $value,'type' => 'string'); + } + + function AssignVar ($name, $value) + { + $this->vars[$name] = $value; + } + + function getVars () + { + return $this->vars; + } + + /** + * Function assignNumber + * assign a Number value to a JS variable + * use this function to send from PHP variables to be used in JavaScript + * + * @author Fernando Ontiveros + * @access public + * @return string + */ + function AssignNumber ($variable, $value) + { + $this->extVariable[] = array ('name' => $variable,'value' => $value,'type' => 'number'); + } + + /** + * Function renderExtJs + * this function returns the content rendered using ExtJs + * extJsContent have an array, and we iterate this array to draw the content + * + * @author Fernando Ontiveros + * @access public + * @return string + */ + function renderExtJs () + { + $body = ''; + if (isset( $this->extJsContent ) && is_array( $this->extJsContent )) { + foreach ($this->extJsContent as $key => $file) { + $sPath = PATH_TPL; + //if the template file doesn't exists, then try with the plugins folders + if (! is_file( $sPath . $file . ".html" )) { + $aux = explode( PATH_SEP, $file ); + //check if G_PLUGIN_CLASS is defined, because publisher can be called without an environment + if (count( $aux ) == 2 && defined( 'G_PLUGIN_CLASS' )) { + $oPluginRegistry = & PMPluginRegistry::getSingleton(); + if ($oPluginRegistry->isRegisteredFolder( $aux[0] )) { + $sPath = PATH_PLUGINS; + } + } + } + + $template = new TemplatePower( $sPath . $file . '.html' ); + $template->prepare(); + + foreach ($this->getVars() as $k => $v) { + $template->assign( $k, $v ); + } + + $body .= $template->getOutputContent(); + } + } + return $body; + } + + function stripCodeQuotes ($sJson) + { + $fields = array ("editor","renderer"); + foreach ($fields as $field) { + $pattern = '/"(' . $field . ')":"[a-zA-Z.()]*"/'; + // echo $pattern."
"; + preg_match( $pattern, $sJson, $matches ); + // var_dump ($matches); + // echo "
"; + if (! empty( $matches )) { + $rendererMatch = $matches[0]; + $replaceBy = explode( ":", $matches[0] ); + $replaceBy[1] = str_replace( '"', '', $replaceBy[1] ); + $tmpString = implode( ":", $replaceBy ); + $sJson = str_replace( $rendererMatch, $tmpString, $sJson ); + // var_dump ($sJson); + // echo "
"; + } + } + return $sJson; + } + + /** + * Function disableHeaderScripts + * this function sets disableHeaderScripts to true + * to avoid print scripts into the header + * + * @author Enrique Ponce de Leom + * @access public + * @return string + */ + function disableHeaderScripts () + { + $this->disableHeaderScripts = true; + } } + diff --git a/gulliver/system/class.soapNtlm.php b/gulliver/system/class.soapNtlm.php old mode 100755 new mode 100644 index db8cce921..dfc850a0d --- a/gulliver/system/class.soapNtlm.php +++ b/gulliver/system/class.soapNtlm.php @@ -1,308 +1,299 @@ -. - * - * For more information, contact Colosa Inc, 2566 Le Jeune Rd., - * Coral Gables, FL, 33134, USA, or email info@colosa.com. - * - */ +. + * + * For more information, contact Colosa Inc, 2566 Le Jeune Rd., + * Coral Gables, FL, 33134, USA, or email info@colosa.com. + * + */ /* SOAP NTLM * This class is used to extend SoapClient native PHP * to allow NTLM authentication throw soap connection - */ - -/** - * @package gulliver.system - */ -class soapNtlm { - - private $path; - private $mode; - private $options; - private $opened_path; - private $buffer; - private $pos; - - public function getuser() - { - return ""; - } - - public function getpassword() - { - return ""; - } - - /** - * Open the stream - * - * @param unknown_type $path - * @param unknown_type $mode - * @param unknown_type $options - * @param unknown_type $opened_path - * @return unknown - */ - public function stream_open($path, $mode, $options, $opened_path) { - //echo "[NTLMStream::stream_open] $path , mode=$mode
"; -//G::pr($options); - - $this->path = $path; - $this->mode = $mode; - $this->options = $options; - $this->opened_path = $opened_path; - - $this->createBuffer($this->path); - - return true; - } - - /** - * Close the stream - * - */ - public function stream_close() { - //echo "[NTLMStream::stream_close]
"; - curl_close($this->ch); - } - - /** - * Read the stream - * - * @param int $count number of bytes to read - * @return content from pos to count - */ - public function stream_read($count) { - //echo "[NTLMStream::stream_read] $count
"; - if (strlen($this->buffer) == 0) { - return false; - } - - $read = substr($this->buffer, $this->pos, $count); - - $this->pos += $count; - - return $read; - } - - /** - * write the stream - * - * @param int $count number of bytes to read - * @return content from pos to count - */ - public function stream_write($data) { - //echo "[NTLMStream::stream_write]
"; - if (strlen($this->buffer) == 0) { - return false; - } - return true; - } - - /** - * - * @return true if eof else false - */ - public function stream_eof() { - //echo "[NTLMStream::stream_eof] "; - if ($this->pos > strlen($this->buffer)) { - //echo "true
"; - return true; - } - - //echo "false
"; - return false; - } - - /** - * @return int the position of the current read pointer - */ - public function stream_tell() { - //echo "[NTLMStream::stream_tell]
"; - return $this->pos; - } - - /** - * Flush stream data - */ - public function stream_flush() { - //echo "[NTLMStream::stream_flush]
"; - $this->buffer = null; - $this->pos = null; - } - - /** - * Stat the file, return only the size of the buffer - * - * @return array stat information - */ - public function stream_stat() { - //echo "[NTLMStream::stream_stat]
"; - - $this->createBuffer($this->path); - $stat = array( - 'size' => strlen($this->buffer), - ); - - return $stat; - } - - /** - * Stat the url, return only the size of the buffer - * - * @return array stat information - */ - public function url_stat($path, $flags) { - //G::pr($this->options); - //echo "[NTLMStream::url_stat] -> $path
"; - $this->createBuffer($path); - $stat = array( - 'size' => strlen($this->buffer), - ); - - return $stat; - } - - /** - * Create the buffer by requesting the url through cURL - * - * @param unknown_type $path - */ - private function createBuffer($path) { - if ($this->buffer) { - return; - } - - //echo "[NTLMStream::createBuffer] create buffer from : $path
"; - $this->ch = curl_init($path); - curl_setopt($this->ch, CURLOPT_RETURNTRANSFER, true); - curl_setopt($this->ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1); - curl_setopt($this->ch, CURLOPT_HTTPAUTH, CURLAUTH_NTLM); - //curl_setopt($this->ch, CURLOPT_USERPWD, $this->options['auth']); // Hugo's code - curl_setopt($this->ch, CURLOPT_USERPWD, $this->getuser().':'.$this->getpassword());// Ankit's code - - //Apply proxy settings - if (class_exists('System')) { - $sysConf = System::getSystemConfiguration(); - if ($sysConf['proxy_host'] != '') { - curl_setopt($this->ch, CURLOPT_PROXY, $sysConf['proxy_host'] . ($sysConf['proxy_port'] != '' ? ':' . $sysConf['proxy_port'] : '')); - if ($sysConf['proxy_port'] != '') { - curl_setopt($this->ch, CURLOPT_PROXYPORT, $sysConf['proxy_port']); - } - if ($sysConf['proxy_user'] != '') { - curl_setopt($this->ch, CURLOPT_PROXYUSERPWD, $sysConf['proxy_user'] . ($sysConf['proxy_pass'] != '' ? ':' . $sysConf['proxy_pass'] : '')); - } - curl_setopt($this->ch, CURLOPT_HTTPHEADER, array('Expect:')); - } - } - - echo $this->buffer = curl_exec($this->ch); - - //echo "[NTLMStream::createBuffer] buffer size : " . strlen($this->buffer) . "bytes
"; - $this->pos = 0; - } - -} - -class NTLMSoapClient extends SoapClient { - - - function __doRequest($request, $location, $action, $version) { - $headers = array( - 'Method: POST', - 'Connection: Keep-Alive', - 'User-Agent: PHP-SOAP-CURL', - 'Content-Type: text/xml; charset=utf-8', - 'SOAPAction: "' . $action . '"', - ); - - $this->__last_request_headers = $headers; - $ch = curl_init($location); - curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); - curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); - curl_setopt($ch, CURLOPT_POST, true); - curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); - curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); - curl_setopt($ch, CURLOPT_POSTFIELDS, $request); - curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1); - curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_NTLM); - //curl_setopt($ch, CURLOPT_USERPWD, $this->options['auth']); //Hugo's Code - curl_setopt($ch, CURLOPT_USERPWD, $this->user.':'.$this->password); //Ankit's Code - - //Apply proxy settings - if (class_exists('System')) { - $sysConf = System::getSystemConfiguration(); - if ($sysConf['proxy_host'] != '') { - curl_setopt($ch, CURLOPT_PROXY, $sysConf['proxy_host'] . ($sysConf['proxy_port'] != '' ? ':' . $sysConf['proxy_port'] : '')); - if ($sysConf['proxy_port'] != '') { - curl_setopt($ch, CURLOPT_PROXYPORT, $sysConf['proxy_port']); - } - if ($sysConf['proxy_user'] != '') { - curl_setopt($ch, CURLOPT_PROXYUSERPWD, $sysConf['proxy_user'] . ($sysConf['proxy_pass'] != '' ? ':' . $sysConf['proxy_pass'] : '')); - } - curl_setopt($ch, CURLOPT_HTTPHEADER, array('Expect:')); - } - } - - $response = curl_exec($ch); - - return $response; - } - - function __getLastRequestHeaders() { - return implode("\n", $this->__last_request_headers) . "\n"; - } - -} - -class PMServiceNTLMSoapClient extends NTLMSoapClient { - protected $user; - protected $password; - - function setAuthClient($auth){ - $authInfo=explode(":",$auth); - $this->user=$authInfo[0]; - $this->password=$authInfo[1]; - } -} - -class PMServiceProviderNTLMStream extends soapNtlm { - - protected static $user ; - protected static $password; - - - public function getuser() - { - return self::$user; - } - - public function getpassword() - { - return self::$password; - } - - static function setAuthStream($auth){ - $authInfo=explode(":",$auth); - self::$user=$authInfo[0]; - self::$password=$authInfo[1]; - } - -} \ No newline at end of file + */ + +/** + * + * @package gulliver.system + */ +class soapNtlm +{ + private $path; + private $mode; + private $options; + private $opened_path; + private $buffer; + private $pos; + + public function getuser () + { + return ""; + } + + public function getpassword () + { + return ""; + } + + /** + * Open the stream + * + * @param unknown_type $path + * @param unknown_type $mode + * @param unknown_type $options + * @param unknown_type $opened_path + * @return unknown + */ + public function stream_open ($path, $mode, $options, $opened_path) + { + //echo "[NTLMStream::stream_open] $path , mode=$mode
"; + //G::pr($options); + $this->path = $path; + $this->mode = $mode; + $this->options = $options; + $this->opened_path = $opened_path; + $this->createBuffer( $this->path ); + return true; + } + + /** + * Close the stream + */ + public function stream_close () + { + //echo "[NTLMStream::stream_close]
"; + curl_close( $this->ch ); + } + + /** + * Read the stream + * + * @param int $count number of bytes to read + * @return content from pos to count + */ + public function stream_read ($count) + { + //echo "[NTLMStream::stream_read] $count
"; + if (strlen( $this->buffer ) == 0) { + return false; + } + $read = substr( $this->buffer, $this->pos, $count ); + $this->pos += $count; + return $read; + } + + /** + * write the stream + * + * @param int $count number of bytes to read + * @return content from pos to count + */ + public function stream_write ($data) + { + //echo "[NTLMStream::stream_write]
"; + if (strlen( $this->buffer ) == 0) { + return false; + } + return true; + } + + /** + * + * @return true if eof else false + */ + public function stream_eof () + { + //echo "[NTLMStream::stream_eof] "; + if ($this->pos > strlen( $this->buffer )) { + //echo "true
"; + return true; + } + //echo "false
"; + return false; + } + + /** + * + * @return int the position of the current read pointer + */ + public function stream_tell () + { + //echo "[NTLMStream::stream_tell]
"; + return $this->pos; + } + + /** + * Flush stream data + */ + public function stream_flush () + { + //echo "[NTLMStream::stream_flush]
"; + $this->buffer = null; + $this->pos = null; + } + + /** + * Stat the file, return only the size of the buffer + * + * @return array stat information + */ + public function stream_stat () + { + //echo "[NTLMStream::stream_stat]
"; + $this->createBuffer( $this->path ); + $stat = array ('size' => strlen( $this->buffer )); + return $stat; + } + + /** + * Stat the url, return only the size of the buffer + * + * @return array stat information + */ + public function url_stat ($path, $flags) + { + //G::pr($this->options); + //echo "[NTLMStream::url_stat] -> $path
"; + $this->createBuffer( $path ); + $stat = array ('size' => strlen( $this->buffer )); + return $stat; + } + + /** + * Create the buffer by requesting the url through cURL + * + * @param unknown_type $path + */ + private function createBuffer ($path) + { + if ($this->buffer) { + return; + } + + //echo "[NTLMStream::createBuffer] create buffer from : $path
"; + $this->ch = curl_init( $path ); + curl_setopt( $this->ch, CURLOPT_RETURNTRANSFER, true ); + curl_setopt( $this->ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1 ); + curl_setopt( $this->ch, CURLOPT_HTTPAUTH, CURLAUTH_NTLM ); + //curl_setopt($this->ch, CURLOPT_USERPWD, $this->options['auth']); // Hugo's code + curl_setopt( $this->ch, CURLOPT_USERPWD, $this->getuser() . ':' . $this->getpassword() ); // Ankit's code + //Apply proxy settings + if (class_exists( 'System' )) { + $sysConf = System::getSystemConfiguration(); + if ($sysConf['proxy_host'] != '') { + curl_setopt( $this->ch, CURLOPT_PROXY, $sysConf['proxy_host'] . ($sysConf['proxy_port'] != '' ? ':' . $sysConf['proxy_port'] : '') ); + if ($sysConf['proxy_port'] != '') { + curl_setopt( $this->ch, CURLOPT_PROXYPORT, $sysConf['proxy_port'] ); + } + if ($sysConf['proxy_user'] != '') { + curl_setopt( $this->ch, CURLOPT_PROXYUSERPWD, $sysConf['proxy_user'] . ($sysConf['proxy_pass'] != '' ? ':' . $sysConf['proxy_pass'] : '') ); + } + curl_setopt( $this->ch, CURLOPT_HTTPHEADER, array ('Expect:') ); + } + } + echo $this->buffer = curl_exec( $this->ch ); + //echo "[NTLMStream::createBuffer] buffer size : " . strlen($this->buffer) . "bytes
"; + $this->pos = 0; + } + +} + +class NTLMSoapClient extends SoapClient +{ + function __doRequest ($request, $location, $action, $version) + { + $headers = array ('Method: POST','Connection: Keep-Alive','User-Agent: PHP-SOAP-CURL','Content-Type: text/xml; charset=utf-8','SOAPAction: "' . $action . '"'); + + $this->__last_request_headers = $headers; + $ch = curl_init( $location ); + curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true ); + curl_setopt( $ch, CURLOPT_HTTPHEADER, $headers ); + curl_setopt( $ch, CURLOPT_POST, true ); + curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, false ); + curl_setopt( $ch, CURLOPT_SSL_VERIFYHOST, false ); + curl_setopt( $ch, CURLOPT_POSTFIELDS, $request ); + curl_setopt( $ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1 ); + curl_setopt( $ch, CURLOPT_HTTPAUTH, CURLAUTH_NTLM ); + //curl_setopt($ch, CURLOPT_USERPWD, $this->options['auth']); //Hugo's Code + curl_setopt( $ch, CURLOPT_USERPWD, $this->user . ':' . $this->password ); //Ankit's Code + + //Apply proxy settings + if (class_exists( 'System' )) { + $sysConf = System::getSystemConfiguration(); + if ($sysConf['proxy_host'] != '') { + curl_setopt( $ch, CURLOPT_PROXY, $sysConf['proxy_host'] . ($sysConf['proxy_port'] != '' ? ':' . $sysConf['proxy_port'] : '') ); + if ($sysConf['proxy_port'] != '') { + curl_setopt( $ch, CURLOPT_PROXYPORT, $sysConf['proxy_port'] ); + } + if ($sysConf['proxy_user'] != '') { + curl_setopt( $ch, CURLOPT_PROXYUSERPWD, $sysConf['proxy_user'] . ($sysConf['proxy_pass'] != '' ? ':' . $sysConf['proxy_pass'] : '') ); + } + curl_setopt( $ch, CURLOPT_HTTPHEADER, array ('Expect:' + ) ); + } + } + $response = curl_exec( $ch ); + return $response; + } + + function __getLastRequestHeaders () + { + return implode( "\n", $this->__last_request_headers ) . "\n"; + } + +} + +class PMServiceNTLMSoapClient extends NTLMSoapClient +{ + protected $user; + protected $password; + + function setAuthClient ($auth) + { + $authInfo = explode( ":", $auth ); + $this->user = $authInfo[0]; + $this->password = $authInfo[1]; + } +} + +class PMServiceProviderNTLMStream extends soapNtlm +{ + protected static $user; + protected static $password; + + public function getuser () + { + return self::$user; + } + + public function getpassword () + { + return self::$password; + } + + static function setAuthStream ($auth) + { + $authInfo = explode( ":", $auth ); + self::$user = $authInfo[0]; + self::$password = $authInfo[1]; + } +} + diff --git a/gulliver/system/class.table.php b/gulliver/system/class.table.php old mode 100755 new mode 100644 index 42b2555e1..3a43acd9a --- a/gulliver/system/class.table.php +++ b/gulliver/system/class.table.php @@ -1,1213 +1,1207 @@ -. - * - * For more information, contact Colosa Inc, 2566 Le Jeune Rd., - * Coral Gables, FL, 33134, USA, or email info@colosa.com. - * - */ - -/** - * - * Table class definition - * Render table - * @package gulliver.system - * @author Fernando Ontiveros Lira - * @copyright (C) 2002 by Colosa Development Team. - * - */ - -class Table -{ - var $Columns = NULL; - var $Labels = NULL; - var $rows_per_page = 25; - var $show_nummbers = NULL; - var $first_row = 0; - var $row_pos = 0; - var $Action = ""; //not used - var $ActionLabel = "Continuar"; //not used - var $_dbc = NULL; - var $_dbses = NULL; - var $_dbset = NULL; - var $_source = ""; - var $DefaultOrder = "UID"; - var $DefaultOrderDir = 'ASC'; - var $CustomOrder = ""; - var $WhereClause = ""; - var $_row_values = NULL; - var $_ordered = true; - var $orderprefix = ""; - var $CountQry = ""; - var $filtro = 1; - var $title = ''; - - /** - * Asocia un arreglo con valores de traducci?n/conversi?n a un contexto - * - * @var array - */ - var $contexto = NULL; - - /** - * Arreglo que contiene las cadenas que van a ser usadas al traducir/convertir - * - * @var array - */ - var $translate = NULL; - - /** - * Establece el ?ltimo contexto utilizado - * - * @var string - */ - var $_contexto = ''; - - -/** - * Set conecction using default values - * - * @author Fernando Ontiveros Lira - * @access public - * @param string $objConnection connection string - * @return void - */ - function Table( $objConnection = NULL ) - { - $this->SetTo( $objConnection ); - } - -/** - * Set conecction using default values - * - * @author Fernando Ontiveros Lira - * @access public - * @param string $objConnection connection string - * @return void - */ - function SetTo( $objConnection = NULL ) - { - $this->_dbc = $objConnection; - } - -/** - * Set query string - * - * @author Fernando Ontiveros Lira - * @access public - * @param string $stQry query string - * @param string $stDefaultOrder index to order by, default value='UID' - * @return void - */ - function SetSource( $stQry = "", $stDefaultOrder = "UID", $stDefaultOrderDir = 'ASC' ) - { - //to fix missing value for variable orderDir, when between pages changes. - $url1 = $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] . '?'; - $url2 = strstr ( $_SERVER['HTTP_REFERER']. '?', $_SERVER['HTTP_HOST'] ); - $url1 = substr ( $url1, 0, strpos ( $url1, '?' ) ) ; - $url2 = substr ( $url2, 0, strpos ( $url2, '?' ) ) ; - if ( $url1 != $url2 ) { - if ( isset ($_SESSION['OrderBy'] ) ) unset ( $_SESSION['OrderBy'] ); - if ( isset ($_SESSION['OrderDir'] )) unset ( $_SESSION['OrderDir'] ); - } - $this->_source = $stQry; - $this->DefaultOrder = $stDefaultOrder; - $this->DefaultOrderDir = $stDefaultOrderDir; - } - -/** - * Obtains query string asociated - * - * @author Fernando Ontiveros Lira - * @access public - * @return void - */ - function GetSource() - { - global $HTTP_GET_VARS; - global $HTTP_SESSION_VARS; - $stOrderByDir = $this->DefaultOrderDir; - if( isset( $HTTP_SESSION_VARS['OrderDir'] ) && ( $HTTP_SESSION_VARS['OrderDir'] == 'DESC' || $HTTP_SESSION_VARS['OrderDir'] == 'ASC' ) ) - $stOrderByDir = $HTTP_SESSION_VARS['OrderDir'] ; - - - $stQry = $this->_source; - if( $this->WhereClause != "" ) - { - $stQry .= " WHERE " . $this->WhereClause; - } - - if( $this->_ordered == true ) - { - $stOrderBy = ( isset ( $HTTP_GET_VARS[ $this->orderprefix . 'order'] ) ? $HTTP_GET_VARS[ $this->orderprefix . 'order'] : '' ); - $stOrderLb = ( isset ( $HTTP_GET_VARS[ $this->orderprefix . 'label'] ) ? $HTTP_GET_VARS[ $this->orderprefix . 'label'] : '' ); - - //if( isset( $HTTP_SESSION_VARS['OrderDir'] ) && $HTTP_SESSION_VARS['OrderDir'] == $stOrderBy ) { - if ( $stOrderLb ) { - if ( $HTTP_SESSION_VARS['OrderDir'] == 'ASC') - $stOrderByDir = 'DESC'; - elseif ($HTTP_SESSION_VARS['OrderDir'] == 'DESC') - $stOrderByDir = 'ASC'; - } - else - if ( isset ( $HTTP_SESSION_VARS['OrderDir'] ) && $HTTP_SESSION_VARS['OrderDir'] != '' ) - $stOrderByDir = $HTTP_SESSION_VARS['OrderDir']; - else - $stOrderByDir = $this->DefaultOrderDir; - //} - - if( $stOrderBy == "" ) { - if( $this->DefaultOrder != "" ) - { - $aux = str_replace( ' ASC|', '', $this->DefaultOrder . '|' ); - $aux = str_replace( ' DESC|', '', $aux ); - $aux = str_replace( '|', '', $aux ); - $stQry .= " ORDER BY " . $aux . " " . $stOrderByDir; - } - } - else - { - $stQry .= " ORDER BY " . $stOrderBy; - if( $stOrderByDir != "" ) - $stQry .= " $stOrderByDir"; - } - } - else - { - if( $this->DefaultOrder != "" ) - { - $stQry .= " ORDER BY " . $this->DefaultOrder . " " . ( isset ( $stOrderBy ) ? $stOrderBy : '' ); - } - - } - //print $stQry; - - $HTTP_SESSION_VARS['OrderBy'] = isset ( $stOrderBy ) ? $stOrderBy : '' ; - $HTTP_SESSION_VARS['OrderDir'] = $stOrderByDir; - - $page = ( isset ($HTTP_GET_VARS[ "page"] ) ? $HTTP_GET_VARS[ "page"] : '' ) ; - - $tr = ( isset ( $HTTP_SESSION_VARS['TP'] ) ? $HTTP_SESSION_VARS['TP'] : '' ); - - $desde=0; - - if ($page != "") - { - //$desde=(($page-1)*25); - $desde=(($page-1) * $this->rows_per_page); - - //$strLimit = " LIMIT $desde , 25"; - $strLimit = " LIMIT $desde , $this->rows_per_page"; - if ( PEAR_DATABASE == 'pgsql' ) { - //$strLimit = " OFFSET $desde LIMIT 25"; - $strLimit = " OFFSET $desde LIMIT $this->rows_per_page"; - } - $stQry .= $strLimit; - } - - //print $stQry; - $this->_dbses = new DBSession( $this->_dbc ); - $this->_dbses->UseDB( DB_NAME ); - $this->_dbses->Query( $stQry ); - $this->_dbset = new DBRecordset( $this->_dbses->result ); - } - -/** - * Obtains number of elements of asociated query - * - * @author Fernando Ontiveros Lira - * @access public - * @return int - */ - function TotalCount() - { - global $HTTP_GET_VARS; - global $HTTP_SESSION_VARS; - - $stQry = $this->_source; - if( $this->WhereClause != "" ) { - $stQry .= " WHERE " . $this->WhereClause; - } - if( $this->_ordered == true ) { - $stOrderBy = ( isset($HTTP_GET_VARS[ $this->orderprefix . 'order']) ? $HTTP_GET_VARS[ $this->orderprefix . 'order'] : '' ); - if( $stOrderBy == "" ) - { - if( $this->DefaultOrder != "" ) - { - $stQry .= " ORDER BY " . $this->DefaultOrder; - } - } - else { - $stQry .= " ORDER BY " . $stOrderBy; - } - } - else - { - if( $this->DefaultOrder != "" ) { - $stQry .= " ORDER BY " . $this->DefaultOrder; - } - } - - $dbses = new DBSession( $this->_dbc ); - $dbses->UseDB( DB_NAME ); - $dset = $dbses->Execute( $stQry ); - return $dset->Count(); - } - - -/** - * Obtains number of elements of asociated recordset - * - * @author Fernando Ontiveros Lira - * @access public - * @return int - */ - function Count() - { - if( is_object($this->_dbset) ) { - return $this->_dbset->Count(); - } - else - { - return 0; - } - } - -/** - * Obtains row position - * - * @author Fernando Ontiveros Lira - * @access public - * @return int - */ - function CurRow() - { - return $this->row_pos; - } - -/** - * Obtains number columns - * - * @author Fernando Ontiveros Lira - * @access public - * @return int - */ - function ColumnCount() - { - $result = 0; - if( is_array( $this->Columns ) ) { - $result = count( $this->Columns ); - } - return $result; - } - -/** - * Obtains a row array and moves the internal data pointer ahead - * - * @author Fernando Ontiveros Lira - * @access public - * @return array - */ - function Read() - { - $this->_row_values = $this->_dbset->Read(); - $this->row_pos++; - return $this->_row_values; - } - -/** - * Moves the internal row pointer - * - * @author Fernando Ontiveros Lira - * @access public - * @param int $intPos position to seek - * @return int - */ - function Seek( $intPos=0 ) - { - $result = $this->_dbset->Seek( $intPos ); - if( $result ) { - $this->row_pos = $intPos; - } - return $result; - } - -/** - * Moves the internal row pointer to first position - * - * @author Fernando Ontiveros Lira - * @access public - * @return int - */ - function MoveFirst() - { - if( $this->Count() != 0 ) { - if( $this->first_row < $this->Count() ) { - $this->Seek( $this->first_row ); - } - } - } - -/** - * Verify if row position is in the end - * - * @author Fernando Ontiveros Lira - * @access public - * @return boolean - */ - function EOF() - { - $result = false; - if($this->Count() == 0 ) { - $result = true; - } - else { - if($this->row_pos >= $this->Count()) { - $result = true; - } - else { - if( $this->rows_per_page != 0 ) { - if( $this->row_pos >= $this->first_row + $this->rows_per_page ) { - $result = true; - } - } - } - } - return $result; - } - -/** - * Set values to add a column to show in the dynaform - * - * @author Fernando Ontiveros Lira - * @access public - * @param $strLabel - * @param $strType - * @param $strName - * @param $strAlign - * @param $intWidth - * @param $strTarget - * @param $strContent - * @return void - */ - function AddColumn( $strLabel = "", $strType = "text", $strName = "", $strAlign = "left", $intWidth = 0, $strTarget = "", $strContent = "" ) - { - $tmpCol = array( "Name" => $strName , - "Type" => $strType , - "Width" => $intWidth , - "Align" => $strAlign , - "Target" => $strTarget , - "Content" => $strContent ); - $pos = 0; - if( is_array( $this->Columns ) ) { - $pos = count( $this->Columns ); - } - $this->Columns[$pos] = $tmpCol; - $this->Labels[$pos] = $strLabel; - } - -/** - * Set values to add a column to show in the dynaform - * - * @author Fernando Ontiveros Lira - * @access public - * @param $strType - * @param $strName - * @param $strAlign - * @param $intWidth - * @param $strTarget - * @param $strContent - * @param $strExtra - * @param $strCondition - * @param $orderByThis - * @return void - */ - function AddRawColumn( $strType = "text", $strName = "", $strAlign = "left", $intWidth = 0, $strTarget = "", $strContent = "", $strExtra = "", $strCondition="", $orderByThis = true ) - { - $tmpCol = array( "Name" => $strName , - "Type" => $strType , - "Width" => $intWidth , - "Align" => $strAlign , - "Target" => $strTarget , - "Content" => $strContent, - "Extra" => $strExtra, - "Condition" => $strCondition, - "orderByThis" => $orderByThis); - $pos = 0; - if( is_array( $this->Columns ) ) { - $pos = count( $this->Columns ); - } - $this->Columns[$pos] = $tmpCol; - $this->Labels[$pos] = ""; - } - - -/** - * Show dynaform's title - * - * @author Fernando Ontiveros Lira - * @access public - * @param $pa - * @param $intPos - * @param $strClass - * @return void - */ - function RenderTitle($pa,$intPos=1, $strClass = "tblHeader" ) - { - if ( ! defined ( 'ENABLE_ENCRYPT') ) define ( 'ENABLE_ENCRYPT', 'no' ) ; - - global $HTTP_SESSION_VARS; - $col = $this->Columns[$intPos]; - $order = !($col["Type"] == "image"); - if( $this->_ordered == true && $order ) { - $res = " 0) $res .= " width=\"" . $col["Width"] . "\""; - $res .= ">"; - - //$res .= "" . $this->Labels[$intPos] . ""; - - $res .= "\n";//echo $res;die; - } - else { - $res = " 0) $res .= " width=\"" . $col["Width"] . "\""; - $res .= ">"; - $res .= $this->Labels[$intPos] . "\n"; - } - return $res; - } - -/** - * Show dynaform's title using ajax - * - * @author Fernando Ontiveros Lira - * @access public - * @param $pa - * @param $intPos - * @param $strClass - * @return void - */ - function RenderTitle_ajax($pa,$intPos=1, $strClass = "tblHeader" ) - { - global $HTTP_SESSION_VARS; - $col = $this->Columns[$intPos]; - $order = !(($col["Type"] == "image")||($col["Type"] == "jsimglink")); - - if( $this->_ordered == true && $order ) { - $res = " 0) $res .= " width=\"" . $col["Width"] . "\""; - $res .= ">"; - - //$res .= "Columns[$intPos]['Name']; - $res .= "Javascript:changetableOrder('$_temp_var',$pa)" ; - //$res .= $_SERVER['REDIRECT_URL'] . "?order=" . $this->Columns[$intPos]['Name']."&page=".$pa."&label=true"; - $res .= "\">" . $this->Labels[$intPos] . ""; - if($HTTP_SESSION_VARS['OrderBy'] == $this->Columns[$intPos]['Name'] ) { - if($HTTP_SESSION_VARS['OrderDir'] == 'DESC') - $res .= " "; - else - $res .= " "; - } - - $res .= "\n";//echo $res;die; - } - else { - $res = " 0) $res .= " width=\"" . $col["Width"] . "\""; - $res .= ">"; - $res .= $this->Labels[$intPos] . "\n"; - } - return $res; - } - -/** - * Show dynaform title - * - * @author Fernando Ontiveros Lira - * @access public - * @param $pa - * @param $fil - * @param $intPos - * @param $strClass - * @param $auxgetval - * @return void - */ - function RenderTitle2($pa, $fil, $intPos, $strClass = "tblHeader", $auxgetval = '') { - if ( ! defined ( 'ENABLE_ENCRYPT') ) define ( 'ENABLE_ENCRYPT', 'no' ) ; - global $HTTP_SESSION_VARS; - - if ($auxgetval == '') - $targ = SYS_TARGET.".html"; - else - $targ = SYS_TARGET.'.html?'.$auxgetval; - $target = (ENABLE_ENCRYPT=='yes'?G::encryptUrl(urldecode($targ), URL_KEY):$targ); - - $col = $this->Columns[$intPos]; - - if ($col['Type'] == 'hidden') return ''; - - $order = !($col["Type"] == "image"); - - if( ($this->_ordered == true) && ($order) && ($this->Columns[$intPos]['orderByThis'])) { - $res = ""; - if (($this->show_nummbers) and ($intPos == 0)) - $res = "# "; - - $res .= " 0) $res .= " width=\"" . $col["Width"] . "\""; - $res .= "> "; - - $res .= "Columns[$intPos]['Name']."&page=".$pa."&label=true"; - $res .= "javascript:bsearch('$direccion')"; - //$res .= $target . "?".$fil."order=" . $this->Columns[$intPos]['Name']."&page=".$pa."&label=true"; - $res .= "\">" . $this->Labels[$intPos] . ""; - - $res .= "\n"; - } - else { - $col = $this->Columns[$intPos]; - $res = " 0) $res .= " width=\"" . $col["Width"] . "\""; - $res .= ">"; - $res .= ( isset ( $this->Labels[$intPos] ) ? $this->Labels[$intPos] : '' ) . "\n"; - } - return $res; - } - -/** - * Show dynaform column - * - * @author Fernando Ontiveros Lira - * @access public - * @param $intPos - * @param $strClass - * @param $strClassLink - * @param $number - * @param $renderTD if this value = 1, this function will include the TD tags - * @return void - */ - function RenderColumn( $intPos = 0, $strClass = "tblCell", $strClassLink = "tblCellA" , $number = 0, $renderTD = 1) - { - if ( ! defined ( 'ENABLE_ENCRYPT') ) define ( 'ENABLE_ENCRYPT', 'no' ) ; - - global $G_DATE_FORMAT; - global $G_TABLE_DATE_FORMAT; - $col = $this->Columns[$intPos]; - - switch (substr($col['Name'], 0, 1)) { - case '=': - // Si empieza con '=' entonces se toma como valor constante - $val = substr($col['Name'], 1, strlen($col['Name'])-1); - break; - case '%': - // Si empieza con '%' entonces traducir/convertir el valor - $fieldname = substr($col['Name'], 1, strlen($col['Name'])-1); - $val = $this->_row_values[$fieldname]; - $val = $this->translateValue( $this->_contexto, $val, SYS_LANG ); - break; - default: - $fieldname = $col['Name']; - $val = isset ( $this->_row_values[$fieldname] ) ? $this->_row_values[$fieldname] : '' ; - } - - $res = ""; - if (($this->show_nummbers)and ($intPos == 0)) - $res = "$number"; - - if(!(stristr($val,"script") === false)) $val = htmlentities($val,ENT_QUOTES,'utf-8'); - - if ( $renderTD == 1 ) { - $res .= " 0 ) $res .= " width=\"" . $col["Width"] . "\""; - $res .= "> " ; - } - - switch ( $col["Type"] ) - { - case 'hidden': - return ''; - break; - case "text": - if ( $val != "" ) $res .= G::unhtmlentities($val,ENT_QUOTES,'utf-8'); - else $res .= " "; - break; - case "text-dontSearch": - if ( $val != "" ) $res .= G::unhtmlentities($val); - else $res .= " "; - break; - case "html": - if ( $val != "" ) $res .= ($val); - else $res .= " "; - break; - case "textPlain": - if ( $val != "" ) $res .= ($this->ParsingFromHtml(G::unhtmlentities($val),"300")); - //if ( $val != "" ) $res .= (($val)); - else $res .= " "; - break; - case "currency": - if ( $val != "" ) { - $aux = explode (' ', $val); - $format = number_format( (float)$aux[0], 2, ".", ","); - $res .= htmlentities( $format . ' ' . ( isset( $aux[1] ) ? $aux[1] : '' ) ,ENT_QUOTES,'utf-8'); - } - else - $res .= " "; - break; - - case "currency2": - if ( $val != "" ) { - $res .= G::NumberToCurrency( $val); - } - else - $res .= "$ 0.00"; - break; - - case "percentage2": - if ( $val != "" ) { - $res .= G::NumberToPercentage( $val); - } - else - $res .= "0.00 %"; - break; - - case "percentage": - if ( $val != "" ) { - $res .= htmlentities( number_format( (float)$val, 2, ".", ",") . " %" ,ENT_QUOTES,'utf-8'); - } - else { - $res .= " "; - } - break; - - case "date": - if ( $val != "" && $val != '0000-00-00 00:00:00' ) { - $part = explode (' ', $val); - $aux = explode ('-', $part[0]); - - switch($G_DATE_FORMAT) { - case 'DD/MM/AAAA':$res .= formatDate('$d/$m/$Y $H:$i:$s',$val); - break; - case 'MM/DD/AAAA':$res .= formatDate('$m/$d/$Y $H:$i:$s EST',$val); - break; - case 'AAAA/MM/DD':$res .= formatDate('$Y/$m/$d $H:$i:$s',$val); - break; - case 'LITERAL' :$res .= formatDate('$M $d $Y',$val); - break; - } - - } - else - $res .= " "; - - break; - - case "email": - if( $val != "" ) { - $res .= ""; - $res .= $val; - $res .= ""; - } - else { - $res .= " "; - } - break; - - case "ifpdf": - if ( $val == '1' ) { - $image = ""; - //valor - $tlabel = substr( $col["Content"] , 0, 1 ); - $vname = substr( $col["Content"], 1, (strlen($col["Content"]) - 1) ); - $lval = $this->_row_values[$vname]; - //$res .= " $image "; //It open a new window... better the other way By JHL 16/11/06 - $res .= " $image "; - } - else - $res .= " "; - break; - - case "ifimg": - $image = ""; - if ( $val == '1' ) { - //valor - $tlabel = substr( $col["Content"] , 0, 1 ); - $vname = substr( $col["Content"], 1, (strlen($col["Content"]) - 1) ); - $lval = $this->_row_values[$vname]; - $res .= " $image "; - } - else - $res .= " "; - break; - - - case "ifrtf": - if ( $val == '1' ) { - $image = ""; - //valor - $tlabel = substr( $col["Content"] , 0, 1 ); - $vname = substr( $col["Content"], 1, (strlen($col["Content"]) - 1) ); - $lval = $this->_row_values[$vname]; - //$res .= " $image "; //It open a new window... better the other way By JHL 16/11/06 - $res .= " $image "; - } - else - $res .= " "; - break; - - case "image": - - if (is_array($col["Condition"])) //By JHL to enable Condition to display a image -- New parameter Condition in Addrawcolumn - { - $field_compare=$col["Condition"]['field']; - $tlabel = substr($field_compare,0,1); - switch($tlabel) - { - case "&": - $vname = substr($field_compare, 1, (strlen($field_compare) - 1) ); - $field_val = $this->_row_values[$vname]; - break; - } - - - } - else - $val = ""; -// break; - - case "textimage": - $AAS=$col['Extra']; - $val1 = " "; -// break; - case "image-text": - if ( is_array($col['Content']) && $col['Content'] != "") { - // Hay mas de un valor para el link - $values = $col['Content']; - $n = count($values); - - $res .= "_row_values[$vname]; - - $res .= $i == $n-1 ? $lval : $lval . "/"; - break; - } - } - $res .= "\">".strtoupper($fieldname)."$val"; - }else - $val2 = "".strtoupper($fieldname).""; -// break; - - - case "link": - if ( $val == "" ) $res .= " "; - $title = ''; - if ( $col["Type"] == 'link' && trim( isset ( $this->_row_values['TOOLTIP']) ? $this->_row_values['TOOLTIP'] : '' ) ); - $title = (isset ( $this->_row_values['TOOLTIP']) ? "title=\" " .$this->_row_values['TOOLTIP']. " \"" : '' ) ; - if ( is_array($col['Content']) && $col['Content'] != "") { - // Hay mas de un valor para el link - $values = $col['Content']; - $n = count($values); - - $res .= "_row_values[$vname]; - - $res .= $i == $n-1 ? $lval : $lval . "/"; - break; - } - } - $res .= "\">$val"; - } - elseif ( $col["Content"] != "" && !is_array($col['Content']) ) { - $tlabel = substr( $col["Content"] , 0, 1 ); - switch( $tlabel ) - { - case "&": - $vname = substr( $col["Content"], 1, (strlen($col["Content"]) - 1) ); - $lval = $this->_row_values[$vname]; - if ( ENABLE_ENCRYPT == 'yes' ) { - - //$encoded = G::encrypt ( $col["Target"] . "/" . $lval . ".html", URL_KEY ); - $encoded = G::encryptUrl ( $col["Target"] . "/" . $lval . ".html", URL_KEY ); - $res .= ""; - if ($col["Type"]=="textimage") - { - $res .= $val1; - $val=" (".$val.")"; - } - if ($col["Type"]=="image-text") { - - $res .= $val2; - } - $res .= $val; - $res .= ""; - } - else { - $res .= ""; - if ($col["Type"]=="textimage") - { - $res .= $val1; - $val=" (".$val.")"; - } - if ($col["Type"]=="image-text") { - - $res .= $val2; - } - $res .= $val; - $res .= ""; - } - break; - case "$": - $vname = substr( $col["Content"], 1, (strlen($col["Content"]) - 1) ); - $lval = $HTTP_SESSION_VARS[$vname]; - $res .= ""; - $res .= $val; - $res .= ""; - break; - default: - $res .= ""; - $res .= $col["Content"]; - $res .= ""; - break; - } - } - else - { - $res .= ""; - $res .= $val; - $res .= ""; - } - break; - - - case "linknew": - if ( $val == "" ) $res .= " "; - if ( $col["Content"] != "" ) { - $tlabel = substr( $col["Content"] , 0, 1 ); - switch( $tlabel ) - { - case "&": - if ( ENABLE_ENCRYPT == 'yes' ) { - $vname = substr( $col["Content"], 1, (strlen($col["Content"]) - 1) ); - $lval = $this->_row_values[$vname]; - //$encoded = G::encryptUrl ( $col["Target"] , URL_KEY ). "/" . $lval . ".html"; - $encoded = G::encryptUrl ( $col["Target"]. "/" . $lval . "" , URL_KEY ); - $res .= ""; - $res .= $val; - $res .= ""; - } - else { - $vname = substr( $col["Content"], 1, (strlen($col["Content"]) - 1) ); - $lval = $this->_row_values[$vname]; - $res .= ""; - $res .= $val; - $res .= ""; - } - break; - case "$": - $vname = substr( $col["Content"], 1, (strlen($col["Content"]) - 1) ); - $lval = $HTTP_SESSION_VARS[$vname]; - $res .= ""; - $res .= $val; - $res .= ""; - break; - default: - $res .= ""; - $res .= $col["Content"]; - $res .= ""; - break; - } - } - else - { - $res .= ""; - $res .= $val; - $res .= ""; - } - break; - - case "iflink": - if ( $col["Content"] != "" ) - { - $tlabel = substr( $col["Content"] , 0, 1 ); - if( $val != "" ) - { - switch( $tlabel ) - { - case "&": - $vname = substr( $col["Content"], 1, (strlen($col["Content"]) - 1) ); - $lval = $this->_row_values[$vname]; - $res .= ""; - $res .= $val; - $res .= ""; - break; - case "$": - $vname = substr( $col["Content"], 1, (strlen($col["Content"]) - 1) ); - $lval = $HTTP_SESSION_VARS[$vname]; - $res .= ""; - $res .= $val; - $res .= ""; - break; - default: - $res .= ""; - $res .= $col["Content"]; - $res .= ""; - break; - } - } - else - { - $res .= " "; - } - } - else - { - $res .= ""; - $res .= $val; - $res .= ""; - } - break; - - - case "jsimglink": - $val = ""; - - case "jslink": - if ( $val == "" ) $val .= " " . $col['Name'] . ''; - if ( $val == "" ) $res .= " "; - if ( $col["Content"] != "" ) - { - $tlabel = substr( $col["Content"] , 0, 1 ); - switch( $tlabel ) - { - case "&": - $vname = substr( $col["Content"], 1, (strlen($col["Content"]) - 1) ); - $lval = $this->_row_values[$vname]; - $res .= ""; - $res .= $val; - $res .= ""; - break; - - case "$": - $vname = substr( $col["Content"], 1, (strlen($col["Content"]) - 1) ); - $lval = $HTTP_SESSION_VARS[$vname]; - $res .= ""; - $res .= $val; - $res .= ""; - break; - - case '_': - $Values = explode(',', substr($col['Content'], 1, strlen($col['Content']))); - $res .= "_row_values[substr($Value, 1, strlen($Value))] . ','; - else - $res .= "'" . $this->_row_values[substr($Value, 1, strlen($Value))] . "',"; - else - $res .= $Value . ','; - } - $res = substr($res, 0, strlen($res) - 1); - $res .= ")\"" . $col['Extra'] . ">"; - $res .= $val; - $res .= ""; - break; - - default: - $res .= ""; - $res .= $col["Content"]; - $res .= ""; - break; - } - } - else - { - $res .= ""; - $res .= $val; - $res .= ""; - } - break; - - case "checkbox": - $res .= " - * @access public - * @param string $strAction Next action to do - * @param string $strLabel Label - * @return void - */ - function SetAction( $strAction, $strLabel="Continue" ) - { - $this->Action = $strAction; - $this->ActionLabel = $strLabel; - } - - /** - * Set contaxt and table (array) of translate - * - * @author Hardy Beltran Monasterios - * @param string $contexto Contexto en el cual se busca la traducci?n - * @param array $tabla Tabla con valores para traducir - * @param string $nombre Nombre del array $tabla - * @access public - * @return void - */ - function setTranslate( $contexto, $tabla, $nombre ) - { - if (is_array($this->contexto)) { - $this->contexto[0][] = $contexto; - $this->contexto[1][] = $nombre; - - } else { - $this->contexto = array(); - $this->contexto[0][] = $contexto; - $this->contexto[1][] = $nombre; - // array_push($this->contexto[0], $contexto); - // array_push($this->contexto[1], $nombre); - } - if (is_array($this->translate)) { - $this->translate = array(); - $this->translate[$nombre] = $tabla; - } else { - $this->translate[$nombre] = $tabla; - } - // Fijamos ultimo contexto usado - $this->_contexto = $contexto; - } - - /** - * Search value in the table of translation and returns last accourding to choised context - * Retorna el valor a su equivalente traducido/convertido - * @author Hardy Beltran Monasterios - * @param string $contexto Contexto en el cual se busca la traducci?n - * @param mixed $valor Valor que se va traducir/convertir - * @param string $lang El lenguaje que se va utilizar - * @return mixed - */ - function translateValue( $contexto, $valor, $lang ) - { - // Verificar si exite el contexto - if (in_array($contexto, $this->contexto[0])) { - $j = count($this->contexto[0]); - for ( $i=0; $i < $j; $i++ ) { - if ($contexto == $this->contexto[0][$i]){ - $origen = $this->contexto[1][$i]; - } - } - $tabla = $this->translate[$origen]; - if (isset($tabla[$lang][$valor])) { - return $tabla[$lang][$valor]; - } else { - print ("l10n error:no lang or value."); - } - } else { - print ("l10n error:no context."); - } - } - - /** - * Estable el contexto de traducci?n/conversi?n - * - * @author Hardy Beltran Monasterios - * @param string $contexto Contexto en el cual se busca la traducci?n - * @return void - */ - function setContext( $contexto ) - { - $this->_context = $contexto; - } - -/** - * Parse from HTML - * - * @author Fernando Ontiveros Lira - * @access public - * @return void - */ - function ParsingFromHtml($value, $number = '100000000') - { - $car = substr($value, 0,1); - $len = strlen($value); - $Flag = 1; - $token = ''; - $i = 0; - - While ($i<=$len and $i <= $number){ - $car=substr($value,$i,1); - $br = strtoupper(substr($value,$i,4)); - if ($car == '<'){ - $Flag = 0; - } - if ($car == '>'){ - $Flag = 1; - } - if($br == '
' || $br == '

') - $token .= "
"; - - if (($Flag == 1)&& ($car != '>')){ - $token .= $car; - if ( $i == $number ) - $token .= "... "; - } - $i = $i +1; - } - return $token; - } +. + * + * For more information, contact Colosa Inc, 2566 Le Jeune Rd., + * Coral Gables, FL, 33134, USA, or email info@colosa.com. + * + */ +/** + * + * + * + * + * Table class definition + * Render table + * + * @package gulliver.system + * @author Fernando Ontiveros Lira + * @copyright (C) 2002 by Colosa Development Team. + * + */ + +class Table +{ + var $Columns = null; + var $Labels = null; + var $rows_per_page = 25; + var $show_nummbers = null; + var $first_row = 0; + var $row_pos = 0; + var $Action = ""; //not used + var $ActionLabel = "Continuar"; //not used + var $_dbc = null; + var $_dbses = null; + var $_dbset = null; + var $_source = ""; + var $DefaultOrder = "UID"; + var $DefaultOrderDir = 'ASC'; + var $CustomOrder = ""; + var $WhereClause = ""; + var $_row_values = null; + var $_ordered = true; + var $orderprefix = ""; + var $CountQry = ""; + var $filtro = 1; + var $title = ''; + + /** + * Asocia un arreglo con valores de traducci?n/conversi?n a un contexto + * + * @var array + */ + var $contexto = null; + + /** + * Arreglo que contiene las cadenas que van a ser usadas al traducir/convertir + * + * @var array + */ + var $translate = null; + + /** + * Establece el ?ltimo contexto utilizado + * + * @var string + */ + var $_contexto = ''; + + /** + * Set conecction using default values + * + * @author Fernando Ontiveros Lira + * @access public + * @param string $objConnection connection string + * @return void + */ + function Table ($objConnection = null) + { + $this->SetTo( $objConnection ); + } + + /** + * Set conecction using default values + * + * @author Fernando Ontiveros Lira + * @access public + * @param string $objConnection connection string + * @return void + */ + function SetTo ($objConnection = null) + { + $this->_dbc = $objConnection; + } + + /** + * Set query string + * + * @author Fernando Ontiveros Lira + * @access public + * @param string $stQry query string + * @param string $stDefaultOrder index to order by, default value='UID' + * @return void + */ + function SetSource ($stQry = "", $stDefaultOrder = "UID", $stDefaultOrderDir = 'ASC') + { + //to fix missing value for variable orderDir, when between pages changes. + $url1 = $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] . '?'; + $url2 = strstr( $_SERVER['HTTP_REFERER'] . '?', $_SERVER['HTTP_HOST'] ); + $url1 = substr( $url1, 0, strpos( $url1, '?' ) ); + $url2 = substr( $url2, 0, strpos( $url2, '?' ) ); + if ($url1 != $url2) { + if (isset( $_SESSION['OrderBy'] )) { + unset( $_SESSION['OrderBy'] ); + } + if (isset( $_SESSION['OrderDir'] )) { + unset( $_SESSION['OrderDir'] ); + } + } + $this->_source = $stQry; + $this->DefaultOrder = $stDefaultOrder; + $this->DefaultOrderDir = $stDefaultOrderDir; + } + + /** + * Obtains query string asociated + * + * @author Fernando Ontiveros Lira + * @access public + * @return void + */ + function GetSource () + { + global $HTTP_GET_VARS; + global $HTTP_SESSION_VARS; + $stOrderByDir = $this->DefaultOrderDir; + if (isset( $HTTP_SESSION_VARS['OrderDir'] ) && ($HTTP_SESSION_VARS['OrderDir'] == 'DESC' || $HTTP_SESSION_VARS['OrderDir'] == 'ASC')) + $stOrderByDir = $HTTP_SESSION_VARS['OrderDir']; + + $stQry = $this->_source; + if ($this->WhereClause != "") { + $stQry .= " WHERE " . $this->WhereClause; + } + + if ($this->_ordered == true) { + $stOrderBy = (isset( $HTTP_GET_VARS[$this->orderprefix . 'order'] ) ? $HTTP_GET_VARS[$this->orderprefix . 'order'] : ''); + $stOrderLb = (isset( $HTTP_GET_VARS[$this->orderprefix . 'label'] ) ? $HTTP_GET_VARS[$this->orderprefix . 'label'] : ''); + + //if( isset( $HTTP_SESSION_VARS['OrderDir'] ) && $HTTP_SESSION_VARS['OrderDir'] == $stOrderBy ) { + if ($stOrderLb) { + if ($HTTP_SESSION_VARS['OrderDir'] == 'ASC') { + $stOrderByDir = 'DESC'; + } elseif ($HTTP_SESSION_VARS['OrderDir'] == 'DESC') { + $stOrderByDir = 'ASC'; + } + } elseif (isset( $HTTP_SESSION_VARS['OrderDir'] ) && $HTTP_SESSION_VARS['OrderDir'] != '') { + $stOrderByDir = $HTTP_SESSION_VARS['OrderDir']; + } else { + $stOrderByDir = $this->DefaultOrderDir; + } + + if ($stOrderBy == "") { + if ($this->DefaultOrder != "") { + $aux = str_replace( ' ASC|', '', $this->DefaultOrder . '|' ); + $aux = str_replace( ' DESC|', '', $aux ); + $aux = str_replace( '|', '', $aux ); + $stQry .= " ORDER BY " . $aux . " " . $stOrderByDir; + } + } else { + $stQry .= " ORDER BY " . $stOrderBy; + if ($stOrderByDir != "") { + $stQry .= " $stOrderByDir"; + + } + } + } else { + if ($this->DefaultOrder != "") { + $stQry .= " ORDER BY " . $this->DefaultOrder . " " . (isset( $stOrderBy ) ? $stOrderBy : ''); + } + } + //print $stQry; + + + $HTTP_SESSION_VARS['OrderBy'] = isset( $stOrderBy ) ? $stOrderBy : ''; + $HTTP_SESSION_VARS['OrderDir'] = $stOrderByDir; + + $page = (isset( $HTTP_GET_VARS["page"] ) ? $HTTP_GET_VARS["page"] : ''); + + $tr = (isset( $HTTP_SESSION_VARS['TP'] ) ? $HTTP_SESSION_VARS['TP'] : ''); + + $desde = 0; + + if ($page != "") { + //$desde=(($page-1)*25); + $desde = (($page - 1) * $this->rows_per_page); + + //$strLimit = " LIMIT $desde , 25"; + $strLimit = " LIMIT $desde , $this->rows_per_page"; + if (PEAR_DATABASE == 'pgsql') { + //$strLimit = " OFFSET $desde LIMIT 25"; + $strLimit = " OFFSET $desde LIMIT $this->rows_per_page"; + } + $stQry .= $strLimit; + } + + //print $stQry; + $this->_dbses = new DBSession( $this->_dbc ); + $this->_dbses->UseDB( DB_NAME ); + $this->_dbses->Query( $stQry ); + $this->_dbset = new DBRecordset( $this->_dbses->result ); + } + + /** + * Obtains number of elements of asociated query + * + * @author Fernando Ontiveros Lira + * @access public + * @return int + */ + function TotalCount () + { + global $HTTP_GET_VARS; + global $HTTP_SESSION_VARS; + + $stQry = $this->_source; + if ($this->WhereClause != "") { + $stQry .= " WHERE " . $this->WhereClause; + } + if ($this->_ordered == true) { + $stOrderBy = (isset( $HTTP_GET_VARS[$this->orderprefix . 'order'] ) ? $HTTP_GET_VARS[$this->orderprefix . 'order'] : ''); + if ($stOrderBy == "") { + if ($this->DefaultOrder != "") { + $stQry .= " ORDER BY " . $this->DefaultOrder; + } + } else { + $stQry .= " ORDER BY " . $stOrderBy; + } + } else { + if ($this->DefaultOrder != "") { + $stQry .= " ORDER BY " . $this->DefaultOrder; + } + } + + $dbses = new DBSession( $this->_dbc ); + $dbses->UseDB( DB_NAME ); + $dset = $dbses->Execute( $stQry ); + return $dset->Count(); + } + + /** + * Obtains number of elements of asociated recordset + * + * @author Fernando Ontiveros Lira + * @access public + * @return int + */ + function Count () + { + if (is_object( $this->_dbset )) { + return $this->_dbset->Count(); + } else { + return 0; + } + } + + /** + * Obtains row position + * + * @author Fernando Ontiveros Lira + * @access public + * @return int + */ + function CurRow () + { + return $this->row_pos; + } + + /** + * Obtains number columns + * + * @author Fernando Ontiveros Lira + * @access public + * @return int + */ + function ColumnCount () + { + $result = 0; + if (is_array( $this->Columns )) { + $result = count( $this->Columns ); + } + return $result; + } + + /** + * Obtains a row array and moves the internal data pointer ahead + * + * @author Fernando Ontiveros Lira + * @access public + * @return array + */ + function Read () + { + $this->_row_values = $this->_dbset->Read(); + $this->row_pos ++; + return $this->_row_values; + } + + /** + * Moves the internal row pointer + * + * @author Fernando Ontiveros Lira + * @access public + * @param int $intPos position to seek + * @return int + */ + function Seek ($intPos = 0) + { + $result = $this->_dbset->Seek( $intPos ); + if ($result) { + $this->row_pos = $intPos; + } + return $result; + } + + /** + * Moves the internal row pointer to first position + * + * @author Fernando Ontiveros Lira + * @access public + * @return int + */ + function MoveFirst () + { + if ($this->Count() != 0) { + if ($this->first_row < $this->Count()) { + $this->Seek( $this->first_row ); + } + } + } + + /** + * Verify if row position is in the end + * + * @author Fernando Ontiveros Lira + * @access public + * @return boolean + */ + function EOF () + { + $result = false; + if ($this->Count() == 0) { + $result = true; + } else { + if ($this->row_pos >= $this->Count()) { + $result = true; + } else { + if ($this->rows_per_page != 0) { + if ($this->row_pos >= $this->first_row + $this->rows_per_page) { + $result = true; + } + } + } + } + return $result; + } + + /** + * Set values to add a column to show in the dynaform + * + * @author Fernando Ontiveros Lira + * @access public + * @param $strLabel + * @param $strType + * @param $strName + * @param $strAlign + * @param $intWidth + * @param $strTarget + * @param $strContent + * @return void + */ + function AddColumn ($strLabel = "", $strType = "text", $strName = "", $strAlign = "left", $intWidth = 0, $strTarget = "", $strContent = "") + { + $tmpCol = array ("Name" => $strName,"Type" => $strType,"Width" => $intWidth,"Align" => $strAlign,"Target" => $strTarget,"Content" => $strContent + ); + $pos = 0; + if (is_array( $this->Columns )) { + $pos = count( $this->Columns ); + } + $this->Columns[$pos] = $tmpCol; + $this->Labels[$pos] = $strLabel; + } + + /** + * Set values to add a column to show in the dynaform + * + * @author Fernando Ontiveros Lira + * @access public + * @param $strType + * @param $strName + * @param $strAlign + * @param $intWidth + * @param $strTarget + * @param $strContent + * @param $strExtra + * @param $strCondition + * @param $orderByThis + * @return void + */ + function AddRawColumn ($strType = "text", $strName = "", $strAlign = "left", $intWidth = 0, $strTarget = "", $strContent = "", $strExtra = "", $strCondition = "", $orderByThis = true) + { + $tmpCol = array ("Name" => $strName,"Type" => $strType,"Width" => $intWidth,"Align" => $strAlign,"Target" => $strTarget,"Content" => $strContent,"Extra" => $strExtra,"Condition" => $strCondition,"orderByThis" => $orderByThis + ); + $pos = 0; + if (is_array( $this->Columns )) { + $pos = count( $this->Columns ); + } + $this->Columns[$pos] = $tmpCol; + $this->Labels[$pos] = ""; + } + + /** + * Show dynaform's title + * + * @author Fernando Ontiveros Lira + * @access public + * @param $pa + * @param $intPos + * @param $strClass + * @return void + */ + function RenderTitle ($pa, $intPos = 1, $strClass = "tblHeader") + { + if (! defined( 'ENABLE_ENCRYPT' )) { + define( 'ENABLE_ENCRYPT', 'no' ); + } + global $HTTP_SESSION_VARS; + $col = $this->Columns[$intPos]; + $order = ! ($col["Type"] == "image"); + if ($this->_ordered == true && $order) { + $res = " 0) { + $res .= " width=\"" . $col["Width"] . "\""; + } + $res .= ">"; + + //$res .= "
" . $this->Labels[$intPos] . ""; + + $res .= "\n"; //echo $res;die; + } else { + $res = " 0) { + $res .= " width=\"" . $col["Width"] . "\""; + } + $res .= ">"; + $res .= $this->Labels[$intPos] . "\n"; + } + return $res; + } + + /** + * Show dynaform's title using ajax + * + * @author Fernando Ontiveros Lira + * @access public + * @param $pa + * @param $intPos + * @param $strClass + * @return void + */ + function RenderTitle_ajax ($pa, $intPos = 1, $strClass = "tblHeader") + { + global $HTTP_SESSION_VARS; + $col = $this->Columns[$intPos]; + $order = ! (($col["Type"] == "image") || ($col["Type"] == "jsimglink")); + + if ($this->_ordered == true && $order) { + $res = " 0) { + $res .= " width=\"" . $col["Width"] . "\""; + } + $res .= ">"; + + //$res .= "Columns[$intPos]['Name']; + $res .= "Javascript:changetableOrder('$_temp_var',$pa)"; + //$res .= $_SERVER['REDIRECT_URL'] . "?order=" . $this->Columns[$intPos]['Name']."&page=".$pa."&label=true"; + $res .= "\">" . $this->Labels[$intPos] . ""; + if ($HTTP_SESSION_VARS['OrderBy'] == $this->Columns[$intPos]['Name']) { + if ($HTTP_SESSION_VARS['OrderDir'] == 'DESC') { + $res .= " "; + } else { + $res .= " "; + } + } + + $res .= "\n"; //echo $res;die; + } else { + $res = " 0) { + $res .= " width=\"" . $col["Width"] . "\""; + } + $res .= ">"; + $res .= $this->Labels[$intPos] . "\n"; + } + return $res; + } + + /** + * Show dynaform title + * + * @author Fernando Ontiveros Lira + * @access public + * @param $pa + * @param $fil + * @param $intPos + * @param $strClass + * @param $auxgetval + * @return void + */ + function RenderTitle2 ($pa, $fil, $intPos, $strClass = "tblHeader", $auxgetval = '') + { + if (! defined( 'ENABLE_ENCRYPT' )) { + define( 'ENABLE_ENCRYPT', 'no' ); + } + global $HTTP_SESSION_VARS; + + if ($auxgetval == '') { + $targ = SYS_TARGET . ".html"; + } else { + $targ = SYS_TARGET . '.html?' . $auxgetval; + } + $target = (ENABLE_ENCRYPT == 'yes' ? G::encryptUrl( urldecode( $targ ), URL_KEY ) : $targ); + + $col = $this->Columns[$intPos]; + + if ($col['Type'] == 'hidden') { + return ''; + } + $order = ! ($col["Type"] == "image"); + + if (($this->_ordered == true) && ($order) && ($this->Columns[$intPos]['orderByThis'])) { + $res = ""; + if (($this->show_nummbers) and ($intPos == 0)) { + $res = "# "; + } + $res .= " 0) { + $res .= " width=\"" . $col["Width"] . "\""; + } + $res .= "> "; + + $res .= "" . $this->Labels[$intPos] . ""; + + $res .= "\n"; + } else { + $col = $this->Columns[$intPos]; + $res = " 0) { + $res .= " width=\"" . $col["Width"] . "\""; + } + $res .= ">"; + $res .= (isset( $this->Labels[$intPos] ) ? $this->Labels[$intPos] : '') . "\n"; + } + return $res; + } + + /** + * Show dynaform column + * + * @author Fernando Ontiveros Lira + * @access public + * @param $intPos + * @param $strClass + * @param $strClassLink + * @param $number + * @param $renderTD if this value = 1, this function will include the TD tags + * @return void + */ + function RenderColumn ($intPos = 0, $strClass = "tblCell", $strClassLink = "tblCellA", $number = 0, $renderTD = 1) + { + if (! defined( 'ENABLE_ENCRYPT' )) { + define( 'ENABLE_ENCRYPT', 'no' ); + } + global $G_DATE_FORMAT; + global $G_TABLE_DATE_FORMAT; + $col = $this->Columns[$intPos]; + + switch (substr( $col['Name'], 0, 1 )) { + case '=': + // Si empieza con '=' entonces se toma como valor constante + $val = substr( $col['Name'], 1, strlen( $col['Name'] ) - 1 ); + break; + case '%': + // Si empieza con '%' entonces traducir/convertir el valor + $fieldname = substr( $col['Name'], 1, strlen( $col['Name'] ) - 1 ); + $val = $this->_row_values[$fieldname]; + $val = $this->translateValue( $this->_contexto, $val, SYS_LANG ); + break; + default: + $fieldname = $col['Name']; + $val = isset( $this->_row_values[$fieldname] ) ? $this->_row_values[$fieldname] : ''; + } + + $res = ""; + if (($this->show_nummbers) and ($intPos == 0)) { + $res = "$number"; + } + if (! (stristr( $val, "script" ) === false)) { + $val = htmlentities( $val, ENT_QUOTES, 'utf-8' ); + } + + if ($renderTD == 1) { + $res .= " 0) { + $res .= " width=\"" . $col["Width"] . "\""; + } + $res .= "> "; + } + + switch ($col["Type"]) { + case 'hidden': + return ''; + break; + case "text": + if ($val != "") { + $res .= G::unhtmlentities( $val, ENT_QUOTES, 'utf-8' ); + } else { + $res .= " "; + } + break; + case "text-dontSearch": + if ($val != "") { + $res .= G::unhtmlentities( $val ); + } else { + $res .= " "; + } + break; + case "html": + if ($val != "") { + $res .= ($val); + } else { + $res .= " "; + } + break; + case "textPlain": + if ($val != "") { + $res .= ($this->ParsingFromHtml( G::unhtmlentities( $val ), "300" )); + //if ( $val != "" ) $res .= (($val)); + } else { + $res .= " "; + } + break; + case "currency": + if ($val != "") { + $aux = explode( ' ', $val ); + $format = number_format( (float) $aux[0], 2, ".", "," ); + $res .= htmlentities( $format . ' ' . (isset( $aux[1] ) ? $aux[1] : ''), ENT_QUOTES, 'utf-8' ); + } else { + $res .= " "; + } + break; + + case "currency2": + if ($val != "") { + $res .= G::NumberToCurrency( $val ); + } else { + $res .= "$ 0.00"; + } + break; + + case "percentage2": + if ($val != "") { + $res .= G::NumberToPercentage( $val ); + } else { + $res .= "0.00 %"; + } + break; + + case "percentage": + if ($val != "") { + $res .= htmlentities( number_format( (float) $val, 2, ".", "," ) . " %", ENT_QUOTES, 'utf-8' ); + } else { + $res .= " "; + } + break; + + case "date": + if ($val != "" && $val != '0000-00-00 00:00:00') { + $part = explode( ' ', $val ); + $aux = explode( '-', $part[0] ); + + switch ($G_DATE_FORMAT) { + case 'DD/MM/AAAA': + $res .= formatDate( '$d/$m/$Y $H:$i:$s', $val ); + break; + case 'MM/DD/AAAA': + $res .= formatDate( '$m/$d/$Y $H:$i:$s EST', $val ); + break; + case 'AAAA/MM/DD': + $res .= formatDate( '$Y/$m/$d $H:$i:$s', $val ); + break; + case 'LITERAL': + $res .= formatDate( '$M $d $Y', $val ); + break; + } + + } else { + $res .= " "; + } + break; + + case "email": + if ($val != "") { + $res .= ""; + $res .= $val; + $res .= ""; + } else { + $res .= " "; + } + break; + + case "ifpdf": + if ($val == '1') { + $image = ""; + //valor + $tlabel = substr( $col["Content"], 0, 1 ); + $vname = substr( $col["Content"], 1, (strlen( $col["Content"] ) - 1) ); + $lval = $this->_row_values[$vname]; + //$res .= " $image "; //It open a new window... better the other way By JHL 16/11/06 + $res .= " $image "; + } else { + $res .= " "; + } + break; + + case "ifimg": + $image = ""; + if ($val == '1') { + //valor + $tlabel = substr( $col["Content"], 0, 1 ); + $vname = substr( $col["Content"], 1, (strlen( $col["Content"] ) - 1) ); + $lval = $this->_row_values[$vname]; + $res .= " $image "; + } else { + $res .= " "; + } + break; + + case "ifrtf": + if ($val == '1') { + $image = ""; + //valor + $tlabel = substr( $col["Content"], 0, 1 ); + $vname = substr( $col["Content"], 1, (strlen( $col["Content"] ) - 1) ); + $lval = $this->_row_values[$vname]; + //$res .= " $image "; //It open a new window... better the other way By JHL 16/11/06 + $res .= " $image "; + } else { + $res .= " "; + } + break; + + case "image": + + if (is_array( $col["Condition"] )) //By JHL to enable Condition to display a image -- New parameter Condition in Addrawcolumn +{ + $field_compare = $col["Condition"]['field']; + $tlabel = substr( $field_compare, 0, 1 ); + switch ($tlabel) { + case "&": + $vname = substr( $field_compare, 1, (strlen( $field_compare ) - 1) ); + $field_val = $this->_row_values[$vname]; + break; + } + + } else { + $val = ""; + } + // break; + + + case "textimage": + $AAS = $col['Extra']; + $val1 = " "; + // break; + case "image-text": + if (is_array( $col['Content'] ) && $col['Content'] != "") { + // Hay mas de un valor para el link + $values = $col['Content']; + $n = count( $values ); + + $res .= "_row_values[$vname]; + + $res .= $i == $n - 1 ? $lval : $lval . "/"; + break; + } + } + $res .= "\">" . strtoupper( $fieldname ) . "$val"; + } else + $val2 = "" . strtoupper( $fieldname ) . ""; + // break; + + + case "link": + if ($val == "") + $res .= " "; + $title = ''; + if ($col["Type"] == 'link' && trim( isset( $this->_row_values['TOOLTIP'] ) ? $this->_row_values['TOOLTIP'] : '' )) + ; + $title = (isset( $this->_row_values['TOOLTIP'] ) ? "title=\" " . $this->_row_values['TOOLTIP'] . " \"" : ''); + if (is_array( $col['Content'] ) && $col['Content'] != "") { + // Hay mas de un valor para el link + $values = $col['Content']; + $n = count( $values ); + + $res .= "_row_values[$vname]; + + $res .= $i == $n - 1 ? $lval : $lval . "/"; + break; + } + } + $res .= "\">$val"; + } elseif ($col["Content"] != "" && ! is_array( $col['Content'] )) { + $tlabel = substr( $col["Content"], 0, 1 ); + switch ($tlabel) { + case "&": + $vname = substr( $col["Content"], 1, (strlen( $col["Content"] ) - 1) ); + $lval = $this->_row_values[$vname]; + if (ENABLE_ENCRYPT == 'yes') { + + //$encoded = G::encrypt ( $col["Target"] . "/" . $lval . ".html", URL_KEY ); + $encoded = G::encryptUrl( $col["Target"] . "/" . $lval . ".html", URL_KEY ); + $res .= ""; + if ($col["Type"] == "textimage") { + $res .= $val1; + $val = " (" . $val . ")"; + } + if ($col["Type"] == "image-text") { + + $res .= $val2; + } + $res .= $val; + $res .= ""; + } else { + $res .= ""; + if ($col["Type"] == "textimage") { + $res .= $val1; + $val = " (" . $val . ")"; + } + if ($col["Type"] == "image-text") { + + $res .= $val2; + } + $res .= $val; + $res .= ""; + } + break; + case "$": + $vname = substr( $col["Content"], 1, (strlen( $col["Content"] ) - 1) ); + $lval = $HTTP_SESSION_VARS[$vname]; + $res .= ""; + $res .= $val; + $res .= ""; + break; + default: + $res .= ""; + $res .= $col["Content"]; + $res .= ""; + break; + } + } else { + $res .= ""; + $res .= $val; + $res .= ""; + } + break; + + case "linknew": + if ($val == "") + $res .= " "; + if ($col["Content"] != "") { + $tlabel = substr( $col["Content"], 0, 1 ); + switch ($tlabel) { + case "&": + if (ENABLE_ENCRYPT == 'yes') { + $vname = substr( $col["Content"], 1, (strlen( $col["Content"] ) - 1) ); + $lval = $this->_row_values[$vname]; + //$encoded = G::encryptUrl ( $col["Target"] , URL_KEY ). "/" . $lval . ".html"; + $encoded = G::encryptUrl( $col["Target"] . "/" . $lval . "", URL_KEY ); + $res .= ""; + $res .= $val; + $res .= ""; + } else { + $vname = substr( $col["Content"], 1, (strlen( $col["Content"] ) - 1) ); + $lval = $this->_row_values[$vname]; + $res .= ""; + $res .= $val; + $res .= ""; + } + break; + case "$": + $vname = substr( $col["Content"], 1, (strlen( $col["Content"] ) - 1) ); + $lval = $HTTP_SESSION_VARS[$vname]; + $res .= ""; + $res .= $val; + $res .= ""; + break; + default: + $res .= ""; + $res .= $col["Content"]; + $res .= ""; + break; + } + } else { + $res .= ""; + $res .= $val; + $res .= ""; + } + break; + + case "iflink": + if ($col["Content"] != "") { + $tlabel = substr( $col["Content"], 0, 1 ); + if ($val != "") { + switch ($tlabel) { + case "&": + $vname = substr( $col["Content"], 1, (strlen( $col["Content"] ) - 1) ); + $lval = $this->_row_values[$vname]; + $res .= ""; + $res .= $val; + $res .= ""; + break; + case "$": + $vname = substr( $col["Content"], 1, (strlen( $col["Content"] ) - 1) ); + $lval = $HTTP_SESSION_VARS[$vname]; + $res .= ""; + $res .= $val; + $res .= ""; + break; + default: + $res .= ""; + $res .= $col["Content"]; + $res .= ""; + break; + } + } else { + $res .= " "; + } + } else { + $res .= ""; + $res .= $val; + $res .= ""; + } + break; + + case "jsimglink": + $val = ""; + + case "jslink": + if ($val == "") { + $val .= " " . $col['Name'] . ''; + } + if ($val == "") { + $res .= " "; + } + if ($col["Content"] != "") { + $tlabel = substr( $col["Content"], 0, 1 ); + switch ($tlabel) { + case "&": + $vname = substr( $col["Content"], 1, (strlen( $col["Content"] ) - 1) ); + $lval = $this->_row_values[$vname]; + $res .= ""; + $res .= $val; + $res .= ""; + break; + + case "$": + $vname = substr( $col["Content"], 1, (strlen( $col["Content"] ) - 1) ); + $lval = $HTTP_SESSION_VARS[$vname]; + $res .= ""; + $res .= $val; + $res .= ""; + break; + + case '_': + $Values = explode( ',', substr( $col['Content'], 1, strlen( $col['Content'] ) ) ); + $res .= "_row_values[substr( $Value, 1, strlen( $Value ) )] . ','; + } else { + $res .= "'" . $this->_row_values[substr( $Value, 1, strlen( $Value ) )] . "',"; + } + } else { + $res .= $Value . ','; + } + } + $res = substr( $res, 0, strlen( $res ) - 1 ); + $res .= ")\"" . $col['Extra'] . ">"; + $res .= $val; + $res .= ""; + break; + + default: + $res .= ""; + $res .= $col["Content"]; + $res .= ""; + break; + } + } else { + $res .= ""; + $res .= $val; + $res .= ""; + } + break; + + case "checkbox": + $res .= " + * @access public + * @param string $strAction Next action to do + * @param string $strLabel Label + * @return void + */ + function SetAction ($strAction, $strLabel = "Continue") + { + $this->Action = $strAction; + $this->ActionLabel = $strLabel; + } + + /** + * Set contaxt and table (array) of translate + * + * @author Hardy Beltran Monasterios + * @param string $contexto Contexto en el cual se busca la traducci?n + * @param array $tabla Tabla con valores para traducir + * @param string $nombre Nombre del array $tabla + * @access public + * @return void + */ + function setTranslate ($contexto, $tabla, $nombre) + { + if (is_array( $this->contexto )) { + $this->contexto[0][] = $contexto; + $this->contexto[1][] = $nombre; + + } else { + $this->contexto = array (); + $this->contexto[0][] = $contexto; + $this->contexto[1][] = $nombre; + // array_push($this->contexto[0], $contexto); + // array_push($this->contexto[1], $nombre); + } + if (is_array( $this->translate )) { + $this->translate = array (); + $this->translate[$nombre] = $tabla; + } else { + $this->translate[$nombre] = $tabla; + } + // Fijamos ultimo contexto usado + $this->_contexto = $contexto; + } + + /** + * Search value in the table of translation and returns last accourding to choised context + * Retorna el valor a su equivalente traducido/convertido + * + * @author Hardy Beltran Monasterios + * @param string $contexto Contexto en el cual se busca la traducci?n + * @param mixed $valor Valor que se va traducir/convertir + * @param string $lang El lenguaje que se va utilizar + * @return mixed + */ + function translateValue ($contexto, $valor, $lang) + { + // Verificar si exite el contexto + if (in_array( $contexto, $this->contexto[0] )) { + $j = count( $this->contexto[0] ); + for ($i = 0; $i < $j; $i ++) { + if ($contexto == $this->contexto[0][$i]) { + $origen = $this->contexto[1][$i]; + } + } + $tabla = $this->translate[$origen]; + if (isset( $tabla[$lang][$valor] )) { + return $tabla[$lang][$valor]; + } else { + print ("l10n error:no lang or value.") ; + } + } else { + print ("l10n error:no context.") ; + } + } + + /** + * Estable el contexto de traducci?n/conversi?n + * + * @author Hardy Beltran Monasterios + * @param string $contexto Contexto en el cual se busca la traducci?n + * @return void + */ + function setContext ($contexto) + { + $this->_context = $contexto; + } + + /** + * Parse from HTML + * + * @author Fernando Ontiveros Lira + * @access public + * @return void + */ + function ParsingFromHtml ($value, $number = '100000000') + { + $car = substr( $value, 0, 1 ); + $len = strlen( $value ); + $Flag = 1; + $token = ''; + $i = 0; + + While ($i <= $len and $i <= $number) { + $car = substr( $value, $i, 1 ); + $br = strtoupper( substr( $value, $i, 4 ) ); + if ($car == '<') { + $Flag = 0; + } + if ($car == '>') { + $Flag = 1; + } + if ($br == '
' || $br == '

') + $token .= "
"; + + if (($Flag == 1) && ($car != '>')) { + $token .= $car; + if ($i == $number) + $token .= "... "; + } + $i = $i + 1; + } + return $token; + } } diff --git a/gulliver/system/class.xmlform.php b/gulliver/system/class.xmlform.php index 5ea33308d..2af106b22 100755 --- a/gulliver/system/class.xmlform.php +++ b/gulliver/system/class.xmlform.php @@ -3101,7 +3101,7 @@ class XmlForm_Field_RadioGroup extends XmlForm_Field { if( isset($this->linkType) && ($this->linkType == 1 || $this->linkType == "1") ){ $html .= '
' . $option . ''; } else { - $html .= '' . $option . ''; + $html .= ''; } if(++$i==count($this->options)){ $html .= '      '.$this->renderHint(); @@ -3117,7 +3117,7 @@ class XmlForm_Field_RadioGroup extends XmlForm_Field { } elseif ($this->mode === 'view') { $html = ''; foreach ( $this->options as $optionName => $option ) { - $html .= '' . $option . '
'; + $html .= '
'; if($optionName == $value) $html .= ''; } @@ -3198,7 +3198,7 @@ class XmlForm_Field_CheckGroup extends XmlForm_Field $i=0; $html = ''; foreach ( $this->options as $optionName => $option ) { - $html .= '' . $option . ''; + $html .= ''; if(++$i==count($this->options)){ $html .= '      '.$this->renderHint(); } @@ -3208,7 +3208,7 @@ class XmlForm_Field_CheckGroup extends XmlForm_Field } elseif ($this->mode === 'view') { $html = ''; foreach ( $this->options as $optionName => $option ) { - $html .= '' . $option . '
'; + $html .= '
'; $html .= ''; } return $html; @@ -4789,18 +4789,7 @@ class xmlformTemplate extends Smarty $value = (isset ( $form->values [$k] )) ? $form->values [$k] : NULL; $result [$k] = G::replaceDataField ( $form->fields [$k]->label, $form->values ); if ($form->type == 'xmlform') { - if ($v->type == 'checkgroup' || $v->type == 'radiogroup') { - $firstValueOptions = ''; - foreach ($v->options as $indexOption => $valueOptions) { - $firstValueOptions = $indexOption; - break; - } - if ($firstValueOptions != '') { - $result[$k] = ''; - } else { - $result[$k] = ''; - } - } else { + if ($v->type != 'checkgroup' && $v->type != 'radiogroup') { $result[$k] = ''; } } diff --git a/phpunit.xml b/phpunit.xml index c423da389..d3ed5e4d7 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -7,14 +7,13 @@ convertNoticesToExceptions="true" convertWarningsToExceptions="true" processIsolation="false" - stopOnFailure="false" - syntaxCheck="false" + stopOnFailure="true" + syntaxCheck="true" bootstrap="tests/bootstrap.php" > ./tests/automated/ - ./tests/unit/backend/services/ ".$v."
"; - */ - if ($value['TAS_TYPE'] == 'NORMAL') { - $ini = ($value['TAS_START'] == 'TRUE') ? 'true' : 'false'; - - $nodo_task = addNodox( $doc, $nodo_tasks, 'Task', '', array ('Title' => $value['TAS_TITLE'],'Description' => $value['TAS_DESCRIPTION'],'Id' => 'ID' . $value['TAS_UID'],'StartingTask' => $ini - ) ); - $nodo_coordinates = addNodox( $doc, $nodo_task, 'Coordinates', '', array ('XCoordinate' => $value['TAS_POSX'],'YCoordinate' => $value['TAS_POSY'] - ) ); - $nodo_derivationrule = addNodox( $doc, $nodo_task, 'DerivationRule', '', '' ); - - derivationRules( $aRoute, $doc, $nodo_derivationrule ); - - $nodo_assignmentrules = addNodox( $doc, $nodo_task, 'AssignmentRules', '', '' ); - $nodo_cyclicalassignment = addNodox( $doc, $nodo_assignmentrules, 'CyclicalAssignment', '', '' ); - $nodo_timingcontrol = addNodox( $doc, $nodo_task, 'TimingControl', '', array ('TaskDuration' => $value['TAS_DURATION'] - ) ); - $nodo_permissions = addNodox( $doc, $nodo_task, 'Permissions', '', '' ); - $nodo_caselabels = addNodox( $doc, $nodo_task, 'CaseLabels', '', '' ); - $nodo_notifications = addNodox( $doc, $nodo_task, 'Notifications', '', '' ); - } else { - require_once ("classes/model/SubProcess.php"); - $oCriteria = new Criteria( 'workflow' ); - $oCriteria->add( SubProcessPeer::PRO_PARENT, $value['PRO_UID'] ); - $oCriteria->add( SubProcessPeer::TAS_PARENT, $value['TAS_UID'] ); - $oDataset = SubProcessPeer::doSelectRS( $oCriteria ); - $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC ); - $oDataset->next(); - $aRow = $oDataset->getRow(); - $nodo_task = addNodox( $doc, $nodo_tasks, 'SubProcess', '', array ('Title' => $value['TAS_TITLE'],'Description' => $value['TAS_DESCRIPTION'],'Id' => 'ID' . $value['TAS_UID'],'ProcessRef' => $aRow['PRO_UID'] - ) ); - $nodo_coordinates = addNodox( $doc, $nodo_task, 'Coordinates', '', array ('XCoordinate' => $value['TAS_POSX'],'YCoordinate' => $value['TAS_POSY'] - ) ); - $nodo_derivationrule = addNodox( $doc, $nodo_task, 'DerivationRule', '', '' ); - - derivationRules( $aRoute, $doc, $nodo_derivationrule ); - } - } - $oDataset->next(); -} -//die; -$doc->preserveWhiteSpace = false; -$doc->formatOutput = true; -$doc->save( PATH_METHODS . 'services/test_xpdl.xml' ); -echo "xml for xpdl creado!!!
"; - diff --git a/workflow/engine/skinEngine/base/css/rtl.css b/workflow/engine/skinEngine/base/css/rtl.css index 2692070ef..32c0aafb5 100644 --- a/workflow/engine/skinEngine/base/css/rtl.css +++ b/workflow/engine/skinEngine/base/css/rtl.css @@ -17,6 +17,7 @@ ul#pm_menu { padding: 0 0 0 13px; } +ul#pm_menu li { float: right;} a.options-tool { color: #FFFFFF; diff --git a/workflow/engine/skinEngine/skinEngine.php b/workflow/engine/skinEngine/skinEngine.php index 25df380ca..a5f59f44b 100755 --- a/workflow/engine/skinEngine/skinEngine.php +++ b/workflow/engine/skinEngine/skinEngine.php @@ -236,7 +236,10 @@ class SkinEngine if (defined('PATH_CUSTOM_SKINS') && is_dir(PATH_CUSTOM_SKINS . $this->mainSkin)) { $templateFile = PATH_CUSTOM_SKINS . $this->mainSkin . PATH_SEP .'extJsInitLoad.html'; } - //Skin uxs - simplefied + //Skin uxs - simplified + if (!isset($_SESSION['user_experience'])) { + $_SESSION['user_experience'] = 'NORMAL'; + } if ($_SESSION['user_experience'] != 'NORMAL') { $templateFile = (is_dir(PATH_CUSTOM_SKINS . 'uxs')) ? PATH_CUSTOM_SKINS . 'simplified' . PATH_SEP . 'extJsInitLoad.html' : $templateFile; } diff --git a/workflow/engine/templates/bpmn/Annotation.js b/workflow/engine/templates/bpmn/Annotation.js deleted file mode 100755 index 2382ad80d..000000000 --- a/workflow/engine/templates/bpmn/Annotation.js +++ /dev/null @@ -1,321 +0,0 @@ -ArrowLine=function(){ - this.lineColor=new Color(0,0,0); - this.stroke=1; - this.canvas=null; - this.workflow=null; - this.html=null; - this.graphics=null; - //this.id=UUID.create(); - this.startX=30; - this.startY=30; - this.endX=100; - this.endY=100; - this.zOrder=Line.ZOrderBaseIndex; - this.setSelectable(true); - this.setDeleteable(true); - this.arrowWidth=8; - this.arrowLength=20; - this.lineWidth=2; -}; - -ArrowLine.prototype=new Line(); -ArrowLine.prototype.type="ArrowLine"; -ArrowLine.prototype.paint=function(){ - if(this.graphics===null){ - this.graphics=new jsGraphics(this.id); - } - else{ - this.graphics.clear(); - } - //this.graphics.setStroke(this.stroke); - this.graphics.setStroke( Stroke.DOTTED ); - this.graphics.setColor(this.lineColor.getHTMLStyle()); - - var endY=this.getLength(); - var _3e2a=[0 ,0 ,endY ]; - var _3e2b=[-this.lineWidth,+this.lineWidth,-(this.lineWidth)]; - var _3e2c=this.getAngle()*Math.PI/180; - var rotX=[]; - var rotY=[]; - for(var i=0;i<_3e2a.length;i++){ - rotX[i]=this.startX+_3e2a[i]*Math.cos(_3e2c)-_3e2b[i]*Math.sin(_3e2c); - rotY[i]=this.startY+_3e2a[i]*Math.sin(_3e2c)+_3e2b[i]*Math.cos(_3e2c); - } - this.graphics.drawPolyLine(rotX,rotY); - this.graphics.paint(); -}; - -DottedConnection=function(){ -ArrowLine.call(this); -this.sourcePort=null; -this.targetPort=null; -this.lineSegments=[]; -this.setColor(new Color(0,0,115)); -this.setLineWidth(1); -}; -DottedConnection.prototype=new ArrowLine(); -DottedConnection.prototype.type="DottedConnection"; -DottedConnection.prototype.disconnect=function(){ -if(this.sourcePort!==null){ -this.sourcePort.detachMoveListener(this); -} -if(this.targetPort!==null){ -this.targetPort.detachMoveListener(this); -} -}; -DottedConnection.prototype.reconnect=function(){ -if(this.sourcePort!==null){ -this.sourcePort.attachMoveListener(this); -} -if(this.targetPort!==null){ -this.targetPort.attachMoveListener(this); -} -}; -DottedConnection.prototype.isConnector=function(){ -return true; -}; -DottedConnection.prototype.isResizeable=function(){ -return false; -}; -DottedConnection.prototype.setSource=function(port){ -if(this.sourcePort!==null){ -this.sourcePort.detachMoveListener(this); -} -this.sourcePort=port; -if(this.sourcePort===null){ -return; -} -this.sourcePort.attachMoveListener(this); -this.setStartPoint(port.getAbsoluteX(),port.getAbsoluteY()); -}; -DottedConnection.prototype.getSource=function(){ -return this.sourcePort; -}; -DottedConnection.prototype.setTarget=function(port){ -if(this.targetPort!==null){ -this.targetPort.detachMoveListener(this); -} -this.targetPort=port; -if(this.targetPort===null){ -return; -} -this.targetPort.attachMoveListener(this); -this.setEndPoint(port.getAbsoluteX(),port.getAbsoluteY()); -}; -DottedConnection.prototype.getTarget=function(){ -return this.targetPort; -}; -DottedConnection.prototype.onOtherFigureMoved=function(_3824){ -if(_3824==this.sourcePort){ -this.setStartPoint(this.sourcePort.getAbsoluteX(),this.sourcePort.getAbsoluteY()); -}else{ -this.setEndPoint(this.targetPort.getAbsoluteX(),this.targetPort.getAbsoluteY()); -} -}; - - - -bpmnAnnotation = function (oWorkflow) { - VectorFigure.call(this); - //Getting width and height from DB - if(typeof oWorkflow.anno_width != 'undefined' && typeof oWorkflow.anno_height != 'undefined'){ - this.width = oWorkflow.anno_width; - this.height = oWorkflow.anno_height; - } - else{ - this.width = 110; - this.height = 50; - } - this.setAnnotationName(oWorkflow.annotationName); //It will set the Default Task Name with appropriate count While dragging a task on the canvas -}; - -bpmnAnnotation.prototype = new VectorFigure; -bpmnAnnotation.prototype.type = "bpmnAnnotation"; -bpmnAnnotation.prototype.setAnnotationName = function (name) { - if(typeof name != 'undefined') - this.annotationName = name; - else - this.annotationName = 'Annotation 1'; -}; - -bpmnAnnotation.prototype.coord_converter = function (bound_width, bound_height, text_length) { - //bound_width = this.workflow.currentSelection.width; - //bound_height = this.workflow.currentSelection.height; - input_width = text_length * 6 - input_height = 10 - - temp_width = bound_width - input_width; - temp_width /= 2; - temp_x = temp_width; - - temp_height = bound_height - 10; - temp_height /= 2; - temp_y = temp_height; - - var temp_coord = new Object(); - temp_coord.temp_x = temp_x; - temp_coord.temp_y = temp_y; - return temp_coord; -}; - - - -bpmnAnnotation.prototype.paint = function () { - VectorFigure.prototype.paint.call(this); - - if(typeof workflow.zoomfactor == 'undefined') - workflow.zoomfactor = 1; - - //Set the Task Limitation - if(typeof this.limitFlag == 'undefined' || this.limitFlag == false) - { - this.originalWidth = 110; - this.originalHeight = 50; - this.orgXPos = this.getX(); - this.orgYPos = this.getY(); - this.orgFontSize =this.fontSize; - } - var zoomRate = workflow.zoomfactor; - - this.width = this.originalWidth * workflow.zoomfactor; - this.height = this.originalHeight * workflow.zoomfactor; - - //this.graphics.setColor("#ffffff"); - this.graphics.setColor("#f8f8f8"); - this.graphics.fillRect(0,0, this.getWidth(), this.getHeight()); - this.graphics.setStroke(1.5); - this.graphics.setColor("#202020"); - this.graphics.drawLine(this.getWidth()/4,0,0,0); - this.graphics.drawLine(0,0,0,this.getHeight()); - this.graphics.drawLine(0,this.getHeight(),this.getWidth()/4,this.getHeight()); - this.graphics.setStroke(1); - this.graphics.paint(); - - /* New object is created to implement changing of Text functionality - */ - this.bpmnText = new jsGraphics(this.id) ; - this.padleft = 0.05*this.getWidth(); - this.padtop = 0.13*this.getHeight() -1; - this.rectwidth = this.getWidth() - this.padleft; - this.rectheight = this.getHeight() - 2 * this.padtop; - - //Setting text size to zoom font size if Zoomed - this.fontSize = 11; - var fontSize = zoomRate * this.fontSize; - this.bpmnText.setFont('verdana', + fontSize+'px', Font.PLAIN); - - this.bpmnText.drawStringAnno(this.annotationName,0,this.padtop,this.rectwidth,this.rectheight,'left'); - this.bpmnText.paint(); - - if( this.input1!=null ){ - this.input1.setPosition(0,this.height/2); - } -}; - - jsGraphics.prototype.drawStringAnno = function(txt, x, y, width,height, halign) - { - this.htm += '
'+ - txt + - '<\/div>'; - }; - -bpmnAnnotation.prototype.setWorkflow=function(_40c5){ - VectorFigure.prototype.setWorkflow.call(this,_40c5); - if(_40c5!=null){ - this.input1=new InputPort(); - this.input1.setWorkflow(_40c5); - this.input1.setName('input1'); - this.input1.setZOrder(-1); - this.input1.setBackgroundColor(new Color(255, 255, 255)); - this.input1.setColor(new Color(255, 255, 255)); - //this.addPort(this.input1,0,this.height/2); - this.addPort(this.input1,-this.getWidth()/2,-this.getHeight()/4); - }; -}; - -bpmnAnnotationDialog = function (_2e5e) { - this.figure = _2e5e; - var title = 'Annotation'; - Dialog.call(this, title); - this.setDimension(400, 150); //Set the width and height of the Dialog box -} - -bpmnAnnotationDialog.prototype = new Dialog(); -bpmnAnnotationDialog.prototype.createHTMLElement = function () { - var item = Dialog.prototype.createHTMLElement.call(this); - var inputDiv = document.createElement("form"); - inputDiv.style.position = "absolute"; - inputDiv.style.left = "10px"; - inputDiv.style.top = "30px"; - inputDiv.style.width = "375px"; - inputDiv.style.font = "normal 10px verdana"; - item.appendChild(inputDiv); - this.label = document.createTextNode("Annotation Name"); - inputDiv.appendChild(this.label); - this.input = document.createElement("textarea"); - this.input.style.border = "1px solid gray"; - this.input.style.font = "normal 10px verdana"; - //this.input.type = "text"; - this.input.maxLength = "500"; - this.input.cols = "50"; - this.input.rows = "3"; - var value = bpmnTask.prototype.trim(this.figure.workflow.currentSelection.annotationName); - if (value) this.input.value = value; - else this.input.value = ""; - this.input.style.width = "100%"; - inputDiv.appendChild(this.input); - this.input.focus(); - return item; -}; - -/*Double Click Event for opening the dialog Box*/ -bpmnAnnotation.prototype.onDoubleClick = function () { - var _409d = new bpmnAnnotationDialog(this); - this.workflow.showDialog(_409d, this.workflow.currentSelection.x, this.workflow.currentSelection.y); -}; - - -/** - * This method will be called if the user pressed the OK button in buttonbar of the dialog.
- * The string is first cleared and new string is painted.

- **/ - bpmnAnnotationDialog.prototype.onOk = function () { - this.figure.bpmnText.clear(); - - len = Math.ceil(this.input.value.length/16); - if(this.input.value.length < 19) - { - len = 1.5; - if(this.input.value.length > 9) - this.figure.rectWidth = this.input.value.length*8; - else - this.figure.rectWidth = 48; - } - else - this.figure.rectWidth = 150; - //tempcoord = this.workflow.currentSelection.coord_converter(this.workflow.currentSelection.width, this.workflow.currentSelection.height, this.input.value.length) - this.figure.bpmnText.drawStringAnno(this.input.value,20,20,this.figure.rectWidth,'left'); - // this.figure.bpmnNewText.drawTextString(this.input.value, this.workflow.currentSelection.width, this.workflow.currentSelection.height, tempcoord.temp_x, tempcoord.temp_y); - this.figure.bpmnText.paint(); - this.figure.annotationName = this.input.value; //Set Updated Text value - - //Updating Annotation Text Async into the DB - this.figure.actiontype = 'updateText'; - this.workflow.saveShape(this.figure); - - if(this.figure.rectWidth<80) - tempW = 110; - else - tempW = this.figure.rectWidth+35; - this.workflow.currentSelection.setDimension(tempW, len*13+40); - - this.workflow.removeFigure(this); -}; diff --git a/workflow/engine/templates/bpmn/Dataobject.js b/workflow/engine/templates/bpmn/Dataobject.js deleted file mode 100755 index 375e499d5..000000000 --- a/workflow/engine/templates/bpmn/Dataobject.js +++ /dev/null @@ -1,33 +0,0 @@ -bpmnDataobject = function (_30ab) { - VectorFigure.call(this); - this.setDimension(50, 80); - this.setTaskName(_30ab.taskNo); //It will set the Default Task Name with appropriate count While dragging a task on the canvas -}; - -bpmnDataobject.prototype = new VectorFigure; -bpmnDataobject.prototype.type = "bpmnDataobject"; -bpmnDataobject.prototype.setTaskName = function (name) { - this.taskName = 'Data Object ' + name; -}; - -bpmnDataobject.prototype.paint = function () { - VectorFigure.prototype.paint.call(this); - var x = new Array(0, this.getWidth()-10, this.getWidth(), this.getWidth()-10, this.getWidth()-10, this.getWidth(), this.getWidth(), 0); - var y = new Array(0, 0, 10, 10, 0, 10, this.getHeight(), this.getHeight()); - - this.graphics.setStroke(this.stroke); - this.graphics.setColor("#c0c0c0"); - this.graphics.fillPolygon(x, y); - - for (var i = 0; i < x.length; i++) { - x[i] = x[i] - 3; - y[i] = y[i] - 3; - } - this.graphics.setColor("#ffffff"); - this.graphics.fillPolygon(x, y); - this.graphics.setColor("#ff0f0f"); - this.graphics.drawPolygon(x, y); - this.graphics.paint(); - this.x_text = this.workflow.getAbsoluteX(); //Get x co-ordinate from figure - this.y_text = this.workflow.getAbsoluteY(); //Get x co-ordinate from figure -} diff --git a/workflow/engine/templates/bpmn/EventBoundaryTimerInter.js b/workflow/engine/templates/bpmn/EventBoundaryTimerInter.js deleted file mode 100755 index 68ba991f8..000000000 --- a/workflow/engine/templates/bpmn/EventBoundaryTimerInter.js +++ /dev/null @@ -1,88 +0,0 @@ -bpmnEventBoundaryInter=function(){ -VectorFigure.call(this); -//Setting width and height values as per the zoom ratio -if(typeof workflow.zoomWidth != 'undefined' || typeof workflow.zoomHeight != 'undefined') - this.setDimension(workflow.zoomWidth, workflow.zoomHeight); -else - this.setDimension(30,30); -this.stroke = 2; -}; -bpmnEventBoundaryInter.prototype=new VectorFigure; -bpmnEventBoundaryInter.prototype.type="bpmnEventBoundaryTimerInter"; -bpmnEventBoundaryInter.prototype.paint=function(){ -VectorFigure.prototype.paint.call(this); -var x_cir1=0; -var y_cir1=0; - -this.graphics.setColor("#c0c0c0"); -this.graphics.fillEllipse(x_cir1+3,y_cir1+3,this.getWidth(),this.getHeight()); - -this.graphics.setStroke(this.stroke); -this.graphics.setColor( "#f9faf2" ); -this.graphics.fillEllipse(x_cir1,y_cir1,this.getWidth(),this.getHeight()); -this.graphics.setColor("#adae5e"); -this.graphics.drawEllipse(x_cir1,y_cir1,this.getWidth(),this.getHeight()); -var x_cir2=3; -var y_cir2=3; -this.graphics.setColor( "#f9faf2" ); -this.graphics.fillEllipse(x_cir2,y_cir2,this.getWidth()-6,this.getHeight()-6); -this.graphics.setColor("#adae5e"); -this.graphics.drawEllipse(x_cir2,y_cir2,this.getWidth()-6,this.getHeight()-6); - -this.graphics.setColor("#adae5e"); -//this.graphics.drawEllipse(x_cir3,y_cir3,this.getWidth()-20,this.getHeight()-20); -this.graphics.drawLine(this.getWidth()/2.2,this.getHeight()/2,this.getWidth()/1.6,this.getHeight()/2); //horizontal line -this.graphics.drawLine(this.getWidth()/2.2,this.getHeight()/2,this.getWidth()/2.2,this.getHeight()/3.7); //vertical line - -this.graphics.drawLine(24,8,20,11); //10th min line -this.graphics.drawLine(22,15,25,15); //15th min line -this.graphics.drawLine(24,22,19,20); //25th min line -this.graphics.drawLine(15,22,15,25); //30th min line -this.graphics.drawLine(8,22,12,19); //40th min line -this.graphics.drawLine(5,15,8,15); //45th min line -this.graphics.drawLine(8,8,11,11); //50th min line -this.graphics.drawLine(15,5,15,8); //60th min line - -this.graphics.paint(); - -/*Code Added to Dynamically shift Ports on resizing of shapes - **/ -if(this.input1!=null){ -this.input1.setPosition(0,this.height/2); -} -if(this.output1!=null){ -this.output1.setPosition(this.width/2,this.height); -} -if(this.input2!=null){ -this.input2.setPosition(this.width/2,0); -} -if(this.output2!=null){ -this.output2.setPosition(this.width,this.height/2); -} -}; - -bpmnEventBoundaryInter.prototype.setWorkflow=function(_40c5){ -VectorFigure.prototype.setWorkflow.call(this,_40c5); -if(_40c5!=null){ - var eventPortName = ['input2','output2']; - var eventPortType = ['InputPort','OutputPort']; - var eventPositionX= [this.width/2,this.width/2]; - var eventPositionY= [0,this.height]; - - for(var i=0; i< eventPortName.length ; i++){ - eval('this.'+eventPortName[i]+' = new '+eventPortType[i]+'()'); //Create New Port - eval('this.'+eventPortName[i]+'.setWorkflow(_40c5)'); //Add port to the workflow - eval('this.'+eventPortName[i]+'.setName("'+eventPortName[i]+'")'); //Set PortName - eval('this.'+eventPortName[i]+'.setZOrder(-1)'); //Set Z-Order of the port to -1. It will be below all the figure - eval('this.'+eventPortName[i]+'.setBackgroundColor(new Color(255, 255, 255))'); //Setting Background of the port to white - eval('this.'+eventPortName[i]+'.setColor(new Color(255, 255, 255))'); //Setting Border of the port to white - eval('this.addPort(this.'+eventPortName[i]+','+eventPositionX[i]+', '+eventPositionY[i]+')'); //Setting Position of the port - } -} -}; - -bpmnEventBoundaryInter.prototype.getContextMenu=function(){ -if(this.id != null){ - this.workflow.handleContextMenu(this); -} -}; diff --git a/workflow/engine/templates/bpmn/EventCancelEnd.js b/workflow/engine/templates/bpmn/EventCancelEnd.js deleted file mode 100755 index 014a07236..000000000 --- a/workflow/engine/templates/bpmn/EventCancelEnd.js +++ /dev/null @@ -1,80 +0,0 @@ -bpmnEventCancelEnd=function(){ -VectorFigure.call(this); -//Setting width and height values as per the zoom ratio -if(typeof workflow.zoomWidth != 'undefined' || typeof workflow.zoomHeight != 'undefined') - this.setDimension(workflow.zoomWidth, workflow.zoomHeight); -else - this.setDimension(30,30); -this.stroke=3; -}; -bpmnEventCancelEnd.prototype=new VectorFigure; -bpmnEventCancelEnd.prototype.type="bpmnEventCancelEnd"; -bpmnEventCancelEnd.prototype.paint=function(){ -VectorFigure.prototype.paint.call(this); - //Set the Task Limitation - if (this.getWidth() < 30 || this.getHeight() < 30) { - this.setDimension(30, 30); - } - -this.graphics.setStroke(this.stroke); -var x_cir = 0; -var y_cir = 0; - -this.graphics.setColor("#c0c0c0"); -this.graphics.fillEllipse(x_cir+5,y_cir+5,this.getWidth(),this.getHeight()); -this.graphics.setColor("#f7f1e5"); -this.graphics.fillEllipse(x_cir,y_cir,this.getWidth(),this.getHeight()); -this.graphics.setColor("#c46508"); -this.graphics.drawEllipse(x_cir,y_cir,this.getWidth(),this.getHeight()); -this.graphics.setStroke(2); -//var x=new Array(16,23,31,36,29,37,32,23,16,11,18,11); -//var y=new Array(35,27,33,29,22,14,9,16,9,14,22,29); -var x=new Array(this.getWidth()/2.8,this.getWidth()/1.95,this.getWidth()/1.45,this.getWidth()/1.25,this.getWidth()/1.55,this.getWidth()/1.21,this.getWidth()/1.4,this.getWidth()/1.95,this.getWidth()/2.8,this.getWidth()/4.1,this.getWidth()/2.5,this.getWidth()/4.1); -var y=new Array(this.getHeight()/1.28,this.getHeight()/1.66,this.getHeight()/1.36,this.getHeight()/1.55,this.getHeight()/2.04,this.getHeight()/3.21,this.getHeight()/5.6,this.getHeight()/2.81,this.getHeight()/5.6,this.getHeight()/3.21,this.getHeight()/2.04,this.getHeight()/1.55); -this.graphics.setColor("#c46508"); -this.graphics.fillPolygon(x,y); -this.graphics.setColor("#c46508"); -//this.graphics.drawPolygon(x,y); -this.graphics.paint(); - -/*Code Added to Dynamically shift Ports on resizing of shapes - **/ -if(this.input1!=null){ -this.input1.setPosition(0,this.height/2); -} -if(this.output1!=null){ -this.output1.setPosition(this.width/2,this.height); -} -if(this.input2!=null){ -this.input2.setPosition(this.width/2,0); -} -if(this.output2!=null){ -this.output2.setPosition(this.width,this.height/2); -} -}; - -bpmnEventCancelEnd.prototype.setWorkflow=function(_40c5){ -VectorFigure.prototype.setWorkflow.call(this,_40c5); -if(_40c5!=null){ - var eventPortName = ['input1','input2']; - var eventPortType = ['InputPort','InputPort']; - var eventPositionX= [this.width/2,0]; - var eventPositionY= [0,this.height/2]; - - for(var i=0; i< eventPortName.length ; i++){ - eval('this.'+eventPortName[i]+' = new '+eventPortType[i]+'()'); //Create New Port - eval('this.'+eventPortName[i]+'.setWorkflow(_40c5)'); //Add port to the workflow - eval('this.'+eventPortName[i]+'.setName("'+eventPortName[i]+'")'); //Set PortName - eval('this.'+eventPortName[i]+'.setZOrder(-1)'); //Set Z-Order of the port to -1. It will be below all the figure - eval('this.'+eventPortName[i]+'.setBackgroundColor(new Color(255, 255, 255))'); //Setting Background of the port to white - eval('this.'+eventPortName[i]+'.setColor(new Color(255, 255, 255))'); //Setting Border of the port to white - eval('this.addPort(this.'+eventPortName[i]+','+eventPositionX[i]+', '+eventPositionY[i]+')'); //Setting Position of the port - } -} -}; - -bpmnEventCancelEnd.prototype.getContextMenu=function(){ -if(this.id != null){ - this.workflow.handleContextMenu(this); -} -}; diff --git a/workflow/engine/templates/bpmn/EventCancelInter.js b/workflow/engine/templates/bpmn/EventCancelInter.js deleted file mode 100755 index 7c5bc20e5..000000000 --- a/workflow/engine/templates/bpmn/EventCancelInter.js +++ /dev/null @@ -1,49 +0,0 @@ -bpmnEventCancelInter=function(){ -VectorFigure.call(this); -this.stroke=1; -}; -bpmnEventCancelInter.prototype=new VectorFigure; -bpmnEventCancelInter.prototype.type="bpmnEventCancelInter"; -bpmnEventCancelInter.prototype.paint=function(){ -VectorFigure.prototype.paint.call(this); - -if(typeof workflow.zoomfactor == 'undefined') - workflow.zoomfactor = 1; - //Set the Task Limitation -if(typeof this.limitFlag == 'undefined' || this.limitFlag == false) -{ - this.originalWidth = 30; - this.originalHeight = 30; - this.orgXPos = this.getX(); - this.orgYPos = this.getY(); - this.orgFontSize =this.fontSize; -} - -this.width = this.originalWidth * workflow.zoomfactor; -this.height = this.originalHeight * workflow.zoomfactor; - -this.graphics.setStroke(this.stroke); -var x_cir = 0; -var y_cir = 0; -this.graphics.setColor("#000000"); -this.graphics.drawEllipse(x_cir,y_cir,this.getWidth(),this.getHeight()); -var x_cir2=5; -var y_cir2=5; -this.graphics.setColor("#000000"); -this.graphics.drawEllipse(x_cir2,y_cir2,this.getWidth()-10,this.getHeight()-10); -//var x=new Array(16,23,31,36,29,37,32,23,16,11,18,11); -//var y=new Array(35,27,33,29,22,14,9,16,9,14,22,29); -var cw = this.getWidth(); -var ch = this.getHeight(); -var x=new Array(cw*0.35,cw*0.51,cw*0.68,cw*0.8,cw*0.64,cw*0.82,cw*0.71,cw*0.51,cw*0.35,cw*0.24,cw*0.4,cw*0.24); -var y=new Array(ch*0.78,ch*0.6,ch*0.73,ch*0.64,ch*0.49,ch*0.31,ch*0.17,ch*0.35,ch*0.17,ch*0.31,ch*0.49,ch*0.64); -//var x=new Array(cw/2.8,cw/1.95,cw/1.45,cw/1.25,cw/1.55,cw/1.21,cw/1.4,cw/1.95,cw/2.8,cw/4.1,cw/2.5,cw/4.1); -//var y=new Array(ch/1.28,ch/1.66,ch/1.36,ch/1.55,ch/2.04,ch/3.21,ch/5.6,ch/2.81,ch/5.6,ch/3.21,ch/2.04,ch/1.55); -this.graphics.setColor("#ffffff"); -this.graphics.fillPolygon(x,y); -this.graphics.setColor("#000000"); -this.graphics.drawPolygon(x,y); -this.graphics.paint(); -}; - - diff --git a/workflow/engine/templates/bpmn/EventCompEnd.js b/workflow/engine/templates/bpmn/EventCompEnd.js deleted file mode 100755 index 86bda85f3..000000000 --- a/workflow/engine/templates/bpmn/EventCompEnd.js +++ /dev/null @@ -1,74 +0,0 @@ -bpmnEventCompEnd=function(){ -VectorFigure.call(this); -//Setting width and height values as per the zoom ratio -if(typeof workflow.zoomWidth != 'undefined' || typeof workflow.zoomHeight != 'undefined') - this.setDimension(workflow.zoomWidth, workflow.zoomHeight); -else - this.setDimension(30,30); -this.stroke=3 -}; -bpmnEventCompEnd.prototype=new VectorFigure; -bpmnEventCompEnd.prototype.type="bpmnEventCompEnd"; -bpmnEventCompEnd.prototype.paint=function(){ -VectorFigure.prototype.paint.call(this); -this.graphics.setStroke(this.stroke); -var x_cir = 0; -var y_cir = 0; - -this.graphics.setColor("#c0c0c0"); -this.graphics.fillEllipse(x_cir+5,y_cir+5,this.getWidth(),this.getHeight()); -this.graphics.setColor("#f7f1e5"); -this.graphics.fillEllipse(x_cir,y_cir,this.getWidth(),this.getHeight()); -this.graphics.setColor("#c46508"); -this.graphics.drawEllipse(x_cir,y_cir,this.getWidth(),this.getHeight()); -//var x_arrow=new Array(6,19,19,32,32,19,19); -//var y_arrow=new Array(22,33,22,33,11,22,11); -var x_arrow=new Array(this.getWidth()/7,this.getWidth()/2.36,this.getWidth()/2.36,this.getWidth()/1.4,this.getWidth()/1.42,this.getWidth()/2.36,this.getWidth()/2.36); -var y_arrow=new Array(this.getHeight()/2,this.getHeight()/1.36,this.getHeight()/2,this.getHeight()/1.36,this.getHeight()/4,this.getHeight()/2,this.getHeight()/4); -this.graphics.setColor( "#c46508" ); -this.graphics.fillPolygon(x_arrow,y_arrow); -this.graphics.setColor("#c46508"); -//this.graphics.drawPolygon(x_arrow,y_arrow); -this.graphics.paint();/*Code Added to Dynamically shift Ports on resizing of shapes - **/ -if(this.input1!=null){ -this.input1.setPosition(0,this.height/2); -} -if(this.output1!=null){ -this.output1.setPosition(this.width/2,this.height); -} -if(this.input2!=null){ -this.input2.setPosition(this.width/2,0); -} -if(this.output2!=null){ -this.output2.setPosition(this.width,this.height/2); -} -}; - -bpmnEventCompEnd.prototype.setWorkflow=function(_40c5){ -VectorFigure.prototype.setWorkflow.call(this,_40c5); -if(_40c5!=null){ - var eventPortName = ['input1','input2']; - var eventPortType = ['InputPort','InputPort']; - var eventPositionX= [this.width/2,0]; - var eventPositionY= [0,this.height/2]; - - for(var i=0; i< eventPortName.length ; i++){ - eval('this.'+eventPortName[i]+' = new '+eventPortType[i]+'()'); //Create New Port - eval('this.'+eventPortName[i]+'.setWorkflow(_40c5)'); //Add port to the workflow - eval('this.'+eventPortName[i]+'.setName("'+eventPortName[i]+'")'); //Set PortName - eval('this.'+eventPortName[i]+'.setZOrder(-1)'); //Set Z-Order of the port to -1. It will be below all the figure - eval('this.'+eventPortName[i]+'.setBackgroundColor(new Color(255, 255, 255))'); //Setting Background of the port to white - eval('this.'+eventPortName[i]+'.setColor(new Color(255, 255, 255))'); //Setting Border of the port to white - eval('this.addPort(this.'+eventPortName[i]+','+eventPositionX[i]+', '+eventPositionY[i]+')'); //Setting Position of the port - } -} -}; - - - -bpmnEventCompEnd.prototype.getContextMenu=function(){ -if(this.id != null){ - this.workflow.handleContextMenu(this); -} -}; diff --git a/workflow/engine/templates/bpmn/EventCompInter.js b/workflow/engine/templates/bpmn/EventCompInter.js deleted file mode 100755 index 5f0f9b3ae..000000000 --- a/workflow/engine/templates/bpmn/EventCompInter.js +++ /dev/null @@ -1,121 +0,0 @@ -bpmnEventCompInter=function(){ -VectorFigure.call(this); -this.stroke=1 -}; -bpmnEventCompInter.prototype=new VectorFigure; -bpmnEventCompInter.prototype.type="bpmnEventCompInter"; -bpmnEventCompInter.prototype.paint=function(){ -VectorFigure.prototype.paint.call(this); - -if(typeof workflow.zoomfactor == 'undefined') - workflow.zoomfactor = 1; - //Set the Task Limitation -if(typeof this.limitFlag == 'undefined' || this.limitFlag == false) -{ - this.originalWidth = 30; - this.originalHeight = 30; - this.orgXPos = this.getX(); - this.orgYPos = this.getY(); - this.orgFontSize =this.fontSize; -} - -this.width = this.originalWidth * workflow.zoomfactor; -this.height = this.originalHeight * workflow.zoomfactor; - -this.graphics.setStroke(this.stroke); -var x_cir =0; -var y_cir =0; - -this.graphics.setColor("#c0c0c0"); -this.graphics.fillEllipse(x_cir+3,y_cir+3,this.getWidth(),this.getHeight()); - -this.graphics.setColor("#f9faf2") -this.graphics.fillEllipse(x_cir,y_cir,this.getWidth(),this.getHeight()) -this.graphics.setColor("#adae5e"); -this.graphics.drawEllipse(x_cir,y_cir,this.getWidth(),this.getHeight()); - -var x_cir2=3; -var y_cir2=3; -this.graphics.setColor("#adae5e"); -this.graphics.drawEllipse(x_cir2,y_cir2,this.getWidth()-6,this.getHeight()-6); -//var x_arrow=new Array(6,19,19,32,32,19,19); -//var y_arrow=new Array(22,33,22,33,11,22,11); -var cw = this.getWidth(); -var ch = this.getHeight(); -var x_arrow=new Array(cw*0.13,cw*0.42,cw*0.42,cw*0.71,cw*0.7,cw*0.42,cw*0.42); -var y_arrow=new Array(ch*0.5,ch*0.73,ch*0.5,ch*0.73,ch*0.25,ch*0.5,ch*0.25); -//var x_arrow=new Array(cw/7.5,cw/2.36,cw/2.36,cw/1.4,cw/1.42,cw/2.36,cw/2.36); -//var y_arrow=new Array(ch/2,ch/1.36,ch/2,ch/1.36,ch/4,ch/2,ch/4); -this.graphics.setColor( "#adae5e" ); -this.graphics.fillPolygon(x_arrow,y_arrow); -this.graphics.setColor("#adae5e"); -this.graphics.drawPolygon(x_arrow,y_arrow); -this.graphics.paint(); - -/*Code Added to Dynamically shift Ports on resizing of shapes - **/ -if(this.input1!=null){ -this.input1.setPosition(0,this.height/2); -} -if(this.output1!=null){ -this.output1.setPosition(this.width/2,this.height); -} -if(this.input2!=null){ -this.input2.setPosition(this.width/2,0); -} -if(this.output2!=null){ -this.output2.setPosition(this.width,this.height/2); -} -}; - -bpmnEventCompInter.prototype.setWorkflow=function(_40c5){ -VectorFigure.prototype.setWorkflow.call(this,_40c5); -if(_40c5!=null){ - - var eventPortName = ['input1','input2','output1','output2']; - var eventPortType = ['InputPort','InputPort','OutputPort','OutputPort']; - var eventPositionX= [0,this.width/2,this.width,this.width/2]; - var eventPositionY= [this.height/2,0,this.height/2,this.height]; - - for(var i=0; i< eventPortName.length ; i++){ - eval('this.'+eventPortName[i]+' = new '+eventPortType[i]+'()'); //Create New Port - eval('this.'+eventPortName[i]+'.setWorkflow(_40c5)'); //Add port to the workflow - eval('this.'+eventPortName[i]+'.setName("'+eventPortName[i]+'")'); //Set PortName - eval('this.'+eventPortName[i]+'.setZOrder(-1)'); //Set Z-Order of the port to -1. It will be below all the figure - eval('this.'+eventPortName[i]+'.setBackgroundColor(new Color(255, 255, 255))'); //Setting Background of the port to white - eval('this.'+eventPortName[i]+'.setColor(new Color(255, 255, 255))'); //Setting Border of the port to white - eval('this.addPort(this.'+eventPortName[i]+','+eventPositionX[i]+', '+eventPositionY[i]+')'); //Setting Position of the port - } -/* -this.output1=new OutputPort(); -this.output1.setWorkflow(_40c5); -this.output1.setName("output1"); -this.output1.setBackgroundColor(new Color(115, 115, 245)); -this.addPort(this.output1,this.width/2,this.height); - -this.output2=new OutputPort(); -this.output2.setWorkflow(_40c5); -this.output2.setName("output2"); -this.output2.setBackgroundColor(new Color(115, 115, 245)); -this.addPort(this.output2,this.width,this.height/2); - -this.input1=new InputPort(); -this.input1.setWorkflow(_40c5); -this.input1.setName("input1"); -this.input1.setBackgroundColor(new Color(245,115,115)); -this.addPort(this.input1,0,this.height/2); - -this.input2=new InputPort(); -this.input2.setWorkflow(_40c5); -this.input2.setName("input2"); -this.input2.setBackgroundColor(new Color(245,115,115)); -this.addPort(this.input2,this.width/2,0);*/ -} -}; - -bpmnEventCompInter.prototype.getContextMenu=function(){ -if(this.id != null){ - this.workflow.handleContextMenu(this); -} -}; - diff --git a/workflow/engine/templates/bpmn/EventEmptyEnd.js b/workflow/engine/templates/bpmn/EventEmptyEnd.js deleted file mode 100755 index 832aebb81..000000000 --- a/workflow/engine/templates/bpmn/EventEmptyEnd.js +++ /dev/null @@ -1,89 +0,0 @@ -bpmnEventEmptyEnd=function(){ -VectorFigure.call(this); -this.stroke=2; -}; -bpmnEventEmptyEnd.prototype=new VectorFigure; -bpmnEventEmptyEnd.prototype.type="bpmnEventEmptyEnd"; -bpmnEventEmptyEnd.prototype.paint=function(){ -VectorFigure.prototype.paint.call(this); -if(typeof workflow.zoomfactor == 'undefined') - workflow.zoomfactor = 1; - //Set the Task Limitation -if(typeof this.limitFlag == 'undefined' || this.limitFlag == false) -{ - this.originalWidth = 30; - this.originalHeight = 30; - this.orgXPos = this.getX(); - this.orgYPos = this.getY(); - this.orgFontSize =this.fontSize; -} - -this.width = this.originalWidth * workflow.zoomfactor; -this.height = this.originalHeight * workflow.zoomfactor; - -var x=0; -var y=0; -this.graphics.setColor("#c0c0c0"); -this.graphics.fillEllipse(x+5,y+5,this.getWidth(),this.getHeight()); -this.graphics.setStroke(this.stroke); -this.graphics.setColor( "#f5d4d4" ); -this.graphics.fillEllipse(x,y,this.getWidth(),this.getHeight()); -this.graphics.setColor("#a23838"); -this.graphics.drawEllipse(x,y,this.getWidth(),this.getHeight()); -this.graphics.paint(); - -/*Code Added to Dynamically shift Ports on resizing of shapes - **/ -if(this.input1!=null){ -this.input1.setPosition(0,this.height/2); -} -if(this.output1!=null){ -this.output1.setPosition(this.width/2,this.height); -} -if(this.input2!=null){ -this.input2.setPosition(this.width/2,0); -} -if(this.output2!=null){ -this.output2.setPosition(this.width,this.height/2); -} -}; - -bpmnEventEmptyEnd.prototype.setWorkflow=function(_40c5){ -VectorFigure.prototype.setWorkflow.call(this,_40c5); -if(_40c5!=null){ - - var eventPortName = ['input1','input2']; - var eventPortType = ['InputPort','InputPort']; - var eventPositionX= [this.width/2,0]; - var eventPositionY= [0,this.height/2]; - - for(var i=0; i< eventPortName.length ; i++){ - eval('this.'+eventPortName[i]+' = new '+eventPortType[i]+'()'); //Create New Port - eval('this.'+eventPortName[i]+'.setWorkflow(_40c5)'); //Add port to the workflow - eval('this.'+eventPortName[i]+'.setName("'+eventPortName[i]+'")'); //Set PortName - eval('this.'+eventPortName[i]+'.setZOrder(-1)'); //Set Z-Order of the port to -1. It will be below all the figure - eval('this.'+eventPortName[i]+'.setBackgroundColor(new Color(255, 255, 255))'); //Setting Background of the port to white - eval('this.'+eventPortName[i]+'.setColor(new Color(255, 255, 255))'); //Setting Border of the port to white - eval('this.addPort(this.'+eventPortName[i]+','+eventPositionX[i]+', '+eventPositionY[i]+')'); //Setting Position of the port - } - /* -this.input1=new InputPort(); -this.input1.setWorkflow(_40c5); -this.input1.setName("input1"); -this.input1.setBackgroundColor(new Color(245,115,115)); -this.addPort(this.input1,this.width/2,0); - -this.input2=new InputPort(); -this.input2.setWorkflow(_40c5); -this.input2.setName("input2"); -this.input2.setBackgroundColor(new Color(245,115,115)); -this.addPort(this.input2,0,this.height/2);*/ -} -}; - - -bpmnEventEmptyEnd.prototype.getContextMenu=function(){ -if(this.id != null){ - this.workflow.handleContextMenu(this); -} -}; diff --git a/workflow/engine/templates/bpmn/EventEmptyInter.js b/workflow/engine/templates/bpmn/EventEmptyInter.js deleted file mode 100755 index 917346cb5..000000000 --- a/workflow/engine/templates/bpmn/EventEmptyInter.js +++ /dev/null @@ -1,91 +0,0 @@ -bpmnEventEmptyInter=function(width,_30ab){ -VectorFigure.call(this); -this.stroke=1; -}; -bpmnEventEmptyInter.prototype=new VectorFigure; -bpmnEventEmptyInter.prototype.type="bpmnEventEmptyInter"; -bpmnEventEmptyInter.prototype.paint=function(){ -VectorFigure.prototype.paint.call(this); -if(typeof workflow.zoomfactor == 'undefined') - workflow.zoomfactor = 1; - //Set the Task Limitation -if(typeof this.limitFlag == 'undefined' || this.limitFlag == false) -{ - this.originalWidth = 30; - this.originalHeight = 30; - this.orgXPos = this.getX(); - this.orgYPos = this.getY(); - this.orgFontSize =this.fontSize; -} -this.width = this.originalWidth * workflow.zoomfactor; -this.height = this.originalHeight * workflow.zoomfactor; - -this.graphics.setStroke(this.stroke); -var x_cir1 = 0; -var y_cir1 = 0; - -this.graphics.setColor("#c0c0c0"); -this.graphics.fillEllipse(x_cir1+3,y_cir1+3,this.getWidth(),this.getHeight()); - -this.graphics.setColor( "#f9faf2" ); -this.graphics.fillEllipse(x_cir1,y_cir1,this.getWidth(),this.getHeight()); - -this.graphics.setColor("#adae5e"); -this.graphics.drawEllipse(x_cir1,y_cir1,this.getWidth(),this.getHeight()); -this.graphics.setStroke(this.stroke); -var x_cir2=3; -var y_cir2=3; - -this.graphics.setColor( "#f9faf2" ); -this.graphics.fillEllipse(x_cir2,y_cir2,this.getWidth()-6,this.getHeight()-6); - -this.graphics.setColor("#adae5e"); -//this.graphics.drawEllipse(x_cir2,y_cir2,this.getWidth()-6,this.getHeight()-6); -var cw = this.getWidth(); -var ch = this.getHeight(); -this.graphics.drawEllipse(cw*0.15, ch*0.15, ch*0.7, ch*0.7); - -this.graphics.paint(); - -/*Code Added to Dynamically shift Ports on resizing of shapes - **/ -if(this.input1!=null){ -this.input1.setPosition(0,this.height/2); -} -if(this.output1!=null){ -this.output1.setPosition(this.width/2,this.height); -} -if(this.input2!=null){ -this.input2.setPosition(this.width/2,0); -} -if(this.output2!=null){ -this.output2.setPosition(this.width,this.height/2); -} -}; - -bpmnEventEmptyInter.prototype.setWorkflow=function(_40c5){ -VectorFigure.prototype.setWorkflow.call(this,_40c5); -if(_40c5!=null){ - var eventPortName = ['input1','input2','output1','output2']; - var eventPortType = ['InputPort','InputPort','OutputPort','OutputPort']; - var eventPositionX= [0,this.width/2,this.width,this.width/2]; - var eventPositionY= [this.height/2,0,this.height/2,this.height]; - - for(var i=0; i< eventPortName.length ; i++){ - eval('this.'+eventPortName[i]+' = new '+eventPortType[i]+'()'); //Create New Port - eval('this.'+eventPortName[i]+'.setWorkflow(_40c5)'); //Add port to the workflow - eval('this.'+eventPortName[i]+'.setName("'+eventPortName[i]+'")'); //Set PortName - eval('this.'+eventPortName[i]+'.setZOrder(-1)'); //Set Z-Order of the port to -1. It will be below all the figure - eval('this.'+eventPortName[i]+'.setBackgroundColor(new Color(255, 255, 255))'); //Setting Background of the port to white - eval('this.'+eventPortName[i]+'.setColor(new Color(255, 255, 255))'); //Setting Border of the port to white - eval('this.addPort(this.'+eventPortName[i]+','+eventPositionX[i]+', '+eventPositionY[i]+')'); //Setting Position of the port - } -} -}; - -bpmnEventEmptyInter.prototype.getContextMenu=function(){ -if(this.id != null){ - this.workflow.handleContextMenu(this); -} -}; - diff --git a/workflow/engine/templates/bpmn/EventEmptyStart.js b/workflow/engine/templates/bpmn/EventEmptyStart.js deleted file mode 100755 index 608c461ea..000000000 --- a/workflow/engine/templates/bpmn/EventEmptyStart.js +++ /dev/null @@ -1,76 +0,0 @@ -bpmnEventEmptyStart=function(){ - VectorFigure.call(this); -}; - -bpmnEventEmptyStart.prototype=new VectorFigure; -bpmnEventEmptyStart.prototype.type="bpmnEventEmptyStart"; -bpmnEventEmptyStart.prototype.paint=function() { - VectorFigure.prototype.paint.call(this); - if(typeof workflow.zoomfactor == 'undefined') - workflow.zoomfactor = 1; - - //Set the Limitation - if(typeof this.limitFlag == 'undefined' || this.limitFlag == false) { - this.originalWidth = 30; - this.originalHeight = 30; - this.orgXPos = this.getX(); - this.orgYPos = this.getY(); - this.orgFontSize =this.fontSize; - } - this.width = this.originalWidth * workflow.zoomfactor; - this.height = this.originalHeight * workflow.zoomfactor; - - var x_cir = 0; - var y_cir = 0; - - //draw the circle - this.graphics.setColor("#d0d0d0"); - this.graphics.fillEllipse(x_cir+2,y_cir+2,this.getWidth(),this.getHeight()); - this.graphics.setColor( "#F6FFDA" ); - this.graphics.fillEllipse(x_cir,y_cir,this.getWidth(),this.getHeight()); - this.graphics.setStroke(1); - this.graphics.setColor("#97C759"); - this.graphics.drawEllipse(x_cir,y_cir,this.getWidth(),this.getHeight()); - this.graphics.setStroke(1); - this.graphics.setColor("#98C951"); - this.graphics.drawEllipse(x_cir,y_cir,this.getWidth(),this.getHeight()); - - - this.graphics.paint(); - - - //Code Added to Dynamically shift Ports on resizing of shapes - if(this.output1!=null) { - this.output1.setPosition(this.width/2,this.height); - } - if(this.output2!=null){ - this.output2.setPosition(this.width,this.height/2); - } -}; - -bpmnEventEmptyStart.prototype.setWorkflow=function(_40c5){ -VectorFigure.prototype.setWorkflow.call(this,_40c5); -if(_40c5!=null){ - var eventPortName = ['output1','output2']; - var eventPortType = ['OutputPort','OutputPort']; - var eventPositionX= [this.width/2,this.width]; - var eventPositionY= [this.height,this.height/2]; - - for(var i=0; i< eventPortName.length ; i++){ - eval('this.'+eventPortName[i]+' = new '+eventPortType[i]+'()'); //Create New Port - eval('this.'+eventPortName[i]+'.setWorkflow(_40c5)'); //Add port to the workflow - eval('this.'+eventPortName[i]+'.setName("'+eventPortName[i]+'")'); //Set PortName - eval('this.'+eventPortName[i]+'.setZOrder(-1)'); //Set Z-Order of the port to -1. It will be below all the figure - eval('this.'+eventPortName[i]+'.setBackgroundColor(new Color(255, 255, 255))'); //Setting Background of the port to white - eval('this.'+eventPortName[i]+'.setColor(new Color(255, 255, 255))'); //Setting Border of the port to white - eval('this.addPort(this.'+eventPortName[i]+','+eventPositionX[i]+', '+eventPositionY[i]+')'); //Setting Position of the port - } -} -}; - -bpmnEventEmptyStart.prototype.getContextMenu=function(){ -if(this.id != null){ - this.workflow.handleContextMenu(this); -} -}; - diff --git a/workflow/engine/templates/bpmn/EventEndSignal.js b/workflow/engine/templates/bpmn/EventEndSignal.js deleted file mode 100755 index db69dccae..000000000 --- a/workflow/engine/templates/bpmn/EventEndSignal.js +++ /dev/null @@ -1,74 +0,0 @@ -bpmnEventEndSignal=function(){ -VectorFigure.call(this); -//Setting width and height values as per the zoom ratio -if(typeof workflow.zoomWidth != 'undefined' || typeof workflow.zoomHeight != 'undefined') - this.setDimension(workflow.zoomWidth, workflow.zoomHeight); -else - this.setDimension(30,30); -this.stroke=2; -}; -bpmnEventEndSignal.prototype=new VectorFigure; -bpmnEventEndSignal.prototype.type="bpmnEventEndSignal"; -bpmnEventEndSignal.prototype.paint=function(){ -VectorFigure.prototype.paint.call(this); -var x=0; -var y=0; - -this.graphics.setColor("#c0c0c0"); -this.graphics.fillEllipse(x+5,y+5,this.getWidth(),this.getHeight()); -this.graphics.setStroke(this.stroke); -this.graphics.setColor( "#f7f1e5" ); -this.graphics.fillEllipse(x,y,this.getWidth(),this.getHeight()); -this.graphics.setColor("#c46508"); -this.graphics.drawEllipse(x,y,this.getWidth(),this.getHeight()); -//var x=new Array(5,41,23); -//var y=new Array(35,35,0); -var x=new Array(5,this.getWidth()-4,this.getWidth()/2); -var y=new Array(this.getHeight()-10,this.getHeight()-10,2); -this.graphics.setColor("#c46508"); -this.graphics.fillPolygon(x,y); -this.graphics.setColor("#000000"); -//this.graphics.drawPolygon(x,y); -this.graphics.paint(); - -/*Code Added to Dynamically shift Ports on resizing of shapes - **/ -if(this.input1!=null){ -this.input1.setPosition(0,this.height/2); -} -if(this.output1!=null){ -this.output1.setPosition(this.width/2,this.height); -} -if(this.input2!=null){ -this.input2.setPosition(this.width/2,0); -} -if(this.output2!=null){ -this.output2.setPosition(this.width,this.height/2); -} -}; - -bpmnEventEndSignal.prototype.setWorkflow=function(_40c5){ -VectorFigure.prototype.setWorkflow.call(this,_40c5); -if(_40c5!=null){ - var eventPortName = ['input1','input2']; - var eventPortType = ['InputPort','InputPort']; - var eventPositionX= [this.width/2,0]; - var eventPositionY= [0,this.height/2]; - - for(var i=0; i< eventPortName.length ; i++){ - eval('this.'+eventPortName[i]+' = new '+eventPortType[i]+'()'); //Create New Port - eval('this.'+eventPortName[i]+'.setWorkflow(_40c5)'); //Add port to the workflow - eval('this.'+eventPortName[i]+'.setName("'+eventPortName[i]+'")'); //Set PortName - eval('this.'+eventPortName[i]+'.setZOrder(-1)'); //Set Z-Order of the port to -1. It will be below all the figure - eval('this.'+eventPortName[i]+'.setBackgroundColor(new Color(255, 255, 255))'); //Setting Background of the port to white - eval('this.'+eventPortName[i]+'.setColor(new Color(255, 255, 255))'); //Setting Border of the port to white - eval('this.addPort(this.'+eventPortName[i]+','+eventPositionX[i]+', '+eventPositionY[i]+')'); //Setting Position of the port - } -} -}; - -bpmnEventEndSignal.prototype.getContextMenu=function(){ -if(this.id != null){ - this.workflow.handleContextMenu(this); -} -}; diff --git a/workflow/engine/templates/bpmn/EventErrorEnd.js b/workflow/engine/templates/bpmn/EventErrorEnd.js deleted file mode 100755 index 1269f803d..000000000 --- a/workflow/engine/templates/bpmn/EventErrorEnd.js +++ /dev/null @@ -1,77 +0,0 @@ -bpmnEventErrorEnd=function(){ -VectorFigure.call(this); -//Setting width and height values as per the zoom ratio -if(typeof workflow.zoomWidth != 'undefined' || typeof workflow.zoomHeight != 'undefined') - this.setDimension(workflow.zoomWidth, workflow.zoomHeight); -else - this.setDimension(30,30); -this.stroke=4; -}; -bpmnEventErrorEnd.prototype=new VectorFigure; -bpmnEventErrorEnd.prototype.type="bpmnEventErrorEnd"; -bpmnEventErrorEnd.prototype.paint=function(){ -VectorFigure.prototype.paint.call(this); -this.graphics.setStroke(this.stroke); -var x_cir = 0; -var y_cir = 0; - -this.graphics.setColor("#c0c0c0"); -this.graphics.fillEllipse(x_cir+5,y_cir+5,this.getWidth(),this.getHeight()); - -this.graphics.setColor("#f7f1e5"); -this.graphics.fillEllipse(x_cir,y_cir,this.getWidth(),this.getHeight()); -this.graphics.setColor("#c46508"); -this.graphics.drawEllipse(x_cir,y_cir,this.getWidth(),this.getHeight()); -//var x=new Array(7,17,24,34,24,17); -//var y=new Array(33,23,33,13,26,16); -var x=new Array(this.getWidth()/6.4,this.getWidth()/2.6,this.getWidth()/1.87,this.getWidth()/1.32,this.getWidth()/1.87,this.getWidth()/2.6); -var y=new Array(this.getHeight()/1.36,this.getHeight()/1.95,this.getHeight()/1.36,this.getHeight()/3.46,this.getHeight()/1.73,this.getHeight()/2.8); -this.graphics.setStroke(2); -this.graphics.setColor("#c46508"); -this.graphics.fillPolygon(x,y); -this.graphics.setColor("#c46508"); -this.graphics.drawPolygon(x,y); -this.graphics.paint(); - -/*Code Added to Dynamically shift Ports on resizing of shapes - **/ -if(this.input1!=null){ -this.input1.setPosition(0,this.height/2); -} -if(this.output1!=null){ -this.output1.setPosition(this.width/2,this.height); -} -if(this.input2!=null){ -this.input2.setPosition(this.width/2,0); -} -if(this.output2!=null){ -this.output2.setPosition(this.width,this.height/2); -} -}; - -bpmnEventErrorEnd.prototype.setWorkflow=function(_40c5){ -VectorFigure.prototype.setWorkflow.call(this,_40c5); -if(_40c5!=null){ - var eventPortName = ['input1','input2']; - var eventPortType = ['InputPort','InputPort']; - var eventPositionX= [this.width/2,0]; - var eventPositionY= [0,this.height/2]; - - for(var i=0; i< eventPortName.length ; i++){ - eval('this.'+eventPortName[i]+' = new '+eventPortType[i]+'()'); //Create New Port - eval('this.'+eventPortName[i]+'.setWorkflow(_40c5)'); //Add port to the workflow - eval('this.'+eventPortName[i]+'.setName("'+eventPortName[i]+'")'); //Set PortName - eval('this.'+eventPortName[i]+'.setZOrder(-1)'); //Set Z-Order of the port to -1. It will be below all the figure - eval('this.'+eventPortName[i]+'.setBackgroundColor(new Color(255, 255, 255))'); //Setting Background of the port to white - eval('this.'+eventPortName[i]+'.setColor(new Color(255, 255, 255))'); //Setting Border of the port to white - eval('this.addPort(this.'+eventPortName[i]+','+eventPositionX[i]+', '+eventPositionY[i]+')'); //Setting Position of the port - } -} -}; - -bpmnEventErrorEnd.prototype.getContextMenu=function(){ -if(this.id != null){ - this.workflow.handleContextMenu(this); -} -}; - diff --git a/workflow/engine/templates/bpmn/EventErrorInter.js b/workflow/engine/templates/bpmn/EventErrorInter.js deleted file mode 100755 index 8c5b8d338..000000000 --- a/workflow/engine/templates/bpmn/EventErrorInter.js +++ /dev/null @@ -1,49 +0,0 @@ -bpmnEventErrorInter=function(){ -VectorFigure.call(this); -this.stroke=1; -}; -bpmnEventErrorInter.prototype=new VectorFigure; -bpmnEventErrorInter.prototype.type="bpmnEventErrorInter"; -bpmnEventErrorInter.prototype.paint=function(){ -VectorFigure.prototype.paint.call(this); - -if(typeof workflow.zoomfactor == 'undefined') - workflow.zoomfactor = 1; - //Set the Task Limitation -if(typeof this.limitFlag == 'undefined' || this.limitFlag == false) -{ - this.originalWidth = 30; - this.originalHeight = 30; - this.orgXPos = this.getX(); - this.orgYPos = this.getY(); - this.orgFontSize =this.fontSize; -} - -this.width = this.originalWidth * workflow.zoomfactor; -this.height = this.originalHeight * workflow.zoomfactor; - -this.graphics.setStroke(this.stroke); -var x_cir = 0; -var y_cir = 0; -this.graphics.setColor("#000000"); -this.graphics.drawEllipse(x_cir,y_cir,this.getWidth(),this.getHeight()); -var x_cir2=5; -var y_cir2=5; -this.graphics.setColor("#000000"); -this.graphics.drawEllipse(x_cir2,y_cir2,this.getWidth()-10,this.getHeight()-10); -//var x=new Array(7,17,24,34,24,17); -//var y=new Array(33,23,33,13,26,16); -var cw = this.getWidth(); -var ch = this.getHeight(); -var x=new Array(cw*0.15,cw*0.38,cw*0.53,cw*0.75,cw*0.53,cw*0.38); -var y=new Array(ch*0.73,ch*0.51,ch*0.73,ch*0.28,ch*0.57,ch*0.35); -//var x=new Array(this.getWidth()/6.4,this.getWidth()/2.6,this.getWidth()/1.87,this.getWidth()/1.32,this.getWidth()/1.87,this.getWidth()/2.6); -//var y=new Array(this.getHeight()/1.36,this.getHeight()/1.95,this.getHeight()/1.36,this.getHeight()/3.46,this.getHeight()/1.73,this.getHeight()/2.8); -this.graphics.setColor("#ffffff"); -this.graphics.fillPolygon(x,y); -this.graphics.setColor("#000000"); -this.graphics.drawPolygon(x,y); -this.graphics.paint(); -}; - - diff --git a/workflow/engine/templates/bpmn/EventInterSignal.js b/workflow/engine/templates/bpmn/EventInterSignal.js deleted file mode 100755 index 0962e8582..000000000 --- a/workflow/engine/templates/bpmn/EventInterSignal.js +++ /dev/null @@ -1,97 +0,0 @@ -bpmnEventInterSignal=function(){ -VectorFigure.call(this); -this.stroke=1; -}; -bpmnEventInterSignal.prototype=new VectorFigure; -bpmnEventInterSignal.prototype.type="bpmnEventInterSignal"; -bpmnEventInterSignal.prototype.paint=function(){ -VectorFigure.prototype.paint.call(this); - -if(typeof workflow.zoomfactor == 'undefined') - workflow.zoomfactor = 1; - //Set the Task Limitation -if(typeof this.limitFlag == 'undefined' || this.limitFlag == false) -{ - this.originalWidth = 30; - this.originalHeight = 30; - this.orgXPos = this.getX(); - this.orgYPos = this.getY(); - this.orgFontSize =this.fontSize; -} - -this.width = this.originalWidth * workflow.zoomfactor; -this.height = this.originalHeight * workflow.zoomfactor; - -this.graphics.setStroke(this.stroke); -var x_cir = 0; -var y_cir = 0; - -this.graphics.setColor("#c0c0c0"); -this.graphics.fillEllipse(x_cir+3,y_cir+3,this.getWidth(),this.getHeight()); - -this.graphics.setColor("#f9faf2"); -this.graphics.fillEllipse(x_cir,y_cir,this.getWidth(),this.getHeight()); -this.graphics.setColor("#adae5e"); -this.graphics.drawEllipse(x_cir,y_cir,this.getWidth(),this.getHeight()); - -var x_cir2=5; -var y_cir2=5; -this.graphics.setColor("#f9faf2"); -this.graphics.fillEllipse(x_cir2,y_cir2,this.getWidth()-10,this.getHeight()-10); -this.graphics.setColor("#adae5e"); -this.graphics.drawEllipse(x_cir2,y_cir2,this.getWidth()-10,this.getHeight()-10); -//var x=new Array(12,32,22); -//var y=new Array(32,32,9); -var cw = this.getWidth(); -var ch = this.getHeight(); -var x=new Array(cw*0.26,cw*0.71,cw*0.49); -var y=new Array(ch*0.71,ch*0.71,ch*0.2); -//var x=new Array(this.getWidth()/3.75,this.getWidth()/1.4,this.getWidth()/2.04); -//var y=new Array(this.getHeight()/1.4,this.getHeight()/1.4,this.getHeight()/5); -this.graphics.setColor("#adae5e"); -this.graphics.fillPolygon(x,y); -this.graphics.setColor("#adae5e"); -this.graphics.drawPolygon(x,y); -this.graphics.paint(); - -/*Code Added to Dynamically shift Ports on resizing of shapes - **/ -if(this.input1!=null){ -this.input1.setPosition(0,this.height/2); -} -if(this.output1!=null){ -this.output1.setPosition(this.width/2,this.height); -} -if(this.input2!=null){ -this.input2.setPosition(this.width/2,0); -} -if(this.output2!=null){ -this.output2.setPosition(this.width,this.height/2); -} -}; - -bpmnEventInterSignal.prototype.setWorkflow=function(_40c5){ -VectorFigure.prototype.setWorkflow.call(this,_40c5); -if(_40c5!=null){ - var eventPortName = ['input1','input2','output1','output2']; - var eventPortType = ['InputPort','InputPort','OutputPort','OutputPort']; - var eventPositionX= [0,this.width/2,this.width,this.width/2]; - var eventPositionY= [this.height/2,0,this.height/2,this.height]; - - for(var i=0; i< eventPortName.length ; i++){ - eval('this.'+eventPortName[i]+' = new '+eventPortType[i]+'()'); //Create New Port - eval('this.'+eventPortName[i]+'.setWorkflow(_40c5)'); //Add port to the workflow - eval('this.'+eventPortName[i]+'.setName("'+eventPortName[i]+'")'); //Set PortName - eval('this.'+eventPortName[i]+'.setZOrder(-1)'); //Set Z-Order of the port to -1. It will be below all the figure - eval('this.'+eventPortName[i]+'.setBackgroundColor(new Color(255, 255, 255))'); //Setting Background of the port to white - eval('this.'+eventPortName[i]+'.setColor(new Color(255, 255, 255))'); //Setting Border of the port to white - eval('this.addPort(this.'+eventPortName[i]+','+eventPositionX[i]+', '+eventPositionY[i]+')'); //Setting Position of the port - } -} -}; - -bpmnEventInterSignal.prototype.getContextMenu=function(){ -if(this.id != null){ - this.workflow.handleContextMenu(this); -} -}; diff --git a/workflow/engine/templates/bpmn/EventLinkEnd.js b/workflow/engine/templates/bpmn/EventLinkEnd.js deleted file mode 100755 index 0ddc4eb74..000000000 --- a/workflow/engine/templates/bpmn/EventLinkEnd.js +++ /dev/null @@ -1,30 +0,0 @@ -bpmnEventLinkEnd=function(){ -VectorFigure.call(this); -//Setting width and height values as per the zoom ratio -if(typeof workflow.zoomWidth != 'undefined' || typeof workflow.zoomHeight != 'undefined') - this.setDimension(workflow.zoomWidth, workflow.zoomHeight); -else - this.setDimension(45,45); -this.stroke=3; -}; -bpmnEventLinkEnd.prototype=new VectorFigure; -bpmnEventLinkEnd.prototype.type="bpmnEventLinkEnd"; -bpmnEventLinkEnd.prototype.paint=function(){ -VectorFigure.prototype.paint.call(this); -var x_cir = -4; -var y_cir = -4; -this.graphics.setStroke(this.stroke); -this.graphics.setColor("#000000"); -this.graphics.drawEllipse(x_cir,y_cir,this.getWidth(),this.getHeight()); -//var x_arrow=new Array(4,4,22,22,37,22,22); //Arrow working -//var y_arrow=new Array(11,26,26,31,18.5,6,11); -var x_arrow=new Array(4,4,this.getWidth()/2,this.getWidth()/2,this.getWidth()/1.2,this.getWidth()/2,this.getWidth()/2); -var y_arrow=new Array(this.getHeight()/4,this.getHeight()/1.7,this.getHeight()/1.7,this.getHeight()/1.5,this.getHeight()/2.5,this.getHeight()/7,this.getHeight()/4); -this.graphics.setColor( "#000000" ); -this.graphics.fillPolygon(x_arrow,y_arrow); -this.graphics.setColor("#000000"); -this.graphics.drawPolygon(x_arrow,y_arrow); -this.graphics.paint(); -}; - - diff --git a/workflow/engine/templates/bpmn/EventLinkInter.js b/workflow/engine/templates/bpmn/EventLinkInter.js deleted file mode 100755 index 093c0e131..000000000 --- a/workflow/engine/templates/bpmn/EventLinkInter.js +++ /dev/null @@ -1,78 +0,0 @@ -bpmnEventLinkInter=function(){ -VectorFigure.call(this); -//Setting width and height values as per the zoom ratio -if(typeof workflow.zoomWidth != 'undefined' || typeof workflow.zoomHeight != 'undefined') - this.setDimension(workflow.zoomWidth, workflow.zoomHeight); -else - this.setDimension(30,30); -this.stroke=2; -}; -bpmnEventLinkInter.prototype=new VectorFigure; -bpmnEventLinkInter.prototype.type="bpmnEventLinkInter"; -bpmnEventLinkInter.prototype.paint=function(){ -VectorFigure.prototype.paint.call(this); -var x_cir = -4; -var y_cir = -4; - -this.graphics.setColor("#c0c0c0"); -this.graphics.fillEllipse(x_cir+3,y_cir+3,this.getWidth(),this.getHeight()); -this.graphics.setColor("#f9faf2"); -this.graphics.fillEllipse(x_cir,y_cir,this.getWidth(),this.getHeight()); -this.graphics.setStroke(this.stroke); -this.graphics.setColor("#adae5e"); -this.graphics.drawEllipse(x_cir,y_cir,this.getWidth(),this.getHeight()); -var x_cir2=-1; -var y_cir2=-1; -this.graphics.setColor("#adae5e"); -this.graphics.drawEllipse(x_cir2,y_cir2,this.getWidth()-6,this.getHeight()-6); -//var x_arrow=new Array(4,4,22,22,37,22,22); //Arrow working -//var y_arrow=new Array(11,26,26,31,18.5,6,11); -var x_arrow=new Array(4,4,this.getWidth()/2,this.getWidth()/2,this.getWidth()/1.2,this.getWidth()/2,this.getWidth()/2); -var y_arrow=new Array(this.getHeight()/4,this.getHeight()/1.7,this.getHeight()/1.7,this.getHeight()/1.5,this.getHeight()/2.5,this.getHeight()/7,this.getHeight()/4); -this.graphics.setColor( "#adae5e" ); -this.graphics.fillPolygon(x_arrow,y_arrow); -this.graphics.setColor("#adae5e"); -this.graphics.drawPolygon(x_arrow,y_arrow); -this.graphics.paint(); - -/*Code Added to Dynamically shift Ports on resizing of shapes - **/ -if(this.input1!=null){ -this.input1.setPosition(0,this.height/2); -} -if(this.output1!=null){ -this.output1.setPosition(this.width/2,this.height); -} -if(this.input2!=null){ -this.input2.setPosition(this.width/2,0); -} -if(this.output2!=null){ -this.output2.setPosition(this.width,this.height/2); -} -}; - -bpmnEventLinkInter.prototype.setWorkflow=function(_40c5){ -VectorFigure.prototype.setWorkflow.call(this,_40c5); -if(_40c5!=null){ -var eventPortName = ['input1','input2','output1','output2']; - var eventPortType = ['InputPort','InputPort','OutputPort','OutputPort']; - var eventPositionX= [0,this.width/2,this.width,this.width/2]; - var eventPositionY= [this.height/2,0,this.height/2,this.height]; - - for(var i=0; i< eventPortName.length ; i++){ - eval('this.'+eventPortName[i]+' = new '+eventPortType[i]+'()'); //Create New Port - eval('this.'+eventPortName[i]+'.setWorkflow(_40c5)'); //Add port to the workflow - eval('this.'+eventPortName[i]+'.setName("'+eventPortName[i]+'")'); //Set PortName - eval('this.'+eventPortName[i]+'.setZOrder(-1)'); //Set Z-Order of the port to -1. It will be below all the figure - eval('this.'+eventPortName[i]+'.setBackgroundColor(new Color(255, 255, 255))'); //Setting Background of the port to white - eval('this.'+eventPortName[i]+'.setColor(new Color(255, 255, 255))'); //Setting Border of the port to white - eval('this.addPort(this.'+eventPortName[i]+','+eventPositionX[i]+', '+eventPositionY[i]+')'); //Setting Position of the port - } -} -}; - -bpmnEventLinkInter.prototype.getContextMenu=function(){ -if(this.id != null){ - this.workflow.handleContextMenu(this); -} -}; diff --git a/workflow/engine/templates/bpmn/EventLinkStart.js b/workflow/engine/templates/bpmn/EventLinkStart.js deleted file mode 100755 index 23797ce33..000000000 --- a/workflow/engine/templates/bpmn/EventLinkStart.js +++ /dev/null @@ -1,36 +0,0 @@ -bpmnEventLinkStart=function(){ -VectorFigure.call(this); -//Setting width and height values as per the zoom ratio -if(typeof workflow.zoomWidth != 'undefined' || typeof workflow.zoomHeight != 'undefined') - this.setDimension(workflow.zoomWidth, workflow.zoomHeight); -else - this.setDimension(45,45); -this.stroke=2 -}; -bpmnEventLinkStart.prototype=new VectorFigure; -bpmnEventLinkStart.prototype.type="bpmnEventLinkStart"; -bpmnEventLinkStart.prototype.paint=function(){ -VectorFigure.prototype.paint.call(this); - -var x_cir = -4; -var y_cir = -4; - -this.graphics.setStroke(this.stroke); - -this.graphics.setColor("#000000"); -this.graphics.drawEllipse(x_cir,y_cir,this.getWidth(),this.getHeight()); - -//var x_arrow=new Array(4,4,22,22,37,22,22); //Arrow working -//var y_arrow=new Array(11,26,26,31,18.5,6,11); -var x_arrow=new Array(4,4,this.getWidth()/2,this.getWidth()/2,this.getWidth()/1.2,this.getWidth()/2,this.getWidth()/2); -var y_arrow=new Array(this.getHeight()/4,this.getHeight()/1.7,this.getHeight()/1.7,this.getHeight()/1.5,this.getHeight()/2.5,this.getHeight()/7,this.getHeight()/4); -this.graphics.setColor( "#ffffff" ); -this.graphics.fillPolygon(x_arrow,y_arrow); - -this.graphics.setColor("#000000"); -this.graphics.drawPolygon(x_arrow,y_arrow); - -this.graphics.paint(); -}; - - diff --git a/workflow/engine/templates/bpmn/EventMessageEnd.js b/workflow/engine/templates/bpmn/EventMessageEnd.js deleted file mode 100755 index 89d1393f0..000000000 --- a/workflow/engine/templates/bpmn/EventMessageEnd.js +++ /dev/null @@ -1,102 +0,0 @@ -bpmnEventMessageEnd=function(){ -VectorFigure.call(this); -this.stroke = 2; -}; -bpmnEventMessageEnd.prototype=new VectorFigure; -bpmnEventMessageEnd.prototype.type="bpmnEventMessageEnd"; -bpmnEventMessageEnd.prototype.paint=function(){ -VectorFigure.prototype.paint.call(this); - -if(typeof workflow.zoomfactor == 'undefined') - workflow.zoomfactor = 1; -//Set the Task Limitation -if(typeof this.limitFlag == 'undefined' || this.limitFlag == false) -{ - this.originalWidth = 30; - this.originalHeight = 30; - this.orgXPos = this.getX(); - this.orgYPos = this.getY(); - this.orgFontSize =this.fontSize; -} - -this.width = this.originalWidth * workflow.zoomfactor; -this.height = this.originalHeight * workflow.zoomfactor; -var x_cir = 0; -var y_cir = 0; - -this.graphics.setColor("#c0c0c0"); -this.graphics.fillEllipse(x_cir+5,y_cir+5,this.getWidth(),this.getHeight()); - -this.graphics.setStroke(this.stroke); -this.graphics.setColor( "#f5d4d4"); -this.graphics.fillEllipse(x_cir,y_cir,this.getWidth(),this.getHeight()); -this.graphics.setColor("#a23838"); -this.graphics.drawEllipse(x_cir,y_cir,this.getWidth(),this.getHeight()); -this.graphics.setStroke(1); -//var x=new Array(12,12,35,35,23.5,12); -//var y=new Array(16,33,33,17,26,17); -/*var x=new Array(this.getWidth()/3.75,this.getWidth()/3.75,this.getWidth()/1.28,this.getWidth()/1.28,this.getWidth()/2,this.getWidth()/3.75,this.getWidth()/3.75); -var y=new Array(this.getHeight()/3.21,this.getHeight()/1.36,this.getHeight()/1.36,this.getHeight()/2.64,this.getHeight()/1.73,this.getHeight()/2.64); -this.graphics.setColor( "#c46508" ); -this.graphics.fillPolygon(x,y); -this.graphics.setColor("#c46508"); -//this.graphics.drawPolygon(x,y); -//var x_tri=new Array(12,23.5,35); -//var y_tri=new Array(13,22,13); -var x_tri=new Array(this.getWidth()/3.75,this.getWidth()/1.91,this.getWidth()/1.28); -var y_tri=new Array(this.getHeight()/3.46,this.getHeight()/2.04,this.getHeight()/3.46); -this.graphics.setColor( "#c46508" ); -this.graphics.fillPolygon(x_tri,y_tri); -this.graphics.setColor("#c46508"); -//this.graphics.drawPolygon(x_tri,y_tri);*/ - -//draw the mail icon - var cw = this.getWidth(); - var ch = this.getHeight(); - var x = new Array( cw*0.25, cw*0.25, cw*0.78, cw*0.78, cw*0.52, cw*0.25, cw*0.25, cw*0.78); - var y = new Array( ch*0.31, ch*0.71, ch*0.71, ch*0.32, ch*0.52, ch*0.32, ch*0.31, ch*0.31); - this.graphics.setColor("#c46508"); - this.graphics.drawPolygon(x,y); -this.graphics.paint(); - -/*Code Added to Dynamically shift Ports on resizing of shapes - **/ -if(this.input1!=null){ -this.input1.setPosition(0,this.height/2); -} -if(this.output1!=null){ -this.output1.setPosition(this.width/2,this.height); -} -if(this.input2!=null){ -this.input2.setPosition(this.width/2,0); -} -if(this.output2!=null){ -this.output2.setPosition(this.width,this.height/2); -} -}; - -bpmnEventMessageEnd.prototype.setWorkflow=function(_40c5){ -VectorFigure.prototype.setWorkflow.call(this,_40c5); -if(_40c5!=null){ - var eventPortName = ['input1','input2']; - var eventPortType = ['InputPort','InputPort']; - var eventPositionX= [this.width/2,0]; - var eventPositionY= [0,this.height/2]; - - for(var i=0; i< eventPortName.length ; i++){ - eval('this.'+eventPortName[i]+' = new '+eventPortType[i]+'()'); //Create New Port - eval('this.'+eventPortName[i]+'.setWorkflow(_40c5)'); //Add port to the workflow - eval('this.'+eventPortName[i]+'.setName("'+eventPortName[i]+'")'); //Set PortName - eval('this.'+eventPortName[i]+'.setZOrder(-1)'); //Set Z-Order of the port to -1. It will be below all the figure - eval('this.'+eventPortName[i]+'.setBackgroundColor(new Color(255, 255, 255))'); //Setting Background of the port to white - eval('this.'+eventPortName[i]+'.setColor(new Color(255, 255, 255))'); //Setting Border of the port to white - eval('this.addPort(this.'+eventPortName[i]+','+eventPositionX[i]+', '+eventPositionY[i]+')'); //Setting Position of the port - } -} -}; - -bpmnEventMessageEnd.prototype.getContextMenu=function(){ -if(this.id != null){ - this.workflow.handleContextMenu(this); -} -}; diff --git a/workflow/engine/templates/bpmn/EventMessageInter.js b/workflow/engine/templates/bpmn/EventMessageInter.js deleted file mode 100755 index 9bfbe5d07..000000000 --- a/workflow/engine/templates/bpmn/EventMessageInter.js +++ /dev/null @@ -1,80 +0,0 @@ -bpmnEventMessageInter=function(){ -VectorFigure.call(this); -this.stroke=1; -}; -bpmnEventMessageInter.prototype=new VectorFigure; -bpmnEventMessageInter.prototype.type="bpmnEventMessageInter"; -bpmnEventMessageInter.prototype.paint=function(){ -VectorFigure.prototype.paint.call(this); - -if(typeof workflow.zoomfactor == 'undefined') - workflow.zoomfactor = 1; - //Set the Task Limitation -if(typeof this.limitFlag == 'undefined' || this.limitFlag == false) -{ - this.originalWidth = 30; - this.originalHeight = 30; - this.orgXPos = this.getX(); - this.orgYPos = this.getY(); - this.orgFontSize =this.fontSize; -} - -this.width = this.originalWidth * workflow.zoomfactor; -this.height = this.originalHeight * workflow.zoomfactor; - -var x_cir = 0; -var y_cir = 0; - -this.graphics.setColor("#c0c0c0"); -this.graphics.fillEllipse(x_cir+3,y_cir+3,this.getWidth(),this.getHeight()); -this.graphics.setStroke(this.stroke); -this.graphics.setColor( "#f9faf2"); -this.graphics.fillEllipse(x_cir,y_cir,this.getWidth(),this.getHeight()); - -this.graphics.setColor("#adae5e"); -this.graphics.drawEllipse(x_cir,y_cir,this.getWidth(),this.getHeight()); - -var x_cir2=3; -var y_cir2=3; - -this.graphics.setColor( "#f9faf2" ); -this.graphics.fillEllipse(x_cir2,y_cir2,this.getWidth()-6,this.getHeight()-6); - -this.graphics.setColor("#adae5e"); -var cw = this.getWidth(); -var ch = this.getHeight(); -this.graphics.drawEllipse(cw*0.15, ch*0.15, ch*0.7, ch*0.7); -//var x=new Array(12,12,32,32,22,12,32); -//var y=new Array(14,31,31,14,23,14,14); -/*var x=new Array(this.getWidth()/3.75,this.getWidth()/3.75,this.getWidth()/1.28,this.getWidth()/1.28,this.getWidth()/2,this.getWidth()/3.75,this.getWidth()/3.75); -var y=new Array(this.getHeight()/3.21,this.getHeight()/1.36,this.getHeight()/1.36,this.getHeight()/2.64,this.getHeight()/1.73,this.getHeight()/2.64); -this.graphics.setStroke(1); -this.graphics.setColor( "#adae5e" ); -//this.graphics.fillPolygon(x,y); -this.graphics.setColor("#adae5e"); -this.graphics.drawPolygon(x,y); -//var x_tri=new Array(12,23.5,35); -//var y_tri=new Array(13,22,13); -var x_tri=new Array(this.getWidth()/3.75,this.getWidth()/1.91,this.getWidth()/1.28); -var y_tri=new Array(this.getHeight()/3.46,this.getHeight()/2.04,this.getHeight()/3.46); -this.graphics.setColor( "#adae5e" ); -//this.graphics.fillPolygon(x_tri,y_tri); -this.graphics.setColor("#adae5e"); -this.graphics.drawPolygon(x_tri,y_tri);*/ - -//draw the mail icon - var cw = this.getWidth(); - var ch = this.getHeight(); - var x = new Array( cw*0.25, cw*0.25, cw*0.78, cw*0.78, cw*0.52, cw*0.25, cw*0.25, cw*0.78); - var y = new Array( ch*0.31, ch*0.71, ch*0.71, ch*0.32, ch*0.52, ch*0.32, ch*0.31, ch*0.31); - this.graphics.setColor("#4aa533"); - this.graphics.drawPolygon(x,y); - -this.graphics.paint(); -}; - -bpmnEventMessageInter.prototype.getContextMenu=function(){ -if(this.id != null){ - this.workflow.handleContextMenu(this); -} -}; diff --git a/workflow/engine/templates/bpmn/EventMessageRecInter.js b/workflow/engine/templates/bpmn/EventMessageRecInter.js deleted file mode 100755 index 3a5d3c7c3..000000000 --- a/workflow/engine/templates/bpmn/EventMessageRecInter.js +++ /dev/null @@ -1,111 +0,0 @@ -bpmnEventMessageRecInter=function(){ -VectorFigure.call(this); -this.stroke=2; -}; -bpmnEventMessageRecInter.prototype=new VectorFigure; -bpmnEventMessageRecInter.prototype.type="bpmnEventMessageRecInter"; -bpmnEventMessageRecInter.prototype.paint=function(){ -VectorFigure.prototype.paint.call(this); - -if(typeof workflow.zoomfactor == 'undefined') - workflow.zoomfactor = 1; - //Set the Task Limitation -if(typeof this.limitFlag == 'undefined' || this.limitFlag == false) -{ - this.originalWidth = 30; - this.originalHeight = 30; - this.orgXPos = this.getX(); - this.orgYPos = this.getY(); - this.orgFontSize =this.fontSize; -} - -this.width = this.originalWidth * workflow.zoomfactor; -this.height = this.originalHeight * workflow.zoomfactor; - -var x_cir = 0; -var y_cir = 0; - -this.graphics.setColor("#c0c0c0"); -this.graphics.fillEllipse(x_cir+3,y_cir+3,this.getWidth(),this.getHeight()); -this.graphics.setStroke(this.stroke); -this.graphics.setColor( "#f9faf2"); -this.graphics.fillEllipse(x_cir,y_cir,this.getWidth(),this.getHeight()); - -this.graphics.setColor("#adae5e"); -this.graphics.drawEllipse(x_cir,y_cir,this.getWidth(),this.getHeight()); - -var x_cir2=3; -var y_cir2=3; - -this.graphics.setColor( "#f9faf2" ); -this.graphics.fillEllipse(x_cir2,y_cir2,this.getWidth()-6,this.getHeight()-6); - -this.graphics.setColor("#adae5e"); -this.graphics.drawEllipse(x_cir2,y_cir2,this.getWidth()-6,this.getHeight()-6); -//var x=new Array(12,12,32,32,22,12,32); -//var y=new Array(14,31,31,14,23,14,14); -/*var x=new Array(this.getWidth()/3.75,this.getWidth()/3.75,this.getWidth()/1.28,this.getWidth()/1.28,this.getWidth()/1.95,this.getWidth()/3.75); -var y=new Array(this.getHeight()/2.64,this.getHeight()/1.36,this.getHeight()/1.36,this.getHeight()/2.64,this.getHeight()/1.73,this.getHeight()/2.64); -this.graphics.setStroke(1); -this.graphics.setColor( "#adae5e" ); -//this.graphics.fillPolygon(x,y); -this.graphics.setColor("#adae5e"); -this.graphics.drawPolygon(x,y); -//var x_tri=new Array(12,23.5,35); -//var y_tri=new Array(13,22,13); -var x_tri=new Array(this.getWidth()/3.75,this.getWidth()/1.91,this.getWidth()/1.28); -var y_tri=new Array(this.getHeight()/3.46,this.getHeight()/2.04,this.getHeight()/3.46); -this.graphics.setColor( "#adae5e" ); -//this.graphics.fillPolygon(x_tri,y_tri); -this.graphics.setColor("#adae5e"); -this.graphics.drawPolygon(x_tri,y_tri);*/ -//draw the mail icon - var cw = this.getWidth(); - var ch = this.getHeight(); - var x = new Array( cw*0.25, cw*0.25, cw*0.78, cw*0.78, cw*0.52, cw*0.25, cw*0.25, cw*0.78); - var y = new Array( ch*0.31, ch*0.71, ch*0.71, ch*0.32, ch*0.52, ch*0.32, ch*0.31, ch*0.31); - this.graphics.setColor("#adae5e"); - this.graphics.drawPolygon(x,y); -this.graphics.paint(); - -/*Code Added to Dynamically shift Ports on resizing of shapes - **/ -if(this.input1!=null){ -this.input1.setPosition(0,this.height/2); -} -if(this.output1!=null){ -this.output1.setPosition(this.width/2,this.height); -} -if(this.input2!=null){ -this.input2.setPosition(this.width/2,0); -} -if(this.output2!=null){ -this.output2.setPosition(this.width,this.height/2); -} -}; - -bpmnEventMessageRecInter.prototype.setWorkflow=function(_40c5){ -VectorFigure.prototype.setWorkflow.call(this,_40c5); -if(_40c5!=null){ - var eventPortName = ['input1','input2','output1','output2']; - var eventPortType = ['InputPort','InputPort','OutputPort','OutputPort']; - var eventPositionX= [0,this.width/2,this.width,this.width/2]; - var eventPositionY= [this.height/2,0,this.height/2,this.height]; - - for(var i=0; i< eventPortName.length ; i++){ - eval('this.'+eventPortName[i]+' = new '+eventPortType[i]+'()'); //Create New Port - eval('this.'+eventPortName[i]+'.setWorkflow(_40c5)'); //Add port to the workflow - eval('this.'+eventPortName[i]+'.setName("'+eventPortName[i]+'")'); //Set PortName - eval('this.'+eventPortName[i]+'.setZOrder(-1)'); //Set Z-Order of the port to -1. It will be below all the figure - eval('this.'+eventPortName[i]+'.setBackgroundColor(new Color(255, 255, 255))'); //Setting Background of the port to white - eval('this.'+eventPortName[i]+'.setColor(new Color(255, 255, 255))'); //Setting Border of the port to white - eval('this.addPort(this.'+eventPortName[i]+','+eventPositionX[i]+', '+eventPositionY[i]+')'); //Setting Position of the port - } -} -}; - -bpmnEventMessageRecInter.prototype.getContextMenu=function(){ -if(this.id != null){ - this.workflow.handleContextMenu(this); -} -}; diff --git a/workflow/engine/templates/bpmn/EventMessageSendInter.js b/workflow/engine/templates/bpmn/EventMessageSendInter.js deleted file mode 100755 index a1fdff3d5..000000000 --- a/workflow/engine/templates/bpmn/EventMessageSendInter.js +++ /dev/null @@ -1,113 +0,0 @@ -bpmnEventMessageSendInter=function(){ -VectorFigure.call(this); - -this.stroke=1; -}; -bpmnEventMessageSendInter.prototype=new VectorFigure; -bpmnEventMessageSendInter.prototype.type="bpmnEventMessageSendInter"; -bpmnEventMessageSendInter.prototype.paint=function(){ -VectorFigure.prototype.paint.call(this); - -if(typeof workflow.zoomfactor == 'undefined') - workflow.zoomfactor = 1; - //Set the Task Limitation -if(typeof this.limitFlag == 'undefined' || this.limitFlag == false) -{ - this.originalWidth = 30; - this.originalHeight = 30; - this.orgXPos = this.getX(); - this.orgYPos = this.getY(); - this.orgFontSize =this.fontSize; -} - -this.width = this.originalWidth * workflow.zoomfactor; -this.height = this.originalHeight * workflow.zoomfactor; - -var x_cir = 0; -var y_cir = 0; - -this.graphics.setColor("#c0c0c0"); -this.graphics.fillEllipse(x_cir+3,y_cir+3,this.getWidth(),this.getHeight()); -this.graphics.setStroke(this.stroke); -this.graphics.setColor( "#f9faf2"); -this.graphics.fillEllipse(x_cir,y_cir,this.getWidth(),this.getHeight()); - -this.graphics.setColor("#adae5e"); -this.graphics.drawEllipse(x_cir,y_cir,this.getWidth(),this.getHeight()); - -var x_cir2=3; -var y_cir2=3; - -this.graphics.setColor( "#f9faf2" ); -this.graphics.fillEllipse(x_cir2,y_cir2,this.getWidth()-6,this.getHeight()-6); - -this.graphics.setColor("#adae5e"); -this.graphics.drawEllipse(x_cir2,y_cir2,this.getWidth()-6,this.getHeight()-6); -//var x=new Array(12,12,32,32,22,12,32); -//var y=new Array(14,31,31,14,23,14,14); -/*var x=new Array(this.getWidth()/3.75,this.getWidth()/3.75,this.getWidth()/1.28,this.getWidth()/1.28,this.getWidth()/1.95,this.getWidth()/3.75); -var y=new Array(this.getHeight()/2.64,this.getHeight()/1.36,this.getHeight()/1.36,this.getHeight()/2.64,this.getHeight()/1.73,this.getHeight()/2.64); -this.graphics.setStroke(1); -this.graphics.setColor( "#adae5e" ); -this.graphics.fillPolygon(x,y); -this.graphics.setColor("#adae5e"); -//this.graphics.drawPolygon(x,y); -//var x_tri=new Array(12,23.5,35); -//var y_tri=new Array(13,22,13); -var x_tri=new Array(this.getWidth()/3.75,this.getWidth()/1.91,this.getWidth()/1.28); -var y_tri=new Array(this.getHeight()/3.46,this.getHeight()/2.04,this.getHeight()/3.46); -this.graphics.setColor( "#adae5e" ); -this.graphics.fillPolygon(x_tri,y_tri); -this.graphics.setColor("#adae5e");*/ -//this.graphics.drawPolygon(x_tri,y_tri); -//draw the mail icon - var cw = this.getWidth(); - var ch = this.getHeight(); - var x = new Array( cw*0.25, cw*0.25, cw*0.78, cw*0.78, cw*0.52, cw*0.25, cw*0.25, cw*0.78); - var y = new Array( ch*0.31, ch*0.71, ch*0.71, ch*0.32, ch*0.52, ch*0.32, ch*0.31, ch*0.31); - this.graphics.setColor("#adae5e"); - this.graphics.drawPolygon(x,y); -this.graphics.paint(); - - -/*Code Added to Dynamically shift Ports on resizing of shapes - **/ -if(this.input1!=null){ -this.input1.setPosition(0,this.height/2); -} -if(this.output1!=null){ -this.output1.setPosition(this.width/2,this.height); -} -if(this.input2!=null){ -this.input2.setPosition(this.width/2,0); -} -if(this.output2!=null){ -this.output2.setPosition(this.width,this.height/2); -} -}; - -bpmnEventMessageSendInter.prototype.setWorkflow=function(_40c5){ -VectorFigure.prototype.setWorkflow.call(this,_40c5); -if(_40c5!=null){ - var eventPortName = ['input1','input2','output1','output2']; - var eventPortType = ['InputPort','InputPort','OutputPort','OutputPort']; - var eventPositionX= [0,this.width/2,this.width,this.width/2]; - var eventPositionY= [this.height/2,0,this.height/2,this.height]; - - for(var i=0; i< eventPortName.length ; i++){ - eval('this.'+eventPortName[i]+' = new '+eventPortType[i]+'()'); //Create New Port - eval('this.'+eventPortName[i]+'.setWorkflow(_40c5)'); //Add port to the workflow - eval('this.'+eventPortName[i]+'.setName("'+eventPortName[i]+'")'); //Set PortName - eval('this.'+eventPortName[i]+'.setZOrder(-1)'); //Set Z-Order of the port to -1. It will be below all the figure - eval('this.'+eventPortName[i]+'.setBackgroundColor(new Color(255, 255, 255))'); //Setting Background of the port to white - eval('this.'+eventPortName[i]+'.setColor(new Color(255, 255, 255))'); //Setting Border of the port to white - eval('this.addPort(this.'+eventPortName[i]+','+eventPositionX[i]+', '+eventPositionY[i]+')'); //Setting Position of the port - } -} -}; - -bpmnEventMessageSendInter.prototype.getContextMenu=function(){ -if(this.id != null){ - this.workflow.handleContextMenu(this); -} -}; diff --git a/workflow/engine/templates/bpmn/EventMessageStart.js b/workflow/engine/templates/bpmn/EventMessageStart.js deleted file mode 100755 index 338ee2de0..000000000 --- a/workflow/engine/templates/bpmn/EventMessageStart.js +++ /dev/null @@ -1,89 +0,0 @@ -bpmnEventMessageStart=function(){ - VectorFigure.call(this); -}; - -bpmnEventMessageStart.prototype=new VectorFigure; -bpmnEventMessageStart.prototype.type="bpmnEventMessageStart"; -bpmnEventMessageStart.prototype.paint=function(){ - VectorFigure.prototype.paint.call(this); - if(typeof workflow.zoomfactor == 'undefined') - workflow.zoomfactor = 1; - - //Set the Limitation - if(typeof this.limitFlag == 'undefined' || this.limitFlag == false) { - this.originalWidth = 30; - this.originalHeight = 30; - this.orgXPos = this.getX(); - this.orgYPos = this.getY(); - this.orgFontSize =this.fontSize; - } - this.width = this.originalWidth * workflow.zoomfactor; - this.height = this.originalHeight * workflow.zoomfactor; - - var x_cir = 0; - var y_cir = 0; - - //draw the circle - this.graphics.setColor("#d0d0d0"); - this.graphics.fillEllipse(x_cir+2,y_cir+2,this.getWidth(),this.getHeight()); - this.graphics.setColor( "#F6FFDA" ); - this.graphics.fillEllipse(x_cir,y_cir,this.getWidth(),this.getHeight()); - this.graphics.setStroke(1); - this.graphics.setColor("#97C759"); - this.graphics.drawEllipse(x_cir,y_cir,this.getWidth(),this.getHeight()); - this.graphics.setStroke(1); - this.graphics.setColor("#98C951"); - this.graphics.drawEllipse(x_cir,y_cir,this.getWidth(),this.getHeight()); - - //draw the mail icon - var cw = this.getWidth(); - var ch = this.getHeight(); - var x = new Array( cw*0.25, cw*0.25, cw*0.78, cw*0.78, cw*0.52, cw*0.25, cw*0.25, cw*0.78); - var y = new Array( ch*0.31, ch*0.71, ch*0.71, ch*0.32, ch*0.52, ch*0.32, ch*0.31, ch*0.31); - this.graphics.setColor("#4aa533"); - this.graphics.drawPolygon(x,y); - - this.graphics.paint(); - - /*Code Added to Dynamically shift Ports on resizing of shapes - **/ - if(this.input1!=null){ - this.input1.setPosition(0,this.height/2); - } - if(this.output1!=null){ - this.output1.setPosition(this.width/2,this.height); - } - if(this.input2!=null){ - this.input2.setPosition(this.width/2,0); - } - if(this.output2!=null){ - this.output2.setPosition(this.width,this.height/2); - } -}; - -bpmnEventMessageStart.prototype.setWorkflow=function(_40c5){ - VectorFigure.prototype.setWorkflow.call(this,_40c5); - if(_40c5!=null){ - var eventPortName = ['output1','output2']; - var eventPortType = ['OutputPort','OutputPort']; - var eventPositionX= [this.width/2,this.width]; - var eventPositionY= [this.height,this.height/2]; - - for(var i=0; i< eventPortName.length ; i++){ - eval('this.'+eventPortName[i]+' = new '+eventPortType[i]+'()'); //Create New Port - eval('this.'+eventPortName[i]+'.setWorkflow(_40c5)'); //Add port to the workflow - eval('this.'+eventPortName[i]+'.setName("'+eventPortName[i]+'")'); //Set PortName - eval('this.'+eventPortName[i]+'.setZOrder(-1)'); //Set Z-Order of the port to -1. It will be below all the figure - eval('this.'+eventPortName[i]+'.setBackgroundColor(new Color(255, 255, 255))'); //Setting Background of the port to white - eval('this.'+eventPortName[i]+'.setColor(new Color(255, 255, 255))'); //Setting Border of the port to white - eval('this.addPort(this.'+eventPortName[i]+','+eventPositionX[i]+', '+eventPositionY[i]+')'); //Setting Position of the port - } - } -}; - -bpmnEventMessageStart.prototype.getContextMenu=function(){ - if(this.id != null){ - this.workflow.handleContextMenu(this); - } -}; - diff --git a/workflow/engine/templates/bpmn/EventMulStart.js b/workflow/engine/templates/bpmn/EventMulStart.js deleted file mode 100755 index 9f1856d43..000000000 --- a/workflow/engine/templates/bpmn/EventMulStart.js +++ /dev/null @@ -1,74 +0,0 @@ -bpmnEventMulStart=function(){ -VectorFigure.call(this); -//Setting width and height values as per the zoom ratio -if(typeof workflow.zoomWidth != 'undefined' || typeof workflow.zoomHeight != 'undefined') - this.setDimension(workflow.zoomWidth, workflow.zoomHeight); -else - this.setDimension(30,30); -this.stroke= 2; -}; -bpmnEventMulStart.prototype=new VectorFigure; -bpmnEventMulStart.prototype.type="bpmnEventMulStart"; -bpmnEventMulStart.prototype.paint=function(){ -VectorFigure.prototype.paint.call(this); -var x=0; -var y=0; -this.graphics.setStroke(this.stroke); -this.graphics.setColor("#c0c0c0"); -this.graphics.fillEllipse(x+3,y+3,this.getWidth(),this.getHeight()); -this.graphics.setColor( "#e4f7df" ); -this.graphics.fillEllipse(x,y,this.getWidth(),this.getHeight()); -this.graphics.setColor("#4aa533"); -this.graphics.drawEllipse(x,y,this.getWidth(),this.getHeight()); -//var x_penta=new Array(13,28,36,22,8);(8.5,18.5,24,14.5,5 -//var y_penta=new Array(33,33,18,8,18);(22,22,12,5,12 -var x_penta=new Array(this.getWidth()/3.5,this.getWidth()/1.6,this.getWidth()/1.25,this.getWidth()/2,this.getWidth()/5.6); -var y_penta=new Array(this.getHeight()/1.36,this.getHeight()/1.36,this.getHeight()/2.5,this.getHeight()/5.6,this.getHeight()/2.5); -//this.graphics.setStroke(1); -this.graphics.setColor( "#4aa533" ); -this.graphics.fillPolygon(x_penta,y_penta); -this.graphics.setColor("#4aa533"); -this.graphics.drawPolygon(x_penta,y_penta); -this.graphics.paint(); - -/*Code Added to Dynamically shift Ports on resizing of shapes - **/ -if(this.input1!=null){ -this.input1.setPosition(0,this.height/2); -} -if(this.output1!=null){ -this.output1.setPosition(this.width/2,this.height); -} -if(this.input2!=null){ -this.input2.setPosition(this.width/2,0); -} -if(this.output2!=null){ -this.output2.setPosition(this.width,this.height/2); -} -}; - -bpmnEventMulStart.prototype.setWorkflow=function(_40c5){ -VectorFigure.prototype.setWorkflow.call(this,_40c5); -if(_40c5!=null){ - var eventPortName = ['output1','output2']; - var eventPortType = ['OutputPort','OutputPort']; - var eventPositionX= [this.width/2,this.width]; - var eventPositionY= [this.height,this.height/2]; - - for(var i=0; i< eventPortName.length ; i++){ - eval('this.'+eventPortName[i]+' = new '+eventPortType[i]+'()'); //Create New Port - eval('this.'+eventPortName[i]+'.setWorkflow(_40c5)'); //Add port to the workflow - eval('this.'+eventPortName[i]+'.setName("'+eventPortName[i]+'")'); //Set PortName - eval('this.'+eventPortName[i]+'.setZOrder(-1)'); //Set Z-Order of the port to -1. It will be below all the figure - eval('this.'+eventPortName[i]+'.setBackgroundColor(new Color(255, 255, 255))'); //Setting Background of the port to white - eval('this.'+eventPortName[i]+'.setColor(new Color(255, 255, 255))'); //Setting Border of the port to white - eval('this.addPort(this.'+eventPortName[i]+','+eventPositionX[i]+', '+eventPositionY[i]+')'); //Setting Position of the port - } -} -}; - -bpmnEventMulStart.prototype.getContextMenu=function(){ -if(this.id != null){ - this.workflow.handleContextMenu(this); -} -}; diff --git a/workflow/engine/templates/bpmn/EventMultipleEnd.js b/workflow/engine/templates/bpmn/EventMultipleEnd.js deleted file mode 100755 index 8a90e1f34..000000000 --- a/workflow/engine/templates/bpmn/EventMultipleEnd.js +++ /dev/null @@ -1,76 +0,0 @@ -bpmnEventMultipleEnd=function(){ -VectorFigure.call(this); -//Setting width and height values as per the zoom ratio -if(typeof workflow.zoomWidth != 'undefined' || typeof workflow.zoomHeight != 'undefined') - this.setDimension(workflow.zoomWidth, workflow.zoomHeight); -else - this.setDimension(30,30); -this.stroke=2; -}; -bpmnEventMultipleEnd.prototype=new VectorFigure; -bpmnEventMultipleEnd.prototype.type="bpmnEventMultipleEnd"; -bpmnEventMultipleEnd.prototype.paint=function(){ -VectorFigure.prototype.paint.call(this); -VectorFigure.prototype.paint.call(this); -this.graphics.setStroke(this.stroke); -var x_cir = 0; -var y_cir = 0; - -this.graphics.setColor("#c0c0c0"); -this.graphics.fillEllipse(x_cir+5,y_cir+5,this.getWidth(),this.getHeight()); -this.graphics.setStroke(this.stroke); -this.graphics.setColor( "#f7f1e5" ); -this.graphics.fillEllipse(x_cir,y_cir,this.getWidth(),this.getHeight()); -this.graphics.setColor("#c46508"); -this.graphics.drawEllipse(x_cir,y_cir,this.getWidth(),this.getHeight()); -//var x_penta=new Array(12.5,27.5,35.5,21.5,8); -//var y_penta=new Array(33,33,18,8,18); -var x_penta=new Array(this.getWidth()/3.6,this.getWidth()/1.63,this.getWidth()/1.26,this.getWidth()/2.14,this.getWidth()/5.6); -var y_penta=new Array(this.getHeight()/1.36,this.getHeight()/1.36,this.getHeight()/2.5,this.getHeight()/5.6,this.getHeight()/2.5); -this.graphics.setColor( "#c46508" ); -this.graphics.fillPolygon(x_penta,y_penta); -this.graphics.setColor("#c46508"); -//this.graphics.drawPolygon(x_penta,y_penta); -this.graphics.paint(); - -/*Code Added to Dynamically shift Ports on resizing of shapes - **/ -if(this.input1!=null){ -this.input1.setPosition(0,this.height/2); -} -if(this.output1!=null){ -this.output1.setPosition(this.width/2,this.height); -} -if(this.input2!=null){ -this.input2.setPosition(this.width/2,0); -} -if(this.output2!=null){ -this.output2.setPosition(this.width,this.height/2); -} -}; - -bpmnEventMultipleEnd.prototype.setWorkflow=function(_40c5){ -VectorFigure.prototype.setWorkflow.call(this,_40c5); -if(_40c5!=null){ - var eventPortName = ['input1','input2']; - var eventPortType = ['InputPort','InputPort']; - var eventPositionX= [this.width/2,0]; - var eventPositionY= [0,this.height/2]; - - for(var i=0; i< eventPortName.length ; i++){ - eval('this.'+eventPortName[i]+' = new '+eventPortType[i]+'()'); //Create New Port - eval('this.'+eventPortName[i]+'.setWorkflow(_40c5)'); //Add port to the workflow - eval('this.'+eventPortName[i]+'.setName("'+eventPortName[i]+'")'); //Set PortName - eval('this.'+eventPortName[i]+'.setZOrder(-1)'); //Set Z-Order of the port to -1. It will be below all the figure - eval('this.'+eventPortName[i]+'.setBackgroundColor(new Color(255, 255, 255))'); //Setting Background of the port to white - eval('this.'+eventPortName[i]+'.setColor(new Color(255, 255, 255))'); //Setting Border of the port to white - eval('this.addPort(this.'+eventPortName[i]+','+eventPositionX[i]+', '+eventPositionY[i]+')'); //Setting Position of the port - } -} -}; - -bpmnEventMultipleEnd.prototype.getContextMenu=function(){ -if(this.id != null){ - this.workflow.handleContextMenu(this); -} -}; diff --git a/workflow/engine/templates/bpmn/EventMultipleInter.js b/workflow/engine/templates/bpmn/EventMultipleInter.js deleted file mode 100755 index 24ccf7a83..000000000 --- a/workflow/engine/templates/bpmn/EventMultipleInter.js +++ /dev/null @@ -1,81 +0,0 @@ -bpmnEventMultipleInter=function(){ -VectorFigure.call(this); -//Setting width and height values as per the zoom ratio -if(typeof workflow.zoomWidth != 'undefined' || typeof workflow.zoomHeight != 'undefined') - this.setDimension(workflow.zoomWidth, workflow.zoomHeight); -else - this.setDimension(30,30); -this.stroke=2 -}; -bpmnEventMultipleInter.prototype=new VectorFigure; -bpmnEventMultipleInter.prototype.type="bpmnEventMultipleInter"; -bpmnEventMultipleInter.prototype.paint=function(){ -VectorFigure.prototype.paint.call(this); -this.graphics.setStroke(this.stroke); -var x_cir = 0; -var y_cir = 0; - -this.graphics.setColor("#c0c0c0"); -this.graphics.fillEllipse(x_cir+3,y_cir+3,this.getWidth(),this.getHeight()); - -this.graphics.setColor("#f9faf2"); -this.graphics.fillEllipse(x_cir,y_cir,this.getWidth(),this.getHeight()); -this.graphics.setColor("#adae5e"); -this.graphics.drawEllipse(x_cir,y_cir,this.getWidth(),this.getHeight()); -var x_cir2=3; -var y_cir2=3; -this.graphics.setColor("#f9faf2"); -this.graphics.fillEllipse(x_cir2,y_cir2,this.getWidth()-6,this.getHeight()-6); -this.graphics.setColor("#adae5e"); -this.graphics.drawEllipse(x_cir2,y_cir2,this.getWidth()-6,this.getHeight()-6); -//var x_penta=new Array(13.5,28.5,37.5,23.1,9); -//var y_penta=new Array(33,33,18,8,18); -var x_penta=new Array(this.getWidth()/3.46,this.getWidth()/1.57,this.getWidth()/1.2,this.getWidth()/1.95,this.getWidth()/5); -var y_penta=new Array(this.getHeight()/1.36,this.getHeight()/1.36,this.getHeight()/2.5,this.getHeight()/5,this.getHeight()/2.5); -this.graphics.setColor( "#adae5e" ); -this.graphics.fillPolygon(x_penta,y_penta); -this.graphics.setColor("#adae5e"); -this.graphics.drawPolygon(x_penta,y_penta); -this.graphics.paint(); - -/*Code Added to Dynamically shift Ports on resizing of shapes - **/ -if(this.input1!=null){ -this.input1.setPosition(0,this.height/2); -} -if(this.output1!=null){ -this.output1.setPosition(this.width/2,this.height); -} -if(this.input2!=null){ -this.input2.setPosition(this.width/2,0); -} -if(this.output2!=null){ -this.output2.setPosition(this.width,this.height/2); -} -}; - -bpmnEventMultipleInter.prototype.setWorkflow=function(_40c5){ -VectorFigure.prototype.setWorkflow.call(this,_40c5); -if(_40c5!=null){ - var eventPortName = ['input1','input2','output1','output2']; - var eventPortType = ['InputPort','InputPort','OutputPort','OutputPort']; - var eventPositionX= [0,this.width/2,this.width,this.width/2]; - var eventPositionY= [this.height/2,0,this.height/2,this.height]; - - for(var i=0; i< eventPortName.length ; i++){ - eval('this.'+eventPortName[i]+' = new '+eventPortType[i]+'()'); //Create New Port - eval('this.'+eventPortName[i]+'.setWorkflow(_40c5)'); //Add port to the workflow - eval('this.'+eventPortName[i]+'.setName("'+eventPortName[i]+'")'); //Set PortName - eval('this.'+eventPortName[i]+'.setZOrder(-1)'); //Set Z-Order of the port to -1. It will be below all the figure - eval('this.'+eventPortName[i]+'.setBackgroundColor(new Color(255, 255, 255))'); //Setting Background of the port to white - eval('this.'+eventPortName[i]+'.setColor(new Color(255, 255, 255))'); //Setting Border of the port to white - eval('this.addPort(this.'+eventPortName[i]+','+eventPositionX[i]+', '+eventPositionY[i]+')'); //Setting Position of the port - } -} -}; - -bpmnEventMultipleInter.prototype.getContextMenu=function(){ -if(this.id != null){ - this.workflow.handleContextMenu(this); -} -}; diff --git a/workflow/engine/templates/bpmn/EventRuleInter.js b/workflow/engine/templates/bpmn/EventRuleInter.js deleted file mode 100755 index c8b613749..000000000 --- a/workflow/engine/templates/bpmn/EventRuleInter.js +++ /dev/null @@ -1,83 +0,0 @@ -bpmnEventRuleInter=function(){ -VectorFigure.call(this); -//Setting width and height values as per the zoom ratio -if(typeof workflow.zoomWidth != 'undefined' || typeof workflow.zoomHeight != 'undefined') - this.setDimension(workflow.zoomWidth, workflow.zoomHeight); -else - this.setDimension(30,30); -this.stroke = 2; -}; -bpmnEventRuleInter.prototype=new VectorFigure; -bpmnEventRuleInter.prototype.type="bpmnEventRuleInter"; -bpmnEventRuleInter.prototype.paint=function(){ -VectorFigure.prototype.paint.call(this); -var x_cir1=0; -var y_cir1=0; - -this.graphics.setColor("#c0c0c0"); -this.graphics.fillEllipse(x_cir1+3,y_cir1+3,this.getWidth(),this.getHeight()); - -this.graphics.setStroke(this.stroke); -this.graphics.setColor( "#f9faf2" ); -this.graphics.fillEllipse(x_cir1,y_cir1,this.getWidth(),this.getHeight()); -this.graphics.setColor("#adae5e"); -this.graphics.drawEllipse(x_cir1,y_cir1,this.getWidth(),this.getHeight()); -var x_cir2=3; -var y_cir2=3; -this.graphics.setColor( "#f9faf2" ); -this.graphics.fillEllipse(x_cir2,y_cir2,this.getWidth()-6,this.getHeight()-6); -this.graphics.setColor("#adae5e"); -this.graphics.drawEllipse(x_cir2,y_cir2,this.getWidth()-6,this.getHeight()-6); -var x=new Array(12,12,this.getWidth()-10,this.getWidth()-10); -var y=new Array(10,this.getHeight()-10,this.getHeight()-10,10); -//this.graphics.setColor("#adae5e"); -//this.graphics.fillPolygon(x,y); -this.graphics.setColor("#adae5e"); -this.graphics.drawPolygon(x,y); -this.graphics.drawLine(14,this.getHeight()/1.5,this.getWidth()-10,this.getHeight()/1.5); -this.graphics.drawLine(14,this.getHeight()/2,this.getWidth()-10,this.getHeight()/2); -this.graphics.drawLine(14,this.getHeight()/3,this.getWidth()-10,this.getHeight()/3); -this.graphics.drawLine(14,this.getHeight()/4,this.getWidth()-10,this.getHeight()/4); -this.graphics.paint(); - -/*Code Added to Dynamically shift Ports on resizing of shapes - **/ -if(this.input1!=null){ -this.input1.setPosition(0,this.height/2); -} -if(this.output1!=null){ -this.output1.setPosition(this.width/2,this.height); -} -if(this.input2!=null){ -this.input2.setPosition(this.width/2,0); -} -if(this.output2!=null){ -this.output2.setPosition(this.width,this.height/2); -} -}; - -bpmnEventRuleInter.prototype.setWorkflow=function(_40c5){ -VectorFigure.prototype.setWorkflow.call(this,_40c5); -if(_40c5!=null){ - var eventPortName = ['input1','input2','output1','output2']; - var eventPortType = ['InputPort','InputPort','OutputPort','OutputPort']; - var eventPositionX= [0,this.width/2,this.width,this.width/2]; - var eventPositionY= [this.height/2,0,this.height/2,this.height]; - - for(var i=0; i< eventPortName.length ; i++){ - eval('this.'+eventPortName[i]+' = new '+eventPortType[i]+'()'); //Create New Port - eval('this.'+eventPortName[i]+'.setWorkflow(_40c5)'); //Add port to the workflow - eval('this.'+eventPortName[i]+'.setName("'+eventPortName[i]+'")'); //Set PortName - eval('this.'+eventPortName[i]+'.setZOrder(-1)'); //Set Z-Order of the port to -1. It will be below all the figure - eval('this.'+eventPortName[i]+'.setBackgroundColor(new Color(255, 255, 255))'); //Setting Background of the port to white - eval('this.'+eventPortName[i]+'.setColor(new Color(255, 255, 255))'); //Setting Border of the port to white - eval('this.addPort(this.'+eventPortName[i]+','+eventPositionX[i]+', '+eventPositionY[i]+')'); //Setting Position of the port - } -} -}; - -bpmnEventRuleInter.prototype.getContextMenu=function(){ -if(this.id != null){ - this.workflow.handleContextMenu(this); -} -}; diff --git a/workflow/engine/templates/bpmn/EventRuleStart.js b/workflow/engine/templates/bpmn/EventRuleStart.js deleted file mode 100755 index ebed18558..000000000 --- a/workflow/engine/templates/bpmn/EventRuleStart.js +++ /dev/null @@ -1,77 +0,0 @@ -bpmnEventRuleStart=function(){ -VectorFigure.call(this); -//Setting width and height values as per the zoom ratio -if(typeof workflow.zoomWidth != 'undefined' || typeof workflow.zoomHeight != 'undefined') - this.setDimension(workflow.zoomWidth, workflow.zoomHeight); -else - this.setDimension(30,30); -this.stroke = 2; -}; -bpmnEventRuleStart.prototype=new VectorFigure; -bpmnEventRuleStart.prototype.type="bpmnEventRuleStart"; -bpmnEventRuleStart.prototype.paint=function(){ -VectorFigure.prototype.paint.call(this); -var x_cir = 0; -var y_cir = 0; - -this.graphics.setColor("#c0c0c0"); -this.graphics.fillEllipse(x_cir+5,y_cir+5,this.getWidth(),this.getHeight()); -this.graphics.setStroke(this.stroke); -this.graphics.setColor( "#e4f7df"); -this.graphics.fillEllipse(x_cir,y_cir,this.getWidth(),this.getHeight()); -this.graphics.setColor("#4aa533"); -this.graphics.drawEllipse(x_cir,y_cir,this.getWidth(),this.getHeight()); -this.graphics.setStroke(1); -var x=new Array(12,12,this.getWidth()-10,this.getWidth()-10); -var y=new Array(10,this.getHeight()-10,this.getHeight()-10,10); -//this.graphics.setColor("#adae5e"); -//this.graphics.fillPolygon(x,y); -this.graphics.setColor("#4aa533"); -this.graphics.drawPolygon(x,y); -this.graphics.drawLine(14,this.getHeight()/1.5,this.getWidth()-10,this.getHeight()/1.5); -this.graphics.drawLine(14,this.getHeight()/2,this.getWidth()-10,this.getHeight()/2); -this.graphics.drawLine(14,this.getHeight()/3,this.getWidth()-10,this.getHeight()/3); -this.graphics.drawLine(14,this.getHeight()/4,this.getWidth()-10,this.getHeight()/4); -this.graphics.paint(); - -/*Code Added to Dynamically shift Ports on resizing of shapes - **/ -if(this.input1!=null){ -this.input1.setPosition(0,this.height/2); -} -if(this.output1!=null){ -this.output1.setPosition(this.width/2,this.height); -} -if(this.input2!=null){ -this.input2.setPosition(this.width/2,0); -} -if(this.output2!=null){ -this.output2.setPosition(this.width,this.height/2); -} -}; - -bpmnEventRuleStart.prototype.setWorkflow=function(_40c5){ -VectorFigure.prototype.setWorkflow.call(this,_40c5); -if(_40c5!=null){ - var eventPortName = ['output1','output2']; - var eventPortType = ['OutputPort','OutputPort']; - var eventPositionX= [this.width/2,this.width]; - var eventPositionY= [this.height,this.height/2]; - - for(var i=0; i< eventPortName.length ; i++){ - eval('this.'+eventPortName[i]+' = new '+eventPortType[i]+'()'); //Create New Port - eval('this.'+eventPortName[i]+'.setWorkflow(_40c5)'); //Add port to the workflow - eval('this.'+eventPortName[i]+'.setName("'+eventPortName[i]+'")'); //Set PortName - eval('this.'+eventPortName[i]+'.setZOrder(-1)'); //Set Z-Order of the port to -1. It will be below all the figure - eval('this.'+eventPortName[i]+'.setBackgroundColor(new Color(255, 255, 255))'); //Setting Background of the port to white - eval('this.'+eventPortName[i]+'.setColor(new Color(255, 255, 255))'); //Setting Border of the port to white - eval('this.addPort(this.'+eventPortName[i]+','+eventPositionX[i]+', '+eventPositionY[i]+')'); //Setting Position of the port - } -} -}; - -bpmnEventRuleStart.prototype.getContextMenu=function(){ -if(this.id != null){ - this.workflow.handleContextMenu(this); -} -}; diff --git a/workflow/engine/templates/bpmn/EventSignalStart.js b/workflow/engine/templates/bpmn/EventSignalStart.js deleted file mode 100755 index 1af578206..000000000 --- a/workflow/engine/templates/bpmn/EventSignalStart.js +++ /dev/null @@ -1,74 +0,0 @@ -bpmnEventSignalStart=function(){ -VectorFigure.call(this); -//Setting width and height values as per the zoom ratio -if(typeof workflow.zoomWidth != 'undefined' || typeof workflow.zoomHeight != 'undefined') - this.setDimension(workflow.zoomWidth, workflow.zoomHeight); -else - this.setDimension(30,30); -this.stroke=2; -}; -bpmnEventSignalStart.prototype=new VectorFigure; -bpmnEventSignalStart.prototype.type="bpmnEventSignalStart"; -bpmnEventSignalStart.prototype.paint=function(){ -VectorFigure.prototype.paint.call(this); -var x=0; -var y=0; - -this.graphics.setColor("#c0c0c0"); -this.graphics.fillEllipse(x+5,y+5,this.getWidth(),this.getHeight()); -this.graphics.setStroke(this.stroke); -this.graphics.setColor( "#e4f7df" ); -this.graphics.fillEllipse(x,y,this.getWidth(),this.getHeight()); -this.graphics.setColor("#4aa533"); -this.graphics.drawEllipse(x,y,this.getWidth(),this.getHeight()); -//var x=new Array(5,41,23); -//var y=new Array(35,35,0); -var x=new Array(5,this.getWidth()-4,this.getWidth()/2); -var y=new Array(this.getHeight()-10,this.getHeight()-10,2); -this.graphics.setColor("#4aa533"); -//this.graphics.fillPolygon(x,y); -this.graphics.setColor("#4aa533"); -this.graphics.drawPolygon(x,y); -this.graphics.paint(); - -/*Code Added to Dynamically shift Ports on resizing of shapes - **/ -if(this.input1!=null){ -this.input1.setPosition(0,this.height/2); -} -if(this.output1!=null){ -this.output1.setPosition(this.width/2,this.height); -} -if(this.input2!=null){ -this.input2.setPosition(this.width/2,0); -} -if(this.output2!=null){ -this.output2.setPosition(this.width,this.height/2); -} -}; - -bpmnEventSignalStart.prototype.setWorkflow=function(_40c5){ -VectorFigure.prototype.setWorkflow.call(this,_40c5); -if(_40c5!=null){ - var eventPortName = ['output1','output2']; - var eventPortType = ['OutputPort','OutputPort']; - var eventPositionX= [this.width/2,this.width]; - var eventPositionY= [this.height,this.height/2]; - - for(var i=0; i< eventPortName.length ; i++){ - eval('this.'+eventPortName[i]+' = new '+eventPortType[i]+'()'); //Create New Port - eval('this.'+eventPortName[i]+'.setWorkflow(_40c5)'); //Add port to the workflow - eval('this.'+eventPortName[i]+'.setName("'+eventPortName[i]+'")'); //Set PortName - eval('this.'+eventPortName[i]+'.setZOrder(-1)'); //Set Z-Order of the port to -1. It will be below all the figure - eval('this.'+eventPortName[i]+'.setBackgroundColor(new Color(255, 255, 255))'); //Setting Background of the port to white - eval('this.'+eventPortName[i]+'.setColor(new Color(255, 255, 255))'); //Setting Border of the port to white - eval('this.addPort(this.'+eventPortName[i]+','+eventPositionX[i]+', '+eventPositionY[i]+')'); //Setting Position of the port - } -} -}; - -bpmnEventSignalStart.prototype.getContextMenu=function(){ -if(this.id != null){ - this.workflow.handleContextMenu(this); -} -}; diff --git a/workflow/engine/templates/bpmn/EventTerminateEnd.js b/workflow/engine/templates/bpmn/EventTerminateEnd.js deleted file mode 100755 index f5f23f41e..000000000 --- a/workflow/engine/templates/bpmn/EventTerminateEnd.js +++ /dev/null @@ -1,74 +0,0 @@ -bpmnEventTerminate=function(){ -VectorFigure.call(this); -//Setting width and height values as per the zoom ratio -if(typeof workflow.zoomWidth != 'undefined' || typeof workflow.zoomHeight != 'undefined') - this.setDimension(workflow.zoomWidth, workflow.zoomHeight); -else - this.setDimension(30,30); -this.stroke=2; -}; -bpmnEventTerminate.prototype=new VectorFigure; -bpmnEventTerminate.prototype.type="bpmnEventTerminateEnd"; -bpmnEventTerminate.prototype.paint=function(){ -VectorFigure.prototype.paint.call(this); -VectorFigure.prototype.paint.call(this); -this.graphics.setStroke(this.stroke); -var x_cir = 0; -var y_cir = 0; - -this.graphics.setColor("#c0c0c0"); -this.graphics.fillEllipse(x_cir+5,y_cir+5,this.getWidth(),this.getHeight()); -this.graphics.setStroke(this.stroke); -this.graphics.setColor( "#f7f1e5" ); -this.graphics.fillEllipse(x_cir,y_cir,this.getWidth(),this.getHeight()); -this.graphics.setColor("#c46508"); -this.graphics.drawEllipse(x_cir,y_cir,this.getWidth(),this.getHeight()); -var x_cir2=5; -var y_cir2=5; -this.graphics.setColor("#c46508"); -this.graphics.fillEllipse(x_cir2,y_cir2,this.getWidth()-10,this.getHeight()-10); -this.graphics.setColor("#c46508"); -this.graphics.drawEllipse(x_cir2,y_cir2,this.getWidth()-10,this.getHeight()-10); -this.graphics.paint(); - -/*Code Added to Dynamically shift Ports on resizing of shapes - **/ -if(this.input1!=null){ -this.input1.setPosition(0,this.height/2); -} -if(this.output1!=null){ -this.output1.setPosition(this.width/2,this.height); -} -if(this.input2!=null){ -this.input2.setPosition(this.width/2,0); -} -if(this.output2!=null){ -this.output2.setPosition(this.width,this.height/2); -} -}; - -bpmnEventTerminate.prototype.setWorkflow=function(_40c5){ -VectorFigure.prototype.setWorkflow.call(this,_40c5); -if(_40c5!=null){ - var eventPortName = ['input1','input2']; - var eventPortType = ['InputPort','InputPort']; - var eventPositionX= [this.width/2,0]; - var eventPositionY= [0,this.height/2]; - - for(var i=0; i< eventPortName.length ; i++){ - eval('this.'+eventPortName[i]+' = new '+eventPortType[i]+'()'); //Create New Port - eval('this.'+eventPortName[i]+'.setWorkflow(_40c5)'); //Add port to the workflow - eval('this.'+eventPortName[i]+'.setName("'+eventPortName[i]+'")'); //Set PortName - eval('this.'+eventPortName[i]+'.setZOrder(-1)'); //Set Z-Order of the port to -1. It will be below all the figure - eval('this.'+eventPortName[i]+'.setBackgroundColor(new Color(255, 255, 255))'); //Setting Background of the port to white - eval('this.'+eventPortName[i]+'.setColor(new Color(255, 255, 255))'); //Setting Border of the port to white - eval('this.addPort(this.'+eventPortName[i]+','+eventPositionX[i]+', '+eventPositionY[i]+')'); //Setting Position of the port - } - } -}; - -bpmnEventTerminate.prototype.getContextMenu=function(){ -if(this.id != null){ - this.workflow.handleContextMenu(this); -} -}; diff --git a/workflow/engine/templates/bpmn/EventTimerInter.js b/workflow/engine/templates/bpmn/EventTimerInter.js deleted file mode 100755 index 28d22dad1..000000000 --- a/workflow/engine/templates/bpmn/EventTimerInter.js +++ /dev/null @@ -1,108 +0,0 @@ -bpmnEventTimerInter=function(){ -VectorFigure.call(this); -this.stroke = 1; -}; -bpmnEventTimerInter.prototype=new VectorFigure; -bpmnEventTimerInter.prototype.type="bpmnEventTimerInter"; -bpmnEventTimerInter.prototype.paint=function(){ -VectorFigure.prototype.paint.call(this); - -if(typeof workflow.zoomfactor == 'undefined') - workflow.zoomfactor = 1; - //Set the Task Limitation -if(typeof this.limitFlag == 'undefined' || this.limitFlag == false) -{ - this.originalWidth = 30; - this.originalHeight = 30; - this.orgXPos = this.getX(); - this.orgYPos = this.getY(); - this.orgFontSize =this.fontSize; -} - -this.width = this.originalWidth * workflow.zoomfactor; -this.height = this.originalHeight * workflow.zoomfactor; - -var cw = this.getWidth(); -var ch = this.getHeight(); - -var x_cir1=0; -var y_cir1=0; - -this.graphics.setColor("#c0c0c0"); -this.graphics.fillEllipse(x_cir1+3,y_cir1+3,this.getWidth(),this.getHeight()); - -this.graphics.setStroke(this.stroke); -this.graphics.setColor( "#f9faf2" ); -this.graphics.fillEllipse(x_cir1,y_cir1,this.getWidth(),this.getHeight()); -this.graphics.setColor("#adae5e"); -this.graphics.drawEllipse(x_cir1,y_cir1,this.getWidth(),this.getHeight()); -this.graphics.setStroke(this.stroke); -var x_cir2=3; -var y_cir2=3; -this.graphics.setColor( "#f9faf2" ); -this.graphics.fillEllipse(x_cir2,y_cir2,this.getWidth()-6,this.getHeight()-6); -this.graphics.setColor("#adae5e"); -this.graphics.drawEllipse(cw*0.15, ch*0.15, ch*0.7, ch*0.7); -//var x_cir3=10; -//var y_cir3=10; -//this.graphics.setColor( "#f9faf2" ); -//this.graphics.fillEllipse(x_cir3,y_cir3,this.getWidth()-20,this.getHeight()-20); -this.graphics.setColor("#adae5e"); -//this.graphics.drawEllipse(x_cir3,y_cir3,this.getWidth()-20,this.getHeight()-20); - -//this.graphics.drawLine(cw*0.5,ch*0.5,cw*0.77,ch*0.5); -//this.graphics.drawLine(cw*0.5,ch*0.5,cw*0.5,ch*0.22); -this.graphics.drawLine( cw*0.56, ch*0.5, cw*0.43, ch*0.5); //horizontal -this.graphics.drawLine( cw*0.6, ch*0.3, cw*0.43, ch*0.5); - -this.graphics.drawLine(cw*0.73,ch*0.26,cw*0.66,ch*0.30); //10th min line -this.graphics.drawLine(cw*0.66,ch*0.50,cw*0.80,ch*0.50); //15th min line -this.graphics.drawLine(cw*0.60,ch*0.66,cw*0.73,ch*0.73); //25th min line -this.graphics.drawLine(cw*0.50,ch*0.83,cw*0.50,ch*0.70); //30th min line -this.graphics.drawLine(cw*0.23,ch*0.70,cw*0.36,ch*0.63); //40th min line -this.graphics.drawLine(cw*0.16,ch*0.50,cw*0.30,ch*0.50); //45th min line -this.graphics.drawLine(cw*0.26,ch*0.26,cw*0.36,ch*0.36); //50th min line -this.graphics.drawLine(cw*0.50,ch*0.16,cw*0.50,ch*0.26); //60th min line -this.graphics.paint(); - -/*Code Added to Dynamically shift Ports on resizing of shapes - **/ -if(this.input1!=null){ -this.input1.setPosition(0,this.height/2); -} -if(this.output1!=null){ -this.output1.setPosition(this.width/2,this.height); -} -if(this.input2!=null){ -this.input2.setPosition(this.width/2,0); -} -if(this.output2!=null){ -this.output2.setPosition(this.width,this.height/2); -} -}; - -bpmnEventTimerInter.prototype.setWorkflow=function(_40c5){ -VectorFigure.prototype.setWorkflow.call(this,_40c5); -if(_40c5!=null){ - var eventPortName = ['input1','input2','output1','output2']; - var eventPortType = ['InputPort','InputPort','OutputPort','OutputPort']; - var eventPositionX= [0,this.width/2,this.width,this.width/2]; - var eventPositionY= [this.height/2,0,this.height/2,this.height]; - - for(var i=0; i< eventPortName.length ; i++){ - eval('this.'+eventPortName[i]+' = new '+eventPortType[i]+'()'); //Create New Port - eval('this.'+eventPortName[i]+'.setWorkflow(_40c5)'); //Add port to the workflow - eval('this.'+eventPortName[i]+'.setName("'+eventPortName[i]+'")'); //Set PortName - eval('this.'+eventPortName[i]+'.setZOrder(-1)'); //Set Z-Order of the port to -1. It will be below all the figure - eval('this.'+eventPortName[i]+'.setBackgroundColor(new Color(255, 255, 255))'); //Setting Background of the port to white - eval('this.'+eventPortName[i]+'.setColor(new Color(255, 255, 255))'); //Setting Border of the port to white - eval('this.addPort(this.'+eventPortName[i]+','+eventPositionX[i]+', '+eventPositionY[i]+')'); //Setting Position of the port - } -} -}; - -bpmnEventTimerInter.prototype.getContextMenu=function(){ -if(this.id != null){ - this.workflow.handleContextMenu(this); -} -}; diff --git a/workflow/engine/templates/bpmn/EventTimerStart.js b/workflow/engine/templates/bpmn/EventTimerStart.js deleted file mode 100755 index e99d4768e..000000000 --- a/workflow/engine/templates/bpmn/EventTimerStart.js +++ /dev/null @@ -1,114 +0,0 @@ -bpmnEventTimerStart=function(){ - VectorFigure.call(this); -}; - -bpmnEventTimerStart.prototype=new VectorFigure; -bpmnEventTimerStart.prototype.type="bpmnEventTimerStart"; -bpmnEventTimerStart.prototype.paint=function(){ - VectorFigure.prototype.paint.call(this); - if(typeof workflow.zoomfactor == 'undefined') - workflow.zoomfactor = 1; - - //Set the Limitation - if(typeof this.limitFlag == 'undefined' || this.limitFlag == false) { - this.originalWidth = 30; - this.originalHeight = 30; - this.orgXPos = this.getX(); - this.orgYPos = this.getY(); - this.orgFontSize =this.fontSize; - } - this.width = this.originalWidth * workflow.zoomfactor; - this.height = this.originalHeight * workflow.zoomfactor; - - var x_cir = 0; - var y_cir = 0; - - //draw the circle - this.graphics.setColor("#d0d0d0"); - this.graphics.fillEllipse(x_cir+2,y_cir+2,this.getWidth(),this.getHeight()); - this.graphics.setColor( "#F6FFDA" ); - this.graphics.fillEllipse(x_cir,y_cir,this.getWidth(),this.getHeight()); - this.graphics.setStroke(1); - this.graphics.setColor("#97C759"); - this.graphics.drawEllipse(x_cir,y_cir,this.getWidth(),this.getHeight()); - this.graphics.setStroke(1); - this.graphics.setColor("#98C951"); - //this.graphics.drawEllipse(x_cir,y_cir,this.getWidth(),this.getHeight()); - - //draw the clock - var cw = this.getWidth(); - var ch = this.getHeight(); - this.graphics.setColor("#98C951"); - this.graphics.drawEllipse(cw*0.15, ch*0.15, ch*0.7, ch*0.7 ); - - var x = new Array( cw*0.60, cw*0.50, cw*0.75, 0.5); - var y = new Array( ch*0.31, ch*0.50, ch*0.50, 0.5); - this.graphics.setColor("#4aa533"); - //this.graphics.drawPolygon(x,y); - this.graphics.drawLine( cw*0.56, ch*0.5, cw*0.43, ch*0.5); //horizontal - this.graphics.drawLine( cw*0.6, ch*0.3, cw*0.43, ch*0.5); - - this.graphics.drawLine(cw*0.73,ch*0.26,cw*0.66,ch*0.30); //10th min line - this.graphics.drawLine(cw*0.66,ch*0.50,cw*0.80,ch*0.50); //15th min line - this.graphics.drawLine(cw*0.60,ch*0.66,cw*0.73,ch*0.73); //25th min line - this.graphics.drawLine(cw*0.50,ch*0.83,cw*0.50,ch*0.70); //30th min line - this.graphics.drawLine(cw*0.23,ch*0.70,cw*0.36,ch*0.63); //40th min line - this.graphics.drawLine(cw*0.16,ch*0.50,cw*0.30,ch*0.50); //45th min line - this.graphics.drawLine(cw*0.26,ch*0.26,cw*0.36,ch*0.36); //50th min line - this.graphics.drawLine(cw*0.50,ch*0.16,cw*0.50,ch*0.26); //60th min line -// this.graphics.drawLine(22,8,20,10); //10th min line -// this.graphics.drawLine(20,15,24,15); //15th min line -// this.graphics.drawLine(18,20,22,22); //25th min line -// this.graphics.drawLine(15,25,15,21); //30th min line -// this.graphics.drawLine(7,21,11,19); //40th min line -// this.graphics.drawLine(5,15,10,15); //45th min line -// this.graphics.drawLine(6,8,10,10); //50th min line -// this.graphics.drawLine(15,5,15,8); //60th min line - - - //this.graphics.setColor("#4aa533"); - //this.graphics.drawEllipse(x_cir2,y_cir2,this.getWidth()-10,this.getHeight()-10); - //this.graphics.drawLine(this.getWidth()/2,this.getHeight()/2,this.getWidth()/1.3,this.getHeight()/2); //horizontal line - //this.graphics.drawLine(this.getWidth()/2,this.getHeight()/2,this.getWidth()/2,this.getHeight()/4.5); //vertical line - this.graphics.paint(); - - //Code Added to Dynamically shift Ports on resizing of shapes/ - if(this.input1!=null){ - this.input1.setPosition(0,this.height/2); - } - if(this.output1!=null){ - this.output1.setPosition(this.width/2,this.height); - } - if(this.input2!=null){ - this.input2.setPosition(this.width/2,0); - } - if(this.output2!=null){ - this.output2.setPosition(this.width,this.height/2); - } -}; - -bpmnEventTimerStart.prototype.setWorkflow=function(_40c5){ -VectorFigure.prototype.setWorkflow.call(this,_40c5); -if(_40c5!=null){ - var eventPortName = ['output1','output2']; - var eventPortType = ['OutputPort','OutputPort']; - var eventPositionX= [this.width/2,this.width]; - var eventPositionY= [this.height,this.height/2]; - - for(var i=0; i< eventPortName.length ; i++){ - eval('this.'+eventPortName[i]+' = new '+eventPortType[i]+'()'); //Create New Port - eval('this.'+eventPortName[i]+'.setWorkflow(_40c5)'); //Add port to the workflow - eval('this.'+eventPortName[i]+'.setName("'+eventPortName[i]+'")'); //Set PortName - eval('this.'+eventPortName[i]+'.setZOrder(-1)'); //Set Z-Order of the port to -1. It will be below all the figure - eval('this.'+eventPortName[i]+'.setBackgroundColor(new Color(255, 255, 255))'); //Setting Background of the port to white - eval('this.'+eventPortName[i]+'.setColor(new Color(255, 255, 255))'); //Setting Border of the port to white - eval('this.addPort(this.'+eventPortName[i]+','+eventPositionX[i]+', '+eventPositionY[i]+')'); //Setting Position of the port - } -} -}; - -bpmnEventTimerStart.prototype.getContextMenu=function(){ -if(this.id != null){ - this.workflow.handleContextMenu(this); -} -}; diff --git a/workflow/engine/templates/bpmn/GatewayComplex.js b/workflow/engine/templates/bpmn/GatewayComplex.js deleted file mode 100755 index fb8e8582b..000000000 --- a/workflow/engine/templates/bpmn/GatewayComplex.js +++ /dev/null @@ -1,102 +0,0 @@ -bpmnGatewayComplex=function(width,_30ab){ - VectorFigure.call(this); - this.stroke =1; -}; - -bpmnGatewayComplex.prototype=new VectorFigure; -bpmnGatewayComplex.prototype.type="bpmnGatewayComplex"; -bpmnGatewayComplex.prototype.paint=function(){ - VectorFigure.prototype.paint.call(this); - if(typeof workflow.zoomfactor == 'undefined') - workflow.zoomfactor = 1; - - //Set the Task Limitation - if(typeof this.limitFlag == 'undefined' || this.limitFlag == false) - { - this.originalWidth = 40; - this.originalHeight = 40; - this.orgXPos = this.getX(); - this.orgYPos = this.getY(); - this.orgFontSize =this.fontSize; - } - - this.width = this.originalWidth * workflow.zoomfactor; - this.height = this.originalHeight * workflow.zoomfactor; - - var cw = this.getWidth(); - var ch = this.getHeight(); - var x=new Array(0,cw*0.5,cw,cw*0.5); - var y=new Array(ch*0.5,cw,cw*0.5,0); - //var x=new Array(0,this.width/2,this.width,this.width/2); - //var y=new Array(this.height/2,this.height,this.height/2,0); - - var x2 = new Array(); - var y2 = new Array(); - - for(var i=0;iThis class represents the primary interface of a component based grid control to represent data - * in a tabular format of rows and columns. The GridPanel is composed of the following:

- *
    - *
  • {@link Ext.data.Store Store} : The Model holding the data records (rows) - *
  • - *
  • {@link Ext.grid.ColumnModel Column model} : Column makeup - *
  • - *
  • {@link Ext.grid.GridView View} : Encapsulates the user interface - *
  • - *
  • {@link Ext.grid.AbstractSelectionModel selection model} : Selection behavior - *
  • - *
- *

Example usage:

- *

-var grid = new Ext.grid.GridPanel({
-    {@link #store}: new {@link Ext.data.Store}({
-        {@link Ext.data.Store#autoDestroy autoDestroy}: true,
-        {@link Ext.data.Store#reader reader}: reader,
-        {@link Ext.data.Store#data data}: xg.dummyData
-    }),
-    {@link #colModel}: new {@link Ext.grid.ColumnModel}({
-        {@link Ext.grid.ColumnModel#defaults defaults}: {
-            width: 120,
-            sortable: true
-        },
-        {@link Ext.grid.ColumnModel#columns columns}: [
-            {id: 'company', header: 'Company', width: 200, sortable: true, dataIndex: 'company'},
-            {header: 'Price', renderer: Ext.util.Format.usMoney, dataIndex: 'price'},
-            {header: 'Change', dataIndex: 'change'},
-            {header: '% Change', dataIndex: 'pctChange'},
-            // instead of specifying renderer: Ext.util.Format.dateRenderer('m/d/Y') use xtype
-            {
-                header: 'Last Updated', width: 135, dataIndex: 'lastChange',
-                xtype: 'datecolumn', format: 'M d, Y'
-            }
-        ],
-    }),
-    {@link #viewConfig}: {
-        {@link Ext.grid.GridView#forceFit forceFit}: true,
-
-//      Return CSS class to apply to rows depending upon data values
-        {@link Ext.grid.GridView#getRowClass getRowClass}: function(record, index) {
-            var c = record.{@link Ext.data.Record#get get}('change');
-            if (c < 0) {
-                return 'price-fall';
-            } else if (c > 0) {
-                return 'price-rise';
-            }
-        }
-    },
-    {@link #sm}: new Ext.grid.RowSelectionModel({singleSelect:true}),
-    width: 600,
-    height: 300,
-    frame: true,
-    title: 'Framed with Row Selection and Horizontal Scrolling',
-    iconCls: 'icon-grid'
-});
- * 
- *

Notes:

- *
    - *
  • Although this class inherits many configuration options from base classes, some of them - * (such as autoScroll, autoWidth, layout, items, etc) are not used by this class, and will - * have no effect.
  • - *
  • A grid requires a width in which to scroll its columns, and a height in which to - * scroll its rows. These dimensions can either be set explicitly through the - * {@link Ext.BoxComponent#height height} and {@link Ext.BoxComponent#width width} - * configuration options or implicitly set by using the grid as a child item of a - * {@link Ext.Container Container} which will have a {@link Ext.Container#layout layout manager} - * provide the sizing of its child items (for example the Container of the Grid may specify - * {@link Ext.Container#layout layout}:'fit').
  • - *
  • To access the data in a Grid, it is necessary to use the data model encapsulated - * by the {@link #store Store}. See the {@link #cellclick} event for more details.
  • - *
- * @constructor - * @param {Object} config The config object - * @xtype grid - */ -Ext.grid.GridPanel = Ext.extend(Ext.Panel, { - /** - * @cfg {String} autoExpandColumn - *

The {@link Ext.grid.Column#id id} of a {@link Ext.grid.Column column} in - * this grid that should expand to fill unused space. This value specified here can not - * be 0.

- *

Note: If the Grid's {@link Ext.grid.GridView view} is configured with - * {@link Ext.grid.GridView#forceFit forceFit}=true the autoExpandColumn - * is ignored. See {@link Ext.grid.Column}.{@link Ext.grid.Column#width width} - * for additional details.

- *

See {@link #autoExpandMax} and {@link #autoExpandMin} also.

- */ - autoExpandColumn : false, - /** - * @cfg {Number} autoExpandMax The maximum width the {@link #autoExpandColumn} - * can have (if enabled). Defaults to 1000. - */ - autoExpandMax : 1000, - /** - * @cfg {Number} autoExpandMin The minimum width the {@link #autoExpandColumn} - * can have (if enabled). Defaults to 50. - */ - autoExpandMin : 50, - /** - * @cfg {Boolean} columnLines true to add css for column separation lines. - * Default is false. - */ - columnLines : false, - /** - * @cfg {Object} cm Shorthand for {@link #colModel}. - */ - /** - * @cfg {Object} colModel The {@link Ext.grid.ColumnModel} to use when rendering the grid (required). - */ - /** - * @cfg {Array} columns An array of {@link Ext.grid.Column columns} to auto create a - * {@link Ext.grid.ColumnModel}. The ColumnModel may be explicitly created via the - * {@link #colModel} configuration property. - */ - /** - * @cfg {String} ddGroup The DD group this GridPanel belongs to. Defaults to 'GridDD' if not specified. - */ - /** - * @cfg {String} ddText - * Configures the text in the drag proxy. Defaults to: - *

-     * ddText : '{0} selected row{1}'
-     * 
- * {0} is replaced with the number of selected rows. - */ - ddText : '{0} selected row{1}', - /** - * @cfg {Boolean} deferRowRender

Defaults to true to enable deferred row rendering.

- *

This allows the GridPanel to be initially rendered empty, with the expensive update of the row - * structure deferred so that layouts with GridPanels appear more quickly.

- */ - deferRowRender : true, - /** - * @cfg {Boolean} disableSelection

true to disable selections in the grid. Defaults to false.

- *

Ignored if a {@link #selModel SelectionModel} is specified.

- */ - /** - * @cfg {Boolean} enableColumnResize false to turn off column resizing for the whole grid. Defaults to true. - */ - /** - * @cfg {Boolean} enableColumnHide - * Defaults to true to enable {@link Ext.grid.Column#hidden hiding of columns} - * with the {@link #enableHdMenu header menu}. - */ - enableColumnHide : true, - /** - * @cfg {Boolean} enableColumnMove Defaults to true to enable drag and drop reorder of columns. false - * to turn off column reordering via drag drop. - */ - enableColumnMove : true, - /** - * @cfg {Boolean} enableDragDrop

Enables dragging of the selected rows of the GridPanel. Defaults to false.

- *

Setting this to true causes this GridPanel's {@link #getView GridView} to - * create an instance of {@link Ext.grid.GridDragZone}. Note: this is available only after - * the Grid has been rendered as the GridView's {@link Ext.grid.GridView#dragZone dragZone} - * property.

- *

A cooperating {@link Ext.dd.DropZone DropZone} must be created who's implementations of - * {@link Ext.dd.DropZone#onNodeEnter onNodeEnter}, {@link Ext.dd.DropZone#onNodeOver onNodeOver}, - * {@link Ext.dd.DropZone#onNodeOut onNodeOut} and {@link Ext.dd.DropZone#onNodeDrop onNodeDrop} are able - * to process the {@link Ext.grid.GridDragZone#getDragData data} which is provided.

- */ - enableDragDrop : false, - /** - * @cfg {Boolean} enableHdMenu Defaults to true to enable the drop down button for menu in the headers. - */ - enableHdMenu : true, - /** - * @cfg {Boolean} hideHeaders True to hide the grid's header. Defaults to false. - */ - /** - * @cfg {Object} loadMask An {@link Ext.LoadMask} config or true to mask the grid while - * loading. Defaults to false. - */ - loadMask : false, - /** - * @cfg {Number} maxHeight Sets the maximum height of the grid - ignored if autoHeight is not on. - */ - /** - * @cfg {Number} minColumnWidth The minimum width a column can be resized to. Defaults to 25. - */ - minColumnWidth : 25, - /** - * @cfg {Object} sm Shorthand for {@link #selModel}. - */ - /** - * @cfg {Object} selModel Any subclass of {@link Ext.grid.AbstractSelectionModel} that will provide - * the selection model for the grid (defaults to {@link Ext.grid.RowSelectionModel} if not specified). - */ - /** - * @cfg {Ext.data.Store} store The {@link Ext.data.Store} the grid should use as its data source (required). - */ - /** - * @cfg {Boolean} stripeRows true to stripe the rows. Default is false. - *

This causes the CSS class x-grid3-row-alt to be added to alternate rows of - * the grid. A default CSS rule is provided which sets a background colour, but you can override this - * with a rule which either overrides the background-color style using the '!important' - * modifier, or which uses a CSS selector of higher specificity.

- */ - stripeRows : false, - /** - * @cfg {Boolean} trackMouseOver True to highlight rows when the mouse is over. Default is true - * for GridPanel, but false for EditorGridPanel. - */ - trackMouseOver : true, - /** - * @cfg {Array} stateEvents - * An array of events that, when fired, should trigger this component to save its state. - * Defaults to:

-     * stateEvents: ['columnmove', 'columnresize', 'sortchange', 'groupchange']
-     * 
- *

These can be any types of events supported by this component, including browser or - * custom events (e.g., ['click', 'customerchange']).

- *

See {@link Ext.Component#stateful} for an explanation of saving and restoring - * Component state.

- */ - stateEvents : ['columnmove', 'columnresize', 'sortchange', 'groupchange'], - /** - * @cfg {Object} view The {@link Ext.grid.GridView} used by the grid. This can be set - * before a call to {@link Ext.Component#render render()}. - */ - view : null, - - /** - * @cfg {Array} bubbleEvents - *

An array of events that, when fired, should be bubbled to any parent container. - * See {@link Ext.util.Observable#enableBubble}. - * Defaults to []. - */ - bubbleEvents: [], - - /** - * @cfg {Object} viewConfig A config object that will be applied to the grid's UI view. Any of - * the config options available for {@link Ext.grid.GridView} can be specified here. This option - * is ignored if {@link #view} is specified. - */ - - // private - rendered : false, - // private - viewReady : false, - - // private - initComponent : function(){ - Ext.grid.GridPanel.superclass.initComponent.call(this); - - if(this.columnLines){ - this.cls = (this.cls || '') + ' x-grid-with-col-lines'; - } - // override any provided value since it isn't valid - // and is causing too many bug reports ;) - this.autoScroll = false; - this.autoWidth = false; - - if(Ext.isArray(this.columns)){ - this.colModel = new Ext.grid.ColumnModel(this.columns); - delete this.columns; - } - - // check and correct shorthanded configs - if(this.ds){ - this.store = this.ds; - delete this.ds; - } - if(this.cm){ - this.colModel = this.cm; - delete this.cm; - } - if(this.sm){ - this.selModel = this.sm; - delete this.sm; - } - this.store = Ext.StoreMgr.lookup(this.store); - - this.addEvents( - // raw events - /** - * @event click - * The raw click event for the entire grid. - * @param {Ext.EventObject} e - */ - 'click', - /** - * @event dblclick - * The raw dblclick event for the entire grid. - * @param {Ext.EventObject} e - */ - 'dblclick', - /** - * @event contextmenu - * The raw contextmenu event for the entire grid. - * @param {Ext.EventObject} e - */ - 'contextmenu', - /** - * @event mousedown - * The raw mousedown event for the entire grid. - * @param {Ext.EventObject} e - */ - 'mousedown', - /** - * @event mouseup - * The raw mouseup event for the entire grid. - * @param {Ext.EventObject} e - */ - 'mouseup', - /** - * @event mouseover - * The raw mouseover event for the entire grid. - * @param {Ext.EventObject} e - */ - 'mouseover', - /** - * @event mouseout - * The raw mouseout event for the entire grid. - * @param {Ext.EventObject} e - */ - 'mouseout', - /** - * @event keypress - * The raw keypress event for the entire grid. - * @param {Ext.EventObject} e - */ - 'keypress', - /** - * @event keydown - * The raw keydown event for the entire grid. - * @param {Ext.EventObject} e - */ - 'keydown', - - // custom events - /** - * @event cellmousedown - * Fires before a cell is clicked - * @param {Grid} this - * @param {Number} rowIndex - * @param {Number} columnIndex - * @param {Ext.EventObject} e - */ - 'cellmousedown', - /** - * @event rowmousedown - * Fires before a row is clicked - * @param {Grid} this - * @param {Number} rowIndex - * @param {Ext.EventObject} e - */ - 'rowmousedown', - /** - * @event headermousedown - * Fires before a header is clicked - * @param {Grid} this - * @param {Number} columnIndex - * @param {Ext.EventObject} e - */ - 'headermousedown', - - /** - * @event groupmousedown - * Fires before a group header is clicked. Only applies for grids with a {@link Ext.grid.GroupingView GroupingView}. - * @param {Grid} this - * @param {String} groupField - * @param {String} groupValue - * @param {Ext.EventObject} e - */ - 'groupmousedown', - - /** - * @event rowbodymousedown - * Fires before the row body is clicked. Only applies for grids with {@link Ext.grid.GridView#enableRowBody enableRowBody} configured. - * @param {Grid} this - * @param {Number} rowIndex - * @param {Ext.EventObject} e - */ - 'rowbodymousedown', - - /** - * @event containermousedown - * Fires before the container is clicked. The container consists of any part of the grid body that is not covered by a row. - * @param {Grid} this - * @param {Ext.EventObject} e - */ - 'containermousedown', - - /** - * @event cellclick - * Fires when a cell is clicked. - * The data for the cell is drawn from the {@link Ext.data.Record Record} - * for this row. To access the data in the listener function use the - * following technique: - *


-function(grid, rowIndex, columnIndex, e) {
-    var record = grid.getStore().getAt(rowIndex);  // Get the Record
-    var fieldName = grid.getColumnModel().getDataIndex(columnIndex); // Get field name
-    var data = record.get(fieldName);
-}
-
- * @param {Grid} this - * @param {Number} rowIndex - * @param {Number} columnIndex - * @param {Ext.EventObject} e - */ - 'cellclick', - /** - * @event celldblclick - * Fires when a cell is double clicked - * @param {Grid} this - * @param {Number} rowIndex - * @param {Number} columnIndex - * @param {Ext.EventObject} e - */ - 'celldblclick', - /** - * @event rowclick - * Fires when a row is clicked - * @param {Grid} this - * @param {Number} rowIndex - * @param {Ext.EventObject} e - */ - 'rowclick', - /** - * @event rowdblclick - * Fires when a row is double clicked - * @param {Grid} this - * @param {Number} rowIndex - * @param {Ext.EventObject} e - */ - 'rowdblclick', - /** - * @event headerclick - * Fires when a header is clicked - * @param {Grid} this - * @param {Number} columnIndex - * @param {Ext.EventObject} e - */ - 'headerclick', - /** - * @event headerdblclick - * Fires when a header cell is double clicked - * @param {Grid} this - * @param {Number} columnIndex - * @param {Ext.EventObject} e - */ - 'headerdblclick', - /** - * @event groupclick - * Fires when group header is clicked. Only applies for grids with a {@link Ext.grid.GroupingView GroupingView}. - * @param {Grid} this - * @param {String} groupField - * @param {String} groupValue - * @param {Ext.EventObject} e - */ - 'groupclick', - /** - * @event groupdblclick - * Fires when group header is double clicked. Only applies for grids with a {@link Ext.grid.GroupingView GroupingView}. - * @param {Grid} this - * @param {String} groupField - * @param {String} groupValue - * @param {Ext.EventObject} e - */ - 'groupdblclick', - /** - * @event containerclick - * Fires when the container is clicked. The container consists of any part of the grid body that is not covered by a row. - * @param {Grid} this - * @param {Ext.EventObject} e - */ - 'containerclick', - /** - * @event containerdblclick - * Fires when the container is double clicked. The container consists of any part of the grid body that is not covered by a row. - * @param {Grid} this - * @param {Ext.EventObject} e - */ - 'containerdblclick', - - /** - * @event rowbodyclick - * Fires when the row body is clicked. Only applies for grids with {@link Ext.grid.GridView#enableRowBody enableRowBody} configured. - * @param {Grid} this - * @param {Number} rowIndex - * @param {Ext.EventObject} e - */ - 'rowbodyclick', - /** - * @event rowbodydblclick - * Fires when the row body is double clicked. Only applies for grids with {@link Ext.grid.GridView#enableRowBody enableRowBody} configured. - * @param {Grid} this - * @param {Number} rowIndex - * @param {Ext.EventObject} e - */ - 'rowbodydblclick', - - /** - * @event rowcontextmenu - * Fires when a row is right clicked - * @param {Grid} this - * @param {Number} rowIndex - * @param {Ext.EventObject} e - */ - 'rowcontextmenu', - /** - * @event cellcontextmenu - * Fires when a cell is right clicked - * @param {Grid} this - * @param {Number} rowIndex - * @param {Number} cellIndex - * @param {Ext.EventObject} e - */ - 'cellcontextmenu', - /** - * @event headercontextmenu - * Fires when a header is right clicked - * @param {Grid} this - * @param {Number} columnIndex - * @param {Ext.EventObject} e - */ - 'headercontextmenu', - /** - * @event groupcontextmenu - * Fires when group header is right clicked. Only applies for grids with a {@link Ext.grid.GroupingView GroupingView}. - * @param {Grid} this - * @param {String} groupField - * @param {String} groupValue - * @param {Ext.EventObject} e - */ - 'groupcontextmenu', - /** - * @event containercontextmenu - * Fires when the container is right clicked. The container consists of any part of the grid body that is not covered by a row. - * @param {Grid} this - * @param {Ext.EventObject} e - */ - 'containercontextmenu', - /** - * @event rowbodycontextmenu - * Fires when the row body is right clicked. Only applies for grids with {@link Ext.grid.GridView#enableRowBody enableRowBody} configured. - * @param {Grid} this - * @param {Number} rowIndex - * @param {Ext.EventObject} e - */ - 'rowbodycontextmenu', - /** - * @event bodyscroll - * Fires when the body element is scrolled - * @param {Number} scrollLeft - * @param {Number} scrollTop - */ - 'bodyscroll', - /** - * @event columnresize - * Fires when the user resizes a column - * @param {Number} columnIndex - * @param {Number} newSize - */ - 'columnresize', - /** - * @event columnmove - * Fires when the user moves a column - * @param {Number} oldIndex - * @param {Number} newIndex - */ - 'columnmove', - /** - * @event sortchange - * Fires when the grid's store sort changes - * @param {Grid} this - * @param {Object} sortInfo An object with the keys field and direction - */ - 'sortchange', - /** - * @event groupchange - * Fires when the grid's grouping changes (only applies for grids with a {@link Ext.grid.GroupingView GroupingView}) - * @param {Grid} this - * @param {String} groupField A string with the grouping field, null if the store is not grouped. - */ - 'groupchange', - /** - * @event reconfigure - * Fires when the grid is reconfigured with a new store and/or column model. - * @param {Grid} this - * @param {Ext.data.Store} store The new store - * @param {Ext.grid.ColumnModel} colModel The new column model - */ - 'reconfigure', - /** - * @event viewready - * Fires when the grid view is available (use this for selecting a default row). - * @param {Grid} this - */ - 'viewready' - ); - }, - - // private - onRender : function(ct, position){ - Ext.grid.GridPanel.superclass.onRender.apply(this, arguments); - - var c = this.getGridEl(); - - this.el.addClass('x-grid-panel'); - - this.mon(c, { - scope: this, - mousedown: this.onMouseDown, - click: this.onClick, - dblclick: this.onDblClick, - contextmenu: this.onContextMenu - }); - - this.relayEvents(c, ['mousedown','mouseup','mouseover','mouseout','keypress', 'keydown']); - - var view = this.getView(); - view.init(this); - view.render(); - this.getSelectionModel().init(this); - }, - - // private - initEvents : function(){ - Ext.grid.GridPanel.superclass.initEvents.call(this); - - if(this.loadMask){ - this.loadMask = new Ext.LoadMask(this.bwrap, - Ext.apply({store:this.store}, this.loadMask)); - } - }, - - initStateEvents : function(){ - Ext.grid.GridPanel.superclass.initStateEvents.call(this); - this.mon(this.colModel, 'hiddenchange', this.saveState, this, {delay: 100}); - }, - - applyState : function(state){ - var cm = this.colModel, - cs = state.columns, - store = this.store, - s, - c, - oldIndex; - - if(cs){ - for(var i = 0, len = cs.length; i < len; i++){ - s = cs[i]; - c = cm.getColumnById(s.id); - if(c){ - c.hidden = s.hidden; - c.width = s.width; - oldIndex = cm.getIndexById(s.id); - if(oldIndex != i){ - cm.moveColumn(oldIndex, i); - } - } - } - } - if(store){ - s = state.sort; - if(s){ - store[store.remoteSort ? 'setDefaultSort' : 'sort'](s.field, s.direction); - } - s = state.group; - if(store.groupBy){ - if(s){ - store.groupBy(s); - }else{ - store.clearGrouping(); - } - } - - } - var o = Ext.apply({}, state); - delete o.columns; - delete o.sort; - Ext.grid.GridPanel.superclass.applyState.call(this, o); - }, - - getState : function(){ - var o = {columns: []}, - store = this.store, - ss, - gs; - - for(var i = 0, c; (c = this.colModel.config[i]); i++){ - o.columns[i] = { - id: c.id, - width: c.width - }; - if(c.hidden){ - o.columns[i].hidden = true; - } - } - if(store){ - ss = store.getSortState(); - if(ss){ - o.sort = ss; - } - if(store.getGroupState){ - gs = store.getGroupState(); - if(gs){ - o.group = gs; - } - } - } - return o; - }, - - // private - afterRender : function(){ - Ext.grid.GridPanel.superclass.afterRender.call(this); - var v = this.view; - this.on('bodyresize', v.layout, v); - v.layout(); - if(this.deferRowRender){ - if (!this.deferRowRenderTask){ - this.deferRowRenderTask = new Ext.util.DelayedTask(v.afterRender, this.view); - } - this.deferRowRenderTask.delay(10); - }else{ - v.afterRender(); - } - this.viewReady = true; - }, - - /** - *

Reconfigures the grid to use a different Store and Column Model - * and fires the 'reconfigure' event. The View will be bound to the new - * objects and refreshed.

- *

Be aware that upon reconfiguring a GridPanel, certain existing settings may become - * invalidated. For example the configured {@link #autoExpandColumn} may no longer exist in the - * new ColumnModel. Also, an existing {@link Ext.PagingToolbar PagingToolbar} will still be bound - * to the old Store, and will need rebinding. Any {@link #plugins} might also need reconfiguring - * with the new data.

- * @param {Ext.data.Store} store The new {@link Ext.data.Store} object - * @param {Ext.grid.ColumnModel} colModel The new {@link Ext.grid.ColumnModel} object - */ - reconfigure : function(store, colModel){ - var rendered = this.rendered; - if(rendered){ - if(this.loadMask){ - this.loadMask.destroy(); - this.loadMask = new Ext.LoadMask(this.bwrap, - Ext.apply({}, {store:store}, this.initialConfig.loadMask)); - } - } - if(this.view){ - this.view.initData(store, colModel); - } - this.store = store; - this.colModel = colModel; - if(rendered){ - this.view.refresh(true); - } - this.fireEvent('reconfigure', this, store, colModel); - }, - - // private - onDestroy : function(){ - if (this.deferRowRenderTask && this.deferRowRenderTask.cancel){ - this.deferRowRenderTask.cancel(); - } - if(this.rendered){ - Ext.destroy(this.view, this.loadMask); - }else if(this.store && this.store.autoDestroy){ - this.store.destroy(); - } - Ext.destroy(this.colModel, this.selModel); - this.store = this.selModel = this.colModel = this.view = this.loadMask = null; - Ext.grid.GridPanel.superclass.onDestroy.call(this); - }, - - // private - processEvent : function(name, e){ - this.view.processEvent(name, e); - }, - - // private - onClick : function(e){ - this.processEvent('click', e); - }, - - // private - onMouseDown : function(e){ - this.processEvent('mousedown', e); - }, - - // private - onContextMenu : function(e, t){ - this.processEvent('contextmenu', e); - }, - - // private - onDblClick : function(e){ - this.processEvent('dblclick', e); - }, - - // private - walkCells : function(row, col, step, fn, scope){ - var cm = this.colModel, - clen = cm.getColumnCount(), - ds = this.store, - rlen = ds.getCount(), - first = true; - - if(step < 0){ - if(col < 0){ - row--; - first = false; - } - while(row >= 0){ - if(!first){ - col = clen-1; - } - first = false; - while(col >= 0){ - if(fn.call(scope || this, row, col, cm) === true){ - return [row, col]; - } - col--; - } - row--; - } - } else { - if(col >= clen){ - row++; - first = false; - } - while(row < rlen){ - if(!first){ - col = 0; - } - first = false; - while(col < clen){ - if(fn.call(scope || this, row, col, cm) === true){ - return [row, col]; - } - col++; - } - row++; - } - } - return null; - }, - - /** - * Returns the grid's underlying element. - * @return {Element} The element - */ - getGridEl : function(){ - return this.body; - }, - - // private for compatibility, overridden by editor grid - stopEditing : Ext.emptyFn, - - /** - * Returns the grid's selection model configured by the {@link #selModel} - * configuration option. If no selection model was configured, this will create - * and return a {@link Ext.grid.RowSelectionModel RowSelectionModel}. - * @return {SelectionModel} - */ - getSelectionModel : function(){ - if(!this.selModel){ - this.selModel = new Ext.grid.RowSelectionModel( - this.disableSelection ? {selectRow: Ext.emptyFn} : null); - } - return this.selModel; - }, - - /** - * Returns the grid's data store. - * @return {Ext.data.Store} The store - */ - getStore : function(){ - return this.store; - }, - - /** - * Returns the grid's ColumnModel. - * @return {Ext.grid.ColumnModel} The column model - */ - getColumnModel : function(){ - return this.colModel; - }, - - /** - * Returns the grid's GridView object. - * @return {Ext.grid.GridView} The grid view - */ - getView : function(){ - if(!this.view){ - this.view = new Ext.grid.GridView(this.viewConfig); - } - return this.view; - }, - /** - * Called to get grid's drag proxy text, by default returns this.ddText. - * @return {String} The text - */ - getDragDropText : function(){ - var count = this.selModel.getCount(); - return String.format(this.ddText, count, count == 1 ? '' : 's'); - } - - /** - * @cfg {String/Number} activeItem - * @hide - */ - /** - * @cfg {Boolean} autoDestroy - * @hide - */ - /** - * @cfg {Object/String/Function} autoLoad - * @hide - */ - /** - * @cfg {Boolean} autoWidth - * @hide - */ - /** - * @cfg {Boolean/Number} bufferResize - * @hide - */ - /** - * @cfg {String} defaultType - * @hide - */ - /** - * @cfg {Object} defaults - * @hide - */ - /** - * @cfg {Boolean} hideBorders - * @hide - */ - /** - * @cfg {Mixed} items - * @hide - */ - /** - * @cfg {String} layout - * @hide - */ - /** - * @cfg {Object} layoutConfig - * @hide - */ - /** - * @cfg {Boolean} monitorResize - * @hide - */ - /** - * @property items - * @hide - */ - /** - * @method add - * @hide - */ - /** - * @method cascade - * @hide - */ - /** - * @method doLayout - * @hide - */ - /** - * @method find - * @hide - */ - /** - * @method findBy - * @hide - */ - /** - * @method findById - * @hide - */ - /** - * @method findByType - * @hide - */ - /** - * @method getComponent - * @hide - */ - /** - * @method getLayout - * @hide - */ - /** - * @method getUpdater - * @hide - */ - /** - * @method insert - * @hide - */ - /** - * @method load - * @hide - */ - /** - * @method remove - * @hide - */ - /** - * @event add - * @hide - */ - /** - * @event afterlayout - * @hide - */ - /** - * @event beforeadd - * @hide - */ - /** - * @event beforeremove - * @hide - */ - /** - * @event remove - * @hide - */ - - - - /** - * @cfg {String} allowDomMove @hide - */ - /** - * @cfg {String} autoEl @hide - */ - /** - * @cfg {String} applyTo @hide - */ - /** - * @cfg {String} autoScroll @hide - */ - /** - * @cfg {String} bodyBorder @hide - */ - /** - * @cfg {String} bodyStyle @hide - */ - /** - * @cfg {String} contentEl @hide - */ - /** - * @cfg {String} disabledClass @hide - */ - /** - * @cfg {String} elements @hide - */ - /** - * @cfg {String} html @hide - */ - /** - * @cfg {Boolean} preventBodyReset - * @hide - */ - /** - * @property disabled - * @hide - */ - /** - * @method applyToMarkup - * @hide - */ - /** - * @method enable - * @hide - */ - /** - * @method disable - * @hide - */ - /** - * @method setDisabled - * @hide - */ -}); -Ext.reg('grid', Ext.grid.GridPanel); \ No newline at end of file diff --git a/workflow/engine/templates/bpmn/Lane.js b/workflow/engine/templates/bpmn/Lane.js deleted file mode 100755 index bd1b12a80..000000000 --- a/workflow/engine/templates/bpmn/Lane.js +++ /dev/null @@ -1,36 +0,0 @@ -bpmnLane = function (_30ab) { - VectorFigure.call(this); - this.setDimension(500, 300); - // this.setTaskName(_30ab.taskNo); //It will set the Default Task Name with appropriate count While dragging a task on the canvas -}; - -bpmnLane.prototype = new VectorFigure; -bpmnLane.prototype.type = "bpmnLane"; -bpmnLane.prototype.setTaskName = function (name) { - this.taskName = 'Data Object ' + name; -}; - -bpmnLane.prototype.paint = function () { - VectorFigure.prototype.paint.call(this); - var x = new Array(0, this.getWidth(), this.getWidth(), 0); - var y = new Array(0, 0, this.getHeight(), this.getHeight()); - - this.graphics.setStroke(this.stroke); - this.graphics.setColor("#c0c0c0"); - this.graphics.fillPolygon(x, y); - - for (var i = 0; i < x.length; i++) { - x[i] = x[i] - 3; - y[i] = y[i] - 3; - } - this.graphics.setColor("#ffffff"); - this.graphics.fillPolygon(x, y); - this.graphics.setColor("#ff0f0f"); - this.graphics.drawPolygon(x, y); - this.graphics.drawLine(45, 0-3, 45, this.getHeight()-3); - this.graphics.drawLine(90, 0-3, 90, this.getHeight()-3); - this.graphics.drawLine(45, 150-3, this.getWidth()-3, 150-3); - this.graphics.paint(); - this.x_text = this.workflow.getAbsoluteX(); //Get x co-ordinate from figure - this.y_text = this.workflow.getAbsoluteY(); //Get x co-ordinate from figure -} diff --git a/workflow/engine/templates/bpmn/LoopingSubProcess.js b/workflow/engine/templates/bpmn/LoopingSubProcess.js deleted file mode 100755 index af7cae056..000000000 --- a/workflow/engine/templates/bpmn/LoopingSubProcess.js +++ /dev/null @@ -1,105 +0,0 @@ -bpmnLoopingSubProcess=function(_30ab){ -VectorFigure.call(this); -this.setDimension(110,60); -this.setTaskName(_30ab); //It will set the Default Task Name with appropriate count While dragging a task on the canvas -}; - -bpmnLoopingSubProcess.prototype=new VectorFigure; -bpmnLoopingSubProcess.prototype.type="bpmnLoopingSubProcess"; -bpmnLoopingSubProcess.prototype.setTaskName=function(name){ -this.taskName = 'Task '+name; -}; -bpmnLoopingSubProcess.prototype.paint=function(){ -VectorFigure.prototype.paint.call(this); -var x=new Array(6, this.getWidth()-3, this.getWidth(), this.getWidth(), this.getWidth()-3, 6, 3, 3, 6); -var y=new Array(3, 3, 6, this.getHeight()-3, this.getHeight(), this.getHeight(), this.getHeight()-3, 6, 3); -this.graphics.setStroke(this.stroke); -this.graphics.setColor( "#c0c0c0" ); -this.graphics.fillPolygon(x,y); - -for(var i=0;i - * The string is first cleared and new string is painted.

-**/ -bpmnLoopingSubProcess.prototype.onOk=function(){ - this.figure.bpmnNewText.clear(); - //this.figure.bpmnNewText.drawStringRect(this.input.value,this.workflow.currentSelection.width/2-30,this.workflow.currentSelection.height/2-10,200,'left'); - this.figure.bpmnNewText.drawString(this.input.value,this.workflow.currentSelection.width/2.5,this.workflow.currentSelection.height/2.5); - this.figure.bpmnNewText.paint(); - this.figure.taskName = this.input.value; //Set Updated Text value - this.workflow.removeFigure(this); -}; \ No newline at end of file diff --git a/workflow/engine/templates/bpmn/LoopingTask.js b/workflow/engine/templates/bpmn/LoopingTask.js deleted file mode 100755 index b7271081c..000000000 --- a/workflow/engine/templates/bpmn/LoopingTask.js +++ /dev/null @@ -1,46 +0,0 @@ -bpmnLoopingTask=function(_30ab){ -VectorFigure.call(this); -this.setDimension(110,60); -this.setTaskName(_30ab); //It will set the Default Task Name with appropriate count While dragging a task on the canvas -}; - -bpmnLoopingTask.prototype=new VectorFigure; -bpmnLoopingTask.prototype.type="bpmnLoopingTask"; -bpmnLoopingTask.prototype.setTaskName=function(name){ -this.taskName = 'Task '+name; -}; - -bpmnLoopingTask.prototype.paint=function(){ -VectorFigure.prototype.paint.call(this); - -var x_subtask=new Array(6, this.getWidth()-3, this.getWidth(), this.getWidth(), this.getWidth()-3, 6, 3, 3, 6); -var y_subtask=new Array(3, 3, 6, this.getHeight()-3, this.getHeight(), this.getHeight(), this.getHeight()-3, 6, 3); -var x_subtask=new Array(6,125,128,128,125,6,3,3,6); -var y_subtask=new Array(3,3,6,87,90,90,87,6,3); -this.graphics.setStroke(this.stroke); -this.graphics.setColor( "#c0c0c0" ); -this.graphics.fillPolygon(x_subtask,y_subtask); -for(var i=0;i 1300 - oShape.width) { - workflow.main.setWidth(oShape.x+150); - } - //Top Border - if (oShape.y < 20) { - oShape.y = 20; - } - //Bottom Border - if (oShape.y > 1000 - oShape.height) { - workflow.main.setHeight(oShape.y+75); - } -} - -/** - * ExtJS Form on Right Click of Task - * @Param Shape Object - * @Author Safan Maredia - */ -MyWorkflow.prototype.AddTaskContextMenu= function(oShape) -{ - var taskExtObj = new TaskContext(); - if (oShape.id != null) { - this.canvasTask = Ext.get(oShape.id); - this.contextTaskmenu = new Ext.menu.Menu({ - items: [ -/* - { - text: 'Steps', - iconCls: 'button_menu_ext ss_sprite ss_shape_move_forwards', - handler: taskExtObj.editTaskSteps, - scope: oShape - }, - { - text: 'Users & Users Group', - iconCls: 'button_menu_ext ss_sprite ss_group', - handler: taskExtObj.editUsers, - scope: oShape - }, - { - text: 'Users & Users Groups (ad-hoc)', - iconCls: 'button_menu_ext ss_sprite ss_group', - handler: taskExtObj.editUsersAdHoc, - scope: oShape - }, -*/ - { - text: 'Transform To', - iconCls: 'button_menu_ext ss_sprite ss_page_refresh', - menu: { // <-- submenu by nested config object - items: [ - // stick any markup in a menu - { - text: 'Sub Process', - iconCls: 'button_menu_ext ss_sprite ss_layout_link', - type:'bpmnSubProcess', - scope:oShape, - handler: MyWorkflow.prototype.toggleShapes - } - ] - }, - scope: this - }, - { - text: 'Attach Event', - iconCls: 'button_menu_ext ss_sprite ss_link', - menu: { // <-- submenu by nested config object - items: [ - // stick any markup in a menu - { - text: 'Timer Boundary Event', - iconCls: 'button_menu_ext ss_sprite ss_clock', - type:'bpmnEventBoundaryTimerInter', - scope:oShape, - handler: MyWorkflow.prototype.toggleShapes - } - ] - }, - scope: this - } -/* , - { - text: 'Properties', - handler: taskExtObj.editTaskProperties, - scope: oShape - } -*/ - ] - }); - } - - this.canvasTask.on('contextmenu', function (e) { - e.stopEvent(); - this.contextTaskmenu.showAt(e.getXY()); - }, this); - -} - -/** - * ExtJS Menu on Right Click of Connection - * @Param Shape Object - * @Author Girish Joshi - */ -MyWorkflow.prototype.connectionContextMenu=function(oShape) -{ - this.canvasEvent = Ext.get(oShape.id); - this.contextEventmenu = new Ext.menu.Menu({ - items: [{ - text: 'Straight Line', - iconCls: 'button_menu_ext ss_sprite ss_bullet_white ', - scope: this, - handler: MyWorkflow.prototype.toggleConnection - }, { - text: 'Curvy Line', - scope: this, - iconCls: 'button_menu_ext ss_sprite ss_vector', - handler: MyWorkflow.prototype.toggleConnection - }, { - text: 'Angled Line', - scope: this, - iconCls: 'button_menu_ext ss_sprite ss_bullet_white ', - handler: MyWorkflow.prototype.toggleConnection - }, { - text: 'Delete Line', - iconCls: 'button_menu_ext ss_sprite ss_delete', - scope: this, - handler:function() - { - MyWorkflow.prototype.deleteRoute(oShape.workflow.currentSelection,0) - } - }] - }); - - this.canvasEvent.on('contextmenu', function(e) { - e.stopEvent(); - this.contextEventmenu.showAt(e.getXY()); - }, this); -} - -/** - * Draw2d Functionality of Changing the routers - * @Param Shape Object - * @Author Girish Joshi - */ -MyWorkflow.prototype.toggleConnection=function(oShape) -{ - this.currentSelection.workflow.contextClicked = false; - switch (oShape.text) { - case 'NULL Router': - this.currentSelection.setRouter(null); - break; - case 'Angled Line': - this.currentSelection.setRouter(new ManhattanConnectionRouter()); - break; - case 'Curvy Line': - this.currentSelection.setRouter(new BezierConnectionRouter()); - break; - case 'Straight Line': - this.currentSelection.setRouter(new FanConnectionRouter()); - break; - case 'Delete Line': - this.currentSelection.workflow.getCommandStack().execute(new CommandDelete(this.currentSelection.workflow.getCurrentSelection())); - ToolGeneric.prototype.execute.call(this); - break; - } -} - -/** - * Draw2d Functionality of Adding Port to Gateways - * @Param Shape Object - * @Author Girish Joshi - */ -MyWorkflow.prototype.AddGatewayPorts = function(_40c5) -{ - var TaskPortName = ['inputPort1','inputPort2','outputPort1','outputPort2','outputPort3']; - var TaskPortType = ['InputPort','InputPort','OutputPort','OutputPort','OutputPort']; - var TaskPositionX= [0,_40c5.width/2,_40c5.width,_40c5.width/2, 0]; - var TaskPositionY= [_40c5.height/2,0,_40c5.height/2,_40c5.Height, _40c5.height/2 + 10]; - - for(var i=0; i< TaskPortName.length ; i++){ - eval('_40c5.'+TaskPortName[i]+' = new '+TaskPortType[i]+'()'); //Create New Port - eval('_40c5.'+TaskPortName[i]+'.setWorkflow(_40c5)'); //Add port to the workflow - eval('_40c5.'+TaskPortName[i]+'.setName("'+TaskPortName[i]+'")'); //Set PortName - eval('_40c5.'+TaskPortName[i]+'.setZOrder(-1)'); //Set Z-Order of the port to -1. It will be below all the figure - eval('_40c5.'+TaskPortName[i]+'.setBackgroundColor(new Color(255, 255, 255))'); //Setting Background of the port to white - eval('_40c5.'+TaskPortName[i]+'.setColor(new Color(255, 255, 255))'); //Setting Border of the port to white - this.workflow = _40c5.workflow; - this.workflow.currentSelection =_40c5; - eval('_40c5.addPort(_40c5.'+TaskPortName[i]+','+TaskPositionX[i]+', '+TaskPositionY[i]+')'); //Setting Position of the port - } -} -/** - * ExtJs Form on right Click of Gateways - * @Param Shape Object - * @Author Girish Joshi - */ -MyWorkflow.prototype.AddGatewayContextMenu=function(_4092) -{ - this.canvasGateway = Ext.get(_4092.id); - this.contextGatewaymenu = new Ext.menu.Menu({ - items: [{ - text: 'Gateway Type', - menu: { // <-- submenu by nested config object - items: [ - // stick any markup in a menu - { - text: 'Exclusive Gateway', - type:'bpmnGatewayExclusiveData', - scope:_4092, - handler: MyWorkflow.prototype.toggleShapes - }, { - text: 'Inclusive Gateway', - type:'bpmnGatewayInclusive', - scope:_4092, - handler: MyWorkflow.prototype.toggleShapes - }, { - text: 'Parallel Gateway', - type:'bpmnGatewayParallel', - scope:_4092, - handler: MyWorkflow.prototype.toggleShapes - } -/* , { - text: 'Complex Gateway', - type:'bpmnGatewayComplex', - scope:_4092, - handler: MyWorkflow.prototype.toggleShapes - }, { - text: 'Event Based Gateway', - type:'bpmnGatewayExclusiveEvent', - scope:_4092, - handler: MyWorkflow.prototype.toggleShapes - } -*/ - ] - }, - scope: this - },{ - text: 'Properties', - handler: this.editGatewayProperties, - scope: this - }] - }); - -this.canvasGateway.on('contextmenu', function(e) { - e.stopEvent(); - this.contextGatewaymenu.showAt(e.getXY()); -}, this); -} - -/** - * ExtJs Menu on right Click of SubProcess - * @Param Shape Object - * @Author Safan Maredia - */ -MyWorkflow.prototype.AddSubProcessContextMenu=function(_4092) -{ - var taskExtObj = new TaskContext(); - this.canvasSubProcess = Ext.get(_4092.id); - this.contextSubProcessmenu = new Ext.menu.Menu({ - items: [ - { - text: 'Transform To', - menu: { // <-- submenu by nested config object - items: [ - // stick any markup in a menu - { - text: 'Task', - type:'bpmnTask', - scope:_4092, - handler: MyWorkflow.prototype.toggleShapes - } - ] - }, - scope: this - }, - { - text: 'Properties', - handler: taskExtObj.editSubProcessProperties, - scope: this - }] - }); - -this.canvasSubProcess.on('contextmenu', function(e) { - e.stopEvent(); - this.contextSubProcessmenu.showAt(e.getXY()); -}, this); -} - - -//Window pop up function when user clicks on Gateways properties - -MyWorkflow.prototype.editGatewayProperties= function() -{ - -} -/** - * Changing the Shape and Maintaining the Connections - * @Param Shape Object - * @Author Girish Joshi - */ -MyWorkflow.prototype.toggleShapes=function(item) -{ - - //Set the context Clicked Flag to false because context click action is performed - if(item.scope.workflow != null){ - item.scope.workflow.contextClicked = false; - if(item.scope.workflow.currentSelection != null){ - - //Get all the ports of the shapes - var ports = item.scope.workflow.currentSelection.getPorts(); - var len =ports.data.length; - - //Get all the connection of the shape - var conn = new Array(); - for(var i=0; i<=len; i++){ - if(typeof ports.data[i] === 'object') - conn[i] = ports.data[i].getConnections(); - } - - //Initializing Arrays and variables - var connLength = conn.length; - var sourceNode = new Array(); - var targetNode = new Array(); - var countConn = 0; - var sourcePortName = new Array(); - var targetPortName = new Array(); - var sourcePortId = new Array(); - var targetPortId = new Array(); - - //Get the pre-selected id into new variable to compare in future code - var shapeId = this.workflow.currentSelection.id; - - //Get the current pre-selected figure object in the new object, because not accessible after adding new shapes - var oldWorkflow = this.workflow.currentSelection; - - //Get the source and Target object of all the connections in an array - for(i = 0; i< connLength ; i++) - { - for(var j = 0; j < conn[i].data.length ; j++) - { - if(typeof conn[i].data[j] != 'undefined') { - sourceNode[countConn] = conn[i].data[j].sourcePort.parentNode; - targetNode[countConn] = conn[i].data[j].targetPort.parentNode; - sourcePortName[countConn] = conn[i].data[j].sourcePort.properties.name; - targetPortName[countConn] = conn[i].data[j].targetPort.properties.name; - sourcePortId[countConn] = conn[i].data[j].sourcePort.parentNode.id; - targetPortId[countConn] = conn[i].data[j].targetPort.parentNode.id; - countConn++; - } - } - } - - //Add new selected Figure - var x =item.scope.workflow.currentSelection.getX(); //Get x co-ordinate from figure - var y =item.scope.workflow.currentSelection.getY(); //Get y co-ordinate from figure - - if(item.type == 'bpmnEventBoundaryTimerInter') { - workflow.currentSelection.boundaryEvent = true; - workflow.taskName = oldWorkflow.taskName; - var newShape = workflow.currentSelection; - newShape.setDimension(newShape.getWidth(),newShape.getHeight()); - } - else if(item.type == 'bpmnSubProcess') { - workflow.subProcessName = 'Sub Process'; - newShape = eval("new "+item.type+"(this.workflow)"); - } - else - newShape = eval("new "+item.type+"(this.workflow)"); - - if(item.type != 'bpmnEventBoundaryTimerInter') { - this.workflow.addFigure(newShape,x,y); //Add New Selected Shape First - //Delete Old Shape - item.scope.workflow.getCommandStack().execute(new CommandDelete(oldWorkflow)); - ToolGeneric.prototype.execute.call(item.scope); - //to create all the new connections again - var connObj; - for(i=0 ; i < countConn ; i++){ - if(sourcePortId[i] == shapeId) //If shapeId is equal to sourceId the , replace the oldShape object by new shape Object - sourceNode[i] = newShape; - else - targetNode[i] = newShape; - connObj = new DecoratedConnection(); - connObj.setTarget(eval('targetNode[i].getPort(targetPortName[i])')); - connObj.setSource(eval('sourceNode[i].getPort(sourcePortName[i])')); - newShape.workflow.addFigure(connObj); - } - } - //Saving Asynchronously deleted shape and new created shape into DB - if(item.type.match(/Boundary/)) { - newShape.actiontype = 'updateTask'; - workflow.saveShape(newShape); - } - if(newShape.type.match(/Event/) && !item.type.match(/Boundary/)) { - newShape.mode = 'ddEvent'; - newShape.actiontype = 'addEvent'; - //Set the Old Id to the Newly created Event - newShape.html.id = oldWorkflow.id; - newShape.id = oldWorkflow.id; - newShape.workflow.saveShape(newShape); - } - if(newShape.type.match(/Gateway/)) { - newShape.mode = 'ddGateway'; - newShape.actiontype = 'addGateway'; - //Set the Old Id to the Newly created Gateway - newShape.html.id = oldWorkflow.id; - newShape.id = oldWorkflow.id; - newShape.workflow.saveShape(newShape); - } - //Swapping from Task to subprocess and vice -versa - if((newShape.type == 'bpmnSubProcess' || newShape.type == 'bpmnTask') && !item.type.match(/Boundary/)) { - newShape.actiontype = 'addSubProcess'; - if(newShape.type == 'bpmnTask') - newShape.actiontype = 'addTask'; - newShape.workflow.saveShape(newShape); - } - if((this.type == 'bpmnTask' || this.type == 'bpmnSubProcess') && !item.type.match(/Boundary/)) { - this.actiontype = 'deleteTask'; - this.noAlert = true; - if(this.type == 'bpmnSubProcess') - this.actiontype = 'deleteSubProcess'; - newShape.workflow.deleteSilently(this); - } - } - } -} - -/** - * Toggling Between Task and SubProcess - * @Param Shape Object - * @Author Safan Maredia - */ -MyWorkflow.prototype.swapTaskSubprocess=function(itemObj) -{ - if(itemObj.type == 'bpmnSubProcess') - { - workflow.subProcessName = 'Sub Process'; - var newShape = eval("new "+itemObj.type+"(this.workflow)"); - } - else - newShape = eval("new "+itemObj.type+"(this.workflow)"); - - //Swapping from Task to subprocess and vice -versa - if((newShape.type == 'bpmnSubProcess' || newShape.type == 'bpmnTask') && !itemObj.type.match(/Boundary/)) { - newShape.actiontype = 'addSubProcess'; - if(newShape.type == 'bpmnTask') - newShape.actiontype = 'addTask'; - newShape.workflow.saveShape(newShape); - } - if((this.type == 'bpmnTask' || this.type == 'bpmnSubProcess') && !itemObj.type.match(/Boundary/)) { - this.actiontype = 'deleteTask'; - this.noAlert = true; - if(this.type == 'bpmnSubProcess') - this.actiontype = 'deleteSubProcess'; - newShape.workflow.deleteShape(this); - } -} - -/** - * Validating Connection on Input/Output onDrop Event - * @Param port - * @Param portType - * @Param portTypeName - * @Author Girish Joshi - */ -MyWorkflow.prototype.checkConnectionsExist=function(port,portType,portTypeName) -{ - //Get all the ports of the shapes - var ports = port.workflow.currentSelection.getPorts(); - var len =ports.data.length; - - //Get all the connection of the shape - var conn = new Array(); - for(var i=0; i<=len; i++){ - if(typeof ports.data[i] === 'object') - if(ports.data[i].type == portTypeName) - conn[i] = ports.data[i].getConnections(); - } - //Initializing Arrays and variables - var countConn = 0; - var portParentId= new Array(); - var portName = new Array(); - - //Get ALL the connections for the specified PORT - for(i = 0; i< conn.length ; i++) - { - if(typeof conn[i] != 'undefined') - for(var j = 0; j < conn[i].data.length ; j++) - { - if(typeof conn[i].data[j] != 'undefined') { - portParentId[countConn] = eval('conn[i].data[j].'+portType+'.parentNode.id'); - portName[countConn] = eval('conn[i].data[j].'+portType+'.properties.name'); - countConn++; - } - } - } - var conx = 0; - var parentid; - for(i=0 ; i < countConn ; i++) - { - if(portParentId[i] == port.parentNode.id) - conx++; - } - return conx; - -} -/** - * ExtJs Menu on right Click of Start Event - * @Param Shape Object - * @Author Girish Joshi - */ -MyWorkflow.prototype.AddEventStartContextMenu=function(oShape) -{ - this.canvasEvent = Ext.get(oShape.id); - this.contextEventmenu = new Ext.menu.Menu({ - items: [{ - text: 'Event Type', - menu: { // <-- submenu by nested config object - items: [ - // stick any markup in a menu - { - text: 'Empty', - type:'bpmnEventEmptyStart', - scope:oShape, - handler: MyWorkflow.prototype.toggleShapes - }, - { - text: 'Message', - type:'bpmnEventMessageStart', - scope:oShape, - handler: MyWorkflow.prototype.toggleShapes - }, { - text: 'Timer', - type:'bpmnEventTimerStart', - scope:oShape, - handler: MyWorkflow.prototype.toggleShapes - }/*, { - text: 'Conditional', - type:'bpmnEventRuleStart', - scope:oShape, - handler: MyWorkflow.prototype.toggleShapes - }/*, { - text: 'Signal', - type:'bpmnEventSignalStart', - scope:oShape, - handler: MyWorkflow.prototype.toggleShapes - }, { - text: 'Multiple', - type:'bpmnEventMulStart', - scope:oShape, - handler: MyWorkflow.prototype.toggleShapes - }*/ - ] - }, - scope: this - },{ - text: 'Properties', - scope: this, - handler: MyWorkflow.prototype.editEventProperties - }] - }); - -this.canvasEvent.on('contextmenu', function(e) { - e.stopEvent(); - this.contextEventmenu.showAt(e.getXY()); -}, this); -} -/** - * ExtJs Menu on right Click of Intermediate Event - * @Param Shape Object - * @Author Girish Joshi - */ -MyWorkflow.prototype.AddEventInterContextMenu=function(_4093) -{ - this.canvasEvent = Ext.get(_4093.id); - this.contextEventmenu = new Ext.menu.Menu({ - items: [{ - text: 'Event Type', - menu: { // <-- submenu by nested config object - items: [ - // stick any markup in a menu - /*{ - text: 'Empty', - type:'bpmnEventEmptyInter', - scope:_4093, - handler: MyWorkflow.prototype.toggleShapes - },*/ - { - text: 'Message : Throw', - type:'bpmnEventMessageSendInter', - scope:_4093, - handler: MyWorkflow.prototype.toggleShapes - }, - { - text: 'Timer', - type:'bpmnEventTimerInter', - scope:_4093, - handler: MyWorkflow.prototype.toggleShapes - } - /* - { - text: 'Intermediate Boundary Timer', - type:'bpmnEventBoundaryInter', - scope:_4093, - handler: MyWorkflow.prototype.toggleShapes - },{ - text: 'Message : Catch', - type:'bpmnEventMessageRecInter', - scope:_4093, - handler: MyWorkflow.prototype.toggleShapes - }, { - text: 'Compensate', - type:'bpmnEventCompInter', - scope:_4093, - handler: MyWorkflow.prototype.toggleShapes - }, { - text: 'Conditional', - type:'bpmnEventRuleInter', - scope:_4093, - handler: MyWorkflow.prototype.toggleShapes - }, { - text: 'Link', - type:'bpmnEventLinkInter', - scope:_4093, - handler: MyWorkflow.prototype.toggleShapes - }, { - text: 'Signal', - type:'bpmnEventInterSignal', - scope:_4093, - handler: MyWorkflow.prototype.toggleShapes - }, { - text: 'Multiple', - type:'bpmnEventMultipleInter', - scope:_4093, - handler: MyWorkflow.prototype.toggleShapes - }*/ - ] - }, - scope: this - },{ - text: 'Properties', - handler: MyWorkflow.prototype.editEventProperties, - scope: this - }] - }); - -this.canvasEvent.on('contextmenu', function(e) { - e.stopEvent(); - this.contextEventmenu.showAt(e.getXY()); -}, this); -} -/** - * ExtJs Menu on right Click of End Event - * @Param Shape Object - * @Author Girish Joshi - */ -MyWorkflow.prototype.AddEventEndContextMenu=function(_4093) -{ - this.canvasEvent = Ext.get(_4093.id); - this.contextEventmenu = new Ext.menu.Menu({ - items: [{ - text: 'Event Type', - menu: { // <-- submenu by nested config object - items: [ - // stick any markup in a menu - { - text: 'Empty', - type:'bpmnEventEmptyEnd', - scope:_4093, - handler: MyWorkflow.prototype.toggleShapes - }, - { - text: 'Message', - type:'bpmnEventMessageEnd', - scope:_4093, - handler: MyWorkflow.prototype.toggleShapes - }/*, - { - text: 'Error', - type:'bpmnEventErrorEnd', - scope:_4093, - handler: MyWorkflow.prototype.toggleShapes - }, { - text: 'Cancel', - type:'bpmnEventCancelEnd', - scope:_4093, - handler: MyWorkflow.prototype.toggleShapes - }, { - text: 'Compensate', - type:'bpmnEventCompEnd', - scope:_4093, - handler: MyWorkflow.prototype.toggleShapes - }, { - text: 'Signal', - type:'bpmnEventEndSignal', - scope:_4093, - handler: MyWorkflow.prototype.toggleShapes - }, { - text: 'Multiple', - type:'bpmnEventMultipleEnd', - scope:_4093, - handler: MyWorkflow.prototype.toggleShapes - }, { - text: 'Terminate', - type:'bpmnEventTerminate', - scope:_4093, - handler: MyWorkflow.prototype.toggleShapes - }*/ - ] - }, - scope: this - },{ - text: 'Properties', - handler: MyWorkflow.prototype.editEventProperties, - scope: this - }] - }); - -this.canvasEvent.on('contextmenu', function(e) { - e.stopEvent(); - this.contextEventmenu.showAt(e.getXY()); -}, this); -} - -/** - * Hiding Ports according to the Shape Selected - * @Param Shape Object - * @Author Girish Joshi - */ -MyWorkflow.prototype.disablePorts=function(oShape) -{ - if(oShape.type != ''){ - var ports =''; - if(oShape.type.match(/Gateway/)) { - ports = ['output1','input1','output2','input2', 'output3' ]; - } - else if(oShape.type.match(/Task/) || oShape.type.match(/Gateway/) || oShape.type.match(/Inter/) || oShape.type.match(/SubProcess/)) { - ports = ['output1','input1','output2','input2' ]; - } - else if(oShape.type.match(/End/)) { - ports = ['input1','input2']; - } - else if(oShape.type.match(/Start/)) { - ports = ['output1','output2']; - } - else if(oShape.type.match(/Annotation/)) { - ports = ['input1']; - } - for(var i=0; i< ports.length ; i++) { - eval('oShape.'+ports[i]+'.setZOrder(-1)'); - eval('oShape.'+ports[i]+'.setBackgroundColor(new Color(255, 255, 255))'); - eval('oShape.'+ports[i]+'.setColor(new Color(255, 255, 255))'); - } - } -} -/** - * Show Ports according to the Shape Selected - * @Param Shape Object - * @Param aPort Array - * @Author Girish Joshi - */ -MyWorkflow.prototype.enablePorts=function(oShape,aPort) -{ - /*Setting Background ,border and Z-order of the flow menu back to original when clicked - *on the shape - **/ - for(var i=0; i< aPort.length ; i++) - { - if(aPort[i].match(/input/)) { - eval('oShape.workflow.currentSelection.'+aPort[i]+'.setBackgroundColor(new Color(245, 115, 115))'); - eval('oShape.workflow.currentSelection.'+aPort[i]+'.setZOrder(49000)'); - } - else { - eval('oShape.workflow.currentSelection.'+aPort[i]+'.setBackgroundColor(new Color(115, 115, 245))'); - eval('oShape.workflow.currentSelection.'+aPort[i]+'.setZOrder(50000)'); - } - eval('oShape.workflow.currentSelection.'+aPort[i]+'.setColor(new Color(90, 150, 90))'); - } -} - -/** - * Hide Flow menu according to the Shape Selected - * @Param Shape Object - * @Param aPort Array - * @Author Girish Joshi - */ -MyWorkflow.prototype.disableFlowMenu =function(oShape,aPort) -{ - /*Setting Background ,border and Z-order of the flow menu back to original when clicked - *on the shape - */ - for(var i=0; i< aPort.length ; i++) - { - if(aPort[i].match(/input/)) - eval('oShape.workflow.currentSelection.'+aPort[i]+'.setBackgroundColor(new Color(245, 115, 115))'); - else - eval('oShape.workflow.currentSelection.'+aPort[i]+'.setBackgroundColor(new Color(115, 115, 245))'); - eval('oShape.workflow.currentSelection.'+aPort[i]+'.setColor(new Color(90, 150, 90))'); - eval('oShape.workflow.currentSelection.'+aPort[i]+'.setZOrder(50000)'); - } -} - -/** - * This function is called on Right Click of All Shapes - * and menu is shown according to the shape selected - * @Param Shape Object - * @Author Girish Joshi - */ -MyWorkflow.prototype.handleContextMenu=function(oShape) -{ - workflow.hideResizeHandles(); - //Enable the contextClicked Flag - workflow.contextClicked = true; - - //Set the current Selection to the selected Figure - workflow.setCurrentSelection(oShape); - - //Disable Resize of all the figures - //oShape.workflow.hideResizeHandles(); -// oShape.setSelectable(false); -// oShape.setResizeable(false); - //Handle the Right click menu - var pmosExtObj = new pmosExt(); - //Load all the process Data - pmosExtObj.loadProcess(oShape); - - //Load Dynaform List - // pmosExtObj.loadDynaforms(oShape); - - if(oShape.type != ''){ - if(oShape.type.match(/Task/)) { - oShape.workflow.taskid = new Array(); - oShape.workflow.taskid.value = oShape.id; - pmosExtObj.loadTask(oShape); - oShape.workflow.AddTaskContextMenu(oShape); - } - else if(oShape.type.match(/Start/)) { - oShape.workflow.taskUid = workflow.getStartEventConn(oShape,'targetPort','OutputPort'); - pmosExtObj.loadDynaforms(oShape); - oShape.workflow.AddEventStartContextMenu(oShape); - } - else if(oShape.type.match(/Inter/)) { - oShape.workflow.taskUidFrom = workflow.getStartEventConn(oShape,'sourcePort','InputPort'); - //oShape.workflow.taskid = oShape.workflow.taskUid[0]; - oShape.workflow.taskUidTo = workflow.getStartEventConn(oShape,'targetPort','OutputPort'); - oShape.workflow.taskid = oShape.workflow.taskUidFrom[0]; - pmosExtObj.loadTask(oShape); - pmosExtObj.getTriggerList(oShape); - oShape.workflow.AddEventInterContextMenu(oShape); - } - else if(oShape.type.match(/End/)) { - oShape.workflow.taskUid = workflow.getStartEventConn(oShape,'sourcePort','InputPort'); - oShape.workflow.AddEventEndContextMenu(oShape); - } - else if(oShape.type.match(/Gateway/)) { - oShape.workflow.AddGatewayContextMenu(oShape); - } - else if(oShape.type.match(/SubProcess/)) { - oShape.workflow.AddSubProcessContextMenu(oShape); - } - } - //this.workflow.AddEventStartContextMenu(oShape); - - -} - -/** - * This function is called in Save Process - * and menu is shown according to the shape selected - * @Param Shape Object - * @Author Javed Aman - */ -MyWorkflow.prototype.getCommonConnections = function(oShape) -{ - var routes = new Array(); - var counter = 0 - for(var p=0; p < oShape.workflow.commonPorts.data.length; p++) - { - if(typeof oShape.workflow.commonPorts.data[p] === "object" && oShape.workflow.commonPorts.data[p] != null) - { - counter++; - } - } - for(var j=0; j< counter; j++) - { - //var temp1 = eval("this.workflow.commonPorts.data["+i+"].parentNode.output"+count+".getConnections()"); - var tester = oShape.workflow.commonPorts.data; - var temp1 = eval("oShape.workflow.commonPorts.data["+j+"].getConnections()"); - if(temp1.data[0]) { - if(routes[j]) { - if(routes[j][1] != temp1.data[0].sourcePort.parentNode.id) { - routes[j] = new Array(3); - routes[j][0] = temp1.data[0].id; - routes[j][1] = temp1.data[0].sourcePort.parentNode.id; - routes[j][2] = temp1.data[0].targetPort.parentNode.id; - routes[j][3] = temp1.data[0].targetPort.properties.name; - routes[j][4] = temp1.data[0].sourcePort.properties.name; - } - } - else { - routes[j] = new Array(3); - routes[j][0] = temp1.data[0].id; - routes[j][1] = temp1.data[0].sourcePort.parentNode.id; - routes[j][2] = temp1.data[0].targetPort.parentNode.id; - routes[j][3] = temp1.data[0].targetPort.properties.name; - routes[j][4] = temp1.data[0].sourcePort.properties.name; - } - } - } - var j = 0; - var serial = new Array(); - for(key in routes) - { - if(typeof routes[key] === 'object') { - serial[j] = routes[key]; - j++; - } - } - var routes = serial.getUniqueValues(); - for(var i=0;i< routes.length ; i++) - { - routes[i] = routes[i].split(','); - } - - return routes; -} - -Array.prototype.getUniqueValues = function () { -var hash = new Object(); -for (j = 0; j < this.length; j++) {hash[this[j]] = true} -var array = new Array(); -for (value in hash) {array.push(value)}; -return array; -} -/** - * Get Process UID - * @Param Shape Object - * @Author Safan maredia - */ -MyWorkflow.prototype.getUrlVars = function() -{ - var vars = [], hash; - var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&'); - - for(var i = 0; i < hashes.length; i++) - { - hash = hashes[i].split('='); - vars.push(hash[0]); - vars[hash[0]] = hash[1]; - } - var pro_uid = vars["PRO_UID"]; - return pro_uid; -} - - -MyWorkflow.prototype.savePosition= function(oShape) -{ - var shapeId = oShape.id; - var actiontype = oShape.actiontype; - var xpos = oShape.x; - var ypos = oShape.y; - var pos = '{"x":'+xpos+',"y":'+ypos+'}'; - - var width = oShape.width; - var height = oShape.height; - var cordinates = '{"x":'+width+',"y":'+height+'}'; - var urlparams = ''; - switch(actiontype) - { - case 'saveTaskPosition': - urlparams = '?action='+actiontype+'&data={"uid":"'+ shapeId +'","position":'+pos+'}'; - break; - case 'saveEventPosition': - urlparams = '?action='+actiontype+'&data={"uid":"'+ shapeId +'","position":'+pos+'}'; - break; - case 'saveTextPosition': - urlparams = '?action='+actiontype+'&data={"uid":"'+ shapeId +'","position":'+pos+'}'; - break; - case 'saveGatewayPosition': - urlparams = '?action='+actiontype+'&data={"uid":"'+ shapeId +'","position":'+pos+'}'; - break; - case 'saveTaskCordinates': - urlparams = '?action='+actiontype+'&data={"uid":"'+ shapeId +'","position":'+cordinates+'}'; - break; - case 'saveAnnotationCordinates': - urlparams = '?action='+actiontype+'&data={"uid":"'+ shapeId +'","position":'+cordinates+'}'; - break; - } - if(urlparams != ''){ - Ext.Ajax.request({ - url: "bpmn/processes_Ajax.php"+ urlparams, - success: function(response) { - //Ext.Msg.alert (response.responseText); - }, - failure: function(){ - //Ext.Msg.alert ('Failure'); - } - }); - } -} -/** - * Saving Shape Asychronously - * @Param oNewShape Object - * @Author Safan maredia - */ -MyWorkflow.prototype.saveShape= function(oNewShape) -{ - //Initializing variables - var shapeId = oNewShape.id; - var shapetype = oNewShape.type; - var actiontype = oNewShape.actiontype; - var xpos = oNewShape.x; - var ypos = oNewShape.y; - var pos = '{"x":'+xpos+',"y":'+ypos+'}'; - var width = oNewShape.width; - var height = oNewShape.height; - var cordinates = '{"x":'+width+',"y":'+height+'}'; - - if(shapetype == 'bpmnTask'){ - var newlabel = oNewShape.taskName; - } - if(shapetype == 'bpmnAnnotation'){ - newlabel = oNewShape.annotationName; - } - - //var urlparams = "action=addTask&data={"uid":"4708462724ca1d281210739068208635","position":{"x":707,"y":247}}"; - var urlparams = ''; - switch(actiontype) - { - case 'addTask': - urlparams = '?action='+actiontype+'&data={"uid":"'+ pro_uid +'","position":'+pos+',"cordinate":'+cordinates+'}'; - break; - case 'updateTask': - urlparams = '?action='+actiontype+'&data={"uid":"'+ shapeId +'","boundary":"TIMER"}'; - break; - case 'updateTaskName': - urlparams = '?action='+actiontype+'&data={"uid":"'+ shapeId +'","label":"'+newlabel+'"}'; - break; - case 'addSubProcess': - urlparams = '?action='+actiontype+'&data={"uid":"'+ pro_uid +'","position":'+pos+'}'; - break; - case 'addText': - var next_uid = ''; - var taskUidFrom = workflow.getStartEventConn(oNewShape,'sourcePort','OutputPort'); - if(taskUidFrom.length > 0) - next_uid = taskUidFrom[0].value; - urlparams = '?action='+actiontype+'&data={"uid":"'+ pro_uid +'","label":"'+newlabel+'","task_uid":"'+ next_uid +'","position":'+pos+'}'; - break; - case 'updateText': - next_uid = ''; - if(workflow.currentSelection.type == 'bpmnTask') - taskUidFrom = workflow.getStartEventConn(oNewShape,'sourcePort','OutputPort'); - else - taskUidFrom = workflow.getStartEventConn(oNewShape,'sourcePort','InputPort'); - if(taskUidFrom.length > 0) - next_uid = taskUidFrom[0].value; - - urlparams = '?action='+actiontype+'&data={"uid":"'+ shapeId +'","label":"'+newlabel+'","next_uid":"'+ next_uid +'"}'; - break; - case 'saveStartEvent': - //If we change Event to start from Message/Timer then Delete the record from Events Table - this.deleteEvent(oNewShape); - var tas_start = 'TRUE'; - var tas_uid = oNewShape.task_uid; - urlparams = '?action='+actiontype+'&data={"tas_uid":"'+tas_uid+'","tas_start":"'+tas_start+'"}'; - break; - case 'addEvent': - urlparams = '?action='+actiontype+'&data={"uid":"'+ pro_uid +'","evn_type":"'+shapetype+'","position":'+pos+',"evn_uid":"'+shapeId+'"}'; - break; - case 'updateEvent': - urlparams = '?action='+actiontype+'&data={"evn_uid":"'+shapeId +'","evn_type":"'+shapetype+'"}'; - break; - case 'addGateway': - urlparams = '?action='+actiontype+'&data={"pro_uid":"'+ pro_uid +'","gat_uid":"'+ shapeId +'","gat_type":"'+ shapetype +'","position":'+ pos +'}'; - break; - } - //var urlparams = '?action='+actiontype+'&data={"uid":"'+ pro_uid +'","position":'+pos+'}'; - - if(urlparams != ''){ - Ext.Ajax.request({ - url: "bpmn/processes_Ajax.php"+ urlparams, - success: function(response) { - //Ext.Msg.alert (response.responseText); - if(response.responseText != 1 && response.responseText != ""){ - this.workflow.newTaskInfo = Ext.util.JSON.decode(response.responseText); - oNewShape.html.id = this.workflow.newTaskInfo.uid; - oNewShape.id = this.workflow.newTaskInfo.uid; - if(oNewShape.type == 'bpmnTask' && oNewShape.boundaryEvent != true){ - oNewShape.taskName = this.workflow.newTaskInfo.label; - workflow.redrawTaskText(oNewShape); - //After Figure is added, Update Start Event connected to Task - if(typeof this.workflow.preSelectedObj != 'undefined' ){ - var preSelectedFigure = this.workflow.preSelectedObj; - if(preSelectedFigure.type.match(/Start/) && preSelectedFigure.type.match(/Event/)) - this.workflow.saveEvents(preSelectedFigure,oNewShape.id); - else if(preSelectedFigure.type.match(/Task/)) - this.workflow.saveRoute(preSelectedFigure,oNewShape); - else if (preSelectedFigure.type.match(/Gateway/)) - //preSelectedFigure.rou_type = 'SEQUENTIAL'; - this.workflow.saveRoute(preSelectedFigure,oNewShape); - else if (preSelectedFigure.type.match(/Inter/)) { - //preSelectedFigure.rou_type = 'SEQUENTIAL'; - this.workflow.saveEvents(preSelectedFigure,oNewShape); - } - } - - /** - * erik: Setting Drop targets from users & groups grids to assignment to tasks - * for new tasks created recently - */ - //var dropEls = Ext.get('paintarea').query('.x-task'); - //for(var i = 0; i < dropEls.length; i++) - //new Ext.dd.DropTarget(dropEls[i], {ddGroup:'task-assignment', notifyDrop : Ext.getCmp('usersPanel')._onDrop}); - - } - else if(oNewShape.type == 'bpmnSubProcess'){ - oNewShape.subProcessName = this.workflow.newTaskInfo.label; - } - /*else if(oNewShape.type.match(/Inter/) && oNewShape.type.match(/Start/)) { - workflow.saveEvents(oNewShape); - } - else if(oNewShape.type.match(/Start/) && oNewShape.type.match(/Event/)) { - workflow.saveEvents(oNewShape); - }*/ - else if(oNewShape.type.match(/End/) && oNewShape.type.match(/Event/)) { - if(workflow.currentSelection != null && workflow.currentSelection != '') //will check for standalone event - workflow.saveRoute(workflow.currentSelection,oNewShape); - } - else if(oNewShape.type.match(/Gateway/)) { - workflow.saveGateways(oNewShape); - } - else if(oNewShape.type.match(/Inter/) && oNewShape.type.match(/Event/)) { - preSelectedFigure = this.workflow.preSelectedFigure; - workflow.saveEvents(oNewShape,preSelectedFigure.id); - } - } - }, - failure: function(){ - //Ext.Msg.alert ('Failure'); - } - }); - } -} - -MyWorkflow.prototype.saveTask= function(actiontype,xpos,ypos) -{ - if(actiontype != '') { - var pro_uid = this.getUrlVars(); - var actiontype = actiontype; - var pos = '{"x":'+xpos+',"y":'+ypos+'}'; - switch(actiontype) { - case 'addTask': - urlparams = '?action='+actiontype+'&data={"uid":"'+ pro_uid +'","position":'+pos+'}'; - break; - } - Ext.Ajax.request({ - url: "bpmn/processes_Ajax.php"+ urlparams, - success: function(response) { - //Ext.Msg.alert (response.responseText); - if(response.responseText != 1 && response.responseText != "") { - workflow.newTaskInfo = Ext.util.JSON.decode(response.responseText); - workflow.taskName = this.workflow.newTaskInfo.label; - workflow.task = eval("new bpmnTask(workflow) "); - workflow.addFigure(workflow.task, xpos, ypos); - workflow.task.html.id = workflow.newTaskInfo.uid; - workflow.task.id = workflow.newTaskInfo.uid; - } - } - }) - } -} -//Deleting shapes silently on swapping task to sub process and vice-versa -MyWorkflow.prototype.deleteSilently= function(oShape) -{ - //Initializing variables - var pro_uid = this.getUrlVars(); - var shapeId = oShape.id; - var actiontype = oShape.actiontype; - //var shapeName = ''; - - switch(actiontype) - { - case 'deleteTask': - var urlparams = '?action='+actiontype+'&data={"pro_uid":"'+ pro_uid +'","tas_uid":"'+shapeId+'"}'; - this.urlparameter = urlparams; - //shapeName = 'Task :'+ oShape.taskName; - break; - case 'deleteSubProcess': - urlparams = '?action='+actiontype+'&data={"pro_uid":"'+ pro_uid +'","tas_uid":"'+shapeId+'"}'; - this.urlparameter = urlparams; - break; - } - - Ext.Ajax.request({ - url: "bpmn/processes_Ajax.php"+ urlparams, - success: function(response) { - //Ext.Msg.alert (response.responseText); - }, - failure: function(){ - Ext.Msg.alert ('Failure'); - } - }); - //workflow.getCommandStack().execute(new CommandDelete(workflow.getCurrentSelection())); -} -/** - * Deleting Shape Asychronously - * @Param oShape Object - * @Author Safan maredia - */ -MyWorkflow.prototype.deleteShape= function(oShape) -{ - var shapeId = oShape.id; - var actiontype = oShape.actiontype; - var shapeName = ''; - switch(actiontype) - { - case 'deleteTask': - var urlparams = '?action='+actiontype+'&data={"pro_uid":"'+ pro_uid +'","tas_uid":"'+shapeId+'"}'; - this.urlparameter = urlparams; - shapeName = 'Task :'+ oShape.taskName; - break; - case 'deleteSubProcess': - urlparams = '?action='+actiontype+'&data={"pro_uid":"'+ pro_uid +'","tas_uid":"'+shapeId+'"}'; - this.urlparameter = urlparams; - shapeName = oShape.subProcessName; - break; - case 'deleteText': - urlparams = '?action='+actiontype+'&data={"uid":"'+shapeId+'"}'; - this.urlparameter = urlparams; - shapeName = 'Annotation'; - break; - case 'deleteStartEvent': - var task_detail = this.getStartEventConn(this.currentSelection,'targetPort','OutputPort'); - var evn_uid = this.currentSelection.id; - if(task_detail.length > 0){ - var tas_uid = task_detail[0].value; - var tas_start = 'FALSE'; - this.urlparameter = '?action=deleteStartEvent&data={"tas_uid":"'+tas_uid+'","tas_start":"'+tas_start+'","evn_uid":"'+evn_uid+'"}'; - } - else - this.urlparameter = '?action=deleteEvent&data={"uid":"'+evn_uid+'"}'; - shapeName = 'Start Event'; - break; - case 'deleteEndEvent': - shapeName = 'End Event'; - var evn_uid = this.currentSelection.id; - this.urlparameter = '?action=deleteEvent&data={"uid":"'+evn_uid+'"}'; - break; - case 'deleteInterEvent': - shapeName = 'Intermediate Event'; - var evn_uid = this.currentSelection.id; - this.urlparameter = '?action=deleteEvent&data={"uid":"'+evn_uid+'"}'; - break; - case 'deleteGateway': - shapeName = 'Gateway'; - urlparams = '?action='+actiontype+'&data={"pro_uid":"'+ pro_uid +'","gat_uid":"'+shapeId+'"}'; - this.urlparameter = urlparams; - break; - } -if(typeof oShape.noAlert == 'undefined' || oShape.noAlert == null){ - Ext.MessageBox.confirm('Confirm', 'Are you sure you want to delete the '+ shapeName,this.showAjaxDialog); -} -else{ - Ext.MessageBox.confirm('Confirm', 'Are you sure you want to delete the '+ shapeName,this.showDeleteDialog); -} -} - -MyWorkflow.prototype.showAjaxDialog = function(btn){ - //this.workflow.confirm = btn; - if(typeof workflow.urlparameter != 'undefined'){ - var url = workflow.urlparameter; - if(btn == 'yes'){ - var currentObj = workflow.currentSelection; - - //Check for End Event and delete from route table - if(workflow.currentSelection.type.match(/End/) && workflow.currentSelection.type.match(/Event/)){ - var ports = currentObj.getPorts(); - var len =ports.data.length; - var conn = new Array(); - for(var i=0; i<=len; i++){ - if(typeof ports.data[i] === 'object') - conn[i] = ports.data[i].getConnections(); - } - for(i = 0; i< conn.length ; i++) - { - if(typeof conn[i] != 'undefined') - for(var j = 0; j < conn[i].data.length ; j++) - { - if(typeof conn[i].data[j] != 'undefined'){ - if(conn[i].data[j].targetPort.parentNode.id == currentObj.id){ - route = conn[i].data[j]; - break; - } - } - } - } - if(typeof route != 'undefined'){ - workflow.deleteRoute(route,1); - } - } - Ext.Ajax.request({ - url: "bpmn/processes_Ajax.php"+ url, - success: function(response) { - workflow.getCommandStack().execute(new CommandDelete(currentObj)); - }, - failure: function(){ - Ext.Msg.alert ('Failure'); - } - }); - - } - } - }; - -MyWorkflow.prototype.showDeleteDialog = function(btn){ - if(btn == 'yes'){ - workflow.getCommandStack().execute(new CommandDelete(workflow.getCurrentSelection())); - } - }; - - -/** - * ExtJs Menu on right click on Event Shape - * @Param oShape Object - * @Author Girish joshi - */ -MyWorkflow.prototype.editEventProperties = function(oShape) -{ - var currentSelection = oShape.scope.currentSelection; - var pmosExtObj = new pmosExt(); - - switch (currentSelection.type){ - case 'bpmnEventMessageStart': - pmosExtObj.popWebEntry(currentSelection); - break; - case 'bpmnEventTimerStart': - pmosExtObj.popCaseSchedular(currentSelection); - break; - case 'bpmnEventMessageSendInter': - pmosExtObj.popTaskNotification(currentSelection); - break; - case 'bpmnEventTimerInter': - pmosExtObj.popMultipleEvent(currentSelection); - break; - case 'bpmnEventMessageEnd': - pmosExtObj.popMessageEvent(currentSelection); - break; - } -} - -/** - * Get the Source / Target of the shape - * @Param oShape Object - * @Param sPort string - * @Param sPortType string - * @return aStartTask array - * @Author Girish joshi - */ -MyWorkflow.prototype.getStartEventConn = function(oShape,sPort,sPortType) -{ - var aStartTask= new Array(); - - //Get all the ports of the shapes - if( workflow.currentSelection != null && typeof workflow.currentSelection != 'undefined') { - var ports = workflow.currentSelection.getPorts(); - //var ports = oShape.getPorts(); - var len = ports.data.length; - - //Get all the connection of the shape - var conn = new Array(); - for(var i=0; i<=len; i++){ - if(typeof ports.data[i] === 'object') - if(ports.data[i].type == sPortType) - conn[i] = ports.data[i].getConnections(); - } - //Initializing Arrays and variables - var countConn = 0; - - var type; - //Get ALL the connections for the specified PORT - for(i = 0; i< conn.length ; i++) - { - if(typeof conn[i] != 'undefined') - for(var j = 0; j < conn[i].data.length ; j++) - { - if(typeof conn[i].data[j] != 'undefined') - { - type = eval('conn[i].data[j].'+sPort+'.parentNode.type') - if(type == 'bpmnTask') - { - aStartTask[countConn] = new Array(); - aStartTask[countConn].value = eval('conn[i].data[j].'+sPort+'.parentNode.id'); - aStartTask[countConn].name = eval('conn[i].data[j].'+sPort+'.parentNode.taskName'); - countConn++; - } - } - } - } - } - return aStartTask; -} - -/** - * save Gateway depending on the Shape Type - * @Param oGateway Object - * @Param sTaskUID string - * @Author Safan Maredia - */ -MyWorkflow.prototype.saveGateways = function(oGateway){ - var task_uid = ''; - var next_task_uid = ''; - var next_task_type = ''; - var urlparams = ''; - var xpos = oGateway.x; - var ypos = oGateway.y; - var pos = '{"x":'+xpos+',"y":'+ypos+'}'; - - var ports = oGateway.getPorts(); - var len =ports.data.length; - //Get all the connection of the shape - var conn = new Array(); - var count1 = 0; - var count2 = 0; - for(var i=0; i<=len; i++){ - if(typeof ports.data[i] === 'object') - conn[i] = ports.data[i].getConnections(); - } - //Get ALL the connections for the specified PORT - for(i = 0; i< conn.length ; i++){ - if(typeof conn[i] != 'undefined') - for(var j = 0; j < conn[i].data.length ; j++){ - if(typeof conn[i].data[j] != 'undefined'){ - if(conn[i].data[j].sourcePort.parentNode.id != oGateway.id){ - // task_uid[count1] = new Array(); - task_uid = conn[i].data[j].sourcePort.parentNode.id; - count1++; - } - if(conn[i].data[j].targetPort.parentNode.id != oGateway.id){ - // task_uid[count2] = new Array(); - next_task_uid = conn[i].data[j].targetPort.parentNode.id; - next_task_type = conn[i].data[j].targetPort.parentNode.type; - //count2++; - } - } - } - } - // var staskUid = Ext.util.JSON.encode(task_uid); - // var sNextTaskUid = Ext.util.JSON.encode(next_task_uid); - urlparams = '?action=addGateway&data={"pro_uid":"'+ pro_uid +'","tas_from":"'+task_uid+'","tas_to":"'+next_task_uid+'","gat_type":"'+oGateway.type+'","gat_uid":"'+oGateway.id+'","gat_next_type":"'+next_task_type+'","position":'+pos+'}'; - if(urlparams != ''){ - Ext.Ajax.request({ - url: "bpmn/processes_Ajax.php"+ urlparams, - success: function(response) { - if(response.responseText != '') - { - // workflow.currentSelection.id = response.responseText; - /*if(workflow.currentSelection.type.match(/Inter/) && workflow.currentSelection.type.match(/Event/)){ - workflow.currentSelection.id = response.responseText; - var newObj = workflow.currentSelection; - var preObj = new Array(); - preObj.type = 'bpmnTask'; - preObj.id = task_uid[0]; - newObj.evn_uid = workflow.currentSelection.id; - newObj.task_to = next_task_uid[0]; - this.workflow.saveRoute(preObj,newObj); - }*/ - } - }, - failure: function(){ - Ext.Msg.alert ('Failure'); - } - }); - } -} - -/** - * save Event depending on the Shape Type - * @Param oShape Object - * @Param sPort string - * @Param sPortType string - * @Author Girish joshi - */ -MyWorkflow.prototype.saveEvents = function(oEvent,sTaskUID) -{ - var task_uid = new Array(); - var next_task_uid = new Array(); - var urlparams = ''; - - if(typeof sTaskUID == 'undefined') //Will be undefined for standalone events - sTaskUID = ''; - if(oEvent.type.match(/Start/)) - { - var tas_start = 'TRUE'; - urlparams = '?action=saveEvents&data={"tas_uid":"'+sTaskUID+'","tas_start":"'+tas_start+'","evn_type":"'+oEvent.type+'","evn_uid":"'+oEvent.id+'"}'; - } - else if(oEvent.type.match(/Inter/)) - { - var ports = oEvent.getPorts(); - var len =ports.data.length; - - //Get all the connection of the shape - var conn = new Array(); - var count1 = 0; - var count2 = 0; - for(var i=0; i<=len; i++) { - if(typeof ports.data[i] === 'object') - conn[i] = ports.data[i].getConnections(); - } - - //Get ALL the connections for the specified PORT - for(i = 0; i< conn.length ; i++){ - if(typeof conn[i] != 'undefined') - for(var j = 0; j < conn[i].data.length ; j++) { - if(typeof conn[i].data[j] != 'undefined'){ - if(conn[i].data[j].sourcePort.parentNode.type != oEvent.type){ - // task_uid[count1] = new Array(); - task_uid = conn[i].data[j].sourcePort.parentNode.id; - count1++; - } - if(conn[i].data[j].targetPort.parentNode.type != oEvent.type){ - // task_uid[count2] = new Array(); - next_task_uid = conn[i].data[j].targetPort.parentNode.id; - //count2++; - } - } - } - } - // var staskUid = Ext.util.JSON.encode(task_uid); - // var sNextTaskUid = Ext.util.JSON.encode(next_task_uid); - if(typeof task_uid == 'undefined') - task_uid = ''; - if(typeof next_task_uid == 'undefined') - next_task_uid = ''; - - urlparams = '?action=saveEvents&data={"tas_from":"'+task_uid+'","tas_to":"'+next_task_uid+'","evn_type":"'+oEvent.type+'","evn_uid":"'+oEvent.id+'"}'; - } - - if(urlparams != '') { - Ext.Ajax.request({ - url: "bpmn/processes_Ajax.php"+ urlparams, - success: function(response) { - if(response.responseText != '') - { - //Save Route - //disabled by Fernando, because the workflow.currentSelection arrives null and throwing an error in javascript -// if(workflow.currentSelection.type.match(/Inter/) && workflow.currentSelection.type.match(/Event/)){ -// workflow.currentSelection.id = response.responseText; -// var newObj = workflow.currentSelection; -// var preObj = new Array(); -// preObj.type = 'bpmnTask'; -// preObj.id = task_uid[0]; -// newObj.evn_uid = workflow.currentSelection.id; -// newObj.task_to = next_task_uid[0]; -// this.workflow.saveRoute(preObj,newObj); -// } - } - }, - failure: function(){ - Ext.Msg.alert ('Failure'); - } - }); - } -} - -/** - * save Route on Changing of route Ports depending on the Shape Type - * @Param preObj Object - * @Param newObj Object - * @Author Girish joshi - */ -MyWorkflow.prototype.saveRoute = function(preObj,newObj) -{ - var task_uid = new Array(); - var next_task_uid = new Array(); - var rou_type =''; - var rou_evn_uid = ''; - var port_numberIP = ''; - var port_numberOP = ''; - var sGatUid = ''; - var sGatType = ''; - - if(typeof newObj.sPortType != 'undefined') - { - sPortTypeIP = newObj.sPortType; - sPortTypeOP = preObj.sPortType; - var sPortType_lenIP = sPortTypeIP.length; - var sPortType_lenOP = sPortTypeOP.length; - port_numberIP = sPortTypeIP.charAt(sPortType_lenIP-1); - port_numberOP = sPortTypeOP.charAt(sPortType_lenOP-1); - } - if(preObj.type.match(/Task/) && newObj.type.match(/Event/) && newObj.type.match(/Inter/)) - { - task_uid[0] = preObj.id; - next_task_uid[0] = newObj.task_to; - rou_type = 'SEQUENTIAL'; - rou_evn_uid = newObj.id; - } - //If both the Object are Task - else if(preObj.type.match(/Task/) && newObj.type.match(/Task/)) - { - task_uid[0] = preObj.id; - next_task_uid[0] = newObj.id; - rou_type = 'SEQUENTIAL'; - } - else if(preObj.type.match(/Task/) && newObj.type.match(/End/) && newObj.type.match(/Event/) || newObj.reverse == 1) - { - //this.deleteRoute(newObj.conn,1); - if(newObj.reverse == 1) //Reverse Routing - task_uid[0] = newObj.id; - else - task_uid[0] = preObj.id; - - next_task_uid[0] = '-1'; - - rou_type = 'SEQUENTIAL'; - rou_evn_uid = newObj.id; - } - else if(preObj.type.match(/Gateway/)) - { - switch(preObj.type){ - case 'bpmnGatewayParallel': - rou_type ='PARALLEL'; - break; - case 'bpmnGatewayExclusiveData': - rou_type = 'EVALUATE'; - break; - case 'bpmnGatewayInclusive': - rou_type = 'PARALLEL-BY-EVALUATION'; - break; - case 'bpmnGatewayComplex': - rou_type = 'DISCRIMINATOR'; - break; - } - var ports = preObj.getPorts(); - var len =ports.data.length; - - //Get all the connection of the shape - var conn = new Array(); - var count1 = 0; - var count2 = 0; - for(var i=0; i<=len; i++){ - if(typeof ports.data[i] === 'object') - conn[i] = ports.data[i].getConnections(); - } - - //Get ALL the connections for the specified PORT - for(i = 0; i< conn.length ; i++) - { - if(typeof conn[i] != 'undefined') - for(var j = 0; j < conn[i].data.length ; j++) - { - if(typeof conn[i].data[j] != 'undefined') - { - if(conn[i].data[j].sourcePort.parentNode.type != preObj.type){ - // task_uid[count1] = new Array(); - task_uid[count1] = conn[i].data[j].sourcePort.parentNode.id; - count1++; - } - if(conn[i].data[j].targetPort.parentNode.type != preObj.type){ - // task_uid[count2] = new Array(); - next_task_uid[count2] = conn[i].data[j].targetPort.parentNode.id; - count2++; - } - - } - } - } - } - - var staskUid = Ext.util.JSON.encode(task_uid); - var sNextTaskUid = Ext.util.JSON.encode(next_task_uid); - if(preObj.type.match(/Gateway/)){ - sGatUid = preObj.id; - sGatType = preObj.type; - } - if(task_uid.length > 0 && next_task_uid.length > 0) - { - Ext.Ajax.request({ - url: "bpmn/patterns_Ajax.php", - success: function(response) { - if(response.responseText != 0) { - if(typeof newObj.conn != 'undefined') { - //var resp = response.responseText.split("|"); //resp[0] => gateway UID OR event_UID , resp[1] => route UID - var resp = response.responseText; //resp[0] => gateway UID OR event_UID , resp[1] => route UID - newObj.conn.html.id = resp; - newObj.conn.id = resp; - } - } - }, - failure: function(){ - Ext.Msg.alert ('Failure'); - }, - params: { - action :'savePattern', - PROCESS : pro_uid, - TASK : staskUid, - ROU_NEXT_TASK : sNextTaskUid, - ROU_TYPE : rou_type, - ROU_EVN_UID : rou_evn_uid, - PORT_NUMBER_IP: port_numberIP, - PORT_NUMBER_OP: port_numberOP, - GAT_UID : sGatUid, - GAT_TYPE : sGatType, - mode:'Ext' - } - }); - } - else - workflow.saveGateways(preObj); -} - -MyWorkflow.prototype.deleteRoute = function(oConn,iVal){ - workflow.oConn = oConn; - var sourceObjType = oConn.sourcePort.parentNode.type; - var targetObjType = oConn.targetPort.parentNode.type; - var rou_uid = oConn.id; - //Setting Condition for VALID ROUTE_UID present in Route Table - //For start and gateway event, we dont have entry in ROUTE table - if(rou_uid != '' && !sourceObjType.match(/Gateway/) && !sourceObjType.match(/Start/) && !targetObjType.match(/Gateway/)){ - workflow.urlDeleteparameter = '?action=deleteRoute&data={"uid":"'+ rou_uid +'"}'; - } - //Deleting route for Start event and also deleting start event - else if(sourceObjType.match(/Start/)){ - var targetObj = oConn.targetPort.parentNode; //Task - var tas_uid = targetObj.id; - var tas_start = 'FALSE'; - workflow.urlDeleteparameter = '?action=saveStartEvent&data={"tas_uid":"'+tas_uid+'","tas_start":"'+tas_start+'"}'; - } - if(iVal == 0) - Ext.MessageBox.confirm('Confirm', 'Are you sure you want to delete the Route',this.showEventResult); - else - this.showEventResult('yes'); -} - -MyWorkflow.prototype.showEventResult = function(btn){ - //this.workflow.confirm = btn; - if(typeof workflow.urlDeleteparameter != 'undefined') - { - var url = workflow.urlDeleteparameter; - if(btn == 'yes') - { - Ext.Ajax.request({ - url: "bpmn/processes_Ajax.php"+ url, - success: function(response) { - workflow.getCommandStack().execute(new CommandDelete(workflow.oConn)); - }, - failure: function(){ - Ext.Msg.alert ('Failure'); - } - }); - } - } - - }; -/** - * Deleting Event - * @Param eventObj Object - * @Author Girish joshi - */ -MyWorkflow.prototype.deleteEvent = function(eventObj){ - - var event_uid = eventObj.id; - if(event_uid != '') { - var urlparams = '?action=deleteEvent&data={"uid":"'+ event_uid +'"}'; - Ext.Ajax.request({ - url: "bpmn/processes_Ajax.php"+ urlparams, - success: function(response) { - }, - failure: function(){ - Ext.Msg.alert ('Failure'); - } - }); - } -} - -MyWorkflow.prototype.getDeleteCriteria = function() -{ - var shape = workflow.currentSelection.type; - var currentObj = workflow.currentSelection; - if(shape.match(/Task/)){ - workflow.currentSelection.actiontype = 'deleteTask'; - } - else if(shape.match(/SubProcess/)){ - workflow.currentSelection.actiontype = 'deleteSubProcess'; - } - else if(shape.match(/Annotation/)){ - workflow.currentSelection.actiontype = 'deleteText'; - } - else if(shape.match(/Event/) && shape.match(/Start/)){ - workflow.currentSelection.actiontype = 'deleteStartEvent'; - } - else if(shape.match(/Event/) && shape.match(/End/)){ - workflow.currentSelection.actiontype = 'deleteEndEvent'; - } - else if(shape.match(/Event/) && shape.match(/Inter/)){ - workflow.currentSelection.actiontype = 'deleteInterEvent'; - } - else if(shape.match(/Gateway/)){ - workflow.currentSelection.actiontype = 'deleteGateway'; - workflow.deleteShape(workflow.currentSelection); - } - if(workflow.currentSelection.actiontype != '') - workflow.deleteShape(workflow.currentSelection); -} - -/** - * Zoom Function - * @Param sType string(in/out) - * @Author Girish joshi - */ -MyWorkflow.prototype.zoom = function(sType) -{ - //workflow.zoomFactor = 1; - var loadMask = new Ext.LoadMask(document.body, {msg:'Zooming..'}); - var figures = workflow.getDocument().getFigures(); - - var lines=workflow.getLines(); - var size=lines.getSize(); - - sType =sType/100; - workflow.zoomfactor = sType; - var figSize = figures.getSize(); - // loadMask.show(); - for(f = 0;f @@ Replace the value in quotes ';}, - items: - { - xtype:'tabpanel', - activeTab: 0, - defaults:{ - autoHeight:true - }, - items:[{ - title:'All Variables', - id :'allVar', - layout:'form', - listeners: { - activate: function(tabPanel){ - // use {@link Ext.data.HttpProxy#setUrl setUrl} to change the URL for *just* this request. - var link = 'proxyVariable?pid='+pro_uid+'&type='+tabPanel.id+'&sFieldName=form[CTO_CONDITION]&sSymbol=@@'; - varStore.proxy.setUrl(link, true); - varStore.load(); - } - }, - items:[{ - xtype: 'grid', - ds: varStore, - cm: varColumns, - width: 380, - autoHeight: true, - //plugins: [editor], - //loadMask : true, - loadingText : 'Loading...', - border: false, - listeners: { - //rowdblclick: alert("ok"), - rowdblclick: function(){ - var getObjectGridRow = workflow.gridObjectRowSelected; - var FieldSelected = workflow.gridField; - - //getting selected row of variables - var rowSelected = this.getSelectionModel().getSelected(); - var rowLabel = rowSelected.data.variable; - - //Assigned new object with condition - if(typeof rowData.colModel != 'undefined') - rowData.colModel.config[3].editor.setValue(rowLabel); - //Assigning / updating Condition for a row - else - rowData[0].set(fieldName,rowLabel); - } - } - }] - }] - } -}); - var window = new Ext.Window({ - title: 'Variables', - collapsible: false, - maximizable: false, - scrollable: true, - width: 400, - height: 350, - minWidth: 200, - minHeight: 150, - autoScroll: true, - layout: 'fit', - plain: true, - buttonAlign: 'center', - items: [varForm] - }); - window.show(); - -} diff --git a/workflow/engine/templates/bpmn/Pool.js b/workflow/engine/templates/bpmn/Pool.js deleted file mode 100755 index 6c3946973..000000000 --- a/workflow/engine/templates/bpmn/Pool.js +++ /dev/null @@ -1,53 +0,0 @@ -bpmnPool = function (workflow) { - VectorFigure.call(this); - this.setDimension(800, 600); - var figures = workflow.getFigures(); - for(var i=0;i" + aData.FILENAME + "<\/a>"); - form.findField('XPDL_FILENAME').setValue("" + aData.FILENAMEXPDL + "<\/a>"); - }, - failure:function(form, action) { - } - }); - - var exportProcesswindow = new Ext.Window({ - title : _('ID_EXPORT_PROCESS'), - collapsible: false, - maximizable: false, - sizeable : false, - width : 420, - height : 210, - resizable : false, - layout : 'fit', - plain : true, - buttonAlign: 'center', - items : exportProcessForm - }); - - workflow.exportProcesswindow = exportProcesswindow; - exportProcesswindow.show(); -} - -ProcessMapContext.prototype.addTask= function() - { - var newShape = eval("new bpmnTask(workflow)"); - var xPos = workflow.contextX; - var yPos = workflow.contextY; - workflow.addFigure(newShape, xPos, yPos); - newShape.actiontype = 'addTask'; - workflow.saveShape(newShape); //Saving Annotations when user drags and drops it - } - -ProcessMapContext.prototype.horiLine= function() - { - PMExt.notify( _('ID_STATUS') , _('ID_HORIZONTAL_LINE') ); - } - -ProcessMapContext.prototype.vertiLine= function() - { - PMExt.notify( _('ID_STATUS') , _('ID_VERTICAL_LINE') ); - } - -ProcessMapContext.prototype.delLines= function() - { - PMExt.notify( _('ID_STATUS') , _('ID_DELETE_LINES') ); - } - -ProcessMapContext.prototype.processPermission= function() - { - //Process Permission store code starts here - var dbConnFields = Ext.data.Record.create([ - { name: 'OP_UID',type: 'string'}, - { name: 'LABEL',type: 'string'}, - { name: 'TASK_TARGET',type: 'string'}, - { name: 'GROUP_USER',type: 'string'}, - { name: 'TASK_SOURCE',type: 'string'}, - { name: 'PARTICIPATED',type: 'string'}, - { name: 'OBJECT_TYPE',type: 'string'}, - { name: 'OBJECT',type: 'string'}, - { name: 'ACTION',type: 'string'}, - { name: 'OP_CASE_STATUS',type: 'string'}, - { name: 'DYNAFORM',type: 'string'}, - { name: 'INPUT',type: 'string'}, - { name: 'OUTPUT',type: 'string'}, - { name: 'TAS_UID',type: 'string'}, - { name: 'OP_TASK_SOURCE',type: 'string'}, - { name: 'OP_PARTICIPATE',type: 'string'}, - { name: 'OP_OBJ_TYPE',type: 'string'}, - { name: 'OP_GROUP_USER',type: 'string'}, - { name: 'OBJ_NAME',type: 'string'}, - { name: 'OP_ACTION',type: 'string'}, - { name: 'USR_FULLNAME',type: 'string'}, - { name: 'DYNAFORM_NAME',type: 'string'}, - { name: 'INPUT_NAME',type: 'string'}, - { name: 'OUTPUT_NAME',type: 'string'} - ]); - - //Creating different stores required for fields in form - var selectField = Ext.data.Record.create([ - { name: 'LABEL',type: 'string'}, - { name: 'UID',type: 'string'} - ]); - - var editor = new Ext.ux.grid.RowEditor({ - saveText: _('ID_UPDATE') - }); - - var btnCreate = new Ext.Button({ - id: 'btnCreate', - text: _('ID_NEW'), - iconCls: 'button_menu_ext ss_sprite ss_add', - handler: function () { - PermissionForm.getForm().reset(); - formWindow.show(); - - } - }); - - var editProPermission = function() { - editor.stopEditing(); - var rowSelected = Ext.getCmp('permissiongrid').getSelectionModel().getSelections(); - if( rowSelected.length == 0 ) { - PMExt.error('', _('ID_NO_SELECTION_WARNING')); - return false; - } - var opUID = rowSelected[0].get('OP_UID'); - PermissionForm.form.load({ - url:'bpmn/proxyExtjs.php?pid='+pro_uid+'&op_uid=' +opUID+'&action=editObjectPermission', - method:'GET', - waitMsg:'Loading', - success:function(form, action) { - formWindow.show(); - if(action.result.data.OP_PARTICIPATE == 1) - form.findField('OP_PARTICIPATE').setValue('Yes'); - else - form.findField('OP_PARTICIPATE').setValue('No'); - - if(action.result.data.OP_OBJ_TYPE == 'DYNAFORM') - Ext.getCmp('dynaform').show(); - if(action.result.data.OP_OBJ_TYPE == 'INPUT') - Ext.getCmp('inputdoc').show(); - if(action.result.data.OP_OBJ_TYPE == 'OUTPUT') - Ext.getCmp('outputdoc').show(); - }, - failure:function(form, action) { - PMExt.notify( _('ID_STATUS') , _('ID_LOAD_FAILED') ); - } - }); - } - - var deleteProPermission = function(){ - ids = Array(); - - editor.stopEditing(); - var rowsSelected = Ext.getCmp('permissiongrid').getSelectionModel().getSelections(); - - if( rowsSelected.length == 0 ) { - PMExt.error('', _('ID_NO_SELECTION_WARNING')); - return false; - } - - for(i=0; i",record.data.CTO_UID); - } - }*/] - }), - sm: new Ext.grid.RowSelectionModel({ - singleSelect: true, - listeners: { - rowselect: function(smObj, rowIndex, record) { - workflow.currentrowIndex = rowIndex; - } - } - }), - stripeRows: true, - viewConfig: {forceFit: true}, - tbar: tb, - bbar: new Ext.PagingToolbar({ - pageSize: 10, - store: assignedStore, - displayInfo: true, - displayMsg: 'Displaying Case Tracker Object {0} - {1} of {2}', - emptyMsg: "No Case Tracker Object to display", - items:[] - }) - }); - - editor.on({ - scope: this, - afteredit: function(roweditor, changes, record, rowIndex) { - var objType = record.data.OBJECT_TYPE; - var objUID = record.data.OBJECT_UID; - var objTitle = record.data.OBJECT_TITLE; - var cto_uid = record.data.CTO_UID; - var condition = record.data.CTO_CONDITION; - - Ext.Ajax.request({ - url : '../tracker/tracker_Ajax.php', - method: 'POST', - params:{ - PRO_UID : pro_uid, - OBJECT_TYPE : objType, - OBJECT_UID : objUID, - action :'assignCaseTrackerObject' - }, - success: function (response) - { - cto_uid = response.responseText; - Ext.Ajax.request({ - url : '../tracker/tracker_ConditionsSave.php', - method: 'POST', - params: - { - PRO_UID : pro_uid, - CTO_UID : cto_uid, - CTO_CONDITION : condition - }, - success: function (response){ - PMExt.notify( _('ID_STATUS') , _('ID_OBJECT_ASSIGNED') ); - availableStore.reload(); - assignedStore.reload(); - } - }) - }, - failure: function () { // when saving data failed - PMExt.notify( _('ID_STATUS') , _('ID_OBJECT_FAILED') ); - } - }) - //Updating the user incase if already assigned user has been replaced by other user - if(changes != '' && typeof record.json != 'undefined') - { - var obj_type = record.json.CTO_TYPE_OBJ; - var obj_UID = record.json.CTO_UID; - var obj_title = record.json.CTO_TITLE; - var obj_uid = record.json.CTO_UID; - var obj_condition = record.json.CTO_CONDITION; - var obj_position = record.json.CTO_POSITION; - - Ext.Ajax.request({ - url: '../tracker/tracker_Ajax.php', - method: 'POST', - params: { - action :'removeCaseTrackerObject', - CTO_UID : obj_UID, - PRO_UID : pro_uid, - STEP_POSITION : obj_position - }, - success: function(response) { - PMExt.notify( _('ID_STATUS') , _('ID_OBJECT_UPDATE') ); - } - }); - } - availableStore.reload(); - assignedStore.reload(); - } - }); - - var gridObjectWindow = new Ext.Window({ - title : 'Objects', - collapsible : false, - maximizable : false, - width : 550, - defaults :{ autoScroll:true }, - height : 380, - minWidth : 200, - minHeight : 150, - plain : true, - items : Objectsgrid, - buttonAlign : 'center' - }); - gridObjectWindow.show() -} - -ProcessMapContext.prototype.ExtVariables = function() -{ - var varFields = Ext.data.Record.create([ - { - name: 'variable', - type: 'string' - }, - { - name: 'type', - type: 'string' - }, - { - name: 'label', - type: 'string' - } - ]); - var varStore = ''; - varStore = new Ext.data.JsonStore({ - root : 'data', - totalProperty: 'totalCount', - idProperty : 'gridIndex', - remoteSort : true, - fields : varFields, - proxy : new Ext.data.HttpProxy({ - url : 'bpmn/proxyExtjs?pid='+pro_uid+'&action=getVariables&sFieldName=form[CTO_CONDITION]&sSymbol=@@' - }) - }); - //varStore.load(); - - var varColumns = new Ext.grid.ColumnModel({ - columns: [ - new Ext.grid.RowNumberer(), - { - id: 'FLD_NAME', - header: _('ID_VARIABLES'), - dataIndex: 'variable', - width: 170, - editable: false, - sortable: true - },{ - id: 'PRO_VARIABLE', - header: _('ID_LABEL'), - dataIndex: 'label', - width: 150, - sortable: true - } - ] - }); - - var varForm = new Ext.FormPanel({ - labelWidth: 100, - monitorValid : true, - width : 400, - bodyStyle : 'padding:10px 0 0 10px;', - height : 350, - renderer: function(val){return '
@@ Replace the value in quotes
';}, - items: - { - xtype:'tabpanel', - activeTab: 0, - defaults:{ - autoHeight:true - }, - items:[{ - title:_('ID_ALL_VARIABLES'), - id :'allVar', - layout:'form', - listeners: { - activate: function(tabPanel){ - // use {@link Ext.data.HttpProxy#setUrl setUrl} to change the URL for *just* this request. - var link = 'bpmn/proxyExtjs?pid='+pro_uid+'&action=getVariables&type='+tabPanel.id+'&sFieldName=form[CTO_CONDITION]&sSymbol=@@'; - varStore.proxy.setUrl(link, true); - varStore.load(); - } - }, - items:[{ - xtype: 'grid', - ds: varStore, - cm: varColumns, - width: 380, - autoHeight: true, - //plugins: [editor], - //loadMask : true, - loadingText : 'Loading...', - border: false, - listeners: { - //rowdblclick: alert("ok"), - rowdblclick: function(){ - var objectSelected = workflow.variablesAction; - switch(objectSelected) - { - case 'grid': - var getObjectGridRow = workflow.gridObjectRowSelected; - var FieldSelected = workflow.gridField; - //getting selected row of variables - var rowSelected = this.getSelectionModel().getSelected(); - var rowLabel = rowSelected.data.variable; - - //Assigned new object with condition - if(typeof getObjectGridRow.colModel != 'undefined') - getObjectGridRow.colModel.config[3].editor.setValue(rowLabel); - //Assigning / updating Condition for a row - else - getObjectGridRow[0].set(FieldSelected,rowLabel); - - if(FieldSelected=='CTO_CONDITION') - { - Ext.Ajax.request({ - url : '../tracker/tracker_ConditionsSave.php', - method: 'POST', - params: - { - PRO_UID : pro_uid, - CTO_UID : getObjectGridRow[0].data.CTO_UID, - CTO_CONDITION : getObjectGridRow[0].data.CTO_CONDITION - }, - success: function (response){ - Ext.MessageBox.alert ('Status','Objects has been edited successfully '); - } - }) - } - else if (FieldSelected=='STEP_CONDITION') - { - Ext.Ajax.request({ - url : '../steps/conditions_Save.php', - method: 'POST', - params: - { - PRO_UID : pro_uid, - STEP_UID : getObjectGridRow[0].data.STEP_UID, - STEP_CONDITION : getObjectGridRow[0].data.STEP_CONDITION - }, - success: function (response){ - Ext.MessageBox.alert ('Status','Objects has been edited successfully '); - } - }) - } - else if (FieldSelected=='ST_CONDITION') - { - Ext.Ajax.request({ - url : '../steps/steps_Ajax.php', - method: 'POST', - params: - { - action : 'saveTriggerCondition', - PRO_UID : pro_uid, - STEP_UID : getObjectGridRow[0].data.STEP_UID, - ST_CONDITION : getObjectGridRow[0].data.STEP_CONDITION, - TAS_UID : taskId, - TRI_UID : getObjectGridRow[0].data.TRI_UID, - ST_TYPE : getObjectGridRow[0].data.ST_TYPE - - }, - success: function (response){ - Ext.MessageBox.alert ('Status','Objects has been edited successfully '); - } - }) - } - - window.hide(); - - - break; - case 'form': - FormSelected = workflow.formSelected; - rowSelected = this.getSelectionModel().getSelected(); - FieldSelected = workflow.fieldName; - rowLabel = rowSelected.data.variable; - var value = FormSelected.getForm().findField(FieldSelected).setValue(rowLabel); - window.hide(); - break; - - } - - } - } - }] - },{ - title:_('ID_SYSTEM'), - id:'system', - layout:'form', - listeners:{ - activate: function(tabPanel){ - // use {@link Ext.data.HttpProxy#setUrl setUrl} to change the URL for *just* this request. - var link = 'bpmn/proxyExtjs?pid='+pro_uid+'&action=getVariables&type='+tabPanel.id+'&sFieldName=form[CTO_CONDITION]&sSymbol=@@'; - varStore.proxy.setUrl(link, true); - varStore.load(); - } - }, - items:[{ - xtype: 'grid', - ds: varStore, - cm: varColumns, - width: 380, - autoHeight: true, - //plugins: [editor], - //loadMask : true, - loadingText : 'Loading...', - border: false, - listeners: { - //rowdblclick: alert("ok"), - rowdblclick: function(){ - var objectSelected = workflow.variablesAction; - switch(objectSelected) - { - case 'grid': - var getObjectGridRow = workflow.gridObjectRowSelected; - var FieldSelected = workflow.gridField; - //getting selected row of variables - var rowSelected = this.getSelectionModel().getSelected(); - var rowLabel = rowSelected.data.variable; - //Assigned new object with condition - if(typeof getObjectGridRow.colModel != 'undefined') - getObjectGridRow.colModel.config[3].editor.setValue(rowLabel); - //Assigning / updating Condition for a row - else - getObjectGridRow[0].set(FieldSelected,rowLabel); - if(CTO_UID!='') - { - Ext.Ajax.request({ - url : '../tracker/tracker_ConditionsSave.php', - method: 'POST', - params: - { - PRO_UID : pro_uid, - CTO_UID : getObjectGridRow[0].data.CTO_UID, - CTO_CONDITION : getObjectGridRow[0].data.CTO_CONDITION - }, - success: function (response){ - Ext.MessageBox.alert ('Status','Objects has been edited successfully '); - } - }) - window.hide(); - } - - break; - case 'form': - FormSelected = workflow.formSelected; - rowSelected = this.getSelectionModel().getSelected(); - FieldSelected = workflow.fieldName; - rowLabel = rowSelected.data.variable; - var value = FormSelected.getForm().findField(FieldSelected).setValue(rowLabel); - window.hide(); - break; - - } - - } - } - }] - },{ - title:_('ID_CASESLIST_APP_PRO_TITLE'), - id :'process', - layout:'form', - listeners: { - activate: function(tabPanel){ - // use {@link Ext.data.HttpProxy#setUrl setUrl} to change the URL for *just* this request. - var link = 'bpmn/proxyExtjs?pid='+pro_uid+'&action=getVariables&type='+tabPanel.id+'&sFieldName=form[CTO_CONDITION]&sSymbol=@@'; - varStore.proxy.setUrl(link, true); - varStore.load(); - } - }, - items:[{ - xtype: 'grid', - ds: varStore, - cm: varColumns, - width: 380, - autoHeight: true, - //plugins: [editor], - //loadMask : true, - loadingText : 'Loading...', - border: false, - listeners: { - //rowdblclick: alert("ok"), - rowdblclick: function(){ - var objectSelected = workflow.variablesAction; - switch(objectSelected) - { - case 'grid': - var getObjectGridRow = workflow.gridObjectRowSelected; - var FieldSelected = workflow.gridField; - //getting selected row of variables - var rowSelected = this.getSelectionModel().getSelected(); - var rowLabel = rowSelected.data.variable; - //Assigned new object with condition - if(typeof getObjectGridRow.colModel != 'undefined') - getObjectGridRow.colModel.config[3].editor.setValue(rowLabel); - //Assigning / updating Condition for a row - else - getObjectGridRow[0].set(FieldSelected,rowLabel); - Ext.Ajax.request({ - url : '../tracker/tracker_ConditionsSave.php', - method: 'POST', - params: - { - PRO_UID : pro_uid, - CTO_UID : getObjectGridRow[0].data.CTO_UID, - CTO_CONDITION : getObjectGridRow[0].data.CTO_CONDITION - }, - success: function (response){ - Ext.MessageBox.alert ('Status','Objects has been edited successfully '); - } - }) - window.hide(); - break; - case 'form': - FormSelected = workflow.formSelected; - rowSelected = this.getSelectionModel().getSelected(); - FieldSelected = workflow.fieldName; - rowLabel = rowSelected.data.variable; - var value = FormSelected.getForm().findField(FieldSelected).setValue(rowLabel); - window.hide(); - break; - - } - - } - } - }] - }] - } - - }); - - var window = new Ext.Window({ - title: _('ID_VARIABLES'), - collapsible: false, - maximizable: false, - scrollable: true, - width: 400, - height: 350, - minWidth: 200, - minHeight: 150, - autoScroll: true, - layout: 'fit', - plain: true, - buttonAlign: 'center', - items: [varForm] - }); - window.show(); -} diff --git a/workflow/engine/templates/bpmn/ProcessOptions.js b/workflow/engine/templates/bpmn/ProcessOptions.js deleted file mode 100755 index 373200f8a..000000000 --- a/workflow/engine/templates/bpmn/ProcessOptions.js +++ /dev/null @@ -1,3911 +0,0 @@ -var workflow = {}; - -var ProcessOptions = function(id){ - //Workflow.call(this,id); -}; - -//ProcessOptions.prototype=new Workflow; -//ProcessOptions.prototype.type="ProcessOptions"; - -/** - * 'addDynaform' function that will allow adding new dynaforms and showing list of - * dynaforms available - */ -ProcessOptions.prototype.addDynaform= function(_5625) -{ - var dynaFields = Ext.data.Record.create([ - {name: 'DYN_UID'}, - {name: 'DYN_TYPE'}, - {name: 'DYN_TITLE'}, - {name: 'DYN_DESCRIPTION'}, - {name: 'TAS_EDIT'}, - {name: 'TAS_VIEW'}, - {name: 'ACTION'} - ]); - - var editor = new Ext.ux.grid.RowEditor({ - saveText: 'Update' - }); - - var btnAdd = new Ext.Button({ - id: 'btnEdit', - text: _('ID_NEW'), - iconCls: 'button_menu_ext ss_sprite ss_add', - //iconCls: 'application_add', - handler: function () { - dynaformDetails.getForm().reset(); - dynaformDetails.getForm().items.items[0].focus('',200); - dynaformDetails.getForm().items.items[1].setValue('normal'); - formWindow.show(); - } - }); - - //edit dynaform Function - var editDynaform = function() { - var rowSelected = Ext.getCmp('dynaformGrid').getSelectionModel().getSelected(); - - if( rowSelected ) { - //location.href = '../dynaforms/dynaforms_Editor?PRO_UID='+pro_uid+'&DYN_UID='+rowSelected.data.DYN_UID+'&bpmn=1' - var url = 'dynaforms/dynaforms_Editor?PRO_UID='+pro_uid+'&DYN_UID='+rowSelected.data.DYN_UID+'&bpmn=1'; - Ext.getCmp('mainTabPanel')._addTabFrame(rowSelected.data.DYN_UID, rowSelected.data.DYN_TITLE, url); - } else - PMExt.error('', _('ID_NO_SELECTION_WARNING')); - } - - var removeDynaform = function() { - ids = Array(); - - editor.stopEditing(); - var rowsSelected = Ext.getCmp('dynaformGrid').getSelectionModel().getSelections(); - - if( rowsSelected.length == 0 ) { - PMExt.error('', _('ID_NO_SELECTION_WARNING')); - return false; - } - - for(i=0; i"+TRANSLATIONS.ID_DESCRIPTION+": {DYN_DESCRIPTION}

") - }); - - var dynaformColumns = new Ext.grid.ColumnModel({ - defaults: { - width: 90, - sortable: true - }, - columns: [ - expander, - { - header: _('ID_TITLE_FIELD'), - dataIndex: 'DYN_TITLE', - width: 280 - },{ - header: _('ID_TYPE'), - dataIndex: 'DYN_TYPE', - width: 90 - },{ - sortable: false, - header: _('ID_TAS_EDIT'), - dataIndex: 'TAS_EDIT', - width: 110 - },{ - sortable: false, - header: _('ID_TAS_VIEW'), - dataIndex: 'TAS_VIEW', - width: 110 - } - ] - }); - - - var addTableColumns = new Ext.grid.ColumnModel({ - columns: [ - new Ext.grid.RowNumberer(), - { - id: 'FLD_NAME', - header: _('ID_PRIMARY_KEY'), - dataIndex: 'FLD_NAME', - width: 200, - editable: false, - sortable: true, - editor: new Ext.form.TextField({ - allowBlank: false - }) - },{ - id: 'PRO_VARIABLE', - header: _('ID_VARIABLES'), - dataIndex: 'PRO_VARIABLE', - width: 200, - sortable: true, - editor: new Ext.form.TextField({ - allowBlank: false - }) - },{ - sortable: false, - renderer: function(val){return '';} - } - ] - }); - - var dynaformGrid = new Ext.grid.GridPanel({ - store: taskDynaform, - id : 'dynaformGrid', - loadMask: true, - loadingText: 'Loading...', - //renderTo: 'cases-grid', - frame: false, - autoHeight:false, - minHeight:400, - height :400, - width: '', - layout: 'fit', - cm: dynaformColumns, - stateful : true, - stateId : 'grid', - plugins: expander, - stripeRows: true, - tbar: tb, - bbar: new Ext.PagingToolbar({ - pageSize: 10, - store: taskDynaform, - displayInfo: true, - displayMsg: 'Displaying dynaforms {0} - {1} of {2}', - emptyMsg: "No users to display", - items:[] - }), - viewConfig: {forceFit: true} - }); - - //connecting context menu to grid - dynaformGrid.addListener('rowcontextmenu', onDynaformsContextMenu,this); - dynaformGrid.addListener('rowdblclick', editDynaform,this); - - //by default the right click is not selecting the grid row over the mouse - //we need to set this four lines - dynaformGrid.on('rowcontextmenu', function (grid, rowIndex, evt) { - var sm = grid.getSelectionModel(); - sm.selectRow(rowIndex, sm.isSelected(rowIndex)); - }, this); - - //prevent default - dynaformGrid.on('contextmenu', function (evt) { - evt.preventDefault(); - }, this); - - function onDynaformsContextMenu(grid, rowIndex, e) { - e.stopEvent(); - var coords = e.getXY(); - dynaformsContextMenu.showAt([coords[0], coords[1]]); - } - - var dynaformsContextMenu = new Ext.menu.Menu({ - id: 'messageContextMenu', - items: [{ - text: _('ID_EDIT'), - iconCls: 'button_menu_ext ss_sprite ss_pencil', - handler: editDynaform - },{ - text: _('ID_DELETE'), - icon: '/images/delete.png', - handler: removeDynaform - },{ - text: _('ID_UID'), - handler: function(){ - var rowSelected = Ext.getCmp('dynaformGrid').getSelectionModel().getSelected(); - workflow.createUIDButton(rowSelected.data.DYN_UID); - } - } - ] - }); - - - - var dynaformDetails = new Ext.FormPanel({ - labelWidth : 100, - buttonAlign : 'center', - width : 490, - height : 420, - bodyStyle : 'padding:10px 0 0 10px;', - autoHeight: true, - items: - [ -// { -// xtype: 'fieldset', -// layout: 'fit', -// border:true, -// title: _('ID_SELECT_DYNAFORM'), -// width: 500, -// collapsible: false, -// labelAlign: 'top', -// items:[{ -// xtype: 'radiogroup', -// //id: 'dynaformType', -// layout: 'fit', -// fieldLabel: _('ID_TYPE'), -// itemCls: 'x-check-group-alt', -// columns: 1, -// items: [ -// { -// boxLabel: _('ID_BLANK_DYNAFORM'), -// name: 'DYN_SOURCE', -// inputValue: 'blankDyna', -// checked: true -// }, -// { -// boxLabel: _('ID_PM_DYNAFORM'), -// name: 'DYN_SOURCE', -// inputValue: 'pmTableDyna' -// }], -// listeners: { -// change: function(radiogroup, radio) { -// if(radio.inputValue == 'blankDyna') -// { -// Ext.getCmp("blankDynaform").show(); -// var f = form.findField('yourField'); -// f.container.up('div.x-form-item').hide(); -// } -// else -// { -// Ext.getCmp("blankDynaform").hide(); -// Ext.getCmp("pmTableDynaform").show(); -// } -// } -// } -// }] -// }, - - { - xtype: 'fieldset', - id: 'blankDynaform', - border:true, - hidden: false, - title: _('ID_DYNAFORM_INFORMATION'), - width: 500, - items:[{ - xtype : 'textfield', - fieldLabel: _('ID_TITLE'), - name : 'DYN_TITLE1', - width : 350, - allowBlank: false - },{ - width : 350, - xtype : 'combo', - allowBlank : false, - mode : 'local', - editable : false, - fieldLabel : _('ID_TYPE'), - triggerAction : 'all', - forceSelection : true, - name : 'DYN_TYPE', - valueField : 'value', - displayField : 'name', - value : 'normal', - store : new Ext.data.JsonStore({ - fields : ['value', 'name'], - data : [ - {value: 'normal', name : _('ID_NORMAL')}, - {value: 'grid', name : _('ID_GRID')} - ] - }) - },{ - xtype : 'textarea', - fieldLabel: _('ID_DESCRIPTION'), - name : 'DYN_DESCRIPTION1', - height : 120, - width : 350 - } - ] - } -// ,{ -// xtype: 'fieldset', -// id: 'pmTableDynaform', -// border:true, -// hidden: true, -// title: 'Dynaform Information', -// width: 500, -// items:[{ -// width: 350, -// xtype: 'combo', -// mode: 'local', -// editable: true, -// triggerAction: 'all', -// forceSelection: true, -// fieldLabel: _('ID_CREATE_PM_TABLE'), -// emptyText : 'Select Table', -// displayField: 'ADD_TAB_NAME', -// valueField: 'ADD_TAB_UID', -// value : '---------------------------', -// store : additionalTables, -// onSelect: function(record, index){ -// var link = 'bpmn/proxyExtjs?tabId='+record.data.ADD_TAB_UID+'&action=getPMTableDynaform'; -// tablesFieldsStore.proxy.setUrl(link, true); -// tablesFieldsStore.load(); -// -// Ext.getCmp("fieldsGrid").show(); -// Ext.getCmp("pmTable").setValue(record.data.ADD_TAB_UID); -// -// this.setValue(record.data[this.valueField || this.displayField]); -// this.collapse(); -// } -// },{ -// xtype:'hidden',//<--hidden field -// name:'ADD_TABLE', -// id :'pmTable' -// }, -// { -// xtype : 'textfield', -// fieldLabel: _('ID_TITLE'), -// name : 'DYN_TITLE2', -// allowBlank: false, -// width : 350 -// },{ -// xtype : 'textarea', -// fieldLabel: _('ID_DESCRIPTION'), -// name : 'DYN_DESCRIPTION2', -// height : 120, -// width : 350 -// }, -// { -// xtype: 'grid', -// id:'fieldsGrid', -// hidden: true, -// store: tablesFieldsStore, -// cm: addTableColumns, -// width: 500, -// //height: 300, -// autoHeight: true, -// clicksToEdit: 1, -// plugins: [editor], -// //loadMask : true, -// loadingText : 'Loading...', -// border: false -// //renderTo : Ext.getBody() -// } -// ] -// } - ], buttons: [{ - text: _('ID_SAVE'), - handler: function(){ - var getForm = dynaformDetails.getForm().getValues(); - //var sDynaformType = getForm.DYN_TYPE; - var sDynaformType = dynaformDetails.getForm().items.items[1].getValue(); - if ( sDynaformType == 'normal' || sDynaformType == '' ) - sDynaformType = 'xmlform'; - else - sDynaformType = 'grid'; - -// if ( getForm.DYN_SOURCE == 'blankDyna') -// { - var sTitle = getForm.DYN_TITLE1; - var sDesc = getForm.DYN_DESCRIPTION1; -// } -// else -// { -// var sAddTab = getForm.ADD_TABLE; -// var aStoreFields = tablesFieldsStore.data.items; -// var fName = new Array(); -// var pVar = new Array(); -// for(var i=0;i"+TRANSLATIONS.ID_DESCRIPTION+": {DBS_DESCRIPTION}

" - ) - }); - - - var dbGridColumn = new Ext.grid.ColumnModel({ - columns: [ - expander, - { - id: 'DBS_TYPE', - header: _('ID_TYPE'), - dataIndex: 'DBS_TYPE', - //width: 100, - editable: false, - sortable: true, - editor: new Ext.form.TextField({ - //allowBlank: false - }) - },{ - id: 'DBS_SERVER', - header: _('ID_SERVER'), - dataIndex: 'DBS_SERVER', - //width: 100, - sortable: true, - editor: new Ext.form.TextField({ - //allowBlank: false - }) - },{ - id: 'DBS_DATABASE_NAME', - header: _('ID_DATABASE_NAME'), - dataIndex: 'DBS_DATABASE_NAME', - width: 150, - sortable: true, - editor: new Ext.form.TextField({ - // allowBlank: false - }) - },{ - id: 'DBS_DESCRIPTION', - header: _('ID_DESCRIPTION'), - dataIndex: 'DBS_DESCRIPTION', - width: 100, - sortable: true, - editor: new Ext.form.TextField({ - }) - } - ] - }); - - var dbGrid = new Ext.grid.GridPanel({ - store: dbStore, - id : 'dbConnGrid', - loadMask: true, - loadingText: 'Loading...', - //renderTo: 'cases-grid', - frame: false, - autoHeight:false, - clicksToEdit: 1, - width:480, - minHeight:400, - height :380, - layout: 'fit', - cm: dbGridColumn, - plugins: expander, - stripeRows: true, - tbar: tb, - bbar: new Ext.PagingToolbar({ - pageSize: 10, - store: dbStore, - displayInfo: true, - displayMsg: 'Displaying DB Connection {0} - {1} of {2}', - emptyMsg: "No DB Connection to display", - items:[] - }), - viewConfig: {forceFit: true} - }); - - //connecting context menu to grid - dbGrid.addListener('rowcontextmenu', ondbGridContextMenu,this); - - //by default the right click is not selecting the grid row over the mouse - //we need to set this four lines - dbGrid.on('rowcontextmenu', function (grid, rowIndex, evt) { - var sm = grid.getSelectionModel(); - sm.selectRow(rowIndex, sm.isSelected(rowIndex)); - }, this); - - //prevent default - dbGrid.on('contextmenu', function (evt) { - evt.preventDefault(); - }, this); - - function ondbGridContextMenu(grid, rowIndex, e) { - e.stopEvent(); - var coords = e.getXY(); - dbGridContextMenu.showAt([coords[0], coords[1]]); - } - - var dbGridContextMenu = new Ext.menu.Menu({ - id: 'messageContextMenu', - items: [{ - text: _('ID_EDIT'), - iconCls: 'button_menu_ext ss_sprite ss_pencil', - handler: editDBConn - },{ - text: _('ID_DELETE'), - icon: '/images/delete.png', - handler: removeDBConn - },{ - text: _('ID_UID'), - handler: function(){ - var rowSelected = Ext.getCmp('dbConnGrid').getSelectionModel().getSelected(); - workflow.createUIDButton(rowSelected.data.DBS_UID); - } - } - ] - }); - - - var dbconnForm =new Ext.FormPanel({ - // title:"Add new Database Source", - collapsible: false, - maximizable: true, - //allowBlank:false, - width:400, - frame:false, - autoDestroy : true, - monitorValid : true, - plain: true, - bodyStyle : 'padding:10px 0 0 10px;', - buttonAlign: 'center', - items:[{ - xtype: 'combo', - width: 200, - mode: 'local', - editable: false, - fieldLabel: _('ID_ENGINE'), - triggerAction: 'all', - forceSelection: true, - name: 'DBS_TYPE', - displayField: 'name', - emptyText : 'Select Format', - valueField : 'value', - allowBlank: false, - //value : 'Select', - store: new Ext.data.JsonStore({ - fields : ['name', 'value'], - data : [ - {name : 'Select', value: 'select'}, - {name : 'MySql', value: 'MySql'}, - {name : 'PostGreSql', value: 'PostGreSql'}, - {name : 'Microsoft SQL server', value: 'Microsoft SQL server'} - ]}), - onSelect: function(record, index) { - //Show-Hide Format Type Field - if(record.data.value == 'MySql') - { - Ext.getCmp("encode").show(); - Ext.getCmp("postgre").hide(); - dbconnForm.getForm().findField('DBS_PORT').setValue('3306'); - } - else if(record.data.value == 'PostGreSql') - { - Ext.getCmp("postgre").show(); - Ext.getCmp("encode").hide(); - dbconnForm.getForm().findField('DBS_PORT').setValue('5432'); - } - else - { - Ext.getCmp("sqlserver").show(); - Ext.getCmp("postgre").hide(); - dbconnForm.getForm().findField('DBS_PORT').setValue('1433'); - } - this.setValue(record.data[this.valueField || this.displayField]); - this.collapse(); - } - },{ - xtype: 'fieldset', - id: 'encode', - border:false, - hidden: true, - items: [{ - xtype: 'combo', - width: 220, - mode: 'local', - // hidden: true, - editable: false, - fieldLabel: _('ID_ENCODE'), - triggerAction: 'all', - forceSelection: true, - //dataIndex : 'ENGINE', - displayField: 'value', - valueField: 'name', - name: 'DBS_ENCODE', - store: new Ext.data.JsonStore({ - fields : ['name', 'value'], - data : [ - {name:'armscii8', value:'armscii8 - ARMSCII-8 Armenian'}, - {name:'ascii', value:'ascii - US ASCII'}, - {name:'big5', value:'big5 - Big5 Traditional Chinese'}, - {name:'binary', value: 'binary - Binary pseudo charset'}, - {name:'cp850', value:'cp850 - DOS West European'}, - {name:'cp852', value: 'cp852 - DOS Central European'}, - {name:'cp866', value:'cp866 - DOS Russian'}, - {name:'cp932', value: 'cp932] - SJIS for Windows Japanese'}, - {name:'cp1250', value: 'cp1250 - Windows Central European'}, - {name:'cp1251', value: 'cp1251 - Windows Cyrillic'}, - {name:'cp1256', value: 'cp1256 - Windows Arabic'}, - {name:'cp1257', value: 'cp1257 - Windows Baltic'}, - {name:'dec8', value:'dec8 - DEC West European'}, - {name:'eucjpms', value: 'eucjpms - UJIS for Windows Japanese'}, - {name:'euckr', value: 'euckr - EUC-KR Korean'}, - {name:'gb2312', value: 'gb2312 - GB2312 Simplified Chinese'}, - {name:'gbk', value: 'gbk - GBK Simplified Chinese'}, - {name:'geostd8', value: 'geostd8 - GEOSTD8 Georgian'}, - {name:'greek', value: 'greek - ISO 8859-7 Greek'}, - {name:'hebrew', value: 'hebrew - ISO 8859-8 Hebrew'}, - {name:'hp8', value: 'hp8 - HP West European'}, - {name:'keybcs2', value: 'keybcs2 - DOS Kamenicky Czech-Slovak'}, - {name:'koi8r', value:'koi8r - KOI8-R Relcom Russian'}, - {name:'koi8u', value: 'koi8u - KOI8-U Ukrainian'}, - {name:'latin1', value:'latin1 - cp1252 West European'}, - {name:'latin2', value:'latin2 - ISO 8859-2 Central European'}, - {name:'latin5', value:'latin5 - ISO 8859-9 Turkish'}, - {name:'latin7', value: 'atin7 - ISO 8859-13 Baltic'}, - {name:'macce', value: 'macce - Mac Central European'}, - {name:'macroman', value:'macroman - Mac West European'}, - {name:'sjis', value:'sjis - Shift-JIS Japanese'}, - {name:'swe7', value:'swe7 - 7bit Swedish'}, - {name:'tis620', value: 'tis620 - TIS620 Thai'}, - {name:'ucs2', value:'ucs2 - UCS-2 Unicode'}, - {name:'ujis', value:'ujis - EUC-JP Japanese'}, - {name:'utf8', value:'utf8 - UTF-8 Unicode'} - ]}), - onSelect: function(record, index){ - dbconnForm.getForm().findField('DBS_ENCODE').setValue(record.data.value); - this.setValue(record.data[this.valueField || this.displayField]); - this.collapse(); - } - }] - - },{ - xtype: 'fieldset', - id: 'postgre', - border:false, - hidden: true, - items:[{ - xtype: 'combo', - width: 220, - mode: 'local', - // hidden: true, - editable:false, - fieldLabel:_('ID_ENCODE'), - triggerAction: 'all', - forceSelection: true, - //dataIndex : 'ENGINE', - displayField: 'name', - valueField: 'value', - name: 'DBS_ENCODE', - store: new Ext.data.JsonStore({ - fields : ['name', 'value'], - data : [ - {name:"BIG5", value:"BIG5"}, - {name:"EUC_CN", value:"EUC_CN"}, - {name:"EUC_JP", value:"EUC_JP"}, - {name:"EUC_KR", value:"EUC_KR"}, - {name:"EUC_TW", value:"EUC_TW"}, - {name:"GB18030", value:"GB18030"}, - {name:"GBK", value:"GBK"}, - {name:"ISO_8859_5", value:"ISO_8859_5"}, - {name:"ISO_8859_6", value:"ISO_8859_6"}, - {name:"ISO_8859_7", value:"ISO_8859_7"}, - {name:"ISO_8859_8", value: "ISO_8859_8"}, - {name:"JOHAB", value:"JOHAB"}, - {name:"KOI8", value: "KOI8"}, - {name:"selected", value: "LATIN1"}, - {name:"LATIN2", value:"LATIN2"}, - {name:"LATIN3", value:"LATIN3"}, - {name:"LATIN4", value: "LATIN4"}, - {name:"LATIN5", value:"LATIN5"}, - {name:"LATIN6", value: "LATIN6"}, - {name:"LATIN7", value:"LATIN7"}, - {name:"LATIN8", value:"LATIN8"}, - {name:"LATIN9", value:"LATIN9"}, - {name:"LATIN10", value:"LATIN10"}, - {name:"SJIS", value:"SJIS"}, - {name:"SQL_ASCII", value:"SQL_ASCII"}, - {name:"UHC", value: "UHC"}, - {name:"UTF8", value: "UTF8"}, - {name:"WIN866", value: "WIN866"}, - {name:"WIN874", value:"WIN874"}, - {name:"WIN1250", value:"WIN1250"}, - {name:"WIN1251", value:"WIN1251"}, - {name:"WIN1252", value:"WIN1252"}, - {name:"WIN1256", value:"WIN1256"}, - {name:"WIN1258", value:"WIN1258"} - ]}), - onSelect: function(record, index){ - dbconnForm.getForm().findField('DBS_ENCODE').setValue(record.data.value); - this.setValue(record.data[this.valueField || this.displayField]); - this.collapse(); - } - }] - },{ - xtype: 'fieldset', - id: 'sqlserver', - border:false, - hidden: true, - items:[{ - xtype: 'combo', - width: 220, - mode: 'local', - editable: false, - fieldLabel: _('ID_ENCODE'), - triggerAction: 'all', - forceSelection: true, - //dataIndex : 'ENGINE', - displayField: 'name', - valueField: 'value', - name: 'DBS_ENCODE', - store: new Ext.data.JsonStore({ - fields : ['name', 'value'], - data : [ - {name:'utf8', value: 'utf8'} - ]}), - onSelect: function(record, index){ - dbconnForm.getForm().findField('DBS_ENCODE').setValue(record.data.value); - this.setValue(record.data[this.valueField || this.displayField]); - this.collapse(); - } - }] - - },{ - xtype: 'textfield', - fieldLabel: _('ID_SERVER'), - name: 'DBS_SERVER', - width: 200, - allowBlank: false - },{ - xtype: 'textfield', - fieldLabel: _('ID_DATABASE_NAME'), - name: 'DBS_DATABASE_NAME', - width: 200, - allowBlank: false - },{ - xtype: 'textfield', - fieldLabel: _('ID_USERNAME'), - name: 'DBS_USERNAME', - width: 200, - allowBlank: false - },{ - xtype: 'textfield', - fieldLabel: _('ID_CACHE_PASSWORD'), - inputType:'password', - width: 200, - name: 'DBS_PASSWORD', - allowBlank: true - },{ - xtype: 'textfield', - fieldLabel: _('ID_PORT'), - name: 'DBS_PORT', - width: 200, - //id:'port', - //allowBlank: false, - editable:false - },{ - xtype: 'textarea', - fieldLabel: _('ID_DESCRIPTION'), - name: 'DBS_DESCRIPTION', - allowBlank: true, - width: 220, - height:100 - },{ - id : 'DBS_UID', - xtype: 'hidden', - name : 'DBS_UID' - },{ - id : 'DBS_ENCODE', - xtype: 'hidden', - name : 'DBS_ENCODE' - }], - buttons: [{text:_('ID_TEST_CONNECTION'), - id: 'test', - //formbind: true, - handler: function(){ - // testConnWindow.show(); - } - },{ - text: _('ID_SAVE'), - formBind :true, - handler: function(){ - var getForm = dbconnForm.getForm().getValues(); - var dbConnUID = getForm.DBS_UID; - var Type = getForm.DBS_TYPE; - var Server = getForm.DBS_SERVER; - var DatabaseName = getForm.DBS_DATABASE_NAME; - var Username = getForm.DBS_USERNAME; - var Password = getForm.DBS_PASSWORD; - var Port = getForm.DBS_PORT; - var Description = getForm.DBS_DESCRIPTION; - var encode = getForm.DBS_ENCODE; - - - if(dbConnUID=='') - { - Ext.Ajax.request({ - url : '../dbConnections/dbConnectionsAjax.php', - method: 'POST', - params:{ - dbs_uid :dbConnUID, - type :Type, - server :Server, - db_name :DatabaseName, - user :Username , - passwd :Password, - port :Port, - desc :Description, - PROCESS :pro_uid, - enc :encode, - action :'saveConnection' - }, - success: function(response) { - PMExt.notify( _('ID_STATUS') , _('ID_DBS_CONNECTION_SAVE') ); - } - }); - } - else - { - Ext.Ajax.request({ - url : '../dbConnections/dbConnectionsAjax.php', - method: 'POST', - params:{ - dbs_uid :dbConnUID, - type :Type, - server :Server, - db_name :DatabaseName, - user :Username , - passwd :Password, - port :Port, - PROCESS :pro_uid, - desc :Description, - enc :encode, - action :'saveEditConnection' - }, - success: function(response) { - PMExt.notify( _('ID_STATUS') , _('ID_DBS_CONNECTION_EDIT') ); - } - }); - } - formWindow.hide(); - dbStore.reload(); - } - },{ - text: _('ID_CANCEL'), - handler: function(){ - // when this button clicked, - formWindow.hide(); - } - }] - }) - - - var formWindow = new Ext.Window({ - title: _('ID_DBS_SOURCE'), - collapsible: false, - maximizable: true, - width: 400, - //autoHeight: true, - //height: 400, - //layout: 'fit', - plain: true, - buttonAlign: 'center', - items: dbconnForm - }); - - var gridWindow = new Ext.Window({ - title: _('ID_DBS_LIST'), - collapsible: false, - maximizable: true, - width: 480, - //autoHeight: true, - height: 350, - //layout: 'fit', - plain: true, - buttonAlign: 'center', - items: dbGrid - }); - gridWindow.show(); -} -*/ - -ProcessOptions.prototype.addInputDoc= function(_5625) -{ - var gridWidow; - var inputDocGrid; - var inputDocStore; - var expander; - var inputDocColumns; - var render_version; - var newButton; - var editButton; - var deleteButton; - var saveButton; - var cancelButton; - var smodel; - var bbarpaging; - var idocsContextMenu; - var newIDocWindow; - var inputDocForm; - - //Renderer for Versioning Field - render_version = function(value){ - var out = ''; - switch(value){ - case '0': out = 'No'; break; - case '1': out = 'Yes'; break; - } - return out; - } - - - - newButton = new Ext.Action({ - text : _('ID_NEW'), - iconCls: 'button_menu_ext ss_sprite ss_add', - handler: function(){ - inputDocForm.getForm().reset(); - Ext.getCmp('idoc_FORM_NEEDED').setValue('VIRTUAL'); - Ext.getCmp('idoc_VERSIONING').setValue('0'); - inputDocForm.getForm().findField('INP_DOC_TAGS').setValue('INPUT'); - inputDocForm.getForm().findField('PRO_UID').setValue(pro_uid); - newIDocWindow.setTitle(_('ID_NEW_INPUTDOCS')); - newIDocWindow.show(); - } - }); - - editButton = new Ext.Action({ - text : _('ID_EDIT'), - iconCls: 'button_menu_ext ss_sprite ss_pencil', - disabled: true, - handler: function(){ - Ext.getCmp('designerTab').getEl().mask(_('ID_PROCESSING')); - rowselected = inputDocGrid.getSelectionModel().getSelected(); - Ext.Ajax.request({ - url: 'processOptionsProxy/loadInputDoc', - params: {IDOC_UID: rowselected.data.INP_DOC_UID}, - success: function(r,o){ - Ext.getCmp('designerTab').getEl().unmask(); - var res = Ext.decode(r.responseText); - if (res.success){ - inputDocForm.getForm().reset(); - Ext.getCmp('idoc_FORM_NEEDED').setValue(res.data.INP_DOC_FORM_NEEDED); - if (res.data.INP_DOC_FORM_NEEDED != 'VIRTUAL'){ - Ext.getCmp('formType').setValue(res.data.INP_DOC_ORIGINAL); - Ext.getCmp("formType").enable(); - } - Ext.getCmp('idoc_VERSIONING').setValue(res.data.INP_DOC_VERSIONING); - inputDocForm.getForm().findField('INP_DOC_TITLE').setValue(res.data.INP_DOC_TITLE); - inputDocForm.getForm().findField('INP_DOC_DESCRIPTION').setValue(res.data.INP_DOC_DESCRIPTION); - inputDocForm.getForm().findField('INP_DOC_DESTINATION_PATH').setValue(res.data.INP_DOC_DESTINATION_PATH); - inputDocForm.getForm().findField('INP_DOC_TAGS').setValue(res.data.INP_DOC_TAGS); - inputDocForm.getForm().findField('INP_DOC_UID').setValue(res.data.INP_DOC_UID); - inputDocForm.getForm().findField('PRO_UID').setValue(pro_uid); - newIDocWindow.setTitle(_('ID_EDIT_INPUTDOCS')); - newIDocWindow.show(); - }else{ - PMExt.notify(_('ID_REQUEST_DOCUMENTS'),res.msg); - } - }, - failure: function(r,o){ - Ext.getCmp('designerTab').getEl().unmask(); - PMExt.notify( _('ID_STATUS') , _('ID_LOAD_FAILED')); - } - }); - } - }); - - deleteButton = new Ext.Action({ - text : _('ID_DELETE'), - iconCls: 'button_menu_ext ss_sprite ss_delete', - disabled: true, - handler : function(){ - Ext.getCmp('designerTab').getEl().mask(_('ID_PROCESSING')); - rowselected = inputDocGrid.getSelectionModel().getSelected(); - Ext.Ajax.request({ - url: 'processOptionsProxy/canDeleteInputDoc', - params: {PRO_UID: pro_uid, IDOC_UID: rowselected.data.INP_DOC_UID}, - success: function(r,o){ - Ext.getCmp('designerTab').getEl().unmask(); - var res = Ext.decode(r.responseText); - if (res.success){ - Ext.Msg.confirm(_('ID_CONFIRM'),_('ID_CONFIRM_DELETE_INPUT_DOC'), function(btn, text){ - if (btn=='yes'){ - Ext.getCmp('designerTab').getEl().mask(_('ID_PROCESSING')); - Ext.Ajax.request({ - url: 'processOptionsProxy/deleteInputDoc', - params: {PRO_UID: pro_uid, IDOC_UID: rowselected.data.INP_DOC_UID}, - success: function(r,o){ - Ext.getCmp('designerTab').getEl().unmask(); - var resp = Ext.decode(r.responseText); - if (resp.success){ - editButton.disable(); - deleteButton.disable(); - inputDocGrid.store.load(); - PMExt.notify(_('ID_REQUEST_DOCUMENTS'),resp.msg); - }else{ - PMExt.error(_('ID_ERROR'), resp.msg); - } - }, - failure: function(r,o){ - Ext.getCmp('designerTab').getEl().unmask(); - PMExt.notify( _('ID_STATUS') , _('ID_LOAD_FAILED')); - } - - }); - } - }); - }else{ - PMExt.warning(_('ID_REQUEST_DOCUMENTS'),_('ID_MSG_CANNOT_DELETE_INPUT_DOC')); - } - }, - failure: function(r,o){ - Ext.getCmp('designerTab').getEl().unmask(); - PMExt.notify( _('ID_STATUS') , _('ID_LOAD_FAILED')); - } - }); - } - }); - - saveButton = new Ext.Action({ - text : _('ID_SAVE'), - disabled: false, - handler: function(){ - Ext.getCmp('designerTab').getEl().mask(_('ID_PROCESSING')); - inputDocForm.getForm().submit({ - success: function(f,a){ - Ext.getCmp('designerTab').getEl().unmask(); - var resp = Ext.decode(a.response.responseText); - if (resp.success){ - editButton.disable(); - deleteButton.disable(); - inputDocGrid.store.load(); - Ext.getCmp('frmNewInputDoc').hide(); - PMExt.notify(_('ID_REQUEST_DOCUMENTS'),resp.msg); - }else{ - PMExt.notify( _('ID_ERROR') , resp.msg); - } - }, - failure: function(f,a){ - Ext.getCmp('designerTab').getEl().unmask(); - PMExt.notify( _('ID_REQUEST_DOCUMENTS') , _('ID_SOME_FIELDS_REQUIRED')); - } - }); - } - }); - - cancelButton = new Ext.Action({ - text : _('ID_CANCEL'), - disabled: false, - handler: function(){ - Ext.getCmp('frmNewInputDoc').hide(); - } - }); - - inputDocForm = new Ext.FormPanel({ - labelWidth: 10, - autoWidth : true, - height : 380, - monitorValid : true, - autoHeight: true, - buttonAlign: 'center', - url: 'processOptionsProxy/saveInputDoc', - items: [{ - xtype : 'fieldset', - layout : 'form', - border : true, - title : _('ID_INPUT_INFO'), - autoWidth : true, - labelWidth : 150, - collapsible : false, - labelAlign : '', - plain: false, - items : [ - {xtype: 'textfield', fieldLabel: _('ID_TITLE'),width: 300,name: 'INP_DOC_TITLE', allowBlank: false}, - { - width: 300, - xtype: 'combo', - mode: 'local', - editable: false, - fieldLabel: _('ID_TYPE'), - triggerAction: 'all', - name: 'INP_DOC_FORM_NEEDED', - displayField: 'name', - valueField : 'value', - id: 'idoc_FORM_NEEDED', - autoSelect: true, - allowBlank: false, - submitValue : false, - hiddenName: 'INP_DOC_FORM_NEEDED', - store: new Ext.data.JsonStore({ - fields : ['name', 'value'], - data : [ - {name : 'Digital', value: 'VIRTUAL'}, - {name : 'Printed', value: 'REAL'}, - {name : 'Digital/Printed', value: 'VREAL'} - ] - }), - onSelect: function(record, index) { - if(record.data.value != 'VIRTUAL') { - Ext.getCmp("formType").enable(); - } - else { - Ext.getCmp("formType").disable(); - } - this.collapse(); - this.setValue(record.data[this.valueField || this.displayField]); - } - }, - { - xtype : 'combo', - id : 'formType', - width : 150, - mode : 'local', - editable : false, - hiddenName : 'INP_DOC_ORIGINAL', - disabled : true, - submitValue : false, - fieldLabel : _('ID_FORMAT'), - triggerAction : 'all', - forceSelection : true, - displayField : 'name', - valueField : 'value', - allowBlank : false, - value : 'ORIGINAL', - store : new Ext.data.JsonStore({ - fields : ['name', 'value'], - data : [ - {name : 'Original', value: 'ORIGINAL'}, - {name : 'Legal Copy', value: 'COPYLEGAL'}, - {name : 'Copy', value: 'COPY'} - ]} - ) - }, - {xtype: 'textarea', fieldLabel: _('ID_DESCRIPTION'), name: 'INP_DOC_DESCRIPTION', height: 120, width: 300}, - { - width : 150, - xtype: 'combo', - mode: 'local', - editable: false, - fieldLabel: _('ID_ENABLE_VERSIONING'), - triggerAction: 'all', - forceSelection: true, - hiddenName: 'INP_DOC_VERSIONING', - id: 'idoc_VERSIONING', - submitValue: false, - displayField: 'name', - valueField: 'value', - value : '0', - allowBlank: false, - store: new Ext.data.JsonStore({ - fields : ['name', 'value'], - data : [ - {name : 'No', value: '0'}, - {name : 'Yes', value: '1'} - ]}) - }, - { - layout :'column', - border :false, - items :[{ - layout : 'form', - border :false, - items : [{ - xtype : 'textfield', - width : 250, - fieldLabel : _('ID_DESTINATION_PATH'), - name : 'INP_DOC_DESTINATION_PATH', - anchor :'100%' - }] - },{ - //columnWidth :.4, - layout : 'form', - border :false, - items : [{ - xtype :'button', - title : ' ', - width :50, - text : '@@', - name : 'selectorigin', - handler: function (s) { - workflow.variablesAction = 'form'; - workflow.fieldName = 'INP_DOC_DESTINATION_PATH' ; - workflow.variable = '@@', - workflow.formSelected = inputDocForm; - var rowData = PMVariables(); - } - }] - }] - },{ - layout :'column', - border :false, - items :[{ - //columnWidth :.6, - layout : 'form', - border :false, - items : [{ - xtype : 'textfield', - width : 250, - //id :'tags', - fieldLabel : _('ID_TAGS'), - name : 'INP_DOC_TAGS', - anchor :'100%' - }] - },{ - //columnWidth :.4, - layout : 'form', - border :false, - items : [{ - xtype :'button', - title : ' ', - width:50, - text : '@@', - name : 'selectorigin', - handler: function (s) { - workflow.variablesAction = 'form'; - workflow.fieldName = 'INP_DOC_TAGS' ; - workflow.variable = '@@', - workflow.formSelected = inputDocForm; - var rowData = PMVariables(); - } - }] - }] - }, - {id : 'INP_DOC_UID', xtype: 'hidden', name : 'INP_DOC_UID'}, - {id : 'PRO_UID', xtype: 'hidden', name : 'PRO_UID'} - ] - }], - buttons: [saveButton, cancelButton] - }); - - - smodel = new Ext.grid.RowSelectionModel({ - singleSelect: true, - listeners:{ - rowselect: function(sm){ - editButton.enable(); - deleteButton.enable(); - }, - rowdeselect: function(sm){ - editButton.disable(); - deleteButton.disable(); - } - } - }); - - idocsContextMenu = new Ext.menu.Menu({ - items: [editButton, deleteButton] - }); - - - inputDocStore = new Ext.data.GroupingStore( { - proxy : new Ext.data.HttpProxy({ - url: 'processOptionsProxy/loadInputDocuments?PRO_UID='+pro_uid - //params: {PRO_UID: pro_uid} - }), - reader : new Ext.data.JsonReader( { - root: 'idocs', - totalProperty: 'total_idocs', - fields : [ - {name: 'INP_DOC_UID', type: 'string'}, - {name: 'PRO_UID',type: 'string'}, - {name: 'INP_DOC_TITLE', type: 'string'}, - {name: 'INP_DOC_DESCRIPTION', type: 'string'}, - {name: 'INP_DOC_VERSIONING',type: 'string'}, - {name: 'INP_DOC_DESTINATION_PATH',type: 'string'}, - {name: 'INP_DOC_TASKS', type: 'int'} - ] - }) - }); - - bbarpaging = new Ext.PagingToolbar({ - pageSize: 10, - store: inputDocStore, - displayInfo: true, - displayMsg: _('ID_GRID_PAGE_DISPLAYING_ROLES_MESSAGE') + '    ', - emptyMsg: _('ID_GRID_PAGE_NO_ROLES_MESSAGE'), - items: [] - }); - - expander = new Ext.ux.grid.RowExpander({ - tpl : new Ext.Template("

"+TRANSLATIONS.ID_DESCRIPTION+": {INP_DOC_DESCRIPTION}

") - }); - - inputDocColumns = new Ext.grid.ColumnModel({ - defaults: { - editable: false, - sortable: true - }, - columns: [ - expander, - {id: 'INP_DOC_UID', dataIndex: 'INP_DOC_UID', hidden:true, hideable:false}, - {header: _('ID_TITLE'), dataIndex: 'INP_DOC_TITLE', width: 350}, - {header: _('ID_VERSIONING'), dataIndex: 'INP_DOC_VERSIONING', width: 100, renderer: render_version}, - {header: _('ID_DESTINATION_PATH'), dataIndex: 'INP_DOC_DESTINATION_PATH', width: 150}, - {header: _('ID_TASK'), dataIndex: 'INP_DOC_TASKS', width: 100, align: 'center'} - ] - }); - - inputDocGrid = new Ext.grid.GridPanel({ - store: inputDocStore, - cm: inputDocColumns, - sm: smodel, - id: 'inputdocGrid', - loadMask: true, - frame: false, - autoWidth: true, - clicksToEdit: 1, - height:100, - layout: 'fit', - plugins: expander, - stripeRows: true, - tbar: [newButton, '-', editButton, deleteButton], - bbar: bbarpaging, - viewConfig: {forceFit: true}, - view: new Ext.grid.GroupingView({ - forceFit:true, - groupTextTpl: '{text}' - }) - }); - - //connecting context menu to grid - inputDocGrid.addListener('rowcontextmenu', onInputDocContextMenu,this); - - //by default the right click is not selecting the grid row over the mouse - //we need to set this four lines - inputDocGrid.on('rowcontextmenu', function (grid, rowIndex, evt) { - var sm = grid.getSelectionModel(); - sm.selectRow(rowIndex, sm.isSelected(rowIndex)); - }, this); - - //prevent default - inputDocGrid.on('contextmenu', function (evt) { - evt.preventDefault(); - }, this); - - function onInputDocContextMenu(grid, rowIndex, e) { - e.stopEvent(); - var coords = e.getXY(); - idocsContextMenu.showAt([coords[0], coords[1]]); - } - - inputDocGrid.store.load(); - - gridWindow = new Ext.Window({ - title: _('ID_REQUEST_DOCUMENTS'), - width: 600, - height: 350, - minWidth: 200, - minHeight: 350, - layout: 'fit', - plain: true, - items: inputDocGrid, - autoScroll: true, - modal: true - }); - - newIDocWindow = new Ext.Window({ - title: _('ID_NEW_INPUTDOCS'), - width: 550, - id: 'frmNewInputDoc', - autoHeight: true, - autoScroll: true, - closable: false, - layout: 'fit', - plain: true, - modal: true, - items: inputDocForm - }); - - gridWindow.show(); -} - -ProcessOptions.prototype.addOutputDoc= function(_5625) -{ - - - var outputDocFields = Ext.data.Record.create([ - { - name: 'OUT_DOC_UID', - type: 'string' - }, - { - name: 'OUT_DOC_TYPE', - type: 'string' - }, - { - name: 'OUT_DOC_TITLE', - type: 'string' - }, - { - name: 'OUT_DOC_DESCRIPTION', - type: 'string' - } - ]); - - - var editor = new Ext.ux.grid.RowEditor({ - saveText: _('ID_UPDATE') - }); - - var btnAdd = new Ext.Button({ - id: 'btnAdd', - text: _('ID_NEW'), - iconCls: 'button_menu_ext ss_sprite ss_add', - handler: function () { - outputDocForm.getForm().reset(); - outputDocForm.getForm().items.items[3].setValue('Portrait'); - //outputDocForm.getForm().items.items[4].setValue('Letter'); - outputDocForm.getForm().items.items[9].setValue('BOTH'); - outputDocForm.getForm().items.items[10].setValue(0); - outputDocForm.getForm().items.items[0].focus('',500); - newOPWindow.show(); - } - }); - - //edit output document Function - var editOutputDoc = function(){ - - var rowSelected = Ext.getCmp('outputdocGrid').getSelectionModel().getSelections(); - if( rowSelected.length == 0 ) { - PMExt.error('', _('ID_NO_SELECTION_WARNING')); - return false; - } - var outputDocUID = rowSelected[0].get('OUT_DOC_UID'); - - - - Ext.QuickTips.init(); - - // turn on validation errors beside the field globally - Ext.form.Field.prototype.msgTarget = 'side'; - - var bd = Ext.getBody(); - - var importOption = new Ext.Action({ - text: _('ID_LOAD_FROM_FILE'), - iconCls: 'silk-add', - icon: '/images/import.gif', - handler: function(){ - var w = new Ext.Window({ - title: '', - width: 420, - height: 140, - modal: true, - autoScroll: false, - maximizable: false, - resizable: false, - - items: [ - new Ext.FormPanel({ - /*renderTo: 'form-panel',*/ - id:'uploader', - fileUpload: true, - width: 400, - frame: true, - title: _('ID_OUT_PUT_DOC_UPLOAD_TITLE'), - autoHeight: false, - bodyStyle: 'padding: 10px 10px 0 10px;', - labelWidth: 50, - defaults: { - anchor: '90%', - allowBlank: false, - msgTarget: 'side' - }, - items: [{ - xtype: 'fileuploadfield', - id: 'form-file', - emptyText: _('ID_SELECT_TEMPLATE_FILE'), - fieldLabel: _('ID_FILE'), - name: 'templateFile', - buttonText: '', - buttonCfg: { - iconCls: 'upload-icon' - } - }], - buttons: [{ - text: _('ID_UPLOAD'), - handler: function(){ - var uploader = Ext.getCmp('uploader'); - if(uploader.getForm().isValid()){ - uploader.getForm().submit({ - url: '../outputdocs/outputdocs_Ajax?action=setTemplateFile', - waitMsg: _('ID_UPLOADING_FILE'), - success: function(o, resp){ - w.close(); - - Ext.Ajax.request({ - url: '../outputdocs/outputdocs_Ajax?action=getTemplateFile&r='+Math.random(), - success: function(response){ - top.getForm().findField('OUT_DOC_TEMPLATE').setValue(response.responseText); - if(top.getForm().findFields('OUT_DOC_TEMPLATE').getValue(response.responseText)=='') - Ext.Msg.alert(_('ID_ALERT_MESSAGE'), _('ID_INVALID_FILE')); - }, - failure: function(){}, - params: {request: 'getRows'} - }); - - }, - failure: function(o, resp){ - w.close(); - //alert('ERROR "'+resp.result.msg+'"'); - Ext.MessageBox.show({title: '', msg: resp.result.msg, buttons: - Ext.MessageBox.OK, animEl: 'mb9', fn: function(){}, icon: - Ext.MessageBox.ERROR}); - //setTimeout(function(){Ext.MessageBox.hide(); }, 2000); - } - }); - } - } - },{ - text: _('ID_CANCEL'), - handler: function(){ - // when this button clicked, - w.hide(); - } - }] - }) - ] - }); - w.show(); - } - }); - - - var top = new Ext.FormPanel({ - labelAlign: 'top', - frame:true, - title: '', - bodyStyle:'padding:5px 5px 0', - width: 790, - tbar:[importOption], - items: [ - { - xtype:'htmleditor', - //id:'OUT_DOC_TEMPLATE', - name:'OUT_DOC_TEMPLATE', - fieldLabel:'Output Document Template', - height:300, - anchor:'98%' - }], - - buttons: [{ - text: _('ID_SAVE'), - handler: function(){ - editor.stopEditing(); - Ext.Ajax.request({ - url: 'outputdocs/outputdocs_Save.php', - method: 'POST', - params: { - OUT_DOC_UID: outputDocUID, - functions:'', - OUT_DOC_TEMPLATE:top.getForm().findField('OUT_DOC_TEMPLATE').getValue() - - }, - success: function(response){ - Ext.Msg.show({ - title: '', - msg: 'Saved Successfully', - fn: function(){ - window.hide(); - }, - animEl: 'elId', - icon: Ext.MessageBox.INFO, - buttons: Ext.MessageBox.OK - }); - }, - failure: function(){} - - }); - } - },{ - text: _('ID_CANCEL'), - handler: function(){ - // when this button clicked, - window.hide(); - } - }] - }); - - top.render(document.body); - - var window = new Ext.Window({ - title: _('ID_NEW_INPUTDOCS'), - width: 650, - height: 450, - minWidth: 200, - minHeight: 450, - autoScroll: true, - layout: 'fit', - plain: true, - items: top - }); - window.show(); - - top.form.load({ - url :'bpmn/processes_Ajax.php?OUT_DOC_UID='+outputDocUID+'&action=getOutputDocsTemplates', - method: 'GET', - waitMsg:'Loading', - success:function(form, action) { - //Ext.MessageBox.alert('Message', 'Loaded OK'); - window.show(); - //OUT_DOC_TEMPLATE:Ext.getCmp('OUT_DOC_TEMPLATE').setValue() - }, - failure:function(form, action) { - PMExt.notify( _('ID_STATUS') , _('ID_LOAD_FAILED') ); - } - }); - - -} - - var removeOutputDoc = function(){ - ids = Array(); - - editor.stopEditing(); - var rowsSelected = Ext.getCmp('outputdocGrid').getSelectionModel().getSelections(); - - if( rowsSelected.length == 0 ) { - PMExt.error('', _('ID_NO_SELECTION_WARNING')); - return false; - } - - for(i=0; i"+TRANSLATIONS.ID_DESCRIPTION+": {OUT_DOC_DESCRIPTION}

" - ) - }); - - var outputDocColumns = new Ext.grid.ColumnModel({ - columns: [ - expander, - { - id: 'OUT_DOC_TITLE', - header: _('ID_TITLE'), - dataIndex: 'OUT_DOC_TITLE', - width: 280, - editable: false, - editor: new Ext.form.TextField({ - //allowBlank: false - }) - }, - { - id: 'OUT_DOC_TYPE', - header: _('ID_TYPE'), - dataIndex: 'OUT_DOC_TYPE', - editable: false, - editor: new Ext.form.TextField({ - //allowBlank: false - }) - } - ] - }); - - var outputDocGrid = new Ext.grid.GridPanel({ - store : outputDocStore, - id : 'outputdocGrid', - loadMask : true, - loadingText : 'Loading...', - //renderTo : 'cases-grid', - frame : false, - autoHeight :false, - clicksToEdit: 1, - minHeight :400, - height :400, - layout : 'fit', - cm : outputDocColumns, - stripeRows : true, - plugins: expander, - tbar : tb, - bbar: new Ext.PagingToolbar({ - pageSize: 10, - store: outputDocStore, - displayInfo: true, - displayMsg: 'Displaying Output Document {0} - {1} of {2}', - emptyMsg: "No Output Document to display", - items:[] - }), - viewConfig : {forceFit: true} - }); - - var outputDocForm = new Ext.FormPanel({ - monitorValid :true, - labelWidth : 140, - defaults : {width : 300, autoScroll:true}, - width : 300, - bodyStyle : 'padding:8px 0 0 8px;', - items : [ - { - xtype : 'textfield', - fieldLabel : _('ID_TITLE'), - allowBlank : false, - blankText : 'Enter Title of Output Document', - name : 'OUT_DOC_TITLE' - },{ - width : 450, - layout:'column', - border:false, - items:[{ - columnWidth:.8, - layout : 'form', - width : 300, - border:false, - items: [{ - xtype : 'textfield', - fieldLabel : _('ID_FILENAME_GENERATED'), - name : 'OUT_DOC_FILENAME', - allowBlank : false, - blankText : 'Select Filename generated', - anchor : '100%' - }] - },{ - columnWidth:.2, - layout: 'form', - border:false, - items: [{ - xtype:'button', - title: ' ', - text: '@@', - name: 'selectorigin', - handler: function (s) { - workflow.variablesAction = 'form'; - workflow.fieldName = 'OUT_DOC_FILENAME' ; - workflow.variable = '@#', - workflow.formSelected = outputDocForm; - var rowData = PMVariables(); - console.log(rowData); - } - }] - }] - },{ - xtype : 'textarea', - fieldLabel : _('ID_DESCRIPTION'), - name : 'OUT_DOC_DESCRIPTION', - height : 50, - width : 300 - },{ - width :150, - xtype :'combo', - mode :'local', - editable :false, - fieldLabel :_('ID_ORIENTATION'), - triggerAction :'all', - forceSelection : true, - name :'OUT_DOC_LANDSCAPE', - displayField :'name', - value :'Portrait', - valueField :'value', - store :new Ext.data.JsonStore({ - fields : ['name', 'value'], - data : [ - {name : 'Portrait', value: '0'}, - {name : 'Landscape', value: '1'}]}) - },{ - width :150, - xtype :'combo', - mode :'local', - editable :false, - fieldLabel :_('ID_MEDIA'), - forceSelection : true, - name :'OUT_DOC_MEDIA', - displayField :'name', - value :'Letter', - valueField :'value', - store : new Ext.data.JsonStore({ - fields : ['name', 'value'], - data : [ - {name : 'Letter', value: 'Letter'}, - {name : 'Legal', value: 'Legal'}, - {name : 'Executive', value: 'Executive'}, - {name : 'B5', value: 'B5'}, - {name : 'Folio', value: 'Folio'}, - {name : 'A0Oversize', value: 'A0Oversize'}, - {name : 'A0', value: 'A0'}, - {name : 'A1', value: 'A1'}, - {name : 'A2', value: 'A2'}, - {name : 'A3', value: 'A3'}, - {name : 'A4', value: 'A4'}, - {name : 'A5', value: 'A5'}, - {name : 'A6', value: 'A6'}, - {name : 'A7', value: 'A7'}, - {name : 'A8', value: 'A8'}, - {name : 'A9', value: 'A9'}, - {name : 'A10', value: 'A10'}, - {name : 'Screenshot640', value: 'Screenshot640'}, - {name : 'Screenshot800', value: 'Screenshot800'}, - {name : 'Screenshot1024', value: 'Screenshot1024'} - ] - }) - },{ - xtype : 'numberfield', - fieldLabel : _('ID_LEFT_MARGIN'), - name : 'OUT_DOC_LEFT_MARGIN', - width : 50 - },{ - xtype : 'numberfield', - fieldLabel : _('ID_RIGHT_MARGIN'), - name : 'OUT_DOC_RIGHT_MARGIN', - width : 50 - },{ - xtype : 'numberfield', - fieldLabel : _('ID_TOP_MARGIN'), - name : 'OUT_DOC_TOP_MARGIN', - width : 50 - },{ - xtype : 'numberfield', - fieldLabel : _('ID_BOTTOM_MARGIN'), - name : 'OUT_DOC_BOTTOM_MARGIN', - width : 50 - },{ - width :150, - xtype :'combo', - mode :'local', - editable :false, - fieldLabel :_('ID_OUTPUT_GENERATE'), - triggerAction :'all', - forceSelection :true, - name :'OUT_DOC_GENERATE', - displayField :'name', - value :'Doc', - valueField :'value', - store :new Ext.data.JsonStore({ - fields :['name', 'value'], - data :[ - {name : 'BOTH', value: 'BOTH'}, - {name : 'DOC', value: 'DOC'}, - {name : 'PDF', value: 'PDF'}]}) - },{ - width : 50, - xtype :'combo', - mode :'local', - editable :false, - fieldLabel :_('ID_ENABLE_VERSIONING'), - triggerAction :'all', - forceSelection :true, - name :'OUT_DOC_VERSIONING', - displayField :'name', - value :'NO', - valueField :'value', - store :new Ext.data.JsonStore({ - fields : ['name', 'value'], - data : [ - {name : 'NO', value: '0'}, - {name : 'YES', value: '1'}]}) - },{ - layout :'column', - width : 450, - border :false, - items :[{ - columnWidth :.8, - layout : 'form', - border :false, - items : [{ - xtype : 'textfield', - fieldLabel : _('ID_DESTINATION_PATH'), - name : 'OUT_DOC_DESTINATION_PATH', - anchor :'100%', - width : 300 - }] - },{ - columnWidth :.2, - layout : 'form', - border :false, - items : [{ - xtype : 'button', - title : ' ', - text : '@@', - name : 'selectorigin', - handler: function (s) { - workflow.variablesAction = 'form'; - workflow.fieldName = 'OUT_DOC_DESTINATION_PATH' ; - workflow.variable = '@@', - workflow.formSelected = outputDocForm; - var rowData = PMVariables(); - } - }] - }] - },{ - layout :'column', - width : 450, - border :false, - items :[{ - columnWidth :.8, - layout : 'form', - border :false, - items : [{ - xtype : 'textfield', - fieldLabel : _('ID_TAGS'), - name : 'OUT_DOC_TAGS', - anchor :'100%', - width : 300 - }] - },{ - columnWidth :.2, - layout : 'form', - border :false, - items : [{ - xtype :'button', - title : ' ', - text : '@@', - name : 'selectorigin', - handler: function (s) { - workflow.variablesAction = 'form'; - workflow.fieldName = 'OUT_DOC_TAGS' ; - workflow.variable = '@@', - workflow.formSelected = outputDocForm; - var rowData = PMVariables(); - } - }] - }] - },{ - id : 'OUT_DOC_UID', - xtype: 'hidden', - name : 'OUT_DOC_UID' - } - ], - buttons : [{ - text : _('ID_SAVE'), - formBind :true, - handler : function(){ - var getForm = outputDocForm.getForm().getValues(); - var sDocUID = getForm.OUT_DOC_UID; - var sDocTitle = getForm.OUT_DOC_TITLE; - var sFilename = getForm.OUT_DOC_FILENAME; - var sDesc = getForm.OUT_DOC_DESCRIPTION; - var sLandscape = getForm.OUT_DOC_LANDSCAPE; - if(getForm.OUT_DOC_LANDSCAPE == 'Portrait') - sLandscape=0; - if(getForm.OUT_DOC_LANDSCAPE == 'Landscape') - sLandscape=1; - var sMedia = getForm.OUT_DOC_MEDIA; - var sLeftMargin = getForm.OUT_DOC_LEFT_MARGIN; - var sRightMargin = getForm.OUT_DOC_RIGHT_MARGIN; - var sTopMargin = getForm.OUT_DOC_TOP_MARGIN; - var sBottomMargin = getForm.OUT_DOC_BOTTOM_MARGIN; - var sGenerated = getForm.OUT_DOC_GENERATE; - var sVersioning = getForm.OUT_DOC_VERSIONING; - if(getForm.OUT_DOC_VERSIONING == 'NO') - sVersioning=0; - if(getForm.OUT_DOC_VERSIONING == 'YES') - sVersioning=1; - var sDestPath = getForm.OUT_DOC_DESTINATION_PATH; - var sTags = getForm.OUT_DOC_TAGS; - if(sDocUID == "") - { - Ext.Ajax.request({ - url : 'outputdocs/outputdocs_Save.php', - method: 'POST', - params:{ - functions : 'lookForNameOutput', - NAMEOUTPUT : sDocTitle, - proUid : pro_uid - }, - success: function(response) { - if(response.responseText == "1") - { - Ext.Ajax.request({ - url : 'outputdocs/outputdocs_Save.php', - method: 'POST', - params:{ - functions : '', - OUT_DOC_UID : sDocUID, - OUT_DOC_TITLE : sDocTitle, - OUT_DOC_FILENAME : sFilename, - OUT_DOC_DESCRIPTION : sDesc, - OUT_DOC_LANDSCAPE : sLandscape, - OUT_DOC_MEDIA : sMedia, - OUT_DOC_LEFT_MARGIN : sLeftMargin, - OUT_DOC_RIGHT_MARGIN : sRightMargin, - OUT_DOC_TOP_MARGIN : sTopMargin, - OUT_DOC_BOTTOM_MARGIN : sBottomMargin, - OUT_DOC_GENERATE : sGenerated, - OUT_DOC_VERSIONING : sVersioning, - OUT_DOC_DESTINATION_PATH : sDestPath, - OUT_DOC_TAGS : sTags, - PRO_UID : pro_uid - }, - success: function(response) { - PMExt.notify( _('ID_STATUS') , _('OUTPUT_CREATE') ); - outputDocStore.reload(); - newOPWindow.hide(); - } - }); - - } - - - else - PMExt.error( _('ID_ERROR') , _('ID_OUTPUT_NOT_SAVE') ); - } - }); - } - else - { - Ext.Ajax.request({ - url : 'outputdocs/outputdocs_Save.php', - method: 'POST', - params:{ - functions : '', - OUT_DOC_UID : sDocUID, - OUT_DOC_TITLE : sDocTitle, - OUT_DOC_FILENAME : sFilename, - OUT_DOC_DESCRIPTION : sDesc, - OUT_DOC_LANDSCAPE : sLandscape, - OUT_DOC_MEDIA : sMedia, - OUT_DOC_LEFT_MARGIN : sLeftMargin, - OUT_DOC_RIGHT_MARGIN : sRightMargin, - OUT_DOC_TOP_MARGIN : sTopMargin, - OUT_DOC_BOTTOM_MARGIN : sBottomMargin, - OUT_DOC_GENERATE : sGenerated, - OUT_DOC_VERSIONING : sVersioning, - OUT_DOC_DESTINATION_PATH : sDestPath, - OUT_DOC_TAGS : sTags, - PRO_UID : pro_uid - }, - success: function(response) { - PMExt.notify( _('ID_STATUS') , _('ID_OUTPUT_UPDATE') ); - outputDocStore.reload(); - newOPWindow.hide(); - } - }); - - } - } - },{ - text: _('ID_CANCEL'), - handler: function(){ - // when this button clicked, - newOPWindow.hide(); - } - }], - buttonAlign : 'center' - }); - - var newOPWindow = new Ext.Window({ - title : _('ID_OUTPUT_DOCUMENTS'), - width : 520, - closable : false, - defaults :{autoScroll:true}, - height : 470, - minWidth : 200, - minHeight : 350, - layout : 'fit', - plain : true, - items : outputDocForm, - buttonAlign : 'center' - }); - - //connecting context menu to grid - outputDocGrid.addListener('rowcontextmenu', onOutputDocContextMenu,this); - - //by default the right click is not selecting the grid row over the mouse - //we need to set this four lines - outputDocGrid.on('rowcontextmenu', function (grid, rowIndex, evt) { - var sm = grid.getSelectionModel(); - sm.selectRow(rowIndex, sm.isSelected(rowIndex)); - }, this); - - //prevent default - outputDocGrid.on('contextmenu', function (evt) { - evt.preventDefault(); - }, this); - - function onOutputDocContextMenu(grid, rowIndex, e) { - e.stopEvent(); - var coords = e.getXY(); - outputdocContextMenu.showAt([coords[0], coords[1]]); - } - - var outputdocContextMenu = new Ext.menu.Menu({ - id: 'messageContextMenu', - items: [{ - text: _('ID_EDIT'), - iconCls: 'button_menu_ext ss_sprite ss_pencil', - handler: editOutputDoc - },{ - text: _('ID_PROPERTIES'), - iconCls: 'button_menu_ext ss_sprite ss_application_edit', - handler: propertiesOutputDoc - },{ - text: _('ID_DELETE'), - icon: '/images/delete.png', - handler: removeOutputDoc - },{ - text: _('ID_UID'), - handler: function(){ - var rowSelected = Ext.getCmp('outputdocGrid').getSelectionModel().getSelected(); - workflow.createUIDButton(rowSelected.data.OUT_DOC_UID); - } - } - ] - }); - - var gridWindow = new Ext.Window({ - title : _('ID_OUTPUT_DOCUMENTS'), - collapsible : false, - maximizable : false, - width : 550, - defaults :{autoScroll:true}, - height : 350, - minWidth : 200, - minHeight : 350, - layout : 'fit', - plain : true, - items : outputDocGrid, - buttonAlign : 'center' - }); - gridWindow.show(); -} - -/* -ProcessOptions.prototype.addReportTable= function(_5625) -{ - var reportFields = Ext.data.Record.create([ - { - name:'REP_TAB_UID', - type: 'string' - }, - { - name: 'REP_TAB_TITLE', - type: 'string' - }, - { - name: 'FIELD_NAME', - type: 'string' - }, - { - name: 'FIELD_UID', - type: 'string' - } - ]); - - var editor = new Ext.ux.grid.RowEditor({ - saveText: _('ID_UPDATE') - }); - - var btnAdd = new Ext.Button({ - id: 'btnAdd', - text: _('ID_NEW'), - iconCls: 'button_menu_ext ss_sprite ss_add', - handler: function () { - formWindow.show(); - reportForm.getForm().reset(); - } - }); - - //edit report table Function - var editReportTable = function() { - editor.stopEditing(); - var rowSelected = Ext.getCmp('reportTableGrid').getSelectionModel().getSelections(); - if( rowSelected.length == 0 ) { - PMExt.error('', _('ID_NO_SELECTION_WARNING')); - return false; - } - var repTabUID = rowSelected[0].get('REP_TAB_UID'); - reportForm.form.load({ - url :'bpmn/proxyExtjs.php?pid='+pro_uid+'&REP_TAB_UID=' +repTabUID+'&action=editReportTables', - method: 'GET', - waitMsg:'Loading', - success:function(form, action) { - formWindow.show(); - }, - failure:function(form, action) { - PMExt.notify( _('ID_STATUS') , _('ID_LOAD_FAILED') ); - } - }); - } - - var removeReportTable = function(){ - ids = Array(); - - editor.stopEditing(); - var rowsSelected = Ext.getCmp('reportTableGrid').getSelectionModel().getSelections(); - - if( rowsSelected.length == 0 ) { - PMExt.error('', _('ID_NO_SELECTION_WARNING')); - return false; - } - - for(i=0; i

" - ) - }); - - var reportColumns = new Ext.grid.ColumnModel({ - columns: [ - new Ext.grid.RowNumberer(), - { - id: 'REP_TAB_TITLE', - header: _('ID_TITLE'), - dataIndex: 'REP_TAB_TITLE', - width: 380, - editable: false, - editor: new Ext.form.TextField({ - //allowBlank: false - }) - } - ] - }); - - var reportGrid = new Ext.grid.GridPanel({ - store : reportStore, - id : 'reportTableGrid', - loadMask : true, - loadingText : 'Loading...', - //renderTo : 'cases-grid', - frame : false, - autoHeight :false, - clicksToEdit: 1, - width :420, - height :400, - layout : 'fit', - plugins: expander, - cm : reportColumns, - stripeRows: true, - tbar: tb, - bbar: new Ext.PagingToolbar({ - pageSize: 10, - store: reportStore, - displayInfo: true, - displayMsg: 'Displaying Report Tables {0} - {1} of {2}', - emptyMsg: "No Report Tables to display" - }), - viewConfig: {forceFit: true} - }); - - //connecting context menu to grid - reportGrid.addListener('rowcontextmenu', onreportTableContextMenu,this); - - //by default the right click is not selecting the grid row over the mouse - //we need to set this four lines - reportGrid.on('rowcontextmenu', function (grid, rowIndex, evt) { - var sm = grid.getSelectionModel(); - sm.selectRow(rowIndex, sm.isSelected(rowIndex)); - }, this); - - //prevent default - reportGrid.on('contextmenu', function (evt) { - evt.preventDefault(); - }, this); - - function onreportTableContextMenu(grid, rowIndex, e) { - e.stopEvent(); - var coords = e.getXY(); - reportTableContextMenu.showAt([coords[0], coords[1]]); - } - - var reportTableContextMenu = new Ext.menu.Menu({ - id: 'messageContextMenu', - items: [{ - text: _('ID_EDIT'), - iconCls: 'button_menu_ext ss_sprite ss_pencil', - handler: editReportTable - },{ - text: _('ID_DELETE'), - icon: '/images/delete.png', - handler: removeReportTable - },{ - text: _('ID_UID'), - handler: function(){ - var rowSelected = Ext.getCmp('reportTableGrid').getSelectionModel().getSelected(); - workflow.createUIDButton(rowSelected.data.REP_TAB_UID); - } - } - ] - }); - - var gridWindow = new Ext.Window({ - title : _('ID_REPORT_TABLES'), - collapsible : false, - maximizable : false, - width : 420, - defaults :{autoScroll:true}, - height : 350, - minWidth : 200, - minHeight : 350, - layout : 'fit', - plain : true, - items : reportGrid, - buttonAlign : 'center' - }); - gridWindow.show(); - -var reportForm =new Ext.FormPanel({ - collapsible: false, - maximizable: true, - width:450, - height:325, - frame:false, - monitorValid : true, - plain: true, - bodyStyle : 'padding:10px 0 0 10px;', - buttonAlign: 'center', - items:[{ - xtype: 'textfield', - fieldLabel: _('ID_TITLE'), - width: 250, - name: 'REP_TAB_TITLE', - allowBlank: false - },{ - - xtype: 'textfield', - fieldLabel: _('ID_TABLE_NAME'), - width: 250, - name: 'REP_TAB_NAME', - allowBlank: false - }, - { - xtype: 'combo', - width: 250, - mode: 'local', - editable:false, - fieldLabel: _('ID_TYPE'), - triggerAction: 'all', - forceSelection: true, - name: 'REP_TAB_TYPE', - displayField: 'name', - valueField : 'value', - value : 'Global', - store: new Ext.data.JsonStore({ - fields : ['name', 'value'], - data : [ - {name : 'Global', value: 'NORMAL'}, - {name : 'Grid', value: 'GRID'} - ]}), - onSelect: function(record, index) { - //Show-Hide Format Type Field - if(record.data.value == 'NORMAL') - { - Ext.getCmp("fields").show(); - Ext.getCmp("gridfields").hide(); - } - else - { - Ext.getCmp("gridfields").show(); - Ext.getCmp("fields").hide(); - } - var link = 'bpmn/proxyExtjs?pid='+pro_uid+'&type='+record.data.value+'&action=getReportTableType'; - reportTableTypeStore.proxy.setUrl(link, true); - reportTableTypeStore.load(); - - this.setValue(record.data[this.valueField || this.displayField]); - this.collapse(); - } - }, - { - xtype: 'fieldset', - id: 'fields', - border:false, - hidden: false, - items: [{ - xtype: 'multiselect', - width: 240, - height: 150, - mode: 'local', - style : 'margin-bottom:10px', - editable:true, - fieldLabel: _('ID_FIELDS'), - triggerAction: 'all', - allowblank: true, - forceSelection: false, - dataIndex : 'FIELD_NAME', - name: 'FIELDS', - valueField: 'FIELD_UID', - displayField: 'FIELD_NAME', - store: reportTableTypeStore - }] - }, { - xtype: 'fieldset', - id: 'gridfields', - border:false, - hidden: true, - align:'left', - items:[{ - xtype: 'combo', - width: 200, - mode: 'local', - editable:false, - fieldLabel: _('ID_GRID_FIELDS'), - triggerAction: 'all', - forceSelection: true, - displayField: 'name', - valueField: 'value', - name: 'REP_TAB_GRID', - store: new Ext.data.JsonStore({ - fields : ['name', 'value'], - data : [] - }) - }] - },{xtype:'hidden', name:'REP_TAB_UID'} - ], buttons: [{ - text: _('ID_SAVE'), - formBind :true, - handler: function(){ - var getForm = reportForm.getForm().getValues(); - //var pro_uid = getForm.PRO_UID; - var tableUID = getForm.REP_TAB_UID; - var Title = getForm.REP_TAB_TITLE; - var Name = getForm.REP_TAB_NAME; - var Type = getForm.REP_TAB_TYPE; - if(Type == 'Global') - Type = 'NORMAL'; - else - Type = 'GRID'; - - var Grid = getForm.REP_TAB_GRID; - var Fields = getForm.FIELDS; - - if(tableUID=='') - { - Ext.Ajax.request({ - url : '../reportTables/reportTables_Save.php', - method: 'POST', - params:{ - PRO_UID :pro_uid, - REP_TAB_UID :'', - REP_TAB_TITLE :Title, - REP_TAB_NAME :Name, - REP_TAB_TYPE :Type , - REP_TAB_GRID :Grid, - FIELDS :Fields - }, - success: function(response) { - PMExt.notify( _('ID_STATUS') , _('ID_REPORT_SAVE') ); - } - }); - } - else - { - Ext.Ajax.request({ - url : '../reportTables/reportTables_Save.php', - method: 'POST', - params:{ - PRO_UID :pro_uid, - REP_TAB_UID :tableUID, - REP_TAB_TITLE :Title, - REP_TAB_NAME :Name, - REP_TAB_TYPE :Type , - REP_TAB_GRID :Grid, - FIELDS :Fields - //REP_TAB_CONNECTION: Connection - }, - success: function(response) { - PMExt.notify( _('ID_STATUS') , _('ID_REPORT_EDITED') ); - } - - - }); - } - formWindow.hide(); - reportStore.reload(); - - } - },{ - text: _('ID_CANCEL'), - handler: function(){ - // when this button clicked, - formWindow.hide(); - } - }] - }) - -var formWindow = new Ext.Window({ - title: _('ID_NEW_REPORT_TABLE'), - collapsible: false, - maximizable: true, - width: 400, - //autoHeight: true, - height: 330, - layout: 'fit', - plain: true, - buttonAlign: 'center', - items: reportForm - }); - //gridWindow.show(); -} -*/ - - -ProcessOptions.prototype.addTriggers = function() -{ - - var triggerFields = Ext.data.Record.create([ - {name: 'TRI_UID'}, - {name: 'TRI_TITLE'}, - {name: 'TRI_DESCRIPTION'}, - {name: 'TRI_WEBBOT'} - ]); - - var editor = new Ext.ux.grid.RowEditor({ - saveText: _('ID_UPDATE') - }); - - var btnAdd = new Ext.Button({ - id: 'btnAdd', - text: _('ID_NEW'), - iconCls: 'button_menu_ext ss_sprite ss_add', - handler: function () { - triggersForm.getForm().reset(); - triggersForm.getForm().items.items[0].focus('',200); - formWindow.show(); - } - }); - - //edit report table Function - var editTriggers = function() { - editor.stopEditing(); - var rowSelected = Ext.getCmp('triggersGrid').getSelectionModel().getSelections(); - if( rowSelected.length == 0 ) { - PMExt.error('', _('ID_NO_SELECTION_WARNING')); - return false; - } - var triggerUID = rowSelected[0].get('TRI_UID'); - editTriggerForm.getForm().load({ - url :'bpmn/proxyExtjs.php?pid='+pro_uid+'&TRI_UID='+triggerUID+'&action=editTriggers', - method: 'GET', - waitMsg:'Loading', - success:function(form, action) { - Ext.getCmp('TRI_WEBBOT').setValue(action.result.data.TRI_WEBBOT); - editTriggerFormWindow.show(); - }, - failure:function(form, action) { - PMExt.notify( _('ID_STATUS') , _('ID_LOAD_FAILED') ); - } - }); - } - - var editProperties = function(){ - editor.stopEditing(); - var rowSelected = Ext.getCmp('triggersGrid').getSelectionModel().getSelections(); - if( rowSelected.length == 0 ) { - PMExt.error('', _('ID_NO_SELECTION_WARNING')); - return false; - } - var triggerUID = rowSelected[0].get('TRI_UID'); - //editPropertiesFormWindow.show(); - editPropertiesForm.form.load({ - url :'bpmn/proxyExtjs.php?pid='+pro_uid+'&TRI_UID='+triggerUID+'&action=editTriggers', - method: 'GET', - waitMsg:'Loading', - success:function(form, action) { - editPropertiesFormWindow.show(); - //Ext.getCmp("TRI_UID").setValue(triggerUID); - }, - failure:function(form, action) { - PMExt.notify( _('ID_STATUS') , _('ID_LOAD_FAILED') ); - } - }); - } - - var removeTriggers = function() { - ids = Array(); - - editor.stopEditing(); - var rowsSelected = Ext.getCmp('triggersGrid').getSelectionModel().getSelections(); - - if( rowsSelected.length == 0 ) { - PMExt.error('', _('ID_NO_SELECTION_WARNING')); - return false; - } - - for(i=0; i"+TRANSLATIONS.ID_DESCRIPTION+": {TRI_DESCRIPTION}

") - }); - - var triggersColumns = new Ext.grid.ColumnModel({ - defaults: { - width: 90, - sortable: true - }, - columns: [ - expander, - { - header: _('ID_TITLE_FIELD'), - dataIndex: 'TRI_TITLE', - width: 280 - } - ] - }); - - var tb = new Ext.Toolbar({ - items: [btnAdd, btnEdit,btnProperties,btnRemove] - }); - - var triggersGrid = new Ext.grid.GridPanel({ - store: triggerStore, - id : 'triggersGrid', - loadMask: true, - loadingText: 'Loading...', - //renderTo: 'cases-grid', - frame: false, - autoHeight:false, - minHeight:400, - height :400, - width: '', - layout: 'fit', - cm: triggersColumns, - stateful : true, - stateId : 'grid', - plugins: expander, - stripeRows: true, - tbar: tb, - bbar: new Ext.PagingToolbar({ - pageSize: 10, - store: triggerStore, - displayInfo: true, - displayMsg: 'Displaying Triggers {0} - {1} of {2}', - emptyMsg: "No Triggers to display" - }), - viewConfig: {forceFit: true} - }); - - //connecting context menu to grid - triggersGrid.addListener('rowcontextmenu', ontriggersContextMenu,this); - - //by default the right click is not selecting the grid row over the mouse - //we need to set this four lines - triggersGrid.on('rowcontextmenu', function (grid, rowIndex, evt) { - var sm = grid.getSelectionModel(); - sm.selectRow(rowIndex, sm.isSelected(rowIndex)); - }, this); - - //prevent default - triggersGrid.on('contextmenu', function (evt) { - evt.preventDefault(); - }, this); - - function ontriggersContextMenu(grid, rowIndex, e) { - e.stopEvent(); - var coords = e.getXY(); - triggersContextMenu.showAt([coords[0], coords[1]]); - } - - var triggersContextMenu = new Ext.menu.Menu({ - id: 'messageContextMenu', - items: [{ - text: _('ID_EDIT'), - iconCls: 'button_menu_ext ss_sprite ss_pencil', - handler: editTriggers - },{ - text: _('ID_PROPERTIES'), - iconCls: 'button_menu_ext ss_sprite ss_application_edit', - handler: editProperties - },{ - text: _('ID_DELETE'), - icon: '/images/delete.png', - handler: removeTriggers - },{ - text: _('ID_UID'), - handler: function(){ - var rowSelected = Ext.getCmp('triggersGrid').getSelectionModel().getSelected(); - workflow.createUIDButton(rowSelected.data.TRI_UID); - } - } - ] - }); - -var triggersForm = new Ext.FormPanel({ - labelWidth : 100, - buttonAlign : 'center', - width : 300, - height : 220, - bodyStyle : 'padding:8px 0 0 8px;', - autoHeight: true, - items: - [{ - xtype: 'textfield', - layout: 'fit', - border:true, - name: 'TRI_TITLE', - fieldLabel: _('ID_TITLE'), - width: 300, - collapsible: false, - allowBlank: false, - labelAlign: 'top' - }, - { - xtype: 'textarea', - border:true, - name: 'TRI_DESCRIPTION', - hidden: false, - fieldLabel: _('ID_DESCRIPTION'), - width: 300, - height: 120 - }], - buttons: [{ - text: _('ID_SAVE'), - //formBind :true, - handler: function(){ - var getForm = triggersForm.getForm().getValues(); - var title = getForm.TRI_TITLE; - var triggerUid = getForm.TRI_UID; - var condition = getForm.TRI_WEBBOT; - var desc = getForm.TRI_DESCRIPTION; - - if(title == '') - PMExt.notify( _('ID_ERROR') , _('ID_TRIGGER_TITLE_REQUIRED') ); - else - { - //First check whether trigger name already exist or not - Ext.Ajax.request({ - url : '../triggers/triggers_Save.php', - method: 'POST', - params: { - functions : 'lookforNameTrigger', - proUid : pro_uid, - NAMETRIGGER : title - }, - success: function(response) { - var result = response.responseText; - if(result) { - //now save trigger - Ext.Ajax.request({ - url : '../triggers/triggers_Save.php', - method: 'POST', - params:{ - //functions : 'lookforNameTrigger', - TRI_TITLE : title, - PRO_UID : pro_uid, - TRI_UID :'', - TRI_PARAM :'', - TRI_TYPE :'SCRIPT', - TRI_DESCRIPTION :desc, - TRI_WEBBOT :condition, - mode :'ext' - }, - success: function(response) { - var result = Ext.util.JSON.decode(response.responseText); - if( result.success ){ - PMExt.notify( _('ID_STATUS') , result.msg); - - //Reloading store after saving triggers - triggerStore.reload(); - formWindow.hide(); - } else { - PMExt.error(_('ID_ERROR'), result.msg); - } - } - }); - } else { - PMExt.error(_('ID_VALIDATION_ERROR'), 'There is a triggers with the same name in this process.'); - } - } - }); - formWindow.hide(); - } - } - },{ - text: _('ID_CANCEL'), - handler: function(){ - // when this button clicked, - formWindow.hide(); - } - }] - }); - - var editTriggerForm = new Ext.FormPanel({ - buttonAlign : 'center', - labelWidth : 2, - layout : 'fit', - width : 570, - height : 350, - items: - [{ - layout :'column', - border :false, - items :[{ - //columnWidth :.6, - layout : 'form', - border : false, - items : [{ -// xtype : 'textarea', - xtype : 'codepress', - language : 'generic', - id : 'TRI_WEBBOT', - width : 420, - height : 310, - name : 'TRI_WEBBOT' - }] - },{ - //columnWidth :.4, - layout : 'form', - border :false, - items : [{ - xtype :'button', - title : ' ', - width : 50, - text : '@@', - name : 'selectorigin', - handler: function (s) { - workflow.variablesAction = 'form'; - workflow.fieldName = 'TRI_WEBBOT' ; - workflow.variable = '@@', - workflow.formSelected = editTriggerForm; - var rowData = PMVariables(); - } - }] - }] - },{ - xtype: 'hidden', - name: 'TRI_UID' - }], - buttons: [{ - text: _('ID_SAVE'), - //formBind :true, - handler: function(){ - var getForm = editTriggerForm.getForm().getValues(); - var triggerUid = getForm.TRI_UID; -// var condition = getForm.TRI_WEBBOT; - var condition = Ext.getCmp('TRI_WEBBOT').getCode(); - var desc = getForm.TRI_DESCRIPTION; - Ext.Ajax.request({ - url : '../triggers/triggers_Save.php', - method: 'POST', - params:{ - PRO_UID : pro_uid, - TRI_UID : triggerUid, - TRI_TYPE : 'SCRIPT', - TRI_WEBBOT : condition, - mode : 'ext' - }, - success: function(response) { - var result = Ext.util.JSON.decode(response.responseText); - if( result.success ){ - PMExt.notify( _('ID_STATUS') , result.msg); - - //Reloading store after saving triggers - triggerStore.reload(); - editTriggerFormWindow.hide(); - } else { - PMExt.error(_('ID_ERROR'), result.msg); - } - } - }); - } - },{ - text: _('ID_CANCEL'), - handler: function(){ - // when this button clicked, - editTriggerFormWindow.hide(); - } - }] - }); - - var editPropertiesForm = new Ext.FormPanel({ - labelWidth : 100, - buttonAlign : 'center', - width : 400, - height : 300, - bodyStyle : 'padding:10px 0 0 10px;', - autoHeight: true, - items: - [{ - xtype: 'fieldset', - title: 'Trigger Information', - border:true, - id: 'trigger', - width: 400, - items:[{ - xtype: 'textfield', - layout: 'fit', - border:true, - name: 'TRI_TITLE', - fieldLabel: _('ID_TITLE'), - width: 250, - allowBlank: false, - labelAlign: 'top' - }, - { - xtype: 'textarea', - border:true, - name: 'TRI_DESCRIPTION', - hidden: false, - fieldLabel: _('ID_DESCRIPTION'), - width: 250, - height: 120 - }] - },{ - xtype: 'hidden', - name: 'TRI_UID' - }], - buttons: [{ - text: _('ID_SAVE'), - //formBind :true, - handler: function(){ - var getForm = editPropertiesForm.getForm().getValues(); - var triggerUid = getForm.TRI_UID; - var title = getForm.TRI_TITLE; - var desc = getForm.TRI_DESCRIPTION; - //First check whether trigger name already exist or not - Ext.Ajax.request({ - url : '../triggers/triggers_Save.php', - method: 'POST', - params: { - functions : 'lookforNameTrigger', - proUid : pro_uid, - NAMETRIGGER : title - }, - success: function(response) { - var result = response.responseText; - if(result) { - //now save trigger - Ext.Ajax.request({ - url : '../triggers/triggers_Save.php', - method: 'POST', - params:{ - TRI_TITLE : title, - PRO_UID : pro_uid, - TRI_UID :triggerUid, - TRI_PARAM :'', - TRI_TYPE :'SCRIPT', - TRI_DESCRIPTION :desc, - mode :'ext' - }, - success: function(response) { - var result = Ext.util.JSON.decode(response.responseText); - if( result.success ){ - PMExt.notify( _('ID_STATUS') , result.msg); - - //Reloading store after saving triggers - triggerStore.reload(); - editPropertiesFormWindow.hide(); - } else { - PMExt.error(_('ID_ERROR'), result.msg); - } - } - }); - } else { - PMExt.error(_('ID_VALIDATION_ERROR'), 'There is a triggers with the same name in this process.'); - } - } - }); - editPropertiesFormWindow.hide(); - } - },{ - text: _('ID_CANCEL'), - handler: function(){ - // when this button clicked, - editPropertiesFormWindow.hide(); - } - }] - }); - - var editTriggerFormWindow = new Ext.Window({ - title: _('ID_EDIT_TRIGGERS'), - autoScroll: true, - collapsible: false, - width: 600, - //autoHeight: true, - height: 400, - layout: 'fit', - plain: true, - buttonAlign: 'center', - items: editTriggerForm - }); - - var editPropertiesFormWindow = new Ext.Window({ - title: _('ID_EDIT_TRIGGERS'), - autoScroll: true, - collapsible: false, - width: 450, - //autoHeight: true, - height: 280, - layout: 'fit', - plain: true, - buttonAlign: 'center', - items: editPropertiesForm - }); - - - var formWindow = new Ext.Window({ - title: _('ID_TRIGGERS'), - autoScroll: true, - collapsible: false, - maximizable: true, - width: 450, - //autoHeight: true, - height: 240, - layout: 'fit', - plain: true, - buttonAlign: 'center', - items: triggersForm - }); - - var gridWindow = new Ext.Window({ - title: _('ID_TRIGGERS'), - autoScroll: true, - collapsible: false, - maximizable: true, - width: 600, - //autoHeight: true, - height: 350, - layout: 'fit', - plain: true, - buttonAlign: 'center', - items: triggersGrid - }); - gridWindow.show(); -} - - -///*** from ProcessMapContext ***/// -var PMVariables = function() { - var varFields = Ext.data.Record.create( [ { - name : 'variable', - type : 'string' - }, { - name : 'type', - type : 'string' - }, { - name : 'label', - type : 'string' - } ]); - var varStore = ''; - varStore = new Ext.data.JsonStore( { - root : 'data', - totalProperty : 'totalCount', - idProperty : 'gridIndex', - remoteSort : true, - fields : varFields, - proxy : new Ext.data.HttpProxy( { - url : 'bpmn/proxyExtjs?pid=' + pro_uid + '&action=getVariables&sFieldName=form[CTO_CONDITION]&sSymbol=@@' - }) - }); - //varStore.load(); - - var varColumns = new Ext.grid.ColumnModel( { - columns : [ new Ext.grid.RowNumberer(), { - id : 'FLD_NAME', - header : _('ID_VARIABLES'), - dataIndex : 'variable', - width : 170, - editable : false, - sortable : true - }, { - id : 'PRO_VARIABLE', - header : _('ID_LABEL'), - dataIndex : 'label', - width : 150, - sortable : true - } ] - }); - - var varForm = new Ext.FormPanel( { - labelWidth : 100, - monitorValid : true, - width : 400, - bodyStyle : 'padding:10px 0 0 10px;', - height : 350, - renderer : function(val) { - return '
@@ Replace the value in quotes
'; - }, - items : { - xtype : 'tabpanel', - activeTab : 0, - defaults : { - autoHeight : true - }, - items : [ { - title : _('ID_ALL_VARIABLES'), - id : 'allVar', - layout : 'form', - listeners : { - activate : function(tabPanel) { - // use {@link Ext.data.HttpProxy#setUrl setUrl} to change the URL for *just* this request. - var link = 'bpmn/proxyExtjs?pid=' + pro_uid + '&action=getVariables&type=' + tabPanel.id + '&sFieldName=form[CTO_CONDITION]&sSymbol=@@'; - varStore.proxy.setUrl(link, true); - varStore.load(); - } - }, - items : [ { - xtype : 'grid', - ds : varStore, - cm : varColumns, - width : 380, - autoHeight : true, - //plugins: [editor], - //loadMask : true, - loadingText : 'Loading...', - border : false, - listeners : { - //rowdblclick: alert("ok"), - rowdblclick : function() { - var objectSelected = workflow.variablesAction; - switch (objectSelected) { - case 'grid': - var getObjectGridRow = workflow.gridObjectRowSelected; - var FieldSelected = workflow.gridField; - //getting selected row of variables - var rowSelected = this.getSelectionModel().getSelected(); - var rowLabel = rowSelected.data.variable; - - //Assigned new object with condition - if (typeof getObjectGridRow.colModel != 'undefined') - getObjectGridRow.colModel.config[3].editor.setValue(rowLabel); - //Assigning / updating Condition for a row - else - getObjectGridRow[0].set(FieldSelected, rowLabel); - - if (FieldSelected == 'CTO_CONDITION') { - Ext.Ajax.request( { - url : '../tracker/tracker_ConditionsSave.php', - method : 'POST', - params : { - PRO_UID : pro_uid, - CTO_UID : getObjectGridRow[0].data.CTO_UID, - CTO_CONDITION : getObjectGridRow[0].data.CTO_CONDITION - }, - success : function(response) { - Ext.MessageBox.alert('Status', 'Objects has been edited successfully '); - } - }) - } else if (FieldSelected == 'STEP_CONDITION') { - Ext.Ajax.request( { - url : '../steps/conditions_Save.php', - method : 'POST', - params : { - PRO_UID : pro_uid, - STEP_UID : getObjectGridRow[0].data.STEP_UID, - STEP_CONDITION : getObjectGridRow[0].data.STEP_CONDITION - }, - success : function(response) { - Ext.MessageBox.alert('Status', 'Objects has been edited successfully '); - } - }) - } else if (FieldSelected == 'ST_CONDITION') { - Ext.Ajax.request( { - url : '../steps/steps_Ajax.php', - method : 'POST', - params : { - action : 'saveTriggerCondition', - PRO_UID : pro_uid, - STEP_UID : getObjectGridRow[0].data.STEP_UID, - ST_CONDITION : getObjectGridRow[0].data.STEP_CONDITION, - TAS_UID : taskId, - TRI_UID : getObjectGridRow[0].data.TRI_UID, - ST_TYPE : getObjectGridRow[0].data.ST_TYPE - - }, - success : function(response) { - Ext.MessageBox.alert('Status', 'Objects has been edited successfully '); - } - }) - } - - window.hide(); - - break; - case 'form': - FormSelected = workflow.formSelected; - rowSelected = this.getSelectionModel().getSelected(); - FieldSelected = workflow.fieldName; - rowLabel = rowSelected.data.variable; - var prevContent = FormSelected.getForm().findField(FieldSelected).getValue(); - var newContent = prevContent + ' ' + rowLabel; - var value = FormSelected.getForm().findField(FieldSelected).setValue(newContent); -// if (FormSelected.getForm().findField(FieldSelected).code){ -// FormSelected.getForm().findField(FieldSelected).code=value; -// } - window.hide(); - break; - - } - - } - } - } ] - }, { - title : _('ID_SYSTEM'), - id : 'system', - layout : 'form', - listeners : { - activate : function(tabPanel) { - // use {@link Ext.data.HttpProxy#setUrl setUrl} to change the URL for *just* this request. - var link = 'bpmn/proxyExtjs?pid=' + pro_uid + '&action=getVariables&type=' + tabPanel.id + '&sFieldName=form[CTO_CONDITION]&sSymbol=@@'; - varStore.proxy.setUrl(link, true); - varStore.load(); - } - }, - items : [ { - xtype : 'grid', - ds : varStore, - cm : varColumns, - width : 380, - autoHeight : true, - //plugins: [editor], - //loadMask : true, - loadingText : 'Loading...', - border : false, - listeners : { - //rowdblclick: alert("ok"), - rowdblclick : function() { - var objectSelected = workflow.variablesAction; - switch (objectSelected) { - case 'grid': - var getObjectGridRow = workflow.gridObjectRowSelected; - var FieldSelected = workflow.gridField; - //getting selected row of variables - var rowSelected = this.getSelectionModel().getSelected(); - var rowLabel = rowSelected.data.variable; - //Assigned new object with condition - if (typeof getObjectGridRow.colModel != 'undefined') - getObjectGridRow.colModel.config[3].editor.setValue(rowLabel); - //Assigning / updating Condition for a row - else - getObjectGridRow[0].set(FieldSelected, rowLabel); - if (CTO_UID != '') { - Ext.Ajax.request( { - url : '../tracker/tracker_ConditionsSave.php', - method : 'POST', - params : { - PRO_UID : pro_uid, - CTO_UID : getObjectGridRow[0].data.CTO_UID, - CTO_CONDITION : getObjectGridRow[0].data.CTO_CONDITION - }, - success : function(response) { - Ext.MessageBox.alert('Status', 'Objects has been edited successfully '); - } - }) - window.hide(); - } - - break; - case 'form': - FormSelected = workflow.formSelected; - rowSelected = this.getSelectionModel().getSelected(); - FieldSelected = workflow.fieldName; - rowLabel = rowSelected.data.variable; - var value = FormSelected.getForm().findField(FieldSelected).setValue(rowLabel); - window.hide(); - break; - - } - - } - } - } ] - }, { - title : _('ID_CASESLIST_APP_PRO_TITLE'), - id : 'process', - layout : 'form', - listeners : { - activate : function(tabPanel) { - // use {@link Ext.data.HttpProxy#setUrl setUrl} to change the URL for *just* this request. - var link = 'bpmn/proxyExtjs?pid=' + pro_uid + '&action=getVariables&type=' + tabPanel.id + '&sFieldName=form[CTO_CONDITION]&sSymbol=@@'; - varStore.proxy.setUrl(link, true); - varStore.load(); - } - }, - items : [ { - xtype : 'grid', - ds : varStore, - cm : varColumns, - width : 380, - autoHeight : true, - //plugins: [editor], - //loadMask : true, - loadingText : 'Loading...', - border : false, - listeners : { - //rowdblclick: alert("ok"), - rowdblclick : function() { - var objectSelected = workflow.variablesAction; - switch (objectSelected) { - case 'grid': - var getObjectGridRow = workflow.gridObjectRowSelected; - var FieldSelected = workflow.gridField; - //getting selected row of variables - var rowSelected = this.getSelectionModel().getSelected(); - var rowLabel = rowSelected.data.variable; - //Assigned new object with condition - if (typeof getObjectGridRow.colModel != 'undefined') - getObjectGridRow.colModel.config[3].editor.setValue(rowLabel); - //Assigning / updating Condition for a row - else - getObjectGridRow[0].set(FieldSelected, rowLabel); - Ext.Ajax.request( { - url : '../tracker/tracker_ConditionsSave.php', - method : 'POST', - params : { - PRO_UID : pro_uid, - CTO_UID : getObjectGridRow[0].data.CTO_UID, - CTO_CONDITION : getObjectGridRow[0].data.CTO_CONDITION - }, - success : function(response) { - Ext.MessageBox.alert('Status', 'Objects has been edited successfully '); - } - }) - window.hide(); - break; - case 'form': - FormSelected = workflow.formSelected; - rowSelected = this.getSelectionModel().getSelected(); - FieldSelected = workflow.fieldName; - rowLabel = rowSelected.data.variable; - var value = FormSelected.getForm().findField(FieldSelected).setValue(rowLabel); - window.hide(); - break; - - } - - } - } - } ] - } ] - } - }); - - var window = new Ext.Window( { - title : _('ID_VARIABLES'), - collapsible : false, - maximizable : false, - scrollable : true, - width : 400, - height : 350, - minWidth : 200, - minHeight : 150, - autoScroll : true, - layout : 'fit', - plain : true, - buttonAlign : 'center', - items : [ varForm ] - }); - window.show(); -} diff --git a/workflow/engine/templates/bpmn/SubProcess.js b/workflow/engine/templates/bpmn/SubProcess.js deleted file mode 100755 index 93afc9afd..000000000 --- a/workflow/engine/templates/bpmn/SubProcess.js +++ /dev/null @@ -1,233 +0,0 @@ -bpmnSubProcess = function (_30ab) { - VectorFigure.call(this); - //Setting width and height values as per the zoom ratio - if(typeof workflow.zoomTaskWidth != 'undefined' || typeof workflow.zoomTaskHeight != 'undefined') - this.setDimension(workflow.zoomTaskWidth, workflow.zoomTaskHeight); - else - this.setDimension(165, 50); - this.subProcessName = _30ab.subProcessName; //It will set the Default Task Name with appropriate count While dragging a task on the canvas -}; - -bpmnSubProcess.prototype = new VectorFigure; -bpmnSubProcess.prototype.type = "bpmnSubProcess" -bpmnSubProcess.prototype.setSubProcessName = function () { - this.subProcessName = 'Sub Process'; -}; - -bpmnSubProcess.prototype.coord_converter = function (bound_width, bound_height, text_length) { - //bound_width = this.workflow.currentSelection.width; - //bound_height = this.workflow.currentSelection.height; - input_width = text_length * 6 - input_height = 10 - - temp_width = bound_width - input_width; - temp_width /= 2; - temp_x = temp_width; - - temp_height = bound_height - 10; - temp_height /= 2; - temp_y = temp_height; - - var temp_coord = new Object(); - temp_coord.temp_x = temp_x; - temp_coord.temp_y = temp_y; - return temp_coord; -}; - -//curWidth = this.getWidth(); - -bpmnSubProcess.prototype.paint = function () { - VectorFigure.prototype.paint.call(this); - if(typeof workflow.zoomfactor == 'undefined') - workflow.zoomfactor = 1; - //For Zooming - - if(typeof this.limitFlag == 'undefined' || this.limitFlag == false) - { - this.originalWidth = 165; - this.originalHeight = 40; - this.orgXPos = this.getX(); - this.orgYPos = this.getY(); - this.orgFontSize =this.fontSize; - } - - this.width = this.originalWidth * workflow.zoomfactor; - this.height = this.originalHeight * workflow.zoomfactor; - - var x = new Array(6, this.getWidth() - 3, this.getWidth(), this.getWidth(), this.getWidth() - 3, 6, 3, 3, 6); - var y = new Array(3, 3, 6, this.getHeight() - 3, this.getHeight(), this.getHeight(), this.getHeight() - 3, 6, 3); - this.graphics.setStroke(this.stroke); - this.graphics.setColor("#c0c0c0"); - this.graphics.fillPolygon(x, y); - for (var i = 0; i < x.length; i++) { - x[i] = x[i] - 3; - y[i] = y[i] - 3; - } - this.graphics.setColor("#ffffff"); - this.graphics.fillPolygon(x, y); - this.graphics.setColor("#5164b5"); //Blue Color - this.graphics.drawPolygon(x, y); - - //Circle on right top corner - //var x_cir = this.getWidth()/1.3; - //var y_cir = this.getHeight()/8.75; - // - //this.graphics.setColor("#ffffff"); - //this.graphics.fillEllipse(x_cir,y_cir,this.getHeight()/5,this.getHeight()/5); - //this.graphics.setColor("#5891B7"); - //this.graphics.setStroke(2); - //this.graphics.drawEllipse(x_cir,y_cir,this.getHeight()/5,this.getHeight()/5); - - //Plus symbol on bottom - //Plus symbol on bottom - var zoomfactor = workflow.zoomfactor; - var xb = this.getWidth()/2 - 5*zoomfactor; - var yb = this.getHeight() - 5 - 11*zoomfactor; - var x1 = new Array(xb, xb , xb + 11.5*zoomfactor, xb + 11.5*zoomfactor ); - var y1 = new Array(yb, yb + 11*zoomfactor, yb + 11*zoomfactor, yb ); - - this.graphics.setStroke(1); - this.graphics.setColor("#5891B7"); - this.graphics.drawPolygon(x1,y1); - var x_cross = new Array(xb+ 5*zoomfactor, xb+ 6*zoomfactor, xb+ 6*zoomfactor, xb+ 9*zoomfactor, xb+ 9*zoomfactor, xb+ 6*zoomfactor, xb+ 6*zoomfactor, xb+ 5*zoomfactor, xb+ 5*zoomfactor, xb+ 2*zoomfactor, xb+ 2*zoomfactor, xb+ 5*zoomfactor ); - var y_cross = new Array(yb+ 2*zoomfactor, yb+ 2*zoomfactor, yb+ 5*zoomfactor, yb+ 5*zoomfactor, yb+ 6*zoomfactor, yb+ 6*zoomfactor, yb+ 9*zoomfactor, yb+ 9*zoomfactor, yb+ 6*zoomfactor, yb+ 6*zoomfactor, yb+ 5*zoomfactor, yb+ 5*zoomfactor ); - this.graphics.setColor( "#5891B7" ); - this.graphics.fillPolygon(x_cross,y_cross); - this.graphics.paint(); - - var bpmnText = new jsGraphics(this.id); - var padleft = 0.025*this.getWidth(); - var padtop = 0.15*this.getHeight(); - var rectwidth = this.getWidth() - 3*padleft; - var rectheight = this.getHeight() - 3*padtop; - - - if(typeof this.fontSize == 'undefined' || this.fontSize == '') - this.fontSize = 11; - var fontSize = zoomfactor * this.fontSize; - bpmnText.setFont('verdana', +fontSize+'px', Font.PLAIN); - bpmnText.drawStringRect(this.subProcessName,padleft,padtop,rectwidth,rectheight,'center'); - bpmnText.paint(); - - this.bpmnNewText = bpmnText; - - if (this.input1 != null) { - this.input1.setPosition(0, this.height / 2 -1); - } - if (this.output1 != null) { - this.output1.setPosition(this.width / 2, this.height); - } - if (this.input2 != null) { - this.input2.setPosition(this.width / 2, 0); - } - if (this.output2 != null) { - this.output2.setPosition(this.width, this.height / 2-1); - } - -}; - - jsGraphics.prototype.drawTextString = function (txt, x, y, dx, dy) { - this.htm += '
' + txt + '<\/div>'; -}; - -bpmnSubProcess.prototype.setWorkflow = function (_40c5) { - VectorFigure.prototype.setWorkflow.call(this, _40c5); - if (_40c5 != null) { - /*Adding Port to the Task After dragging Task on the Canvas - *Ports will be invisibe After Drag and Drop, But It will be created - */ - var TaskPortName = ['output1','output2','input1','input2']; - var TaskPortType = ['OutputPort','OutputPort','InputPort','InputPort']; - var TaskPositionX= [this.width/2,this.width,0,this.width/2]; - var TaskPositionY= [this.height,this.height/2,this.height/2,0]; - - for(var i=0; i< TaskPortName.length ; i++){ - eval('this.'+TaskPortName[i]+' = new '+TaskPortType[i]+'()'); //Create New Port - eval('this.'+TaskPortName[i]+'.setWorkflow(_40c5)'); //Add port to the workflow - eval('this.'+TaskPortName[i]+'.setName("'+TaskPortName[i]+'")'); //Set PortName - eval('this.'+TaskPortName[i]+'.setZOrder(-1)'); //Set Z-Order of the port to -1. It will be below all the figure - eval('this.'+TaskPortName[i]+'.setBackgroundColor(new Color(255, 255, 255))'); //Setting Background of the port to white - eval('this.'+TaskPortName[i]+'.setColor(new Color(255, 255, 255))'); //Setting Border of the port to white - eval('this.addPort(this.'+TaskPortName[i]+','+TaskPositionX[i]+', '+TaskPositionY[i]+')'); //Setting Position of the port - } - } -}; - -bpmnSubProcessDialog = function (_2e5e) { - this.figure = _2e5e; - var title = 'Sub Process'; - Dialog.call(this, title); - this.setDimension(400, 150); //Set the width and height of the Dialog box -} - -bpmnSubProcessDialog.prototype = new Dialog(); -bpmnSubProcessDialog.prototype.createHTMLElement = function () { - var item = Dialog.prototype.createHTMLElement.call(this); - var inputDiv = document.createElement("form"); - inputDiv.style.position = "absolute"; - inputDiv.style.left = "10px"; - inputDiv.style.top = "30px"; - inputDiv.style.width = "375px"; - inputDiv.style.font = "normal 10px verdana"; - item.appendChild(inputDiv); - this.label = document.createTextNode("Sub Process Name"); - inputDiv.appendChild(this.label); - this.input = document.createElement("textarea"); - this.input.style.border = "1px solid gray"; - this.input.style.font = "normal 10px verdana"; - //this.input.type = "text"; - this.input.maxLength = "500"; - this.input.cols = "50"; - this.input.rows = "3"; - var value = bpmnTask.prototype.trim(this.figure.workflow.currentSelection.subProcessName); - if (value) this.input.value = value; - else this.input.value = ""; - this.input.style.width = "100%"; - inputDiv.appendChild(this.input); - this.input.focus(); - return item; -}; - -/*Double Click Event for opening the dialog Box*/ -bpmnSubProcess.prototype.onDoubleClick = function () { - var _409d = new bpmnSubProcessDialog(this); - this.workflow.showDialog(_409d, this.workflow.currentSelection.x, this.workflow.currentSelection.y); -}; - - -/** - * This method will be called if the user pressed the OK button in buttonbar of the dialog.
- * The string is first cleared and new string is painted.

- **/ - bpmnSubProcessDialog.prototype.onOk = function () { - this.figure.bpmnNewText.clear(); - - len = Math.ceil(this.input.value.length/16); - if(this.input.value.length < 19) - { - len = 1.5; - if(this.input.value.length > 9) - this.figure.rectWidth = this.input.value.length*8; - else - this.figure.rectWidth = 48; - } - else - this.figure.rectWidth = 150; - //tempcoord = this.workflow.currentSelection.coord_converter(this.workflow.currentSelection.width, this.workflow.currentSelection.height, this.input.value.length) - this.figure.bpmnNewText.drawStringRect(this.input.value,20,20,this.figure.rectWidth,'left'); - // this.figure.bpmnNewText.drawTextString(this.input.value, this.workflow.currentSelection.width, this.workflow.currentSelection.height, tempcoord.temp_x, tempcoord.temp_y); - this.figure.bpmnNewText.paint(); - this.figure.subProcessName = this.input.value; //Set Updated Text value - - if(this.figure.rectWidth<80) - tempW = 110; - else - tempW = this.figure.rectWidth+35; - this.workflow.currentSelection.setDimension(tempW, len*13+40); - - this.workflow.removeFigure(this); -}; - -bpmnSubProcess.prototype.getContextMenu = function () { - this.workflow.handleContextMenu(this); -}; \ No newline at end of file diff --git a/workflow/engine/templates/bpmn/TaskContext.js b/workflow/engine/templates/bpmn/TaskContext.js deleted file mode 100755 index b99e5ebb3..000000000 --- a/workflow/engine/templates/bpmn/TaskContext.js +++ /dev/null @@ -1,2585 +0,0 @@ -TaskContext=function(id){ - Workflow.call(this,id); -}; -TaskContext.prototype=new Workflow; -TaskContext.prototype.type="TaskContext"; - - -TaskContext.prototype.editTaskSteps = function(_3252){ - var taskExtObj = new TaskContext(); - var ProcMapObj= new ProcessMapContext(); - var taskId = _3252.scope.workflow.currentSelection.id; - - var stepsFields = Ext.data.Record.create([ - { - name: 'STEP_TITLE', - type: 'string' - }, - { - name: 'STEP_UID', - type: 'string' - }, - { - name: 'STEP_TYPE_OBJ', - type: 'string' - }, - { - name: 'STEP_CONDITION', - type: 'string' - }, - { - name: 'STEP_POSITION', - type: 'string' - }, - { - name: 'STEP_MODE', - type: 'string' - }, - { - name: 'STEP_UID_OBJ', - type: 'string' - } - ]); - - var editor = new Ext.ux.grid.RowEditor({ - saveText: _('ID_UPDATE') - }); - - var btnAdd = new Ext.Button({ - id: 'btnAdd', - text: _('ID_ASSIGN'), - iconCls: 'button_menu_ext ss_sprite ss_add', - handler: function(){ - var User = grid.getStore(); - var e = new stepsFields({ - //STEP_TITLE: User.data.items[0].data.STEP_TITLE, - STEP_UID : '', - STEP_TYPE_OBJ : '', - STEP_CONDITION : '', - STEP_POSITION : '', - STEP_MODE : '', - STEP_UID_OBJ : '' - }); - - if(availableSteps.data.items.length == 0) - PMExt.notify( _('ID_STATUS') , _('ID_STEPS_UNAVAILABLE') ); - else - { - editor.stopEditing(); - taskSteps.insert(0, e); - grid.getView().refresh(); - //grid.getSelectionModel().selectRow(0); - editor.startEditing(0, 0); - } - } - }); - - var btnRemove = new Ext.Button({ - id: 'btnRemove', - text: _('ID_REMOVE'), - iconCls: 'button_menu_ext ss_sprite ss_pencil', - handler: function (s) { - editor.stopEditing(); - var s = grid.getSelectionModel().getSelections(); - for(var i = 0, r; r = s[i]; i++){ - - //First Deleting step from Database using Ajax - var stepUID = r.data.STEP_UID; - var stepPosition = r.data.STEP_POSITION; - - //if STEP_UID is properly defined (i.e. set to valid value) then only delete the row - //else its a BLANK ROW for which Ajax should not be called. - if(r.data.STEP_UID != "") - { - Ext.Ajax.request({ - url : '../steps/steps_Delete.php', - method: 'POST', - params: { - TASK : taskId, - STEP_UID : stepUID, - STEP_POSITION : stepPosition - }, - success: function(response) { - PMExt.notify( _('ID_STATUS') , _('ID_STEP_REMOVED') ); - //Secondly deleting from Grid - taskSteps.remove(r); - //Reloading store after removing steps - taskSteps.reload(); - } - }); - } - else - taskSteps.remove(r); - } - } - }); - - var tb = new Ext.Toolbar({ - items: [btnAdd, btnRemove] - }); - - // create the Data Store of all Steps that are already been assigned to a task - var taskSteps = new Ext.data.JsonStore({ - root : 'data', - totalProperty: 'totalCount', - idProperty : 'gridIndex', - remoteSort : true, - fields : stepsFields, - proxy : new Ext.data.HttpProxy({ - url : 'bpmn/proxyExtjs?tid='+taskId+'&action=getAssignedSteps' - }) - }); - taskSteps.load({params:{start : 0 , limit : 10 }}); - - // create the Data Store of all Steps that are not been assigned to a task i.e available steps - var availableSteps = new Ext.data.JsonStore({ - root : 'data', - url : 'bpmn/proxyExtjs?pid='+pro_uid+'&tid='+taskId+'&action=getAvailableSteps', - totalProperty : 'totalCount', - idProperty : 'gridIndex', - remoteSort : false, - autoLoad : true, - fields : stepsFields - - }); - availableSteps.load(); - - var btnStepsCondition = new Ext.Button({ - id: 'btnCondition', - text: _('ID_CONDITION'), - handler: function (s) { - workflow.taskUID = taskId - workflow.variablesAction = 'grid'; - workflow.variable = '@@', - workflow.gridField = 'STEP_CONDITION'; - var rowSelected = conditionGrid.getSelectionModel().getSelections(); - if(rowSelected == '') - workflow.gridObjectRowSelected = conditionGrid; - else - workflow.gridObjectRowSelected = rowSelected; - - var rowData = ProcMapObj.ExtVariables(); - console.log(rowData); - } - }) - - - var toolbar = new Ext.Toolbar({ - items: [btnStepsCondition] - }); - //availableSteps.load(); - var conditionGrid = new Ext.grid.GridPanel({ - store : taskSteps, - id : 'conditiongrid', - loadMask : true, - loadingText : 'Loading...', - frame : false, - autoHeight : false, - //enableDragDrop : true, - layout : 'form', - tbar : toolbar, - //ddGroup : 'firstGridDDGroup', - clicksToEdit : 1, - minHeight :400, - height :400, - plugins : [editor], - columns : [{ - id: 'STEP_TITLE', - header: _('ID_STEPS'), - dataIndex: 'STEP_TITLE', - width: 280, - editor: new Ext.form.TextField({ - }) - }, - { - id: 'STEP_CONDITION', - header: _('ID_CONDITION'), - dataIndex: 'STEP_CONDITION', - width: 250, - //editable: true, - editor: new Ext.form.TextField({ - editable : true - }) - } - ] - }); - - - - var grid = new Ext.grid.GridPanel({ - store : taskSteps, - id : 'mygrid', - loadMask : true, - loadingText : 'Loading...', - //renderTo : 'cases-grid', - frame : false, - autoHeight : false, - //enableDragDrop : true, - //ddGroup : 'firstGridDDGroup', - clicksToEdit: 1, - minHeight :400, - height :340, - layout : 'form', - plugins : [editor], - columns : [{ - id: 'STEP_TITLE', - header: _('ID_STEPS'), - dataIndex: 'STEP_TITLE', - width: 200, - sortable: true, - editor: new Ext.form.ComboBox({ - xtype : 'combo', - fieldLabel : 'Users_groups', - store : availableSteps, - displayField : 'STEP_TITLE' , - valueField : 'STEP_TITLE', - scope : this, - triggerAction: 'all', - emptyText : 'Select Step', - allowBlank : false, - onSelect: function(record, index){ - var User = grid.getStore(); - - if(typeof _3252.scope.workflow.currentrowIndex == 'undefined') - var selectedrowIndex = '0'; - else - selectedrowIndex = _3252.scope.workflow.currentrowIndex; //getting Index of the row that has been edited - - //User.data.items[0].data.STEP_TITLE= record.data.STEP_TITLE; - User.data.items[selectedrowIndex].data.STEP_UID = record.data.STEP_UID; - User.data.items[selectedrowIndex].data.STEP_TYPE_OBJ =record.data.STEP_TYPE_OBJ; - User.data.items[selectedrowIndex].data.STEP_CONDITION =record.data.STEP_CONDITION; - User.data.items[selectedrowIndex].data.STEP_POSITION =record.data.STEP_POSITION; - User.data.items[selectedrowIndex].data.STEP_UID_OBJ =record.data.STEP_UID_OBJ; - User.data.items[selectedrowIndex].data.STEP_MODE =record.data.STEP_MODE; - - this.setValue(record.data[this.valueField || this.displayField]); - this.collapse(); - } - }) - }, - { - id: 'STEP_MODE', - header: _('STEP_MODE'), - dataIndex: 'STEP_MODE', - width: 100, - sortable: true, - editor: new Ext.form.ComboBox ({ - editable : false, - triggerAction: 'all', - lazyRender:true, - allowBlank : false, - emptyText : 'Select Mode', - mode: 'local', - scope: this, - store: new Ext.data.ArrayStore({ - id: 0, - fields: [ - 'STEP_MODE', - 'STEP_MODE' - ], - data: [['EDIT', 'Edit'], ['VIEW', 'View']] - }), - valueField: 'STEP_MODE', - defaultValue: 'EDIT', - displayField: 'STEP_MODE', - onSelect: function(record, index){ - var User = grid.getStore(); - User.data.items[0].data.STEP_MODE=record.data.STEP_MODE; - this.setValue(record.data[this.valueField || this.displayField]); - this.collapse(); - } - }) - }, - { - sortable: false, - renderer: function() - { - return String.format("
Edit",pro_uid,taskId); - } - } - ], - sm: new Ext.grid.RowSelectionModel({ - singleSelect: true, - listeners: { - rowselect: function(smObj, rowIndex, record) { - _3252.scope.workflow.currentrowIndex = rowIndex; - } - } - }), - stripeRows: true, - viewConfig: {forceFit: true}, - tbar: tb, - bbar: new Ext.PagingToolbar({ - pageSize: 10, - store: taskSteps, - displayInfo: true, - displayMsg: 'Displaying Steps {0} - {1} of {2}', - emptyMsg: "No Steps to display", - items:[] - }) - }); - - editor.on({ - scope: this, - afteredit: function(roweditor, changes, record, rowIndex) { - - var stepUIDObj = record.data.STEP_UID_OBJ; - var stepTypeObj = record.data.STEP_TYPE_OBJ; - var stepMode = record.data.STEP_MODE; - - Ext.Ajax.request({ - url : '../steps/steps_Save.php', - method: 'POST', - params: { - sProcess : pro_uid, - sTask : taskId, - sType : stepTypeObj, - sUID : stepUIDObj, - sMode : stepMode - }, - success: function(response) { - PMExt.notify( _('ID_STATUS') , _('ID_STEP_ASSIGNED') ); - } - }); - //availableSteps.reload(); - //Deleting previously assigned step on updating/replacing with new step. - if(changes != '' && typeof record.json != 'undefined') - { - var stepUID = record.json.STEP_UID; - var stepPosition = record.json.STEP_POSITION; - - Ext.Ajax.request({ - url : '../steps/steps_Delete.php', - method: 'POST', - params: { - TASK : taskId, - STEP_UID : stepUID, - STEP_POSITION : stepPosition - }, - success: function(response) { - //Ext.MessageBox.alert ('Status','Step has been updated successfully.'); - } - }); - } - - } - }); - - - - //Getting triggers data using stepTriggers function - var treeGrid = taskExtObj.stepTriggers(_3252); - treeGrid.render(document.body); - - var taskStepsTabs = new Ext.FormPanel({ - labelWidth: 100, - monitorValid : true, - width : 850, - height : 400, - items: - { - xtype:'tabpanel', - activeTab: 0, - defaults:{ - autoHeight:true - }, - items:[{ - title:_('ID_STEPS'), - layout:'fit', - defaults: { - width: 400 - }, - listeners: { - tabchange: function(tabPanel,newTab){ - taskSteps.reload(); - } - }, - items:[grid] - },{ - title:_('ID_CONDITION'), - layout:'fit', - defaults: { - width: 400 - }, - listeners: { - tabchange: function(tabPanel,newTab){ - taskSteps.reload(); - } - }, - items:[conditionGrid] - },{ - title:_('ID_TRIGGERS'), - layout:'form', - defaults: { - width: 400 - }, - items:[treeGrid] - }] - } - }); - - taskStepsTabs.render(document.body); - _3252.scope.workflow.taskStepsTabs = taskStepsTabs; - - var window = new Ext.Window({ - title: _('ID_STEPS_OF'), - collapsible: false, - maximizable: false, - width: 770, - height: 380, - minWidth: 200, - minHeight: 150, - layout: 'fit', - plain: true, - buttonAlign: 'center', - items: taskStepsTabs - - }); - window.show(); -} - -TaskContext.prototype.editUsers= function() -{ - var taskExtObj = new TaskContext(); - var taskId = workflow.currentSelection.id; - var userFields = Ext.data.Record.create([ - { - name: 'LABEL', - type: 'string' - }, - { - name: 'TU_TYPE', - type: 'string' - }, - { - name: 'TU_RELATION', - type: 'string' - }, - { - name: 'TAS_UID', - type: 'string' - }, - { - name: 'USR_UID', - type: 'string' - } - ]); - var editor = new Ext.ux.grid.RowEditor({ - saveText: _('ID_UPDATE') - }); - - - var btnAdd = new Ext.Button({ - id: 'btnAdd', - text: _('ID_ASSIGN'), - iconCls: 'button_menu_ext ss_sprite ss_add', - handler: function(){ - var User = grid.getStore(); - var e = new userFields({ - TAS_UID : '', - TU_TYPE : '', - USR_UID : '', - TU_RELATION: '' - }); - //storeUsers.reload(); - if(storeUsers.data.items.length == 0) - PMExt.notify( _('ID_STATUS') , _('ID_USERS_UNAVAILABLE') ); - else - { - editor.stopEditing(); - taskUsers.insert(0, e); - grid.getView().refresh(); - editor.startEditing(0, 0); - } - } - }); - - var btnRemove = new Ext.Button({ - id: 'btnRemove', - text: _('ID_REMOVE'), - iconCls: 'application_delete', - handler: function (s) { - editor.stopEditing(); - var s = grid.getSelectionModel().getSelections(); - for(var i = 0, r; r = s[i]; i++){ - - //First Deleting assigned users from Database - var user_TURel = r.data.TU_RELATION; - var userUID = r.data.USR_UID; - var user_TUtype = r.data.TU_TYPE; - var urlparams = '?action=ofToAssign&data={"TAS_UID":"'+taskId+'","TU_RELATION":"'+user_TURel+'","USR_UID":"'+userUID+'","TU_TYPE":"'+user_TUtype+'"}'; - - //if USR_UID is properly defined (i.e. set to valid value) then only delete the row - //else its a BLANK ROW for which Ajax should not be called. - if(r.data.USR_UID != "") - { - Ext.Ajax.request({ - url : 'bpmn/processes_Ajax.php' +urlparams , - success: function(response) { - PMExt.notify( _('ID_STATUS') , _('ID_USERS_REMOVED') ); - //Secondly deleting from Grid - taskUsers.remove(r); - - //Reloading available user store - taskUsers.reload(); - } - }); - } - else - taskUsers.remove(r); - } - } - }); - - var tb = new Ext.Toolbar({ - items: [btnAdd, btnRemove] - }); - - // create the Data Store of users that are already assigned to a task - var taskUsers = new Ext.data.JsonStore({ - root : 'data', - totalProperty: 'totalCount', - idProperty : 'gridIndex', - remoteSort : true, - fields : userFields, - proxy: new Ext.data.HttpProxy({ - url: 'bpmn/proxyExtjs?pid='+pro_uid+'&tid='+taskId+'&action=getAssignedUsersList' - }) - }); - taskUsers.setDefaultSort('LABEL', 'asc'); - - - // create the Data Store of users that are not assigned to a task - var storeUsers = new Ext.data.JsonStore({ - root : 'data', - url : 'bpmn/proxyExtjs?tid='+taskId+'&action=getAvailableUsersList', - totalProperty : 'totalCount', - idProperty : 'gridIndex', - remoteSort : false, //true, - autoLoad : true, - fields : userFields - }); - storeUsers.load(); - - var grid = new Ext.grid.GridPanel({ - store: taskUsers, - id : 'mygrid', - loadMask: true, - loadingText: 'Loading...', - //renderTo: 'cases-grid', - frame: false, - autoHeight:false, - clicksToEdit: 1, - minHeight:400, - height :320, - layout: 'fit', - plugins: [editor], - cm: new Ext.grid.ColumnModel({ - defaults: { - width: 200, - sortable: true - }, - columns: [ - new Ext.grid.RowNumberer(), - { - id: 'LABEL', - header:_('ID_GROUP_USER'), - dataIndex: 'LABEL', - width: 100, - editor: new Ext.form.ComboBox({ - xtype: 'combo', - fieldLabel: 'Users_groups', - hiddenName: 'number', - store : storeUsers, - displayField : 'LABEL' , - valueField : 'LABEL', - name : 'LABEL', - triggerAction: 'all', - emptyText: 'Select User or Group', - allowBlank: false, - onSelect: function(record, index){ - var User = grid.getStore(); - - if(typeof workflow.currentrowIndex == 'undefined') - var selectedrowIndex = '0'; - else - selectedrowIndex = workflow.currentrowIndex; //getting Index of the row that has been edited - - //User.data.items[0].data.LABEL= record.data.LABEL; - User.data.items[selectedrowIndex].data.TAS_UID = record.data.TAS_UID; - User.data.items[selectedrowIndex].data.TU_TYPE = record.data.TU_TYPE; - User.data.items[selectedrowIndex].data.USR_UID = record.data.USR_UID; - User.data.items[selectedrowIndex].data.TU_RELATION = record.data.TU_RELATION; - - this.setValue(record.data[this.valueField || this.displayField]); - this.collapse(); - } - }) - }, - ] - }), - sm: new Ext.grid.RowSelectionModel({ - singleSelect: true, - listeners: { - rowselect: function(smObj, rowIndex, record) { - workflow.currentrowIndex = rowIndex; - } - } - }), - - stripeRows: true, - viewConfig: {forceFit: true}, - bbar: new Ext.PagingToolbar({ - pageSize: 10, - store: taskUsers, - displayInfo: true, - displayMsg: 'Displaying Users {0} - {1} of {2}', - emptyMsg: "No Users to display", - items:[] - }), - tbar: tb - }); - - taskUsers.load({params:{start : 0 , limit : 10 }}); - - editor.on({ - scope: this, - afteredit: function(roweditor, changes, record, rowIndex) { - var taskId = record.data.TAS_UID; - var userId = record.data.USR_UID; - var tu_Type = record.data.TU_TYPE; - var tu_Relation = record.data.TU_RELATION; - var urlparams = '?action=assign&data={"TAS_UID":"'+taskId+'","USR_UID":"'+userId+'","TU_TYPE":"'+tu_Type+'","TU_RELATION":"'+tu_Relation+'"}'; - - Ext.Ajax.request({ - url: 'bpmn/processes_Ajax.php' +urlparams , - success: function (response) { // When saving data success - PMExt.notify( _('ID_STATUS') , _('ID_USER_ASSIGNED') ); - }, - failure: function () { // when saving data failed - PMExt.notify( _('ID_STATUS') , _('ID_USER_SAVE_FAIL') ); - } - }); - - //Updating the user incase if already assigned user has been replaced by other user - if(changes != '' && typeof record.json != 'undefined') - { - var user_TURel = record.json.TU_RELATION; - var userUID = record.json.USR_UID; - var user_TUtype = record.json.TU_TYPE; - urlparams = '?action=ofToAssign&data={"TAS_UID":"'+taskId+'","TU_RELATION":"'+user_TURel+'","USR_UID":"'+userUID+'","TU_TYPE":"'+user_TUtype+'"}'; - Ext.Ajax.request({ - url : 'bpmn/processes_Ajax.php' +urlparams , - success: function(response) { - //Ext.MessageBox.alert ('Status','User has been updated successfully.'); - } - }); - } - storeUsers.reload(); - } - }); - - var panel = new Ext.Panel({ - id: 'panel', - //renderTo: Ext.getBody(), - items: [grid] - }); - - var window = new Ext.Window({ - title: _('ID_USERS_GROUPS'), - collapsible: false, - maximizable: false, - width: 400, - height: 350, - minWidth: 200, - minHeight: 150, - //layout: 'fit', - plain: true, - buttonAlign: 'center', - items: panel - }); - window.show(); -} - - -TaskContext.prototype.editTaskProperties= function() -{ - var ProcMapObj = new ProcessMapContext(); - var taskExtObj = new TaskContext(); - var taskId = workflow.currentSelection.id; - var oPmosExt = new pmosExt(); - - var fieldsToToggle = new Array(); - - var taskPropertiesTabs = new Ext.FormPanel({ - labelWidth : 140, - //border : false, - monitorValid : true, - // store : taskDetails, - //url : 'proxyTaskPropertiesDetails.php', - width : 600, - items: [{ - xtype:'tabpanel', - activeTab: 0, - bodyStyle : 'padding:5px 0 0 5px;', - defaults:{ - labelWidth : 140, - height : 300 - }, - items:[ - { - title:_('ID_DEFINITION'), - layout:'form', - defaults: { - width: 230 - }, - defaultType: 'textfield', - items: [{ - fieldLabel: _('ID_TITLE'), - name: 'TAS_TITLE', - width: 350 - },{ - xtype: 'textarea', - fieldLabel: _('ID_DESCRIPTION'), - name: 'TAS_DESCRIPTION', - allowBlank: true, - width: 350, - height : 150 - },{ - xtype: 'fieldset', - layout:'column', - border : false, - width: 550, - items:[{ - columnWidth:.7, - layout: 'form', - border : false, - items: [{ - xtype: 'textfield', - labelWidth : 130, - fieldLabel: _('ID_VARIABLES_CASE_PRIORITY'), - name: 'TAS_PRIORITY_VARIABLE', - anchor:'100%' - }] - },{ - columnWidth:.2, - layout: 'form', - border:false, - items: [{ - xtype:'button', - title: ' ', - text: '@@', - name: 'selectorigin', - handler: function (s) { - workflow.variablesAction = 'form'; - workflow.fieldName = 'TAS_PRIORITY_VARIABLE' ; - workflow.formSelected = taskPropertiesTabs; - var rowData = ProcMapObj.ExtVariables(); - console.log(rowData); - } - }] - }] - },{ - xtype: 'checkbox', - fieldLabel: _('ID_START_TASK'), - name: 'TAS_START', - checked:workflow.checkStartingTask - }] - },{ - title:_('ID_ASSIGNMENT_RULES'), - layout : 'form', - defaults: { - width: 260 - }, - items: [{ - xtype: 'radiogroup', - //id: 'assignType', - fieldLabel: _('ID_CASES_ASSIGNED_BY'), - itemCls: 'x-check-group-alt', - columns: 1, - items: [{ - boxLabel: _('ID_CYCLIC_ASSIGNMENT'), - //id: 'BALANCED', - name: 'TAS_ASSIGN_TYPE', - inputValue: 'BALANCED', - checked: false -// listeners: { -// 'check':{ -// fn: function(){ -// Ext.getCmp("staticMI").hide(); -// Ext.getCmp("cancelMI").hide(); -// Ext.getCmp("evaluate").hide(); -// } -// } -// } - },{ - boxLabel: _('ID_MANUAL_ASSIGNMENT'), - // id: 'MANUAL', - name: 'TAS_ASSIGN_TYPE', - inputValue: 'MANUAL', - checked:false -// listeners: { -// 'check':{ -// fn: function(){ -// Ext.getCmp("staticMI").hide(); -// Ext.getCmp("cancelMI").hide(); -// Ext.getCmp("evaluate").hide(); -// } -// } -// } - },{ - boxLabel: _('ID_VALUE_BASED'), - //id:'EVALUATE', - name: 'TAS_ASSIGN_TYPE', - inputValue: 'EVALUATE', - checked:false -// listeners: { -// 'check':{ -// fn: function(){ - - -// var fields = workflow.taskPropertiesTabs.items.items[0].items.items[1].items.items; -// var fieldsToToggle = new Array(); -// fieldsToToggle = [fields[1].items.items[0].items.items[0]]; -// oPmosExt.toggleFields(fieldsToToggle,true); -// } -// } -// } - },{ - boxLabel: _('ID_REPORTS_TO'), - //id:'REPORT_TO', - name: 'TAS_ASSIGN_TYPE', - inputValue: 'REPORT_TO', - checked:false -// listeners: { -// 'check':{ -// fn: function(){ -// Ext.getCmp("staticMI").hide(); -// Ext.getCmp("cancelMI").hide(); -// Ext.getCmp("evaluate").hide(); -// } -// } -// } - },{ - boxLabel: _('ID_SELF_SERVICE'), - //id:'SELF_SERVICE', - name: 'TAS_ASSIGN_TYPE', - inputValue: 'SELF_SERVICE', - checked:false -// listeners: { -// 'check': -// {fn: function(){ -// //fieldsToToggle = [fields[0],fields[1],fields[2],fields[3],fields[4],fields[5],fields[6],fields[7],fields[8]] -// Ext.getCmp("staticMI").hide(); -// Ext.getCmp("cancelMI").hide(); -// Ext.getCmp("evaluate").hide(); -// } -// } -// } - },{ - boxLabel: _('ID_STATIC_PARTIAL_JOIN_MULTIPLE_INSTANCES'), - //id:'STATIC_MI', - name: 'TAS_ASSIGN_TYPE', - inputValue: 'STATIC_MI', - checked:false -// listeners: { -// 'check':{ -// fn: function(){ -// Ext.getCmp("staticMI").show(); -// Ext.getCmp("cancelMI").show(); -// Ext.getCmp("evaluate").hide(); -// } -// } -// } - },{ - boxLabel: _('ID_CANCEL_PARTIAL_JOIN_MULTIPLE_INSTANCE'), - //id : 'CANCEL_MI', - name : 'TAS_ASSIGN_TYPE', - inputValue: 'CANCEL_MI', - checked:false -// listeners: { -// 'check':{ -// fn: function(){ -// Ext.getCmp("staticMI").show(); -// Ext.getCmp("cancelMI").show(); -// Ext.getCmp("evaluate").hide(); -// } -// } -// } - }] - - - },{ - xtype: 'fieldset', - layout:'column', - border:false, - width: 550, - hidden: true, - id: 'evaluate', - items:[{ - columnWidth:.8, - layout: 'form', - border:false, - items: [{ - xtype: 'textfield', - fieldLabel: _('ID_VARIABLES_VALUE_ASSIGNMENT'), - name: 'TAS_ASSIGN_VARIABLE', - anchor:'100%' - }] - },{ - columnWidth:.2, - layout: 'form', - border:false, - items: [{ - xtype:'button', - title: ' ', - text: '@@', - name: 'selectorigin' - }] - } - ] - },{ - xtype: 'fieldset', - layout:'column', - border:false, - width: 550, - hidden: true, - id: 'staticMI', - items:[{ - columnWidth:.8, - layout: 'form', - border:false, - items: [{ - xtype: 'textfield', - fieldLabel: _('ID_VARIABLES_NO_INSTANCES'), - name: 'TAS_MI_INSTANCE_VARIABLE', - anchor:'100%' - }] - },{ - columnWidth:.2, - layout: 'form', - border:false, - items: [{ - xtype:'button', - title: ' ', - text: '@@', - name: 'selectorigin' - }] - }] - },{ - xtype: 'fieldset', - layout:'column', - border:false, - width: 550, - hidden: true, - id: 'cancelMI', - items:[{ - columnWidth:.8, - layout: 'form', - border:false, - items: [{ - xtype: 'textfield', - fieldLabel: _('ID_VARIABLES_INSTANCES_TO _COMPLETE'), - name: 'TAS_MI_COMPLETE_VARIABLE', - anchor:'100%' - }] - },{ - columnWidth:.2, - layout: 'form', - border:false, - items: [{ - xtype:'button', - title: ' ', - text: '@@', - name: 'selectorigin' - }] - }] - }] - },{ - title:'Timing Control Rules', - layout:'form', - defaults: { - width: 260 - }, - defaultType: 'textfield', - items: [{ - xtype: 'checkbox', - boxLabel: _('ID_USER_DEFINED_TIMING_CONTROL'), - name: 'TAS_TRANSFER_FLY', - checked: 'TAS_TRANSFER_FLY', - labelWidth: 100, - listeners: { - /**Listeners for hiding all the fields - * under "Timing Control Rules" tabs - * when user clicks on 'Allow user defined timing control' checkbox - **/ - check : function(a,checked,c) { - if(checked == true) - Ext.getCmp("userDefinedTiming").hide(); - else - Ext.getCmp("userDefinedTiming").show(); - } - } - },{ - xtype: 'fieldset', - layout:'form', - border:false, - width: 550, - hidden: false, - id: 'userDefinedTiming', - - items:[{ - xtype: 'textfield', - fieldLabel: _('ID_TASK_DURATION'), - name: 'TAS_DURATION', - width : 100, - allowBlank:false - },{ - width: 100, - xtype: 'combo', - mode: 'local', - triggerAction: 'all', - forceSelection: true, - editable: false, - fieldLabel: _('ID_TIME_UNIT'), - name: 'TAS_TIMEUNIT', - hiddenName: 'TAS_TIMEUNIT', - displayField: 'name', - valueField: 'value', - store: new Ext.data.JsonStore({ - fields : ['name', 'value'], - data : [ - { - name : 'Days', - value: 'Days' - },{ - name : 'Hours', - value: 'Hours' - }] - }) - },{ - width: 120, - xtype: 'combo', - mode: 'local', - //value: '- None -', - triggerAction: 'all', - forceSelection: true, - editable: false, - fieldLabel: _('ID_COUNT_DAYS'), - name: 'TAS_TYPE_DAY', - hiddenName: 'TAS_TYPE_DAY', - displayField: 'name', - //value: 'TAS_TYPE_DAY', - valueField: 'value', - store: new Ext.data.JsonStore({ - fields : ['name', 'value'], - data : [ - { - name : 'Work Days', - value: '1' - }, - - { - name : 'Calendar Days', - value: '2' - }, - ] - }) - },{ - width: 100, - xtype: 'combo', - mode: 'local', - value: 'Default', - forceSelection: true, - triggerAction: 'all', - editable: false, - fieldLabel: _('ID_CALENDAR'), - name: 'TAS_CALENDAR', - hiddenName: 'TAS_CALENDAR', - displayField: 'name', - valueField: 'value', - store: new Ext.data.JsonStore({ - fields : ['name', 'value'], - data : [ - { - name : '- None-', - value: '- None-' - }, - - { - name : 'Default', - value: 'Default' - }, - ] - }) - }] - }] - },{ - title:_('ID_PERMISSION'), - layout:'form', - defaults: { - width: 260 - }, - defaultType: 'textfield', - labelWidth: 200, - items: [{ - xtype: 'checkbox', - //id: 'ADHOC', - fieldLabel: _('ID_ALLOW_ARBITARY_TRANSFER'), - inputValue:'ADHOC', - checked: false, - name: 'TAS_TYPE' - }] - },{ - title:_('ID_CASE_LABELS'), - layout:'form', - defaults: { - width: 600 - }, - defaultType: 'textfield', - labelWidth: 70, - items: [{ - xtype: 'fieldset', - layout:'column', - border:false, - width: 600, - items:[{ - columnWidth:.8, - layout: 'form', - border:false, - items: [{ - xtype: 'textarea', - fieldLabel: _('ID_CASE_TITLE'), - //id: 'caseTitle', - name: 'TAS_DEF_TITLE', - height : 120, - //value: _5625.scope.workflow.taskDetails.TAS_ASSIGN_VARIABLE - anchor:'100%' - }] - },{ - columnWidth:.2, - layout: 'form', - border:false, - items: [{ - xtype:'button', - title: ' ', - text: '@#', - name: 'selectCaseTitle', - handler: function (s) { - workflow.variablesAction = 'form'; - workflow.variable = '@%23', - workflow.fieldName = 'TAS_DEF_TITLE' ; - workflow.formSelected = taskPropertiesTabs; - var rowData = ProcMapObj.ExtVariables(); - console.log(rowData); - } - }] - }] - },{ - xtype: 'fieldset', - layout:'column', - border:false, - width: 600, - items:[{ - columnWidth:.8, - layout: 'form', - border:false, - items: [{ - xtype: 'textarea', - //id: 'caseDescription', - fieldLabel: _('ID_CASE_DESCRIPTION'), - name: 'TAS_DEF_DESCRIPTION', - height : 120, - anchor:'100%' - - }] - },{ - columnWidth:.2, - layout: 'form', - border:false, - items: [{ - xtype:'button', - title: ' ', - text: '@#', - name: 'selectCaseDesc', - handler: function (s) { - workflow.variablesAction = 'form'; - workflow.variable = '@%23', - workflow.fieldName= 'TAS_DEF_DESCRIPTION' ; - workflow.formSelected = taskPropertiesTabs; - var rowData = ProcMapObj.ExtVariables(); - console.log(rowData); - } - }] - }] - }] - },{ - title:_('ID_NOTIFICATION'), - layout:'form', - defaultType: 'textfield', - labelWidth: 170, - items: [{ - xtype: 'checkbox', - boxLabel: _('ID_NOTIFY_USERS_AFTER_ASSIGN'), - labelWidth: 100, - name: 'SEND_EMAIL', - checked: 'TAS_DEF_MESSAGE_CHECKBOX', - listeners: { - /**Listeners for showing "TAS_DEF_MESSAGE" textarea field - * under "Notification" tab - * when user clicks on 'After routing notify the next assigned user(s).' checkbox - **/ - check : function(a,checked,c) { - if(checked == true) - Ext.getCmp("notifyUser").show(); - else - Ext.getCmp("notifyUser").hide(); - } - } - },{ - xtype: 'fieldset', - id: 'notifyUser', - border: false, - defaults: { - width: 400 - }, - labelWidth: 50, - hidden: true, - items :[{ - xtype: 'textarea', - name: 'TAS_DEF_MESSAGE', - width: 400, - height : 180 - }] - }] - } - ] - }] - }); - - workflow.taskPropertiesTabs = taskPropertiesTabs; - - - //Loading Task Details into the form - taskPropertiesTabs.form.load({ - url:'bpmn/proxyExtjs.php?tid='+taskId+'&action=getTaskPropertiesList', - method:'GET', - waitMsg:'Loading', - success:function(form, action) { - alert(action.result.data.TAS_START); - if(action.result.data.TAS_START== true) - workflow.checkStartingTask = 'on'; - else - workflow.checkStartingTask = 'off'; - - //To load the values of the selecte radio button in Assignment Rules - if(action.result.data.TAS_ASSIGN_TYPE=='BALANCED') - form.items.items[4].items[0].checked=true; - - else if(action.result.data.TAS_ASSIGN_TYPE=='MANUAL') - { - form.items.items[4].items[1].checked=true; - //Ext.getCmp(ID).setValue(true); - //taskPropertiesTabs.getForm().findField('TAS_ASSIGN_TYPE').setValue(true); - } - else if(action.result.data.TAS_ASSIGN_TYPE=='EVALUATE') - { - form.items.items[4].items[2].checked=true; - taskPropertiesTabs.getForm().findField('TAS_ASSIGN_VARIABLE').show(); - } - - else if(action.result.data.TAS_ASSIGN_TYPE=='REPORT_TO') - form.items.items[4].items[3].checked=true; - - else if(action.result.data.TAS_ASSIGN_TYPE=='SELF_SERVICE') - {form.items.items[4].items[4].checked=true; - Ext.getCmp("staticMI").hide(); - Ext.getCmp("cancelMI").hide();} - - else if(action.result.data.TAS_ASSIGN_TYPE=='STATIC_MI') - { - form.items.items[4].items[5].checked=true; - Ext.getCmp("staticMI").show(); - Ext.getCmp("cancelMI").show(); - Ext.getCmp("evaluate").hide(); - } - - else if(action.result.data.TAS_ASSIGN_TYPE=='CANCEL_MI') - { - form.items.items[4].items[6].checked=true; - Ext.getCmp("staticMI").show(); - Ext.getCmp("cancelMI").show(); - Ext.getCmp("evaluate").hide(); - } - - if(action.result.data.TAS_TYPE == 'ADHOC') - form.items.items[13].checked=false; - else - form.items.items[13].checked=true; - - - if(action.result.data.TAS_ASSIGN_TYPE == 'EVALUATE') - form.findField('TAS_ASSIGN_VARIABLE').show(); - - - - }, - failure:function(form, action) { - PMExt.notify( _('ID_STATUS') , _('ID_FAILURE') ); - } - }); - - taskPropertiesTabs.render(document.body); - workflow.taskPropertiesTabs = taskPropertiesTabs; - - var window = new Ext.Window({ - title: _('ID_TASK'), - collapsible: false, - maximizable: false, - width: 600, - height: 370, - minWidth: 300, - minHeight: 150, - layout: 'fit', - plain: true, - buttonAlign: 'center', - items: taskPropertiesTabs, - buttons: [{ - text: _('ID_SAVE'), - formBind :true, - handler: function(){ - //var getstore = taskPropertiesTabs.getStore(); - //var getData = getstore.data.items; - taskExtObj.saveTaskProperties(); - //window.hide(); - - } - },{ - text: _('ID_CANCEL'), - handler: function(){ - // when this button clicked, - window.hide(); - } - }] - }); - window.show(); - -} - -TaskContext.prototype.saveTaskProperties= function() -{ - var saveTaskform = workflow.taskPropertiesTabs.getForm().getValues(); - var taskId = workflow.currentSelection.id; - var tas_start = saveTaskform['TAS_START']; - var tas_type = saveTaskform['TAS_TYPE']; - var tas_transfer_fly = saveTaskform['TAS_TRANSFER_FLY']; - var send_email = saveTaskform['SEND_EMAIL']; - saveTaskform['TAS_UID'] = taskId; - alert(tas_start); - - //Checking checkbox fields - if(typeof tas_start != 'undefined' && tas_start != ''){ - if(tas_start == 'on') - saveTaskform['TAS_START'] = 'TRUE'; - } - else - saveTaskform['TAS_START'] = 'FALSE'; - - if(typeof tas_transfer_fly != 'undefined' && tas_transfer_fly != ''){ - if(tas_transfer_fly == 'on') - saveTaskform['TAS_TRANSFER_FLY'] = 'TRUE'; - } - else - saveTaskform['TAS_TRANSFER_FLY'] = 'FALSE'; - - if(typeof send_email != 'undefined' && send_email != ''){ - if(send_email == 'on') - saveTaskform['SEND_EMAIL'] = 'TRUE'; - } - else - saveTaskform['SEND_EMAIL'] = 'FALSE'; - - if(typeof tas_type != 'undefined' && tas_type != ''){ - if(tas_type == 'on') - saveTaskform['TAS_TYPE'] = 'ADHOC'; - } - else - saveTaskform['TAS_TYPE'] = 'NORMAL'; - - var object_data = Ext.util.JSON.encode(saveTaskform); - - Ext.Ajax.request({ - url: '../tasks/tasks_Ajax.php' , - success: function (response) { // When saving data success - PMExt.notify( _('ID_STATUS') , _('ID_TASK_PROPERTIES_SAVE') ); - }, - failure: function () { // when saving data failed - PMExt.notify( _('ID_STATUS') , _('ID_ERROR_TASK_SAVE') ); - }, - params: { - functions:'saveTaskData', - oData:object_data - } - }); -} - -TaskContext.prototype.stepTriggers = function() - { - var taskId = workflow.currentSelection.id; - var ProcMapObj= new ProcessMapContext(); - var triggersFields = Ext.data.Record.create([ - { - name: 'CON_VALUE', - type: 'string' - }, - { - name: 'ST_TYPE', - type: 'string' - }, - { - name: 'STEP_UID', - type: 'string' - }, - { - name: 'TRI_UID', - type: 'string' - }, - { - name: 'ST_POSITION', - type: 'string' - }, - { - name: 'TRI_TITLE', - type: 'string' - }, - { - name: 'ST_CONDITION', - type: 'string' - } - ]); - - var triggerEditor = new Ext.ux.grid.RowEditor({ - saveText: _('ID_UPDATE') - }); - - var root = new Ext.tree.AsyncTreeNode({text: 'treeRoot',id:'0'}); - var tree = new Ext.tree.TreePanel({ - //renderTo : 'cases-grid', - dataUrl : 'get-triggers-tree.php?tid='+taskId, - border : false, - rootVisible : false, - height : 320, - width : 230, - useArrows : false, - autoScroll : true, - animate : true - }); - tree.setRootNode(root); - root.expand(true); - - tree.on('click', function (node){ - if(node.isLeaf()){ - var sStepUID = node.attributes.id; - workflow.selectedStepUID = sStepUID; - - stepsTriggers.on({ - beforeload: { - fn: function (store, options) { - // use {@link Ext.data.HttpProxy#setUrl setUrl} to change the URL for *just* this request. - var link = 'bpmn/proxyExtjs?tid='+taskId+'&stepid='+sStepUID+'&action=getAssignedStepTriggers'; - store.proxy.setUrl(link, true); - } - } - }); - - availableTriggers.on({ - beforeload: { - fn: function (store, options) { - // use {@link Ext.data.HttpProxy#setUrl setUrl} to change the URL for *just* this request. - var link = 'bpmn/proxyExtjs?pid='+pro_uid+'&tid='+taskId+'&stepid='+sStepUID+'&action=getAvailableStepTriggers'; - store.proxy.setUrl(link, true); - } - } - }); - - triggerGrid.store.load(); - availableTriggers.load(); - //availableTriggers.reload(); - triggerGrid.show(); - } - else - triggerGrid.hide(); - }); - - - var addBtn = new Ext.Button({ - id: 'addBtn', - text: _('ID_ADD'), - iconCls: 'button_menu_ext ss_sprite ss_add', - handler: function(){ - //var User = triggerGrid.getStore(); - var e1 = new triggersFields({ - //STEP_TITLE: User.data.items[0].data.STEP_TITLE, - CON_VALUE : '', - ST_TYPE : '', - STEP_UID : '', - TRI_UID : '', - ST_POSITION : '', - ST_CONDITION : '', - TRI_TITLE : '' - }); - - if(availableTriggers.data.items.length == 0) - PMExt.notify( _('ID_STATUS') , _('ID_TRIGGERS_UNAVAILABLE') ); - else - { - triggerEditor.stopEditing(); - stepsTriggers.insert(0, e1); - triggerGrid.getView().refresh(); - //triggerGrid.getSelectionModel().selectRow(0); - triggerEditor.startEditing(0, 0); - } - - } - }); - - var removeBtn = new Ext.Button({ - id: 'removeBtn', - text: _('ID_REMOVE'), - iconCls: 'button_menu_ext ss_sprite ss_delete', - handler: function (s) { - triggerEditor.stopEditing(); - var s = triggerGrid.getSelectionModel().getSelections(); - for(var i = 0, r; r = s[i]; i++){ - - //First Deleting step from Database using Ajax - var stepUID = r.data.STEP_UID; - var sTrigger = r.data.TRI_UID; - var sType = r.data.ST_TYPE; - var iPosition = r.data.ST_POSITION; - var urlparams = '?action=ofToAssignTrigger&sStep=' + stepUID + '&sTrigger=' + sTrigger + '&sType=' + sType + '&iPosition=' + iPosition - - //if STEP_UID is properly defined (i.e. set to valid value) then only delete the row - //else its a BLANK ROW for which Ajax should not be called. - if(r.data.STEP_UID != "") - { - Ext.Ajax.request({ - url : '../steps/steps_Ajax.php' + urlparams, - success: function(response) { - PMExt.notify( _('ID_STATUS') , _('ID_TRIGGER_REMOVE') ); - //Secondly deleting from Grid - stepsTriggers.remove(r); - - availableTriggers.reload(); - } - }); - } - else - stepsTriggers.remove(r); - } - } - }); - - - var btnTriggerCondition = new Ext.Button({ - //id: 'btnCondition', - text: _('ID_CONDITION'), - handler: function (s) { - workflow.variablesAction = 'grid'; - workflow.variable = '@@', - workflow.gridField = 'ST_CONDITION'; - var rowSelected = triggerGrid.getSelectionModel().getSelections(); - if(rowSelected == '') - workflow.gridObjectRowSelected = triggerGrid; - else - workflow.gridObjectRowSelected = rowSelected; - //var rowSelected = Objectsgrid; - //workflow.gridObject = Objectsgrid; - var rowData = ProcMapObj.ExtVariables(); - } - }); - - var toolBar = new Ext.Toolbar({ - items: [addBtn, removeBtn, btnTriggerCondition] - }); - - - // create the Data Store of users that are already assigned to a task - var stepsTriggers = new Ext.data.JsonStore({ - root : 'data', - url : 'bpmn/proxyExtjs?tid='+taskId+'&action=',//+'&stepid='+workflow.selectedStepUID, - totalProperty : 'totalCount', - idProperty : 'gridIndex', - remoteSort : true, - fields : triggersFields - }); - //taskUsers.setDefaultSort('LABEL', 'asc'); - stepsTriggers.load({params:{start : 0 , limit : 5 }}); - - var availableTriggers = new Ext.data.JsonStore({ - root : 'data', - url : 'bpmn/proxyExtjs?pid='+pro_uid+'&tid='+taskId+'&action=',//+'&stepid='+workflow.selectedStepUID, - totalProperty : 'totalCount', - idProperty : 'gridIndex', - remoteSort : false, //true, - autoLoad : true, - fields : triggersFields - }); - - //availableTriggers.load(); - - var triggerGrid = new Ext.grid.GridPanel({ - store: stepsTriggers, - id : 'triggerGrid', - //cm: cm, - loadMask: true, - loadingText: 'Loading...', - //renderTo: 'cases-grid', - frame: false, - autoHeight:false, - hidden :true, - clicksToEdit: 1, - width : 450, - minHeight:400, - height :320, - layout: 'fit', - plugins: [triggerEditor], - columns: [ - new Ext.grid.RowNumberer(), - { - id: 'blank', - hidden : true, - //width:0, - editable: true, - editor: new Ext.form.TextField({ - allowBlank: true - }) - }, - { - id: 'CON_VALUE', - header: _('ID_TRIGGERS'), - dataIndex: 'CON_VALUE', - //width: 200, - sortable: true, - editor: new Ext.form.ComboBox({ - id : 'available', - xtype : 'combo', - fieldLabel : 'Users_groups', - hiddenName : 'number', - store : availableTriggers, - displayField : 'CON_VALUE', - valueField : 'CON_VALUE', - name : 'CON_VALUE', - scope : this, - triggerAction: 'all', - emptyText : 'Select Triggers', - allowBlank : false, - onSelect : function(record, index){ - var triggerStore = triggerGrid.getStore(); - - if(typeof workflow.currentRowTrigger == 'undefined') - var selectedrowIndex = '0'; - else - selectedrowIndex = workflow.currentRowTrigger; //getting Index of the row that has been edited - - //User.data.items[0].data.CON_VALUE = record.data.CON_VALUE; - triggerStore.data.items[selectedrowIndex].data.ST_TYPE = record.data.ST_TYPE; - triggerStore.data.items[selectedrowIndex].data.STEP_UID = record.data.STEP_UID; - triggerStore.data.items[selectedrowIndex].data.TRI_UID = record.data.TRI_UID; - triggerStore.data.items[selectedrowIndex].data.ST_POSITION = record.data.ST_POSITION; - triggerStore.data.items[selectedrowIndex].data.TRI_TITLE = record.data.TRI_TITLE; - - workflow.currentrowIndex = '0'; - this.setValue(record.data[this.valueField || this.displayField]); - this.collapse(); - } - }) - }, - { - //id: 'STEP_TITLE', - header: _('ID_CONDITION'), - dataIndex: 'ST_CONDITION', - //width: 200, - editable: true, - editor: new Ext.form.TextField({ - allowBlank: true - }) - } - - ], - sm: new Ext.grid.RowSelectionModel({ - singleSelect: true, - listeners: { - rowselect: function(smObj, rowIndex, record) { - workflow.currentRowTrigger = rowIndex; - } - } - }), - stripeRows: true, - viewConfig: {forceFit: true}, - bbar: new Ext.PagingToolbar({ - pageSize: 5, - store: stepsTriggers, - displayInfo: true, - displayMsg: 'Displaying Step Tiggers {0} - {1} of {2}', - emptyMsg: "No Step Tiggers to display", - items:[] - }), - tbar: toolBar - }); - - triggerEditor.on({ - scope: this, - afteredit: function(roweditor, changes, record, rowIndex) { - - var stepUID = record.data.STEP_UID; - var triUID = record.data.TRI_UID; - var sType = record.data.ST_TYPE; - var sCondition = record.data.ST_CONDITION; - //var urlparams = '?action=assignTrigger&data={"STEP_UID":"'+stepUID+'","TRI_UID":"'+triUID+'","ST_TYPE":"'+sType+'","ST_CONDITION":""}'; - Ext.Ajax.request({ - url : '../steps/steps_Ajax.php', - method: 'POST', - params:{ - action : 'assignTrigger', - STEP_UID : stepUID, - TRI_UID : triUID, - ST_TYPE : sType, - ST_CONDITION : sCondition - }, - success: function(response) { - PMExt.notify( _('ID_STATUS') , _('ID_TRIGGER_ASSIGN') ); - tree.getLoader().dataUrl = 'get-triggers-tree.php?tid='+taskId; - tree.getLoader().load(tree.root); - } - }); - - //Deleting previously assigned trigger on updating/replacing with new trigger. - if(changes != '' && typeof record.json != 'undefined' ) - { - stepUID = record.json.STEP_UID; - var sTrigger = record.json.TRI_UID; - sType = record.json.ST_TYPE; - var iPosition = record.json.ST_POSITION; - var condition = record.json.ST_CONDITION; - - var urlparams = '?action=ofToAssignTrigger&sStep=' + stepUID + '&sTrigger=' + sTrigger + '&sType=' + sType + '&iPosition=' + iPosition - - Ext.Ajax.request({ - url : '../steps/steps_Ajax.php' + urlparams, - success: function(response) { - //Ext.MessageBox.alert ('Status','Trigger has been updated successfully.'); - } - }); - } - availableTriggers.reload(); - } - }); - - var treeGrid = new Ext.FormPanel({ - frame: false, - monitorValid : true, - labelAlign: 'left', - width: 750, - height: 500, - layout: 'column', - items: [{ - columnWidth: 0.4, - layout: 'fit', - items: [tree] - },{ - columnWidth: 0.6, - xtype: 'fieldset', - //labelWidth: 120, - title:_('ID_ASSIGN_TRIGGERS'), - //defaults: {width: 140, border:false}, - autoHeight: true, - border: false, - items: [triggerGrid] - }] - }); - - return treeGrid; -} - -TaskContext.prototype.editUsersAdHoc= function() -{ - var taskExtObj = new TaskContext(); - var taskId = workflow.currentSelection.id; - var userFields = Ext.data.Record.create([ - { - name: 'LABEL', - type: 'string' - },{ - name: 'TU_TYPE', - type: 'string' - },{ - name: 'TU_RELATION', - type: 'string' - },{ - name: 'TAS_UID', - type: 'string' - },{ - name: 'USR_UID', - type: 'string' - } - ]); - var editor = new Ext.ux.grid.RowEditor({ - saveText: _('ID_UPDATE') - }); - var taskUsers = new Ext.data.JsonStore({ - root : 'data', - totalProperty: 'totalCount', - idProperty : 'gridIndex', - remoteSort : true, - fields : userFields, - proxy: new Ext.data.HttpProxy({ - url: 'bpmn/proxyExtjs?pid='+pro_uid+'&tid='+taskId+'&action=assignedUsers' - }) - }); - //taskUsers.setDefaultSort('LABEL', 'asc'); - taskUsers.load({params:{start : 0 , limit : 10 }}); - - // create the Data Store of users that are not assigned to a task - var storeUsers = new Ext.data.JsonStore({ - root : 'data', - url : 'bpmn/proxyExtjs?tid='+taskId+'&action=availableUsers', - totalProperty : 'totalCount', - idProperty : 'gridIndex', - remoteSort : false, //true, - autoLoad : true, - fields : userFields - }); - - - var btnAdd = new Ext.Button({ - id: 'btnAdd', - text: _('ID_ASSIGN'), - iconCls: 'button_menu_ext ss_sprite ss_add', - handler: function(){ - var User = grid.getStore(); - var e = new userFields({ - //LABEL: 'Select User or Group', - //LABEL: User.data.items[0].data.LABEL, - TAS_UID: '', - TU_TYPE: '', - USR_UID: '', - TU_RELATION: '' - }); - - //storeUsers.reload(); - if(storeUsers.data.items.length == 0) - PMExt.notify( _('ID_STATUS') , _('ID_USERS_UNAVAILABLE') ); - else - { - editor.stopEditing(); - taskUsers.insert(0, e); - grid.getView().refresh(); - //grid.getSelectionModel().selectRow(0); - editor.startEditing(0, 0); - - } - - } - - }); - - var btnRemove = new Ext.Button({ - id: 'btnRemove', - text: _('ID_REMOVE'), - iconCls: 'button_menu_ext ss_sprite ss_delete', - handler: function (s) { - editor.stopEditing(); - var s = grid.getSelectionModel().getSelections(); - for(var i = 0, r; r = s[i]; i++){ - - //First Deleting assigned users from Database - var user_TURel = r.data.TU_RELATION; - var userUID = r.data.USR_UID; - var user_TUtype = r.data.TU_TYPE; - var urlparams = '?action=ofToAssign&data={"TAS_UID":"'+taskId+'","TU_RELATION":"'+user_TURel+'","USR_UID":"'+userUID+'","TU_TYPE":"'+user_TUtype+'"}'; - - //if USR_UID is properly defined (i.e. set to valid value) then only delete the row - //else its a BLANK ROW for which Ajax should not be called. - if(r.data.USR_UID != "") - { - Ext.Ajax.request({ - url : 'bpmn/processes_Ajax.php' +urlparams , - /*method: 'POST', - params: { - functions : 'ofToAssign', - TAS_UID : taskId, - TU_RELATION : user_TURel, - USR_UID : userUID, - TU_TYPE : user_TUtype - - },*/ - success: function(response) { - PMExt.notify( _('ID_STATUS') , _('ID_USERS_REMOVED') ); - //Secondly deleting from Grid - taskUsers.remove(r); - //Reloading available user store - taskUsers.reload(); - } - }); - } - else - taskUsers.remove(r); - } - } - }); - - var tb = new Ext.Toolbar({ - items: [btnAdd, btnRemove] - }); - - // create the Data Store of users that are already assigned to a task - var grid = new Ext.grid.GridPanel({ - store: taskUsers, - id : 'mygrid', - //cm: cm, - loadMask: true, - loadingText: 'Loading...', - //renderTo: 'cases-grid', - frame: false, - autoHeight:false, - clicksToEdit: 1, - minHeight:400, - height :330, - layout: 'fit', - plugins: [editor], - columns: [ - new Ext.grid.RowNumberer(), - { - id: 'LABEL', - header: _('ID_GROUP_USER'), - dataIndex: 'LABEL', - width: 100, - sortable: true, - editor: new Ext.form.ComboBox({ - xtype: 'combo', - fieldLabel: 'Users_groups', - hiddenName: 'number', - store : storeUsers, - displayField : 'LABEL', - valueField : 'LABEL', - name : 'LABEL', - triggerAction: 'all', - emptyText: 'Select User or Group', - allowBlank: false, - onSelect: function(record, index){ - var User = grid.getStore(); - - if(typeof workflow.currentrowIndex == 'undefined') - var selectedrowIndex = '0'; - else - selectedrowIndex = workflow.currentrowIndex; //getting Index of the row that has been edited - - //User.data.items[0].data.LABEL= record.data.LABEL; - User.data.items[selectedrowIndex].data.TAS_UID = record.data.TAS_UID; - User.data.items[selectedrowIndex].data.TU_TYPE = record.data.TU_TYPE; - User.data.items[selectedrowIndex].data.USR_UID = record.data.USR_UID; - User.data.items[selectedrowIndex].data.TU_RELATION = record.data.TU_RELATION; - - this.setValue(record.data[this.valueField || this.displayField]); - this.collapse(); - } - }) - } - ], - sm: new Ext.grid.RowSelectionModel({ - singleSelect: true, - listeners: { - rowselect: function(smObj, rowIndex, record) { - workflow.currentrowIndex = rowIndex; - } - } - }), - stripeRows: true, - viewConfig: {forceFit: true}, - bbar: new Ext.PagingToolbar({ - pageSize: 10, - store: taskUsers, - displayInfo: true, - displayMsg: 'Displaying Users {0} - {1} of {2}', - emptyMsg: "No Users to display", - items:[] - }), - tbar: tb - }); - - storeUsers.load(); - - editor.on({ - scope: this, - afteredit: function(roweditor, changes, record, rowIndex) { - - var taskId = record.data.TAS_UID; - var userId = record.data.USR_UID; - var tu_Type = record.data.TU_TYPE; - var tu_Relation = record.data.TU_RELATION; - ///var urlparams = '?action=assign&data={"TAS_UID":"'+taskId+'","USR_UID":"'+userId+'","TU_TYPE":"'+tu_Type+'","TU_RELATION":"'+tu_Relation+'"}'; - - Ext.Ajax.request({ - url: '../users/users_Ajax.php', - METHOD:'post', - success: function (response) { // When saving data success - PMExt.notify( _('ID_STATUS') , _('ID_USER_ASSIGNED') ); - }, - params:{ - functions : 'assign', - TAS_UID : taskId, - USR_UID : userId, - TU_TYPE : tu_Type, - TU_RELATION:tu_Relation - - }, - failure: function () { // when saving data failed - PMExt.notify( _('ID_STATUS') , _('ID_USER_SAVE_FAIL') ); - } - }); - - //Updating the user incase if already assigned user has been replaced by other user - if(changes != '' && typeof record.json != 'undefined') - { - var user_TURel = record.json.TU_RELATION; - var userUID = record.json.USR_UID; - var user_TUtype = record.json.TU_TYPE; - //urlparams = '?action=ofToAssign&data={"TAS_UID":"'+taskId+'","TU_RELATION":"'+user_TURel+'","USR_UID":"'+userUID+'","TU_TYPE":"'+user_TUtype+'"}'; - Ext.Ajax.request({ - url : '../users/users_Ajax.php', - method: 'POST', - success: function(response) { - PMExt.notify( _('ID_STATUS') , _('ID_USER_ASSIGNED') ); - //Ext.MessageBox.alert ('Status','User has been updated successfully.'); - }, - params:{ - functions : 'ofToAssign', - TAS_UID : taskId, - USR_UID : userId, - TU_TYPE : tu_Type, - TU_RELATION:tu_Relation - - } - }); - } - //storeUsers.reload(); - } - }); - - var panel = new Ext.Panel({ - id: 'panel', - //renderTo: Ext.getBody(), - items: [grid] - }); - - var window = new Ext.Window({ - title: _('ID_USER_GROUPS_ADHOC'), - collapsible: false, - maximizable: false, - width: 400, - height: 360, - minWidth: 200, - minHeight: 150, - layout: 'fit', - plain: true, - buttonAlign: 'center', - items: panel - }); - window.show(); -} - -/** - * ExtJs Form of SubProcess Properties - * @Param Shape Object - * @Author Safan Maredia - */ -TaskContext.prototype.editSubProcessProperties= function(_3525) -{ - var taskId = workflow.currentSelection.id; - //Variables Out Grid - var subProcessFields = Ext.data.Record.create([ - {name: 'SP_UID',type: 'string'}, - {name: 'TAS_UID',type: 'string'}, - {name: 'PRO_PARENT',type: 'string'}, - {name: 'PRO_UID',type: 'string'}, - {name: 'PRO_TITLE',type: 'string'}, - {name: 'TAS_PARENT',type: 'string'}, - {name: 'SP_SYNCHRONOUS',type: 'string'}, - {name: 'SPROCESS_NAME',type: 'string'}, - {name: 'TASKS',type: 'string'}, - {name: 'TAS_TITLE',type: 'string'}, - {name: 'CON_VALUE',type: 'string'}, - {name: 'VAR_OUT1',type: 'string'}, - {name: 'VAR_OUT2',type: 'string'}, - {name: 'VAR_IN1',type: 'string'}, - {name: 'VAR_IN2',type: 'string'} - ]); - - var editorOut = new Ext.ux.grid.RowEditor({ - saveText: _('ID_UPDATE') - }); - var editorIn = new Ext.ux.grid.RowEditor({ - saveText: _('ID_UPDATE') - }); - - //Variable out grid configuration starts here - var btnAddOut = new Ext.Button({ - id: 'btnAddOut', - text: _('ID_ASSIGN_VARIABLES_OUT'), - iconCls: 'button_menu_ext ss_sprite ss_add', - handler: function(){ - var storeData = variableOutGrid.getStore(); - //STEP_TITLE: storeData.data.items[0].data.STEP_TITLE, - var e = new subProcessFields({ - SP_UID : '', - PRO_PARENT : '', - SP_SYNCHRONOUS : '', - TAS_PARENT : '', - TASKS : '', - VAR_OUT1 : '', - VAR_OUT2 : '' - }); - - editorOut.stopEditing(); - variablesOutStore.insert(0, e); - variableOutGrid.getView().refresh(); - //grid.getSelectionModel().selectRow(0); - editorOut.startEditing(0, 0); - } - }); - - var btnRemoveOut = new Ext.Button({ - id: 'btnRemoveOut', - text: _('ID_REMOVE_VARIABLES_OUT'), - iconCls: 'button_menu_ext ss_sprite ss_delete', - handler: function (s) { - editorOut.stopEditing(); - var s = variableOutGrid.getSelectionModel().getSelections(); - for(var i = 0, r; r = s[i]; i++){ - variablesOutStore.remove(r); - } - } - }); - - var tbOut = new Ext.Toolbar({ - items: [btnAddOut, btnRemoveOut] - }); - - - //Variable out grid configuration starts here - var btnAddIn = new Ext.Button({ - id: 'btnAddIn', - text: 'ID_ASSIGN_VARIABLES_IN', - iconCls: 'button_menu_ext ss_sprite ss_add', - handler: function(){ - var e = new subProcessFields({ - SP_UID : '', - PRO_PARENT : '', - SP_SYNCHRONOUS : '', - TAS_PARENT : '', - VAR_IN1 : '', - VAR_IN2 : '' - }); - - editorIn.stopEditing(); - variablesInStore.insert(0, e); - variableInGrid.getView().refresh(); - editorIn.startEditing(0, 0); - } - }); - - var btnRemoveIn = new Ext.Button({ - id: 'btnRemoveIn', - text: 'ID_REMOVE_VARIABLES_IN', - iconCls: 'button_menu_ext ss_sprite ss_delete', - handler: function (s) { - editorIn.stopEditing(); - var s = variableInGrid.getSelectionModel().getSelections(); - for(var i = 0, r; r = s[i]; i++){ - - - //Secondly deleting from Grid - variablesInStore.remove(r); - } - } - }); - - var tbIn = new Ext.Toolbar({ - items: [btnAddIn, btnRemoveIn] - }); - - // create the Data Store of all Variables Out - var variablesOutStore = new Ext.data.JsonStore({ - root : 'data', - totalProperty: 'totalCount', - idProperty : 'gridIndex', - remoteSort : true, - fields : subProcessFields, - proxy : new Ext.data.HttpProxy({ - url : 'bpmn/proxyExtjs?pid='+pro_uid+'&action=getSubProcessProperties&tid='+taskId+'&type=0' //type=0 specifies Variables Out (Asynchronous) - }) - }); - variablesOutStore.load(); - - // create the Data Store of all Variables In - var variablesInStore = new Ext.data.JsonStore({ - root : 'data', - totalProperty: 'totalCount', - idProperty : 'gridIndex', - remoteSort : true, - fields : subProcessFields, - proxy : new Ext.data.HttpProxy({ - url : 'bpmn/proxyExtjs?pid='+pro_uid+'&action=getSubProcessProperties&tid='+taskId+'&type=1' //type=1 specifies Variables In (Synchronous) - }) - }); - //taskUsers.setDefaultSort('LABEL', 'asc'); - variablesInStore.load(); - - var processListStore = new Ext.data.JsonStore({ - root : 'data', - totalProperty: 'totalCount', - idProperty : 'gridIndex', - remoteSort : true, - fields : subProcessFields, - proxy : new Ext.data.HttpProxy({ - url : '../processes/processesList' - }) - }); - processListStore.load(); - - var variableOutGrid = new Ext.grid.GridPanel({ - store : variablesOutStore, - id : 'mygrid', - loadMask : true, - loadingText : 'Loading...', - //renderTo : 'cases-grid', - frame : false, - autoHeight : true, - autoScroll : true, - clicksToEdit: 1, - layout : 'form', - plugins : [editorOut], - columns : [{ - id : 'VAR_OUT1', - name : 'VAR_OUT1', - header : _('ID_ORIGIN'), - dataIndex: 'VAR_OUT1', - width : 200, - sortable : true, - editor : new Ext.form.TextField({ - allowBlank: true - }) - }, - { - sortable: false, - renderer: function() - { - return ''; - } - }, - { - id : 'VAR_OUT2', - name : 'VAR_OUT2', - header : _('ID_TARGET'), - dataIndex : 'VAR_OUT2', - width : 200, - sortable : true, - editor : new Ext.form.TextField({ - allowBlank: true - }) - }, - { - sortable: false, - renderer: function() - { - return ''; - } - } - ], - viewConfig: {forceFit: true}, - stripeRows: true, - tbar: tbOut - }); - - var variableInGrid = new Ext.grid.GridPanel({ - store : variablesInStore, - id : 'mygrid1', - loadMask : true, - loadingText : 'Loading...', - //renderTo : 'cases-grid', - frame : false, - autoHeight : true, - autoScroll : true, - clicksToEdit: 1, - layout : 'form', - plugins : [editorIn], - columns : [{ - id : 'VAR_IN1', - name : 'VAR_IN1', - header : _('ID_ORIGIN'), - dataIndex: 'VAR_IN1', - width : 200, - sortable : true, - editor : new Ext.form.TextField({ - allowBlank: true - }) - }, - { - sortable: false, - renderer: function() - { - return ''; - } - }, - { - id : 'VAR_IN2', - name : 'VAR_IN2', - header : _('ID_TARGET'), - dataIndex : 'VAR_IN2', - width : 200, - sortable : true, - editor : new Ext.form.TextField({ - allowBlank: true - }) - }, - { - sortable: false, - renderer: function() - { - return ''; - } - } - ], - viewConfig: {forceFit: true}, - stripeRows: true, - tbar: tbIn - }); - - var subProcessProperties = new Ext.FormPanel({ - labelWidth : 110, // label settings here cascade unless overridden - //frame:true, - width: 500, - bodyStyle: 'padding:5px 0 0 5px;', - autoScroll: true, - items: [ - { - xtype:'fieldset', - title: _('ID_SUBPROCESS'), - collapsible: false, - autoHeight:true, - //width: 600, - defaultType: 'textfield', - items:[ - { - id: 'subProcessName', - xtype: 'textfield', - width: 350, - fieldLabel: _('ID_SUBPROCESS_NAME'), - name : 'SPROCESS_NAME', - allowBlank: false - }, - { - width: 300, - xtype: 'combo', - mode: 'local', - triggerAction: 'all', - forceSelection: true, - editable: false, - fieldLabel: _('ID_PROCESS'), - name: 'PRO_TITLE', - emptyText : 'Select Process', - displayField: 'PRO_TITLE', - valueField: 'PRO_TITLE', - store: processListStore, - onSelect: function(record, index){ - //processListStore.data.items[0].data.PRO_UID = record.data.PRO_UID; - Ext.getCmp("SEL_PROCESS").setValue(record.data.PRO_UID); - this.setValue(record.data[this.valueField || this.displayField]); - this.collapse(); - } - },{ - xtype :'hidden', - name :'SEL_PROCESS', - id :'SEL_PROCESS' - }, - { - width: 150, - id : 'spType', - xtype: 'combo', - mode: 'local', - triggerAction: 'all', - forceSelection: true, - editable: false, - fieldLabel: _('ID_TYPE'), - name: 'SP_SYNCHRONOUS', - hiddenName: 'SP_SYNCHRONOUS', - displayField: 'name', - valueField: 'value', - emptyText : 'Select Type', - store: new Ext.data.JsonStore({ - fields : ['name', 'value'], - data : [ - {name : 'Asynchronous', value: '0'}, - {name : 'Synchronous', value: '1'}, - ] - }), - onSelect: function(record, index){ - if(record.data.name == 'Synchronous') - Ext.getCmp("variablein").show(); - else - Ext.getCmp("variablein").hide(); - - this.setValue(record.data[this.valueField || this.displayField]); - this.collapse(); - } - }] - }, - { - id :'variableout', - name :'VAR_OUT1', - xtype:'fieldset', - title: _('ID_VARIABLES_OUT'), - collapsible: false, - labelAlign: 'top', - items:[variableOutGrid] - }, - { - id :'variablein', - name :'VAR_IN1', - xtype:'fieldset', - title: _('ID_VARIABLES_IN'), - //hidden: true, - collapsible: false, - labelAlign: 'top', - items:[variableInGrid] - }] - }); - - //Loading Task Details into the form - subProcessProperties.form.load({ - url:'bpmn/proxyExtjs?pid='+pro_uid+'&action=getSubProcessProperties&tid='+taskId+'&type=2', - method:'GET', - waitMsg:'Loading....', - success:function(form, action) { - var response = action.response.responseText; - var aData = Ext.util.JSON.decode(response); - spUID = aData.data[0].SP_UID; - proUID = aData.data[0].PRO_UID; - proParent = aData.data[0].PRO_PARENT; - spSync = aData.data[0].SP_SYNCHRONOUS; - tasParent = aData.data[0].TAS_PARENT; - tasks = aData.data[0].TASKS; - var processName = aData.data[0].SPROCESS_NAME; - if(action.result.data[0].SP_SYNCHRONOUS == 0) - { - Ext.getCmp("variablein").hide(); - form.findField('SP_SYNCHRONOUS').setValue('Asynchronous'); - } - else - { - Ext.getCmp("variablein").show(); - form.findField('SP_SYNCHRONOUS').setValue('Synchronous'); - } - form.findField('PRO_TITLE').setValue(action.result.data[0].PRO_TITLE); - form.findField('SPROCESS_NAME').setValue(processName); - }, - failure:function(form, action) { - PMExt.notify( _('ID_STATUS') , _('ID_LOAD_FAILED') ); - } - }); - - //subProcessProperties.render(document.body); - - var window = new Ext.Window({ - title: _('ID_PROPERTIES'), - collapsible: false, - maximizable: false, - width: 800, - height: 400, - layout: 'fit', - plain: true, - buttonAlign: 'center', - items: subProcessProperties, - buttons: [{ - text: _('ID_SAVE'), - handler: function(){ - var getForm = subProcessProperties.getForm().getValues(); - - //Getting data from Grid (Variables In and Out) - var storeOutData = variableOutGrid.getStore(); - var storeInData = variableInGrid.getStore(); - var storeOutLength = storeOutData.data.items.length; - var storeInLength = storeInData.data.items.length; - var varOut1 = new Array(); - var varOut2 = new Array(); - for(var i=0;i 200 || this.getHeight() > 100) && this.limitFlag == false) { - this.originalWidth = 200; - this.originalHeight = 100; - this.width = 200; - this.height = 100; - } - if ((this.getWidth() < 165 || this.getHeight() < 40) && this.limitFlag == false) { - this.originalWidth = 165; - this.originalHeight = 40; - this.width = 165; - this.height = 40; - } - } - else { - this.width = this.originalWidth * workflow.zoomfactor; - this.height = this.originalHeight * workflow.zoomfactor; - } - //For Zooming - - //Set the Task Limitation - /*if ((this.getWidth() >= 200 || this.getHeight() >= 100 ) && this.limitFlag != true) { - this.originalWidth = 200; - this.originalHeight = 100; - } - else if ((this.getWidth() <= 165 || this.getHeight() <= 40) && this.limitFlag != true) { - this.originalWidth = 165; - this.originalHeight = 40; - }*/ - - - - var x = new Array(6, this.getWidth() - 3, this.getWidth(), this.getWidth(), this.getWidth() - 3, 6, 3, 3, 6); - var y = new Array(3, 3, 6, this.getHeight() - 3, this.getHeight(), this.getHeight(), this.getHeight() - 3, 6, 3); - this.stroke = 2; - this.graphics.setStroke(this.stroke); - this.graphics.setColor("#c0c0c0"); - this.graphics.fillPolygon(x, y); - for (var i = 0; i < x.length; i++) { - x[i] = x[i] - 3; - y[i] = y[i] - 3; - } - this.graphics.setColor("#DBDFF6"); - this.graphics.fillPolygon(x, y); - - this.graphics.setColor("#5164b5"); //Blue Color - this.graphics.drawPolygon(x, y); - this.graphics.paint(); - this.x_text = this.workflow.getAbsoluteX(); //Get x co-ordinate from figure - this.y_text = this.workflow.getAbsoluteY(); //Get x co-ordinate from figure - - /* Created New Object of jsGraphics to draw String. - * New object is created to implement changing of Text functionality - */ - this.bpmnText = new jsGraphics(this.id); - //erik: overridden the drawStringRect method - this.bpmnText.drawStringRect = function(txt, x, y, width, height, halign, cls) - { - var classBk = typeof(cls) != 'undefined' ? 'class="'+cls+'" ' : ''; - this.htm += '
'+ - '' +txt + '<\/span>'+ - '<\/div>'; - }; - - var zoomRate = workflow.zoomfactor; - var len = this.getWidth() / 18; - if (len >= 6) { - this.padleft = 0.05 * this.getWidth(); - this.padtop = 0.13 * this.getHeight() -1; - this.rectWidth = this.getWidth() - 2 * this.padleft; - } - else { - this.padleft = 2; //0.06 * this.getWidth(); - this.padtop = 2; //0.09 * this.getHeight() -3; - this.rectWidth = this.getWidth() - 2 * this.padleft; - } - - this.rectheight = this.getHeight() - this.padtop -3; - if ( this.rectheight < 7 ) this.rectheight = 7; - - - if(typeof this.taskName == 'undefined') - this.taskName = ''; - - //if (typeof this.fontSize == 'undefined' || this.fontSize == '') - this.fontSize = 11; - var fontSize = zoomRate * this.fontSize; - - this.graphics.setFont('verdana', + fontSize+'px', Font.PLAIN); - - this.graphics.drawStringRect(this.taskName, this.padleft, this.padtop, this.rectWidth, this.rectheight, 'center', 'x-task'); - this.graphics.paint(); - //***** Drawing Timer Boundary event starts here - this.boundaryTimer = new jsGraphics(this.id); - - var x_cir1=5; - var y_cir1=45; - this.x3 = x[3]; - this.y4 = y[4]; - this.y5 = y[5]; - - var xbt = 13*zoomRate; //x-base boundaryTimer - var ybt = this.y4 - 13*zoomRate; //y-base boundaryTimer - var dbt = 30*zoomRate; //diameter boundaryTimer - var ycbt = ybt + 11*zoomRate; //y-center boundaryTimer - this.graphics.setColor("#c0c0c0"); - this.graphics.fillEllipse(xbt+2, ybt+2, dbt, dbt); - this.graphics.setStroke(this.stroke-1); - this.graphics.setColor( "#f9faf2" ); - this.graphics.fillEllipse(xbt, ybt, dbt, dbt); - this.graphics.setColor("#adae5e"); - this.graphics.drawEllipse(xbt,ybt, dbt, dbt); - - var x_cir2=8; - var y_cir2=48; - //this.boundaryTimer.setColor( "#f9faf2" ); - //this.boundaryTimer.fillEllipse(xbt, ybt-9*zoomRate,(30-6)*zoomRate,(30-6)*zoomRate); - this.graphics.setColor("#adae5e"); - this.graphics.drawEllipse(xbt+(3*zoomRate), ybt+3*zoomRate,(24.4)*zoomRate,(24.4)*zoomRate); - - this.graphics.setColor("#adae5e"); - this.graphics.drawLine(dbt*0.45 +xbt, dbt*0.45+this.y5-10*zoomRate, dbt/1.6+xbt, dbt/2 +this.y5-10*zoomRate); //horizontal line - this.graphics.drawLine(dbt*0.45 +xbt, dbt*0.45+this.y5-10*zoomRate, dbt/2.2+xbt, dbt/3.7+this.y5-10*zoomRate); //vertical line - - this.graphics.setStroke(this.stroke-1); - this.graphics.drawLine(xbt +24*zoomRate,ycbt -3*zoomRate, xbt+20*zoomRate, ycbt ); //10th min line - this.graphics.drawLine(xbt +21*zoomRate,ycbt +4*zoomRate, xbt+25*zoomRate, ycbt +4*zoomRate); //15th min line - this.graphics.drawLine(xbt +24*zoomRate,ycbt +11*zoomRate, xbt+19*zoomRate, ycbt +9*zoomRate); //25th min line - this.graphics.drawLine(xbt +15*zoomRate,ycbt +11*zoomRate, xbt+15*zoomRate, ycbt+14*zoomRate); //30th min line - this.graphics.drawLine(xbt +8 *zoomRate,ycbt +11*zoomRate, xbt+12*zoomRate, ycbt +8*zoomRate); //40th min line - this.graphics.drawLine(xbt +5 *zoomRate,ycbt +4*zoomRate, xbt+8 *zoomRate, ycbt +4*zoomRate); //45th min line - this.graphics.drawLine(xbt +8 *zoomRate,ycbt -4*zoomRate, xbt+11*zoomRate, ycbt -1*zoomRate); //50th min line - this.graphics.drawLine(xbt+15 *zoomRate,ycbt -7*zoomRate, xbt+15*zoomRate, ycbt -4*zoomRate); //60th min line - - if(this.boundaryEvent == true) { - this.graphics.paint(); - } - //****************Drawing Timer Boundary event ends here **************** - - //this.bpmnText.paint(); - - //Code Added to Dynamically shift Ports on resizing of shapes - if (this.input1 != null) { - this.input1.setPosition(0, this.height / 2 -1); - } - if (this.output1 != null) { - this.output1.setPosition(this.width / 2, this.height -3); - } - if (this.input2 != null) { - this.input2.setPosition(this.width / 2, 0); - } - if (this.output2 != null) { - this.output2.setPosition(this.width-3, this.height / 2-1); - } - -}; - - -Figure.prototype.onDragend=function() { - if(typeof workflow.currentSelection != 'undefined' && workflow.currentSelection != null){ - var currObj = workflow.currentSelection; - currObj.orgXPos = eval(currObj.getX()/workflow.zoomfactor); - currObj.orgYPos = eval(currObj.getY()/workflow.zoomfactor); - //setPosition(); - if(typeof currObj.id != 'undefined' && currObj.id.length == 32){ - switch (currObj.type) { - case 'bpmnTask': - case 'bpmnSubProcess': - currObj.actiontype = 'saveTaskPosition'; - currObj.workflow.savePosition(currObj); - break; - case 'bpmnAnnotation': - currObj.actiontype = 'saveTextPosition'; - currObj.workflow.savePosition(currObj); - break; - default: - if(currObj.type.match(/Gateway/)){ - currObj.actiontype = 'saveGatewayPosition'; - currObj.workflow.savePosition(currObj); - } - else if(currObj.type.match(/Event/)) { - currObj.actiontype = 'saveEventPosition'; - currObj.workflow.savePosition(currObj); - } - } - } - workflow.setBoundary(currObj); - } - - if(this.getWorkflow().getEnableSmoothFigureHandling()==true) { - var _3dfe=this; - var _3dff=function(){ - if(_3dfe.alpha<1){ - _3dfe.setAlpha(Math.min(1,_3dfe.alpha+0.05)); - } - else { - window.clearInterval(_3dfe.timer); - _3dfe.timer=-1; - } - }; - if(_3dfe.timer>0){ - window.clearInterval(_3dfe.timer); - } - _3dfe.timer=window.setInterval(_3dff,20); - } - else{ - this.setAlpha(1); - } - this.command.setPosition(this.x,this.y); - this.workflow.commandStack.execute(this.command); - this.command=null; - this.isMoving=false; - this.workflow.hideSnapToHelperLines(); - this.fireMoveEvent(); - }; - - Figure.prototype.onKeyDown=function(_3e0e,ctrl){ - if(_3e0e==46&&this.isDeleteable()==true){ - workflow.getDeleteCriteria(); - //this.workflow.commandStack.execute(new CommandDelete(this)); - } - if(ctrl){ - this.workflow.onKeyDown(_3e0e,ctrl); - } -}; - -bpmnTask.prototype.setWorkflow = function (_40c5) { - VectorFigure.prototype.setWorkflow.call(this, _40c5); - if (_40c5 != null) { - /*Adding Port to the Task After dragging Task on the Canvas - *Ports will be invisibe After Drag and Drop, But It will be created - */ - var TaskPortName = ['output1', 'output2', 'input1', 'input2']; - var TaskPortType = ['OutputPort', 'OutputPort', 'InputPort', 'InputPort']; - var TaskPositionX = [this.width / 2, this.width, 0, this.width / 2]; - var TaskPositionY = [this.height-1, this.height / 2, this.height / 2, 0+1]; - - for (var i = 0; i < TaskPortName.length; i++) { - eval('this.' + TaskPortName[i] + ' = new ' + TaskPortType[i] + '()'); //Create New Port - eval('this.' + TaskPortName[i] + '.setWorkflow(_40c5)'); //Add port to the workflow - eval('this.' + TaskPortName[i] + '.setName("' + TaskPortName[i] + '")'); //Set PortName - eval('this.' + TaskPortName[i] + '.setZOrder(-1)'); //Set Z-Order of the port to -1. It will be below all the figure - eval('this.' + TaskPortName[i] + '.setBackgroundColor(new Color(255, 255, 255))'); //Setting Background of the port to white - eval('this.' + TaskPortName[i] + '.setColor(new Color(255, 255, 255))'); //Setting Border of the port to white - var oPort = eval('this.addPort(this.' + TaskPortName[i] + ',' + TaskPositionX[i] + ', ' + TaskPositionY[i] + ')'); //Setting Position of the port - var test = oPort; - } - } -}; - -InputPort.prototype.onDrop = function (port) { - if (port.getMaxFanOut && port.getMaxFanOut() <= port.getFanOut()) { - return; - } - if (this.parentNode.id == port.parentNode.id) { - } - else { - var _4070 = new CommandConnect(this.parentNode.workflow, port, this); - if (_4070.source.type == _4070.target.type) { - return; - } - - if(this.workflow.currentSelection.type.match(/Annotation/)) //Setting connection to Dotted for Annotation - _4070.setConnection(new DottedConnection()); - else - _4070.setConnection(new DecoratedConnection()); - - this.parentNode.workflow.getCommandStack().execute(_4070); - - //Saving Start Event - var preObj = new Array(); - var bpmnType = this.workflow.currentSelection.type; - - //Routing from end event to task - if(bpmnType.match(/End/) && bpmnType.match(/Event/) && port.parentNode.type.match(/Task/)) { - preObj = this.workflow.currentSelection; //end event - var newObj = port.parentNode; //task - newObj.conn = _4070.connection; - newObj.reverse = 1; //setting reverse parameter if user is routing from down to up - this.workflow.saveRoute(preObj,newObj); - } - //Routing from task to start event - else if(bpmnType.match(/Task/) && port.parentNode.type.match(/Event/)) { - preObj = this.workflow.currentSelection; //task - newObj = port.parentNode; //start event - var tas_uid = preObj.id; - this.workflow.saveEvents(newObj,tas_uid); - } - //Routing from task to task - else if(bpmnType.match(/Task/) && port.parentNode.type.match(/Task/)){ - preObj = workflow.currentSelection; - newObj = port.parentNode; - newObj.conn = _4070.connection; - newObj.sPortType =port.properties.name; - preObj.sPortType =this.properties.name; - workflow.saveRoute(newObj,preObj); - } - //Routing from task to gateway - else if(bpmnType.match(/Task/) && port.parentNode.type.match(/Gateway/)){ - var shape = new Array(); - shape.type = ''; - preObj = workflow.currentSelection; - newObj = port.parentNode; - workflow.saveRoute(newObj,shape); - } - //Routing from gateway to task - else if(bpmnType.match(/Gateway/) && (port.parentNode.type.match(/Gateway/) || port.parentNode.type.match(/Task/))){ - preObj = this.workflow.currentSelection; - newObj = port.parentNode; - this.workflow.saveRoute(preObj,newObj); - } - //Routing from task to Intermediate event - else if(port.parentNode.type.match(/Inter/) && port.parentNode.type.match(/Event/) && bpmnType.match(/Task/)){ - workflow.saveEvents(port.parentNode); - } - else if(port.parentNode.type.match(/Task/) && bpmnType.match(/Inter/) && bpmnType.match(/Event/)){ - workflow.saveEvents(workflow.currentSelection); - } - else if(bpmnType.match(/Annotation/)) { //Routing from task to Annotation - newObj = port.parentNode; - preObj = this.workflow.currentSelection; - newObj.actiontype = 'updateText'; - preObj.actiontype = 'updateText'; - this.workflow.saveShape(preObj); - } - } -}; - -OutputPort.prototype.onDrop = function (port) { - if (this.getMaxFanOut() <= this.getFanOut()) { - return; - } - - var connect = true; - var conn = port.workflow.checkConnectionsExist(port, 'targetPort', 'OutputPort'); - if (conn == 0) //If no connection Exist then Allow connect - connect = true; - else - if (conn < 2) //If One connection exist then Do not Allow to connect - connect = false; - - if (this.parentNode.id == port.parentNode.id || connect == false) { - } - else { - var _4070 = new CommandConnect(this.parentNode.workflow, this, port); - if (_4070.source.type == _4070.target.type) { - return; - } - - if(port.parentNode.type.match(/Annotation/)) //Setting connection to Dotted for Annotation - _4070.setConnection(new DottedConnection()); - else - _4070.setConnection(new DecoratedConnection()); - - this.parentNode.workflow.getCommandStack().execute(_4070); - - //Saving Start Event - var preObj = new Array(); - var bpmnType = this.workflow.currentSelection.type; - if(bpmnType.match(/Event/) && port.parentNode.type.match(/Task/)){ - var tas_uid = port.parentNode.id; - this.workflow.saveEvents(this.workflow.currentSelection,tas_uid); - } - else if(bpmnType.match(/Task/) && port.parentNode.type.match(/End/) && port.parentNode.type.match(/Event/)){ - preObj = this.workflow.currentSelection; - var newObj = port.parentNode; - newObj.conn = _4070.connection; - this.workflow.saveRoute(preObj,newObj); - } - else if(port.parentNode.type.match(/Task/) && bpmnType.match(/Inter/) && bpmnType.match(/Event/)){ - this.workflow.saveEvents(workflow.currentSelection); - } - else if(port.parentNode.type.match(/Event/) && port.parentNode.type.match(/Inter/) && bpmnType.match(/Task/)){ - this.workflow.saveEvents(port.parentNode); - } - else if(bpmnType.match(/Task/) && port.parentNode.type.match(/Task/)){ - preObj = this.workflow.currentSelection; - newObj = port.parentNode; - newObj.conn = _4070.connection; - newObj.sPortType =port.properties.name; - preObj.sPortType =this.properties.name; - this.workflow.saveRoute(preObj,newObj); - } - else if(bpmnType.match(/Gateway/) && (port.parentNode.type.match(/Task/) || port.parentNode.type.match(/Gateway/))){ //Routing from gateway to task - var shape = new Array(); - shape.type = ''; - preObj = this.workflow.currentSelection; - this.workflow.saveRoute(preObj,shape); - } - else if(bpmnType.match(/Task/) && port.parentNode.type.match(/Gateway/)){ //Routing from task to gateway - newObj = port.parentNode; - preObj = this.workflow.currentSelection; - this.workflow.saveRoute(newObj,preObj); - } - else if(port.parentNode.type.match(/Annotation/)){ //Routing from task to Annotation - newObj = port.parentNode; - preObj = this.workflow.currentSelection; - newObj.actiontype = 'updateText'; - this.workflow.saveShape(newObj); - } - } -}; - -LineEndResizeHandle.prototype.onDrop=function(_3f3e){ - var line=this.workflow.currentSelection; - line.isMoving=false; - if(line instanceof Connection){ - this.command.setNewPorts(line.getSource(),_3f3e); - - //If Input Port /Output Port is connected to respective ports, then should not connected - if(this.command.newSourcePort.type == this.command.newTargetPort.type) - return; - else { - this.command.newTargetPort.parentNode.conn = this.command.con; - this.command.newTargetPort.parentNode.sPortType = this.command.newTargetPort.properties.name; - this.command.newSourcePort.parentNode.sPortType = this.command.newSourcePort.properties.name; - this.workflow.saveRoute(this.command.newSourcePort.parentNode,this.command.newTargetPort.parentNode); - this.getWorkflow().getCommandStack().execute(this.command); - } - } - this.command=null; -}; - -LineStartResizeHandle.prototype.onDrop=function(_410d){ - var line=this.workflow.currentSelection; - line.isMoving=false; - if(line instanceof Connection){ - this.command.setNewPorts(_410d,line.getTarget()); - - //If Input Port /Output Port is connected to respective ports, then should not connected - if(this.command.newSourcePort.type == this.command.newTargetPort.type) - return; - else{ - this.command.newTargetPort.parentNode.conn = this.command.con; - this.command.newTargetPort.parentNode.sPortType = this.command.newTargetPort.properties.name; - this.command.newSourcePort.parentNode.sPortType = this.command.newSourcePort.properties.name; - this.command.newTargetPort.parentNode.conn = this.command.con; - this.workflow.saveRoute(this.command.newSourcePort.parentNode,this.command.newTargetPort.parentNode); - this.getWorkflow().getCommandStack().execute(this.command); - } - } - this.command=null; -}; - -ResizeHandle.prototype.onDragend=function(){ - if(this.commandMove==null){ - return; - } - var currentSelection = workflow.currentSelection; - if(typeof currentSelection.id != 'undefined' && currentSelection.id.length == 32){ - if(currentSelection.type.match(/Task/)) { - currentSelection.actiontype = 'saveTaskCordinates'; - workflow.savePosition(currentSelection); - } - else if(currentSelection.type.match(/Annotation/)){ - currentSelection.actiontype = 'saveAnnotationCordinates'; - workflow.savePosition(currentSelection); - } - } -} - -VectorFigure.prototype.addChild=function(_4078){ - _4078.setParent(this); - //_4078.setZOrder(this.getZOrder()+1); - //_4078.setParent(this); - //_4078.parent.addChild(_4078); - //this.children[_4078.id]=_4078; - //this.scrollarea.appendChild(_4078.getHTMLElement()); -}; - -////// Decorators to add an arrow to the flow line. To show the direction of flow ////////////// -DecoratedConnection = function () { - Connection.call(this); - this.setTargetDecorator(new ArrowConnectionDecorator()); - this.setRouter(new ManhattanConnectionRouter()); -}; -DecoratedConnection.prototype = new Connection(); -DecoratedConnection.prototype.type = "DecoratedConnection"; -DecoratedConnection.prototype.getContextMenu = function () { - if (this.id != null) { - this.workflow.contextClicked = true; - this.workflow.connectionContextMenu(this); - } -}; - - -//dotted connection and its router -DottedConnectionRouter=function(_354a){ -if(!_354a){ -this.cheapRouter=new ManhattanConnectionRouter(); -}else{ -this.cheapRouter=null; -} -this.iteration=4; -}; -DottedConnectionRouter.prototype=new ConnectionRouter; -DottedConnectionRouter.prototype.type="DottedConnectionRouter"; -DottedConnectionRouter.prototype.drawBezier=function(_354b,_354c,t,iter){ - var n=_354b.length-1; - var q=new Array(); - var _3551=n+1; - for(var i=0;i<_3551;i++){ - q[i]=new Array(); - q[i][0]=_354b[i]; - } - for(var j=1;j<=n;j++){ - for(var i=0;i<=(n-j);i++){ - q[i][j]=new Point((1-t)*q[i][j-1].x+t*q[i+1][j-1].x,(1-t)*q[i][j-1].y+t*q[i+1][j-1].y); - } - } - var c1=new Array(); - var c2=new Array(); - for(var i=0;i=0){ - this.drawBezier(c1,_354c,t,--iter); - this.drawBezier(c2,_354c,t,--iter); - } - else{ - for(var i=0;i0)&&((yDiff*yDiff)0)&&(toDir==DOWN))||((yDiff<0)&&(toDir==UP))){ - point=new Point(toPt.x,_355e.y); - }else{ - if(_355f==toDir){ - var pos=Math.min(_355e.x,toPt.x)-_3564; - point=new Point(pos,_355e.y); - }else{ - point=new Point(_355e.x-(xDiff/2),_355e.y); - } - } - } - if(yDiff>0){ - dir=UP; - }else{ - dir=DOWN; - } - } - } - else{ - if(_355f==RIGHT){ - if((xDiff<0)&&((yDiff*yDiff)0){ - point=new Point(_355e.x+_3564,_355e.y); - }else{ - if(((yDiff>0)&&(toDir==DOWN))||((yDiff<0)&&(toDir==UP))){ - point=new Point(toPt.x,_355e.y); - }else{ - if(_355f==toDir){ - var pos=Math.max(_355e.x,toPt.x)+_3564; - point=new Point(pos,_355e.y); - }else{ - point=new Point(_355e.x-(xDiff/2),_355e.y); - } - } - } - if(yDiff>0){ - dir=UP; - }else{ - dir=DOWN; - } - } - }else{ - if(_355f==DOWN){ - if(((xDiff*xDiff)0){ - point=new Point(_355e.x,_355e.y+_3564); - } - else { - if(((xDiff>0)&&(toDir==RIGHT))||((xDiff<0)&&(toDir==LEFT))){ - point=new Point(_355e.x,toPt.y); - } - else{ - if(_355f==toDir){ - var pos=Math.max(_355e.y,toPt.y)+_3564; - point=new Point(_355e.x,pos); - } - else{ - point=new Point(_355e.x,_355e.y-(yDiff/2)); - } - } - } - if(xDiff>0){ - dir=LEFT; - } - else{ - dir=RIGHT; - } - } - } - else { - if(_355f==UP){ - if(((xDiff*xDiff)0)&&(toDir==DOWN)){ - point=toPt; - dir=toDir; - } - else{ - if(yDiff<0){ - point=new Point(_355e.x,_355e.y-_3564); - } - else{ - if(((xDiff>0)&&(toDir==RIGHT))||((xDiff<0)&&(toDir==LEFT))){ - point=new Point(_355e.x,toPt.y); - } - else{ - if(_355f==toDir){ - var pos=Math.min(_355e.y,toPt.y)-_3564; - point=new Point(_355e.x,pos); - } - else{ - point=new Point(_355e.x,_355e.y-(yDiff/2)); - } - } - } - if(xDiff>0){ - dir=LEFT; - } - else{ - dir=RIGHT; - } - } - } - } - } - } - this._route(_355c,conn,point,dir,toPt,toDir); - _355c.push(_355e); -}; - -DottedConnection = function () { - Connection.call(this); - this.setColor(new Color(0,0,80)); - this.setRouter(new DottedConnectionRouter()); - this.setRouter(new FanConnectionRouter()); -}; -DottedConnection.prototype = new Connection(); -DottedConnection.prototype.type = "DottedConnection"; -DottedConnection.prototype.addPoint=function(p){ - p=new Point(parseInt(p.x),parseInt(p.y)); - var bgColor = new Color(255,255,255); - var fgColor = new Color(0,0,128); - if(this.oldPoint!=null){ - //this.graphics.setColor(new Color(250,250,250)); - this.graphics.setColor(bgColor.getHTMLStyle()); - this.graphics.setStroke( 2); - this.graphics.drawLine(this.oldPoint.x,this.oldPoint.y,p.x,p.y); - this.graphics.setColor(fgColor.getHTMLStyle()); - this.graphics.setStroke( Stroke.DOTTED ); - this.graphics.drawLine(this.oldPoint.x,this.oldPoint.y,p.x,p.y); - //this.graphics.drawLine(p.x,p.y,p.x,p.y); - var line=new Object(); - line.start=this.oldPoint; - line.end=p; - this.lineSegments.add(line); - } - this.oldPoint=new Object(); - this.oldPoint.x=p.x; - this.oldPoint.y=p.y; -}; -DottedConnection.prototype.getContextMenu = function () { - if (this.id != null) { - this.workflow.contextClicked = true; - this.workflow.connectionContextMenu(this); - } -}; - -////////--------------------------------------------------------------------------------------------/////// -FlowMenu = function (_39f9) { - this.actionAdd = new ButtonAdd(this); - this.actionTask = new ButtonTask(this); - this.actionInterEvent = new ButtonInterEvent(this); - this.actionEndEvent = new ButtonEndEvent(this); - this.actionGateway = new ButtonGateway(this); - this.actionFront = new ButtonMoveFront(this); - this.actionBack = new ButtonMoveBack(this); - this.actionDelete = new ButtonDelete(this); - this.actionAnnotation = new ButtonAnnotation(this); - ToolPalette.call(this); - this.setDimension(20, 80); - this.setBackgroundColor(new Color(220, 255, 255)); - this.currentFigure = null; - this.myworkflow = _39f9; - this.added = false; - this.setDeleteable(false); - this.setCanDrag(false); - this.setResizeable(false); - this.setSelectable(false); - var zOrder = this.getZOrder(); - this.setZOrder(4000); - this.setBackgroundColor(null); - this.setColor(null); - this.scrollarea.style.borderBottom = "0px"; - this.actionAdd.setPosition(0, 0); - this.actionInterEvent.setPosition(20, 0); - this.actionGateway.setPosition(20, 20); - this.actionFront.setPosition(0, 18); - this.actionBack.setPosition(0, 36); - this.actionDelete.setPosition(0, 54); -}; - -ToolPalette.prototype.removechild = function (_4079) { - if (_4079 != null) { - var parentNode = this.html; - if (parentNode != null) { - if (typeof parentNode.children != 'undefined') { - var len = parentNode.children[0].children.length; - for (var i = 0; i < len; i++) { - var childNode = parentNode.children[0].children[i]; - if (childNode == _4079.html) { - parentNode.children[0].removeChild(childNode); - } - } - } - } - } -}; -FlowMenu.prototype = new ToolPalette; -FlowMenu.prototype.setAlpha = function (_39fa) { - Figure.prototype.setAlpha.call(this, _39fa); -}; -FlowMenu.prototype.hasTitleBar = function () { - return false; -}; -FlowMenu.prototype.setFigure = function (_3087) { -} - -FlowMenu.prototype.onSelectionChanged = function (_39fb) { - var newWorkflow = ''; - //If Right Clicked on the figure, Disabling Flow menu - if (_39fb != null) { - newWorkflow = _39fb.workflow; - } - else if (this.workflow != null) { - newWorkflow = this.workflow; - } - else { - newWorkflow = this.myworkflow; - } - var contextClicked = newWorkflow.contextClicked; - //Check wheather the figure selected is same as previous figure. - //If figure is different ,then remove the port from the previous selected figure. - if (newWorkflow.currentSelection != null && typeof newWorkflow.preSelectedFigure != 'undefined') { - if (newWorkflow.currentSelection.id != newWorkflow.preSelectedFigure.id) { - newWorkflow.disablePorts(newWorkflow.preSelectedFigure); - } - } - if (_39fb == this.currentFigure && contextClicked == true) { - return; - } - if (this.added == true) { - this.myworkflow.removeFigure(this); - this.added = false; - } - if (_39fb != null && this.added == false) { - if (this.myworkflow.getEnableSmoothFigureHandling() == true) { - this.setAlpha(0.01); - } - this.myworkflow.addFigure(this, 100, 100); - this.added = true; - } - if (this.currentFigure != null) { - this.currentFigure.detachMoveListener(this); - } - this.currentFigure = _39fb; - if (this.currentFigure != null) { - this.currentFigure.attachMoveListener(this); - this.onOtherFigureMoved(this.currentFigure); - } -}; - -FlowMenu.prototype.setWorkflow = function (_39fc) { - Figure.prototype.setWorkflow.call(this, _39fc); -}; - -FlowMenu.prototype.onOtherFigureMoved = function (_39fd) { - if (_39fd != null) { - //Get the workflow object of the selected Figure object, so that we can compare with the new selected figure to remove ports - _39fd.workflow.preSelectedFigure = _39fd.workflow.currentSelection; - var countConn = 0; - //workflow.setBoundary(workflow.currentSelection); - - //Preventing Task from drawing outside canvas Code Ends here - if (_39fd.type == 'DecoratedConnection' || _39fd.type == 'DottedConnection' || _39fd.workflow.contextClicked == true) { - this.removechild(this.actionAdd); - this.removechild(this.actionInterEvent); - this.removechild(this.actionGateway); - this.removechild(this.actionAnnotation); - this.removechild(this.actionTask); - this.removechild(this.actionEndEvent); - this.removechild(this.actionBack); - this.removechild(this.actionDelete); - this.removechild(this.actionFront); - _39fd.workflow.hideResizeHandles(); - } - else { - var pos = _39fd.getPosition(); - this.setPosition(pos.x + _39fd.getWidth() + 7, pos.y - 16); - if (_39fd.workflow != null) { - var bpmnShape = _39fd.workflow.currentSelection.type; - this.addChild(this.actionFront); - this.addChild(this.actionBack); - this.addChild(this.actionDelete); - var ports = ''; - //Disable Resize for All Events and Gateway - if (bpmnShape.match(/Event/) || bpmnShape.match(/Gateway/) || bpmnShape.match(/bpmnDataobject/) || bpmnShape.match(/bpmnSubProcess/)) { - _39fd.workflow.hideResizeHandles(); - } - if (bpmnShape.match(/Task/) || bpmnShape.match(/SubProcess/)) { - this.addChild(this.actionAdd); - this.addChild(this.actionInterEvent); - this.addChild(this.actionEndEvent); - this.addChild(this.actionGateway); - this.addChild(this.actionAnnotation); - this.actionAnnotation.setPosition(20, 60); - this.actionEndEvent.setPosition(20, 40) - this.removechild(this.actionTask); - ports = ['output1', 'input1', 'output2', 'input2']; - //ports = ['output1', 'output2']; - _39fd.workflow.enablePorts(_39fd, ports); - } - else if (bpmnShape.match(/Start/)) { - this.addChild(this.actionAdd); - this.addChild(this.actionAnnotation); - this.actionAnnotation.setPosition(20, 40); - this.addChild(this.actionInterEvent); - this.actionInterEvent.setPosition(20, 20) - this.addChild(this.actionGateway); - this.actionGateway.setPosition(20, 0) - this.removechild(this.actionEndEvent); - ports = ['output1', 'output2']; - _39fd.workflow.enablePorts(_39fd, ports); - } - else if (bpmnShape.match(/Inter/)) { - this.addChild(this.actionAdd); - this.addChild(this.actionAnnotation); - this.actionAnnotation.setPosition(20, 60); - this.addChild(this.actionInterEvent); - this.actionInterEvent.setPosition(20, 20) - this.addChild(this.actionGateway); - this.actionGateway.setPosition(20, 0); - this.addChild(this.actionEndEvent); - this.actionEndEvent.setPosition(20, 40); - ports = ['output1', 'input1', 'output2', 'input2']; - _39fd.workflow.enablePorts(_39fd, ports); - } - else if (bpmnShape.match(/End/)) { - this.removechild(this.actionInterEvent); - this.removechild(this.actionEndEvent); - this.removechild(this.actionAnnotation); - this.removechild(this.actionTask); - this.removechild(this.actionGateway); - this.removechild(this.actionAdd); - ports = ['input1', 'input2']; - _39fd.workflow.enablePorts(_39fd, ports); - } - else if (bpmnShape.match(/Gateway/)) { - this.addChild(this.actionAdd); - this.addChild(this.actionAnnotation); - this.actionAnnotation.setPosition(20, 60); - this.addChild(this.actionInterEvent); - this.actionInterEvent.setPosition(20, 20) - this.addChild(this.actionGateway); - this.actionGateway.setPosition(20, 0); - this.addChild(this.actionEndEvent); - this.actionEndEvent.setPosition(20, 40); - ports = ['output1', 'input1', 'output2', 'input2','output3']; - _39fd.workflow.enablePorts(_39fd, ports); - } - else if (bpmnShape.match(/Annotation/) || bpmnShape.match(/Dataobject/)) { - this.removechild(this.actionAdd); - this.removechild(this.actionAnnotation); - this.removechild(this.actionInterEvent); - this.removechild(this.actionGateway); - this.removechild(this.actionEndEvent); - this.removechild(this.actionAnnotation); - this.removechild(this.actionEndEvent); - if (bpmnShape.match(/Annotation/)) { - ports = ['input1']; - _39fd.workflow.enablePorts(_39fd, ports); - } - } - else if (bpmnShape.match(/Pool/)) { - this.removechild(this.actionAdd); - this.removechild(this.actionInterEvent); - this.removechild(this.actionGateway); - this.removechild(this.actionEndEvent); - this.removechild(this.actionAnnotation); - this.removechild(this.actionEndEvent); - this.removechild(this.actionFront); - this.removechild(this.actionBack); - this.removechild(this.actionDelete); - } - } - } - } -}; - -bpmnTask.prototype.addShapes = function (oStore) { - var xOffset = workflow.currentSelection.getX(); //Get x co-ordinate from figure - var y = workflow.currentSelection.getY(); //Get y co-ordinate from figure - //var xOffset = parseFloat(x + _3896.workflow.currentSelection.width); //Get x-offset co-ordinate from figure - var yOffset = parseFloat(y + workflow.currentSelection.height + 25); //Get y-offset co-ordinate from figure - var shape = workflow.currentSelection.type; - var count; - if (oStore.newShapeName == 'bpmnTask' && shape.match(/Event/)) { - xOffset = workflow.currentSelection.getX() - 67; //Setting new offset value when currentselection is not Task i.e deriving task from events - } - else if (oStore.newShapeName == 'bpmnTask' && shape.match(/Gateway/)) { - xOffset = workflow.currentSelection.getX() - 62; //Setting new offset value when currentselection is not Task i.e deriving task from gateways - } - else if (oStore.newShapeName.match(/Gateway/) && shape.match(/Gateway/)) { - xOffset = workflow.currentSelection.getX(); //Setting new offset value when currentselection is not Task i.e deriving task from gateways - } - else if (oStore.newShapeName.match(/Event/)) { - xOffset = workflow.currentSelection.getX() + 67; //Setting new offset value when newShape is not Task i.e aligning events - } - else if (oStore.newShapeName.match(/Gateway/)) { - xOffset = workflow.currentSelection.getX() + 62; - } - else if (oStore.newShapeName.match(/Annotation/) ) { - xOffset = workflow.currentSelection.getX() + 250; - yOffset = workflow.currentSelection.getY() - 10.5; - } - - workflow.subProcessName = 'Sub Process'; - workflow.annotationName = 'Annotation'; - var newShape = eval("new " + oStore.newShapeName + "(workflow)"); - workflow.addFigure(newShape, xOffset, yOffset); - //Assigning values to newShape Object for Saving Task automatically (Async Ajax Call) - newShape.x = xOffset; - newShape.y = yOffset; - - if(shape.match(/Annotation/) || oStore.newShapeName.match(/Annotation/)) - var conn = new DottedConnection(); - else - conn = new DecoratedConnection(); - - if (newShape.type.match(/Gateway/)) { - conn.setTarget(newShape.getPort("input2")); - conn.setSource(workflow.currentSelection.getPort("output1")); - workflow.addFigure(conn); - newShape.actiontype = 'addGateway'; - workflow.saveShape(newShape); - } - else if (newShape.type.match(/Start/)) { - conn.setTarget(newShape.getPort("output1")); - conn.setSource(workflow.currentSelection.getPort("input2")); - workflow.addFigure(conn); - } - else if (newShape.type.match(/Event/)) { - conn.setTarget(newShape.getPort("input2")); - conn.setSource(workflow.currentSelection.getPort("output1")); - workflow.addFigure(conn); - newShape.conn = conn; - newShape.actiontype = 'addEvent'; - workflow.saveShape(newShape); - } - else if (newShape.type.match(/Task/)) { - conn.setTarget(newShape.getPort("input2")); - conn.setSource(workflow.currentSelection.getPort("output1")); - workflow.addFigure(conn); - } - else if (newShape.type.match(/Annotation/)) { - conn.setTarget(newShape.getPort("input1")); - conn.setSource(workflow.currentSelection.getPort("output2")); - workflow.addFigure(conn); - newShape.actiontype = 'addText'; - newShape.conn = conn; - workflow.saveShape(newShape); //Saving Task automatically (Async Ajax Call) - } - /*if (oStore.newShapeName.match(/Event/) && oStore.newShapeName.match(/End/)) { - newShape.conn = conn; - workflow.saveRoute(workflow.currentSelection,newShape); - }*/ - if (oStore.newShapeName == 'bpmnTask') { - newShape.actiontype = 'addTask'; - newShape.conn = conn; - workflow.saveShape(newShape); //Saving Task automatically (Async Ajax Call) - } -} - -ButtonInterEvent = function (_30a8) { - Button.call(this, _30a8, 16, 16); -}; -ButtonInterEvent.prototype = new Button; -ButtonInterEvent.prototype.type = "/images/ext/gray/shapes/interevent"; -ButtonInterEvent.prototype.execute = function () { - var count = 0; - this.palette.newShapeName = 'bpmnEventEmptyInter'; - bpmnTask.prototype.addShapes(this.palette); -}; - -ButtonEndEvent = function (_30a8) { - Button.call(this, _30a8, 16, 16); -}; -ButtonEndEvent.prototype = new Button; -ButtonEndEvent.prototype.type = "/images/ext/gray/shapes/endevent"; -ButtonEndEvent.prototype.execute = function () { - var count = 0; - this.palette.newShapeName = 'bpmnEventEmptyEnd'; - bpmnTask.prototype.addShapes(this.palette); -}; - -ButtonGateway = function (_30a8) { - Button.call(this, _30a8, 16, 16); -}; -ButtonGateway.prototype = new Button; -ButtonGateway.prototype.type = "/images/ext/gray/shapes/gateway-small"; -ButtonGateway.prototype.execute = function () { - this.palette.newShapeName = 'bpmnGatewayExclusiveData'; - workflow.preSelectedObj = workflow.currentSelection; - bpmnTask.prototype.addShapes(this.palette); -}; - -ButtonAnnotation = function (_30a8) { - Button.call(this, _30a8, 16, 16); -}; -ButtonAnnotation.prototype = new Button; -ButtonAnnotation.prototype.type = "/images/ext/gray/shapes/annotation"; -ButtonAnnotation.prototype.execute = function () { - var count = 0; - this.palette.newShapeName = 'bpmnAnnotation'; - this.palette.workflow.preSelectedObj = this.palette.workflow.currentSelection; - bpmnTask.prototype.addShapes(this.palette); -}; - -ButtonTask = function (_30a8) { - Button.call(this, _30a8, 16, 16); -}; -ButtonTask.prototype = new Button; -ButtonTask.prototype.type = "/images/ext/gray/shapes/Task"; -ButtonTask.prototype.execute = function () { - this.palette.newShapeName = 'bpmnTask'; - bpmnTask.prototype.addShapes(this.palette); -}; - - -ButtonAdd = function (_30a8) { - Button.call(this, _30a8, 16, 16); -}; -ButtonAdd.prototype = new Button; -ButtonAdd.prototype.type = "/images/ext/gray/shapes/btn-add"; -ButtonAdd.prototype.execute = function () { - this.palette.newShapeName = 'bpmnTask'; - this.palette.workflow.preSelectedObj = this.palette.workflow.currentSelection; - bpmnTask.prototype.addShapes(this.palette); -}; - -ButtonDelete = function (_30a9) { - Button.call(this, _30a9, 16, 16); -}; -ButtonDelete.prototype = new Button; -ButtonDelete.prototype.type = "/images/ext/gray/shapes/btn-del"; -ButtonDelete.prototype.execute = function () { - workflow.hideResizeHandles(); - workflow.getDeleteCriteria(); -}; -ButtonMoveFront = function (_3e22) { - Button.call(this, _3e22, 16, 16); -}; -ButtonMoveFront.prototype = new Button; -ButtonMoveFront.prototype.type = "/images/ext/gray/shapes/btn-movefrnt"; -ButtonMoveFront.prototype.execute = function () { - this.palette.workflow.moveFront(this.palette.workflow.getCurrentSelection()); - ToolGeneric.prototype.execute.call(this); -}; -ButtonMoveBack = function (_4091) { - Button.call(this, _4091, 16, 16); -}; -ButtonMoveBack.prototype = new Button; -ButtonMoveBack.prototype.type = "/images/ext/gray/shapes/btn-movebk"; -ButtonMoveBack.prototype.execute = function () { - this.palette.workflow.moveBack(this.palette.workflow.getCurrentSelection()); - ToolGeneric.prototype.execute.call(this); -}; - -bpmnTaskDialog = function (_2e5e) { - this.figure = _2e5e; - var title = 'Task Detail'; - Dialog.call(this, title); - this.setDimension(400, 150); //Set the width and height of the Dialog box -} - -bpmnTaskDialog.prototype = new Dialog(this); -bpmnTaskDialog.prototype.createHTMLElement = function () { - var item = Dialog.prototype.createHTMLElement.call(this); - var inputDiv = document.createElement("form"); - inputDiv.style.position = "absolute"; - inputDiv.style.left = "10px"; - inputDiv.style.top = "30px"; - inputDiv.style.width = "375px"; - inputDiv.style.font = "normal 10px verdana"; - item.appendChild(inputDiv); - this.label = document.createTextNode("Task Name"); - inputDiv.appendChild(this.label); - this.input = document.createElement("textarea"); - this.input.size = '1'; - this.input.style.border = "1px solid gray"; - this.input.style.font = "normal 10px verdana"; - //this.input.type = "text"; - this.input.cols = "50"; - this.input.rows = "3"; - this.input.maxLength = "100"; - var value = bpmnTask.prototype.trim(workflow.currentSelection.taskName); - if (value) this.input.value = value; - else this.input.value = ""; - this.input.style.width = "100%"; - inputDiv.appendChild(this.input); - this.input.focus(); - return item; -}; - -//Double Click Event for opening the dialog Box -bpmnTask.prototype.onDoubleClick = function () { - var _409d = new bpmnTaskDialog(this); - workflow.showDialog(_409d, this.workflow.currentSelection.x, this.workflow.currentSelection.y); -}; - -/** - * erik: Setting task target to Drop user & group assignment - */ -bpmnTask.prototype.onMouseEnter = function () { - if( this.type == 'bpmnTask' ) { - _targetTask = {id: this.id, name: this.taskName}; - } -}; - -bpmnTask.prototype.trim = function (str) { - if (str != null) - return str.replace(/^\s+|\s+$/g, ''); - else - return null; -}; - -/** - * This method will be called if the user pressed the OK button in buttonbar of the dialog.
- * The string is first cleared and new string is painted.

- **/ -bpmnTaskDialog.prototype.onOk = function () { - this.figure.bpmnText.clear(); - //len = Math.ceil(this.input.value.length/16); - var len = this.workflow.currentSelection.width / 18; - if (len >= 6) { - // len = 1.5; - var padleft = 0.12 * this.workflow.currentSelection.width; - var padtop = 0.32 * this.workflow.currentSelection.height - 3; - this.figure.rectWidth = this.workflow.currentSelection.width - 2 * padleft; - } - else { - padleft = 0.1 * this.workflow.currentSelection.width; - padtop = 0.09 * this.workflow.currentSelection.height - 3; - this.figure.rectWidth = this.workflow.currentSelection.width - 2 * padleft; - } - - var rectheight = this.workflow.currentSelection.height - 2*padtop; - this.figure.bpmnText.setFont('verdana', +this.figure.fontSize+'px', Font.PLAIN); - this.figure.bpmnText.drawStringRect(this.input.value, padleft, padtop, this.figure.rectWidth, rectheight, 'center'); - this.figure.bpmnText.paint(); - this.workflow.currentSelection.taskName = this.input.value; //Set Updated Text value - //Saving task name (whenever updated) onAsynch AJAX call - this.figure.actiontype = 'updateTaskName'; - this.workflow.saveShape(this.figure); - if (this.figure.rectWidth < 80) tempW = 110; - else tempW = this.figure.rectWidth + 35; - this.workflow.removeFigure(this); -}; - -bpmnTask.prototype.getContextMenu = function () { - this.workflow.handleContextMenu(this); -}; diff --git a/workflow/engine/templates/bpmn/bpmnZoom.js b/workflow/engine/templates/bpmn/bpmnZoom.js deleted file mode 100755 index 4e627974b..000000000 --- a/workflow/engine/templates/bpmn/bpmnZoom.js +++ /dev/null @@ -1,380 +0,0 @@ -// -------------------------------------------------------------------- -// Javascript Magnifier v 0.97 -// Written by Dino Termini - termini@email.it - May 9, 2003 -// This script is freeware (GPL) but if you use it, please let me know! -// -// Portions of code by zoomIN, zoomOUT -// Author: Nguyen Duong Minh (Obie) - obie4web@yahoo.com -// WWW: http://ObieWebsite.SourceForge.net -// License: GNU (GPL) -// -// Portions of code by Webreference Javascript Cookie Functions -// Jupirmedia Corporation -// http://www.internet.com - - -bpmnZoom=function(){ -// Configuration parameters -// ------------------------ -// Measure unit in pixel (px) or points (pt) -// measureUnit = "pt" -measureUnit = "px" - -// Minimum size allowed for SIZE attribute (like in ) -minSize = 1; - -// Minimum size allowed for STYLE attribute (like in ) -minStyleSize = 10; - -// Maximum size allowed for SIZE attribute -maxSize = 6; - -// Maximum size allowed for STYLE attribute -maxStyleSize = 30; - -// Start size for tags with no SIZE attribute defined -startSize = 1; - -// Start size for tags with no font-size STYLE or CLASS attribute defined -startStyleSize = 10; - -// Increasing and decreasing step -stepSize = 1; - -// Increasing step for STYLE definition (measure previously declared will be used) -stepStyleSize = 2; - -// To set your own hotkeys, use key generator tool page included -// Keys to zooming in (with and without CAPS lock). Default: "+" -var keyin = 61; -var keyinCAPS = 43; - -// Keys to zooming out (with and without CAPS lock). Default: "-" -var keyout = 45; -var keyoutCAPS = 95; - -// Keys for "hard" zooming in (with and without CAPS lock). Default: ">" -var keyinIe = 46; -var keyinIeCAPS = 62; - -// Keys for "hard" zooming out (with and without CAPS lock). Default: "<" -var keyoutIe = 44; -var keyoutIeCAPS = 60; - -// "Hard" zoom factor -var zoomFactor = 1.1; - -// Max zoom allowed -var maxZoom = 4.096; - -// Min zoom allowed -var minZoom = 0.625; - -// Initial decrease zoom -var startDecZoom = 0.7; - -// Initial increase zoom -var startIncZoom = 1.3; - -// Cookie expiry (default one year, actually 365 days) -// 365 days in a year -// 24 hours in a day -// 60 minutes in an hour -// 60 seconds in a minute -// 1000 milliseconds in a second -userExpiry = 365 * 24 * 60 * 60 * 1000; - -// Enable or disable alert messages -alertEnabled = false; - -// Allow input fields resize (text, buttons, and so on) -allowInputResize = false; - -// End of configuration parameters. Please do not edit below this line -// -------------------------------------------------------------------------------- -} - -// Input values: -// name - name of the cookie -// value - value of the cookie -// [expires] - expiration date of the cookie (defaults to end of current session) -// [path] - path for which the cookie is valid (defaults to path of calling document) -// [domain] - domain for which the cookie is valid (defaults to domain of calling document) -// [secure] - Boolean value indicating if the cookie transmission requires a secure transmission -// * an argument defaults when it is assigned null as a placeholder -// * a null placeholder is not required for trailing omitted arguments -bpmnZoom.prototype.setCookie = function(name, value, expires, path, domain, secure) { - // Check whether cookies enabled - document.cookie = "Enabled=true"; - var cookieValid = document.cookie; - - // if retrieving the VALUE we just set actually works - // then we know cookies enabled - if (cookieValid.indexOf("Enabled=true") != -1) { - var curCookie = name + "=" + escape(value) + - ((expires) ? "; expires=" + expires.toGMTString() : "") + - ((path) ? "; path=" + path : "") + - ((domain) ? "; domain=" + domain : "") + - ((secure) ? "; secure" : ""); - - document.cookie = curCookie; - return(true); - } - else { - return(false); - } -} - -// Input value: -// name - name of the desired cookie -// * return string containing value of specified cookie or null if cookie does not exist -bpmnZoom.prototype.getCookie = function(name) { - var dc = document.cookie; - var prefix = name + "="; - var begin = dc.indexOf("; " + prefix); - if (begin == -1) { - begin = dc.indexOf(prefix); - if (begin != 0) return null; - } else - begin += 2; - var end = document.cookie.indexOf(";", begin); - if (end == -1) - end = dc.length; - return unescape(dc.substring(begin + prefix.length, end)); -} - -// Input values: -// name - name of the cookie -// [path] - path of the cookie (must be same as path used to create cookie) -// [domain] - domain of the cookie (must be same as domain used to create cookie) -// * path and domain default if assigned null or omitted if no explicit argument proceeds -bpmnZoom.prototype.deleteCookie = function(name, path, domain) { - if (this.getCookie(name)) { - document.cookie = name + "=" + - ((path) ? "; path=" + path : "") + - ((domain) ? "; domain=" + domain : "") + - "; expires=Thu, 01-Jan-70 00:00:01 GMT"; - } -} - -// Input value: -// date - any instance of the Date object -// * hand all instances of the Date object to this function for "repairs" -bpmnZoom.prototype.fixDate = function(date) { - var base = new Date(0); - var skew = base.getTime(); - if (skew > 0) - date.setTime(date.getTime() - skew); -} - -bpmnZoom.prototype.searchTags = function(childTree, level) { - var retArray = new Array(); - var tmpArray = new Array(); - var j = 0; - var childName = ""; - for (var i=0; i maxSize)) - size = startSize; - - if (isNaN(styleSize) || (styleSize < minStyleSize) || (styleSize > maxStyleSize)) - styleSize = startStyleSize; - - if ( ((size > minSize) && (size < maxSize)) || - ((size == minSize) && (stepSize > 0)) || - ((size == maxSize) && (stepSize < 0)) || useCookie) { - myObj[i].setAttribute("size", size+myStepSize); - } - - if ( ((styleSize > minStyleSize) && (styleSize < maxStyleSize)) || - ((styleSize == minStyleSize) && (stepStyleSize > 0)) || - ((styleSize == maxStyleSize) && (stepStyleSize < 0)) || useCookie) { - newStyleSize = styleSize+myStepStyleSize; - myObj[i].style.fontSize = newStyleSize+measureUnit; - } - } // End if condition ("only some tags") - } // End main for cycle - - // Set the cookies - if (!useCookie) { - cookieIsSet = this.setCookie("incrSize", myStepSize+myCookieSize, now); - cookieIsSet = this.setCookie("incrStyleSize", myStepStyleSize+myCookieStyleSize, now); - if (alertEnabled && !cookieIsSet) { - alert("Per mantenere in memoria la dimensione scelta, abilita i cookie nel browser"); - } - } - - } // End if condition ("document.body exists") -} // End function declaration - -bpmnZoom.prototype.increaseFontSize = function() { - if (document.body) { - this.changeFontSize(stepSize, stepStyleSize, false); - } - else { - if (alertEnabled) { - alert("Spiacente, il tuo browser non supporta questa funzione"); - } - } -} - -bpmnZoom.prototype.decreaseFontSize = function() { - if (document.body) { - myStepSize = -stepSize; - myStepStyleSize = -stepStyleSize; - this.changeFontSize(myStepSize, myStepStyleSize, false); - } - else { - if (alertEnabled) { - alert("Spiacente, il tuo browser non supporta questa funzione"); - } - } -} - -bpmnZoom.prototype.zoomin = function() { - if (window.parent.document.body.style.zoom < maxZoom) { - if (window.parent.document.body.style.zoom > 0) { - window.parent.document.body.style.zoom *= zoomFactor; - } - else { - window.parent.document.body.style.zoom = startIncZoom; - } - } - else { - if (alertEnabled) { - alert("Warning: Max size reached"); - } - } -} - -bpmnZoom.prototype.zoomout = function() { - if ( (window.parent.document.body.style.zoom > minZoom) || - (window.parent.document.body.style.zoom == 0) ) { - if (window.parent.document.body.style.zoom > 0) { - window.parent.document.body.style.zoom /= zoomFactor; - } - else { - window.parent.document.body.style.zoom = startDecZoom; - } - } - else { - if (alertEnabled) { - alert("Warning: Min size reached"); - } - } -} - -bpmnZoom.prototype.checkzoom = function(e) { - - if (document.all) { - myEvent = event.keyCode; - } - else { - myEvent = e.which; - } - - switch(myEvent) { - case keyinIe: - case keyinIeCAPS: - this.zoomin(); - break; - - case keyoutIe: - case keyoutIeCAPS: - this.zoomout(); - break; - - case keyin: - case keyinCAPS: - this.increaseFontSize(); - break; - - case keyout: - case keyoutCAPS: - this.decreaseFontSize(); - break; - - default: - break; - } -} - -if (document.layers) { - document.captureEvents(Event.KEYPRESS); -} - -document.onkeypress = this.checkzoom; - diff --git a/workflow/engine/templates/bpmn/designer.html b/workflow/engine/templates/bpmn/designer.html deleted file mode 100755 index bf830ac66..000000000 --- a/workflow/engine/templates/bpmn/designer.html +++ /dev/null @@ -1,12 +0,0 @@ -
-
-
-
-
-
-
-
-
-
-
-
diff --git a/workflow/engine/templates/bpmn/designer.js b/workflow/engine/templates/bpmn/designer.js deleted file mode 100755 index 87bb991b6..000000000 --- a/workflow/engine/templates/bpmn/designer.js +++ /dev/null @@ -1,926 +0,0 @@ -/** - * BPMN Designer v1.1 - * @date Feb 2th, 2011 - * @author Erik A. O. - */ - -var saveProcess; -var usersPanel; -var _TAS_UID; -var _TU_TYPE; -var processObj; -var ProcessMapObj; - -Ext.onReady(function(){ - //Ext.state.Manager.setProvider(new Ext.state.CookieProvider()); - //Ext.BLANK_IMAGE_URL = '/images/s.gif'; - - var northPanel = new Ext.Toolbar({ - region: 'north', - height: 25, // give north and south regions a height - items: northPanelItems - }) - - var southPanel = { - // lazily created panel (xtype:'panel' is default) - region: 'south', - contentEl: 'south', - split: true, - height: 100, - minSize: 100, - maxSize: 200, - collapsible: true, - title: 'South', - margins: '0 0 0 0' - } - - var eastPanel = { - id: 'eastPanel', - region: 'east', - title: ' ', - collapsible: true, - split: true, - width: 225, // give east and west regions a width - minSize: 175, - maxSize: 400, - margins: '0 3 0 0', - layout:'border', // specify layout manager for items - items: // this TabPanel is wrapped by another Panel so the title will be applied - [ - eastPanelTree, - { - id: 'eastPanelCenter', - xtype: 'panel', - title: _('ID_PROCESS')+': '+pro_title, - region: 'center', - layout: 'fit', - items:[ - new Ext.TabPanel({ - id : 'usersPanelTabs', - title : '', - border: true, // already wrapped so don't add another border - activeTab : 0, // second tab initially active - tabPosition : 'top', - split : true, - collapseMode:'mini', - //height : 318, - items : [ - propertiesGrid, - usersTaskGrid, - usersTaskAdHocGrid - ] - }) - ] - } - ] - } - var westPanel = { - region: 'west', - id: 'west-panel', // see Ext.getCmp() below - title: ' ', - split: false, - width: 37, - minSize: 20, - maxSize: 400, - collapsible: true, - layout: 'table', - layoutConfig: {columns:1}, - defaults: {frame:true}, - margins: '0 3 3 0', - items: [ - toolbarPanel, - actorsPanel - ] - } - - var centerPanel = new Ext.Panel({ - //title: '', - region: 'center', // a center region is ALWAYS required for border layout - id: 'designerPanel', - contentEl: 'center1', - autoScroll: true, - tbar: northPanelItems - }) - - var viewport = new Ext.Viewport({ - layout: 'border', - items:[ - /*new Ext.Toolbar({ - region: 'north', - height: 25, // give north and south regions a height - items: mainMenu - }),*/ - new Ext.TabPanel({ - id: 'mainTabPanel', - region: 'center', - deferredRender: false, - activeTab: 0, // first tab initially active - items: [ - { - title:'BPMN Designer', - id: 'designerTab', - layout: 'border', - items:[ - // create instance immediately - //northPanel, - //southPanel, - eastPanel, - westPanel, - // in this instance the TabPanel is not wrapped by another panel - // since no title is needed, this Panel is added directly - // as a Container - centerPanel - ], - _setDesignerTitle: function(title) { - title = title.length > 20 ? title.substring(0, 20) + '...' : title; - Ext.getCmp('designerTab').setTitle(''+_('ID_PROCESSMAP_TITLE')+': ' + title); - } - } - ], - _addTab: function(option) { - alert(option); - }, - _addTabFrame: tabFrame = function(name, title, url) { - title = title.length > 20 ? title.substring(0, 20) + '...' : title; - tabId = 'pm-tab-'+name ; - //var uri = 'ajaxListener?action=' + name; - var TabPanel = Ext.getCmp('mainTabPanel'); - var tab = TabPanel.getItem(tabId); - - if( tab ) { - TabPanel.setActiveTab(tabId); - } else { - TabPanel.add({ - xtype:'iframepanel', - id: tabId, - title: title, - frameConfig:{name: name + 'Frame', id: name + 'Frame'}, - defaultSrc : url, - loadMask:{msg:'Loading...'}, - bodyStyle:{height:'600px'}, - width:'1024px', - closable:true, - autoScroll: true - }).show(); - - TabPanel.doLayout(); - } - } - }) - ] - }); - - Ext.getCmp('designerTab')._setDesignerTitle(pro_title); - Ext.fly(document).on("scroll", function(){ - if( usersPanel.isVisible() ) { - if (usersPanel._scrollPosTimer) { - clearTimeout(usersPanel._scrollPosTimer); - } - usersPanel._scrollPosTimer = setTimeout(function() { - usersPanel.setPosition(usersPanel._posRelToView[0] + divScroll.scrollLeft, usersPanel._posRelToView[1] + divScroll.scrollTop); - }, 100); - } - }); - - - processObj = new ProcessOptions(); - ProcessMapObj = new ProcessMapContext(); - workflow = new MyWorkflow("paintarea"); - workflow.setEnableSmoothFigureHandling(false); - //workflow.scrollArea.width = 2000; - var listener = new SelectionListener1(workflow); - workflow.addSelectionListener(listener); - - - if(typeof pro_uid !== 'undefined') { - Ext.Ajax.request({ - url: 'bpmnProxy/openProcess?PRO_UID=' + pro_uid, - success: function(response) { - shapesData = createShapes(response.responseText); - createConnection(shapesData); - - /** - * erik: Setting Drop targets from users & groups grids to assignment to tasks - * for all existing tasks - */ - var dropEls = Ext.get('paintarea').query('.x-task'); - for(var i = 0; i < dropEls.length; i++) - new Ext.dd.DropTarget(dropEls[i], {ddGroup:'task-assignment', notifyDrop : _onDropActors}); - - }, - failure: function(){ - Ext.Msg.alert ('Failure'); - } - }); - } - - - - //Get main into workflow object - workflow.main = Ext.getCmp('centerRegion'); - //workflow.setSnapToGeometry(false); - canvas = Ext.get('paintarea'); - - contextCanvasMenu = new Ext.menu.Menu({ - items: [ -/* { - text: 'Edit Process', - handler: ProcessMapObj.editProcess, - iconCls: 'button_menu_ext ss_sprite ss_page_white_edit', - scope: this - }, -*/ - { - text: 'Export Process', - handler: ProcessMapObj.exportProcess, - iconCls: 'button_menu_ext ss_sprite ss_script_go', - scope: this - }, { - text: 'Add Task', - handler: ProcessMapObj.addTask, - iconCls: 'button_menu_ext ss_sprite ss_layout_add', - scope: this - }, { - text: 'Add Subprocess', - handler: workflow.subProcess, - iconCls: 'button_menu_ext ss_sprite ss_layout_link', - scope: this - }/*, { - text: 'Horizontal Line', - handler: ProcessMapObj.horiLine, - scope: this - }, { - text: 'Vertical Line', - handler: ProcessMapObj.vertiLine, - scope: this - }, { - text: 'Delete All Lines', - handler: ProcessMapObj.delLines, - scope: this - }, */ -/* - { - text: 'Process Permission', - iconCls: 'button_menu_ext ss_sprite ss_application_key', - handler: ProcessMapObj.processPermission, - scope: this - },{ - text: 'Process Supervisor', - iconCls: 'button_menu_ext ss_sprite ss_group', - menu: { // <-- submenu by nested config object - items: [ - // stick any markup in a menu - { - text: 'Supervisors', - iconCls: 'button_menu_ext ss_sprite ss_group', - handler: ProcessMapObj.processSupervisors - }, - { - text: 'DynaForm', - iconCls: 'button_menu_ext ss_sprite ss_application_form', - handler: ProcessMapObj.processDynaform - }, - { - text: 'Input Documents', - iconCls: 'button_menu_ext ss_sprite ss_page_white_put', - handler: ProcessMapObj.processIODoc - } - ] - } - },{ - text: 'Case Tracker', - iconCls: 'button_menu_ext ss_sprite ss_exclamation', - - menu: { // <-- submenu by nested config object - items: [ - // stick any markup in a menu - { - text: 'Properties', - iconCls: 'button_menu_ext ss_sprite ss_exclamation', - handler: ProcessMapObj.caseTrackerProperties, - scope:this - }, - { - text: 'Objects', - iconCls: 'button_menu_ext ss_sprite ss_exclamation', - handler: ProcessMapObj.caseTrackerObjects, - scope:this - } - ] - } - }, { - text: 'Process File Manager', - iconCls: 'button_menu_ext ss_sprite ss_folder', - menu: { // <-- submenu by nested config object - items: [ - // stick any markup in a menu - { - text: 'mailTemplates', - iconCls: 'button_menu_ext ss_sprite ss_email', - handler: ProcessMapObj.processFileManager - }, - { - text: 'public', - iconCls: 'button_menu_ext ss_sprite ss_folder_go', - handler: ProcessMapObj.processFileManager - } - ] - } - } -*/ - ] - }); - - canvas.on('contextmenu', function(e) { - e.stopEvent(); - this.workflow.contextX = e.xy[0]; - this.workflow.contextY = e.xy[1]; - var pmosExtObj = new pmosExt(); - this.contextCanvasMenu.showAt(e.getXY()); - }, this); - - /*canvas.on('click', function(e) { - e.stopEvent(); - this.workflow.contextClicked = false; - if(this.workflow.currentSelection != null) - this.workflow.disablePorts(this.workflow.currentSelection); - //Removes Flow menu - this.workflow.setCurrentSelection(null); - }, this);*/ - - var simpleToolbar = new Ext.Toolbar('toolbar'); - simpleToolbar.addButton({ - text: 'Save', - cls: 'x-btn-text-icon scroll-bottom' - }); - simpleToolbar.addButton({ - text: 'Save As', - cls: 'x-btn-text-icon scroll-bottom' - }); - simpleToolbar.addButton({ - text: 'Undo', - cls: 'x-btn-text-icon' - }); - simpleToolbar.addButton({ - text: 'Redo', - cls: 'x-btn-text-icon' - }); - - var menu = new FlowMenu(workflow); - workflow.addSelectionListener(menu); - workflow.scrollArea = document.getElementById("center1").parentNode; - - Ext.get('x-shapes-task').child('.x-btn-mc').setStyle('text-align', 'left'); - Ext.get('x-shapes-startEvent').child('.x-btn-mc').setStyle('text-align', 'left'); - Ext.get('x-shapes-interEvent').child('.x-btn-mc').setStyle('text-align', 'left'); - Ext.get('x-shapes-endEvent').child('.x-btn-mc').setStyle('text-align', 'left'); - Ext.get('x-shapes-gateways').child('.x-btn-mc').setStyle('text-align', 'left'); - Ext.get('x-shapes-annotation').child('.x-btn-mc').setStyle('text-align', 'left'); - - Ext.get('x-pm-users').child('.x-btn-mc').setStyle('text-align', 'left'); - Ext.get('x-pm-groups').child('.x-btn-mc').setStyle('text-align', 'left'); - Ext.get('x-pm-users-adhoc').child('.x-btn-mc').setStyle('text-align', 'left'); - Ext.get('x-pm-groups-adhoc').child('.x-btn-mc').setStyle('text-align', 'left'); - - - /** - * Setting tooltips ti tollbar items - */ - new Ext.ToolTip({ - target: 'x-shapes-task', - title: 'Task', - trackMouse: true, - anchor: 'right', - html: '' - }); - new Ext.ToolTip({ - target: 'x-shapes-startEvent', - title: 'Event', - trackMouse: true, - anchor: 'right', - html: 'Start' - }); - new Ext.ToolTip({ - target: 'x-shapes-interEvent', - title: 'Event', - trackMouse: true, - anchor: 'right', - html: 'Intermediate' - }); - new Ext.ToolTip({ - target: 'x-shapes-endEvent', - title: 'Event', - trackMouse: true, - anchor: 'right', - html: 'End' - }); - new Ext.ToolTip({ - target: 'x-shapes-gateways', - title: 'Gateway', - trackMouse: true, - anchor: 'right', - html: '' - }); - new Ext.ToolTip({ - target: 'x-shapes-annotation', - title: 'Annotation', - anchor: 'right', - trackMouse: true, - html: '' - }); - - new Ext.ToolTip({ - target: 'x-pm-users', - title: 'Actors', - anchor: 'right', - trackMouse: true, - html: 'Users' - }); - new Ext.ToolTip({ - target: 'x-pm-groups', - title: 'Actors', - anchor: 'right', - trackMouse: true, - html: 'Groups' - }); - new Ext.ToolTip({ - target: 'x-pm-users-adhoc', - title: 'Actors', - anchor: 'right', - trackMouse: true, - html: 'Ad Hoc Users' - }); - new Ext.ToolTip({ - target: 'x-pm-groups-adhoc', - title: 'Actors', - anchor: 'right', - trackMouse: true, - html: 'Ad Hoc Groups' - }); - - - /** - * setting drag sources for Toolbar items - */ - var dragsource=new Ext.dd.DragSource("x-shapes-task", { - ddGroup:'TreeDD', - dragData:{ - name: "bpmnTask" - } - }); - var dragsource=new Ext.dd.DragSource("x-shapes-startEvent", { - ddGroup:'TreeDD', - dragData:{ - name: "bpmnEventEmptyStart" - } - }); - var dragsource=new Ext.dd.DragSource("x-shapes-interEvent", { - ddGroup:'TreeDD', - dragData:{ - name: "bpmnEventEmptyInter" - } - }); - var dragsource=new Ext.dd.DragSource("x-shapes-endEvent", { - ddGroup:'TreeDD', - dragData:{ - name: "bpmnEventEmptyEnd" - } - }); - var dragsource=new Ext.dd.DragSource("x-shapes-gateways", { - ddGroup:'TreeDD', - dragData:{ - name: "bpmnGatewayExclusiveData" - } - }); - - var dragsource=new Ext.dd.DragSource("x-shapes-annotation", { - ddGroup:'TreeDD', - dragData:{ - name: "bpmnAnnotation" - } - }); - - /*var dragsource=new Ext.dd.DragSource("x-shapes-dataobject", { - ddGroup:'TreeDD', - dragData:{ - name: "bpmnDataobject" - } - }); - var dragsource=new Ext.dd.DragSource("x-shapes-pool", { - ddGroup:'TreeDD', - dragData:{ - name: "bpmnPool" - } - });*/ - - - - - var droptarget=new Ext.dd.DropTarget('paintarea',{ - ddGroup:'TreeDD' - }); - - //Creating Pool - //var oPool = new bpmnPool(workflow); - //workflow.addFigure(oPool,100,70); - - if(workflow.taskNo == '') - workflow.taskNo= 0; //Initializing Count for the bpmnTask - var count = 0; - this.taskName=''; - droptarget.notifyDrop=function(dd, e, data) - { - if(data.name) - { - var xOffset = workflow.getAbsoluteX(); - var yOffset = workflow.getAbsoluteY(); - var scrollLeft = workflow.getScrollLeft(); - var scrollTop = workflow.getScrollTop(); - if(data.name == 'bpmnTask') { - workflow.boundaryEvent = false; - } - if(typeof workflow.zoomfactor == 'undefined') { - workflow.zoomfactor = 1; - } - workflow.task_width=''; - workflow.annotationName='Annotation'; - workflow.orgXPos = eval(e.xy[0]/workflow.zoomfactor); - workflow.orgYPos = eval(e.xy[1]/workflow.zoomfactor); - NewShape = eval("new "+data.name+"(workflow)"); - NewShape.x = e.xy[0]; - NewShape.y = e.xy[1]; - if(data.name == 'bpmnAnnotation') { - NewShape.actiontype = 'addText'; - workflow.saveShape(NewShape); //Saving task when user drags and drops it - } - else if(data.name == 'bpmnTask') { - NewShape.actiontype = 'addTask'; - workflow.saveShape(NewShape); //Saving Annotations when user drags and drops it - } - else if(data.name.match(/Event/)) { - NewShape.actiontype = 'addEvent'; - NewShape.mode = 'ddEvent'; - workflow.saveShape(NewShape); //Saving Annotations when user drags and drops it - } - else if(data.name.match(/Gateway/)){ - NewShape.actiontype = 'addGateway'; - NewShape.mode = 'ddGateway'; - workflow.saveShape(NewShape); //Saving Annotations when user drags and drops it - } - workflow.addFigure(NewShape,e.xy[0]-xOffset+scrollLeft,e.xy[1]-yOffset+scrollTop); - return true; - } - } - - function createConnection(shapes) - { - //var totaltask = shapes[0].length; //shapes[0] is an array for all the tasks - //var totalgateways = shapes[1].length; //shapes[1] is an array for all the gateways - //var totalevents = shapes[2].length; //shapes[2] is an array for all the events - if(typeof shapes.routes != 'undefined' && shapes.routes != '') { - var totalroutes = shapes.routes.length; //shapes[3] is an array for all the routes - for(var i=0;i<=totalroutes-1;i++){ - var sourceid = shapes.routes[i][1]; //getting source id for connection from Routes array - var targetid = shapes.routes[i][2]; //getting target id for connection from Routes array - //After creating all the shapes, check one by one shape id - for(var conn =0; conn < this.workflow.figures.data.length ; conn++){ - if(typeof this.workflow.figures.data[conn] === 'object'){ - if(sourceid == this.workflow.figures.data[conn].id){ - sourceObj = this.workflow.figures.data[conn]; - } - } - } - for(var conn =0; conn < this.workflow.figures.data.length ; conn++){ - if(typeof this.workflow.figures.data[conn] === 'object'){ - if(targetid == this.workflow.figures.data[conn].id ){ - targetObj = this.workflow.figures.data[conn]; - } - } - } - //Making Connections - if(targetObj.type == 'bpmnAnnotation') { - var connObj = new DottedConnection(); - connObj.setSource(sourceObj.output2); - connObj.setTarget(targetObj.input1); - } - else { - var connObj = new DecoratedConnection(); - connObj.setSource(sourceObj.output1); - connObj.setTarget(targetObj.input2); - } - - connObj.id = shapes.routes[i][0]; - this.workflow.addFigure(connObj); - } - } - } - - function createShapes(stringData) - { - - var shapes = Ext.util.JSON.decode(stringData); //stringData.split("|"); - workflow.taskNo = 0; - //Create all shapes - - //case 'tasks': - for(var k=0;k"+msg; - } - - saveProcess = function() - { - // console.dir(this.workflow); - - var tasks = new Array(); - var events = new Array(); - var gateways = new Array(); - var annotations = new Array(); - var subprocess = new Array(); - var l=0; - var m=0; - var n=0; - var p=0; - var r=0; - - for(var c = 0; c - */ - -var toolbarPanel; -var actorsPanel; -var northPanelItems; -var eastPanelTree; -var ActiveProperty; -var comboCategory; -var comboCalendar; -var comboPMVariables; -var propertiesGrid; -var propertyStore; -var usersTaskStore; -var usersTaskGrid; -var usersTaskGridContextMenu; -var usersTaskAdHocStore; -var usersTaskAdHocGrid; -var usersTaskAdHocGridContextMenu; -var mainMenu; -var tbar1; - -var usersPanelStart = 0; -var usersPanelLimit = 1000; -var usersStore; -var usersGrid; -var groupsStore; -var groupsGrid; -var adHocUsersStore; -var adHocUsersGrid; -var adHocGroupsStore; -var adHocGroupsGrid; - -var usersActorsWin; -var groupsActorsWin; -var adhocUsersActorsWin; -var adHocGroupsActorsWin; - -var _onDropActors; -var _targetTask; - -Ext.onReady(function(){ - divScroll = document.body; - -toolbarPanel = { - title: ' ', - border: true, - xtype:'buttongroup', - defaultType: 'button', - cls: 'btn-panel-pmtoolbar', - columns: 1, - defaults: { - scale: 'small' - }, - - items : [{ - iconCls: 'button_small_ext ss_sprite ss_bpmn_task-18x18', - id:"x-shapes-task", - text: ' ', - width: 22 - },{ - iconCls: 'button_small_ext ss_sprite ss_bpmn_startevent-18x18', - id:"x-shapes-startEvent", - text: ' ', - width: 22 - },{ - iconCls: 'button_small_ext ss_sprite ss_bpmn_interevent-18x18', - id:"x-shapes-interEvent", - text: ' ', - width: 22 - },{ - iconCls: 'button_small_ext ss_sprite ss_bpmn_endevent-18x18', - id:"x-shapes-endEvent", - text: ' ', - width: 22 - },{ - iconCls: 'ss_sprite ss_bpmn_gateway-18x18', - id:"x-shapes-gateways", - text: ' ', - width: 22 - },{ - iconCls: 'ss_sprite ss_bpmn_annotation-18x18', - id:"x-shapes-annotation", - text: ' ', - width: 22 - } - ] -}; - - -actorsPanel = { - title: ' ',//_('ID_ACTORS'), - border: true, - xtype:'buttongroup', - defaultType: 'button', - cls: 'btn-panel-pmtoolbar', - columns: 1, - defaults: { - scale: 'small' - }, - items : [ - { - iconCls: 'ICON_USERS', - id:"x-pm-users", - text: ' ', - width: 22, - handler: function(){ - usersActorsWin.show(); - } - },{ - iconCls: 'ICON_GROUPS', - id:"x-pm-groups", - text: ' ', - width: 22, - handler: function(){ - groupsActorsWin.show(); - } - },{ - iconCls: 'ss_sprite ss_user_suit', - id:"x-pm-users-adhoc", - text: ' ', - width: 22, - handler: function(){ - adHocUsersActorsWin.show(); - } - },{ - iconCls: 'ss_sprite ss_group_suit', - id:"x-pm-groups-adhoc", - text: ' ', - width: 22, - handler: function(){ - adHocGroupsActorsWin.show(); - } - } - ] -}; - - -northPanelItems = [ -/* - { - text: 'Save', - cls: 'x-btn-text-icon', - iconCls: 'button_menu_ext ss_sprite ss_disk', - handler: function() { - saveProcess(); - } - }, { - text:'Save as', - iconCls: 'button_menu_ext ss_sprite ss_disk_multiple' - }, { - xtype: 'tbseparator' - }, -*/{ - //xtype: 'tbsplit', - text:'Edit', - //iconCls: '', - menu: new Ext.menu.Menu({ - items: [ - { - text: _('ID_SWITCH_EDITOR'), - iconCls: 'ss_sprite ss_arrow_switch', - handler: function() { - if(typeof pro_uid !== 'undefined') { - location.href = 'processes/processes_Map?PRO_UID=' +pro_uid+ '&rand=' +Math.random() - } - } - }, { - text: _('ID_SNAP_GEOMETRY'), - checked: false, // when checked has a boolean value, it is assumed to be a CheckItem - checkHandler: function(item, checked){ - workflow.setSnapToGeometry(checked); - } - } - ] - }) - }, - { - //xtype: 'tbsplit', - //iconCls: 'button_menu_ext ss_sprite ss_application', - text: 'Process', - menu: new Ext.menu.Menu({ - items: [{ - text : 'Dynaform', - iconCls: 'button_menu_ext ss_sprite ss_application_form', - handler : function() { - processObj.addDynaform(); - } - }, { - text: 'Input Document', - iconCls: 'button_menu_ext ss_sprite ss_page_white_put', - handler : function() { - processObj.addInputDoc(); - } - }, { - text: 'Output Document', - iconCls: 'button_menu_ext ss_sprite ss_page_white_get', - - handler : function() { - processObj.addOutputDoc(); - } - }, { - text: 'Trigger', - iconCls: 'button_menu_ext ss_sprite ss_cog', - handler : function() { - processObj.addTriggers(); - } - }, { - text: 'Report Table', - iconCls: 'button_menu_ext ss_sprite ss_table', - handler : function() { - processObj.addReportTable(); - } - }, { - text: 'Database Connection', - iconCls: 'button_menu_ext ss_sprite ss_database_connect', - handler : function() { - processObj.dbConnection(); - } - } - - ] - }) - - }, - '-', - { - text:'Undo', - iconCls: 'button_menu_ext ss_sprite ss_arrow_undo', - handler: function() { - workflow.getCommandStack().undo(); - } - }, { - text:'Redo', - iconCls: 'button_menu_ext ss_sprite ss_arrow_redo', - handler: function() { - workflow.getCommandStack().redo(); - } - },{ - //xtype: 'tbsplit', - text:'Zoom', - iconCls: 'button_menu_ext ss_sprite ss_zoom', - menu: new Ext.menu.Menu({ - items: [{ - text : '25%', - handler: function() { - Ext.getCmp('designerTab')._setDesignerTitle(pro_title + ' (25%)'); - workflow.zoom('25'); - } - },{ - text : '50%', - handler: function() { - Ext.getCmp('designerTab')._setDesignerTitle(pro_title + ' (50%)'); - workflow.zoom('50'); - } - },{ - text : '75%', - handler: function() { - Ext.getCmp('designerTab')._setDesignerTitle(pro_title + ' (75%)'); - workflow.zoom('75'); - } - },{ - text : '100%', - handler: function() { - Ext.getCmp('designerTab')._setDesignerTitle(pro_title + ' (100%)'); - workflow.zoom('100'); - } - },{ - text : '125%', - handler: function() { - Ext.getCmp('designerTab')._setDesignerTitle(pro_title + ' (125%)'); - workflow.zoom('125'); - } - },{ - text : '150%', - handler: function() { - Ext.getCmp('designerTab')._setDesignerTitle(pro_title + ' (150%)'); - workflow.zoom('150'); - } - },{ - text : '200%', - handler: function() { - Ext.getCmp('designerTab')._setDesignerTitle(pro_title + ' (200%)'); - workflow.zoom('200'); - } - } - ] - }) - } /*,{ - xtype: 'tbseparator' - }, { - text: _('ID_ACTORS'), - iconCls: 'ICON_USERS', - handler: function(){ - usersPanel.show() - } - - }, { - xtype: 'tbfill' - }, { - text: _('ID_SWITCH_EDITOR'), - iconCls: 'button_menu_ext ss_sprite ss_pencil', - handler: function() { - if(typeof pro_uid !== 'undefined') { - location.href = 'processes/processes_Map?PRO_UID=' +pro_uid+ '&rand=' +Math.random() - } - } - }*/ -] - - - -eastPanelTree = new Ext.tree.TreePanel({ - id: 'eastPanelTree', - useArrows: false, - autoScroll: true, - animate: true, - rootVisible : false, - border: true, - height: PMExt.getBrowser().screen.height * 0.3, - region: 'north', - split : true, - collapseMode:'mini', - loader : new Ext.tree.TreeLoader({ - preloadChildren : true, - dataUrl : 'processProxy/getProcessDetail', - baseParams : { - PRO_UID: pro_uid - } - }), - root: { - nodeType : 'async', - draggable : false, - id : 'root', - expanded : true - } -}); - -// tree east panel selection change -eastPanelTree.getSelectionModel().on('selectionchange', function(tree, node){ - if( node.attributes.type == 'task') { - _TAS_UID = node.attributes.id; - - Ext.getCmp('usersPanelTabs').getTabEl('usersTaskGrid').style.display = ''; - Ext.getCmp('usersPanelTabs').getTabEl('usersTaskAdHocGrid').style.display = ''; - Ext.getCmp('usersTaskGrid').store.reload({params: {tas_uid: _TAS_UID, tu_type: 1}}); - Ext.getCmp('usersTaskAdHocGrid').store.reload({params: {tas_uid: _TAS_UID, tu_type: 2}}); - } else { - Ext.getCmp('usersPanelTabs').setActiveTab(0); - Ext.getCmp('usersPanelTabs').getTabEl('usersTaskGrid').style.display = 'none'; - Ext.getCmp('usersPanelTabs').getTabEl('usersTaskAdHocGrid').style.display = 'none'; - } - propertyStore.reload({params: { - action : 'getProperties', - UID : node.attributes.id, - type : node.attributes.type - }}); - Ext.getCmp('eastPanelCenter').setTitle(node.attributes.typeLabel+': '+node.attributes.text); - //propertiesGrid.store.sort('name','DESC'); - propertiesGrid.setSource(propertyStore.reader.jsonData.prop); - -}) - -ActiveProperty = new Ext.form.Checkbox({ - name : 'active', - fieldLabel : 'Active', - checked : true, - inputValue : '1' -}); - -comboCategory = new Ext.form.ComboBox({ - fieldLabel : 'Category', - name : 'category', - allowBlank : true, - store : new Ext.data.Store( { - //autoLoad: true, //autoload the data - proxy : new Ext.data.HttpProxy( { - url : 'processProxy/getCategoriesList', - method : 'POST' - }), - baseParams : { - action : 'getCategoriesList' - }, - reader : new Ext.data.JsonReader( { - //root : 'rows', - fields : [ - {name : 'CATEGORY_UID'}, - {name : 'CATEGORY_NAME'} - ] - }) - }), - valueField : 'CATEGORY_NAME', - displayField : 'CATEGORY_NAME', - typeAhead : true, - //mode : 'local', - triggerAction : 'all', - editable: true, - forceSelection: true, - selectOnFocus : true -}); - -comboCalendar = new Ext.form.ComboBox({ - fieldLabel : 'Calendar', - name : 'calendar', - allowBlank : true, - store : new Ext.data.Store( { - //autoLoad: true, //autoload the data - proxy : new Ext.data.HttpProxy({ url: 'processProxy/getCaledarList'}), - //baseParams : {action: 'getCaledarList'}, - reader : new Ext.data.JsonReader( { - root : 'rows', - fields : [ - {name : 'CALENDAR_UID'}, - {name : 'CALENDAR_NAME'} - ] - }) - }), - valueField : 'CALENDAR_NAME', - displayField : 'CALENDAR_NAME', - typeAhead : true, - //mode : 'local', - triggerAction : 'all', - editable: true, - forceSelection: true -}); - -var comboPMVariables = new Ext.form.ComboBox({ - fieldLabel : 'Calendar', - name : 'calendar', - allowBlank : true, - store : new Ext.data.Store( { - //autoLoad: false, //autoload the data - proxy : new Ext.data.HttpProxy({ url: 'processProxy/getPMVariables'}), - baseParams : {PRO_UID: pro_uid}, - reader : new Ext.data.JsonReader( { - root : 'rows', - fields : [ - {name : 'sName'}, - {name : 'sName'} - ] - }) - }), - valueField : 'sName', - displayField : 'sName', - typeAhead : true, - //mode : 'local', - triggerAction: 'all', - editable: true, - forceSelection: true -}); - -propertiesGrid = new Ext.grid.PropertyGrid({ - id: 'propGrid', - title: 'Properties', - loadMask : {msg:"Loading..."}, - autoHeight: true, - viewConfig : { - forceFit: true, - scrollOffset: 2 // the grid will never have scrollbars - }, - customEditors: { - //'Debug' : new Ext.grid.GridEditor(ActiveProperty), - 'Category' : new Ext.grid.GridEditor(comboCategory), - 'Calendar' : new Ext.grid.GridEditor(comboCalendar), - 'Variable for case priority' : new Ext.grid.GridEditor(comboPMVariables) - } -}); - -propertiesGrid.on('afteredit', function afterEdit(r) { - var node = Ext.getCmp('eastPanelTree').getSelectionModel().getSelectedNode(); - var UID; - var type; - - if( node ) { - UID = node.attributes.id; - type = node.attributes.type; - } else { - UID = pro_uid; - type = 'process'; - } - Ext.Ajax.request({ - url: 'processProxy/saveProperties', - params: { - UID: UID, - type: type, - property: r.record.data.name, - value: r.value - }, - success: function(response) { - if( type == 'process' && r.record.data.name == 'Title') { - pro_title = r.value; - - Ext.getCmp('designerTab')._setDesignerTitle(pro_title); - Ext.getCmp('eastPanelTree').getNodeById(UID).setText(pro_title); - } else if( type == 'task' && r.record.data.name == 'Title') { - Ext.getCmp('eastPanelTree').getNodeById(UID).setText(r.value); - //here we need to find and update the task title into task figure on designer - //if the current selection is the same node editing the title property - - if( workflow.currentSelection.id == UID ) { - workflow.currentSelection.taskName = r.value; - } - } - }, - failure: function(){ - //Ext.Msg.alert ('Failure'); - } - }); - - //r.record.commit(); -}, this ); - - -propertyStore = new Ext.data.JsonStore({ - id: 'propertyStore', - autoLoad: true, //autoload the data - url: 'processProxy/getProperties', - root: 'prop', - fields: ['title', 'description'], - store: new Ext.grid.PropertyStore({ - sortable: false, - defaultSortable: false - }), - listeners: { - load: { - fn: function(store, records, options){ - //propertiesGrid.store.sort('name','DESC'); - propertiesGrid.setSource(store.reader.jsonData.prop); - } - } - }, - baseParams: { - UID : pro_uid, - type : 'process' - } -}); - - -usersTaskStore = new Ext.data.GroupingStore( { - autoLoad: false, - url: 'processProxy/getActorsTask', - reader : new Ext.data.JsonReader({ - totalProperty: 'totalCount', - root: 'data', - fields : [ - {name : 'USR_UID'}, - {name : 'USR_USERNAME'}, - {name : 'USR_FIRSTNAME'}, - {name : 'USR_LASTNAME'}, - {name : 'NAME'}, - {name : 'TU_RELATION'} - ] - }), - baseParams: {tas_uid: '', tu_type: ''}, - groupField: 'TU_RELATION' - }); - - usersTaskGrid = new Ext.grid.GridPanel({ - id : 'usersTaskGrid', - title : _('ID_ACTORS'), - height : 180, - stateful : true, - stateId : 'usersTaskGrid', - sortable:false, - view: new Ext.grid.GroupingView({ - forceFit:true, - groupTextTpl: '{[values.rs.length]} {[values.rs[0].data["TU_RELATION"] == 1 ? "Users" : "Groups"]}' - }), - cm : new Ext.grid.ColumnModel({ - defaults: { - width: 300, - sortable: true - }, - columns : [ - {id:'USR_UID', dataIndex: 'USR_UID', hidden:true, hideable:false}, - {header: 'Assigned', id:'TU_RELATION', dataIndex: 'TU_RELATION', hidden:true, hideable:false}, - {header: 'User', dataIndex: 'USER', width: 249, renderer:function(v,p,r){ - if( r.data.TU_RELATION == '1' ) - return _FNF(r.data.USR_USERNAME, r.data.USR_FIRSTNAME, r.data.USR_LASTNAME); - else - return r.data.NAME; - }} - ] - }), - store: usersTaskStore, - listeners: { - render: function(){ - this.loadMask = new Ext.LoadMask(this.body, {msg:_('ID_LOADING')}); - } - }/*, - tbar:[ - '->', { - text: _('ID_REMOVE'), - iconCls: 'button_menu_ext ss_sprite ss_delete', - handler: removeUsersTask - } - ]*/, - bbar: [new Ext.PagingToolbar({ - pageSize : 10, - store : usersTaskStore, - displayInfo: true, - displayMsg : '{2} Users', - emptyMsg : '' - })] - }); - - //connecting context menu to grid - usersTaskGrid.addListener('rowcontextmenu', function(grid, rowIndex, e){ - e.stopEvent(); - var coords = e.getXY(); - usersTaskGridContextMenu.showAt([coords[0], coords[1]]); - }); - - //by default the right click is not selecting the grid row over the mouse - usersTaskGrid.on('rowcontextmenu', function (grid, rowIndex, evt) { - var sm = grid.getSelectionModel(); - sm.selectRow(rowIndex, sm.isSelected(rowIndex)); - }); - - //prevent default - usersTaskGrid.on('contextmenu', function (evt) { - evt.preventDefault(); - }); - - usersTaskGridContextMenu = new Ext.menu.Menu({ - id: 'messageContextMenu', - items: [{ - text: _('ID_REMOVE'), - iconCls: 'button_menu_ext ss_sprite ss_delete', - handler: removeUsersTask - } - ] - }); - - //AD HOC - usersTaskAdHocStore = new Ext.data.GroupingStore( { - autoLoad: false, - url: 'processProxy/getActorsTask', - reader : new Ext.data.JsonReader({ - totalProperty: 'totalCount', - root: 'data', - fields : [ - {name : 'USR_UID'}, - {name : 'USR_USERNAME'}, - {name : 'USR_FIRSTNAME'}, - {name : 'USR_LASTNAME'}, - {name : 'NAME'}, - {name : 'TU_RELATION'} - ] - }), - baseParams: {tas_uid: '', tu_type: ''}, - groupField: 'TU_RELATION' - }); - - usersTaskAdHocGrid = new Ext.grid.GridPanel({ - id : 'usersTaskAdHocGrid', - title : _('ID_AD_HOC_ACTORS'), - height : 180, - stateful : true, - stateId : 'usersTaskAdHocGrid', - sortable:false, - view: new Ext.grid.GroupingView({ - forceFit:true, - groupTextTpl: '{[values.rs.length]} {[values.rs[0].data["TU_RELATION"] == 1 ? "Users" : "Groups"]}' - }), - cm : new Ext.grid.ColumnModel({ - defaults: { - width: 300, - sortable: true - }, - columns : [ - {id:'USR_UID', dataIndex: 'USR_UID', hidden:true, hideable:false}, - {header: 'Assigned', id:'TU_RELATION', dataIndex: 'TU_RELATION', hidden:true, hideable:false}, - {header: 'User', dataIndex: 'USER', width: 249, renderer:function(v,p,r){ - if( r.data.TU_RELATION == '1' ) - return _FNF(r.data.USR_USERNAME, r.data.USR_FIRSTNAME, r.data.USR_LASTNAME); - else - return r.data.NAME; - }} - ] - }), - store: usersTaskAdHocStore, - listeners: { - render: function(){ - this.loadMask = new Ext.LoadMask(this.body, {msg:_('ID_LOADING')}); - } - }/*, - tbar:[ - '->', { - text: _('ID_REMOVE'), - iconCls: 'button_menu_ext ss_sprite ss_delete', - handler: removeUsersTask - } - ]*/, - bbar: [new Ext.PagingToolbar({ - pageSize : 10, - store : usersTaskStore, - displayInfo: true, - displayMsg : '{2} Users', - emptyMsg : '' - })] - }); - - - //connecting context menu to grid - usersTaskAdHocGrid.addListener('rowcontextmenu', function(grid, rowIndex, e) { - e.stopEvent(); - var coords = e.getXY(); - usersTaskAdHocGridContextMenu.showAt([coords[0], coords[1]]); - },this); - - //by default the right click is not selecting the grid row over the mouse - //we need to set this four lines - usersTaskAdHocGrid.on('rowcontextmenu', function (grid, rowIndex, evt) { - var sm = grid.getSelectionModel(); - sm.selectRow(rowIndex, sm.isSelected(rowIndex)); - }, this); - - //prevent default - usersTaskGrid.on('contextmenu', function (evt) { - evt.preventDefault(); - }, this); - - usersTaskAdHocGridContextMenu = new Ext.menu.Menu({ - id: 'messagAdHocGrideContextMenu', - items: [{ - text: _('ID_REMOVE'), - iconCls: 'button_menu_ext ss_sprite ss_delete', - handler: removeUsersAdHocTask - } - ] - }); - - /*** for actors ***/ - usersStore = new Ext.data.Store({ - autoLoad: false, - proxy : new Ext.data.HttpProxy({ - url: 'processProxy/getUsers?start='+usersPanelStart+'&limit='+usersPanelLimit - }), - reader : new Ext.data.JsonReader( { - totalProperty: 'totalCount', - root: 'data', - fields : [ - {name : 'USR_UID'}, - {name : 'USER'}, - {name : 'USR_USERNAME'}, - {name : 'USR_FIRSTNAME'}, - {name : 'USR_LASTNAME'} - ] - }), - listeners: { - load: function(){ - usersActorsWin.setTitle(_('ID_USERS_ACTORS') + ' (' +usersStore.reader.jsonData.totalCount+ ')'); - } - } - }); - - usersGrid = new Ext.grid.GridPanel({ - id : 'usersGrid', - height : 180, - ddGroup : 'task-assignment', - enableDragDrop : true, - width: 150, - cm : new Ext.grid.ColumnModel({ - defaults: { - width: 200, - sortable: true - }, - columns : [ - {header: 'USR_UID', id:'USR_UID', dataIndex: 'USR_UID', hidden:true, hideable:false}, - {header: 'User', dataIndex: 'USER', width: 249, renderer:function(v,p,r){ - return _FNF(r.data.USR_USERNAME, r.data.USR_FIRSTNAME, r.data.USR_LASTNAME); - }} - ] - }), - store: usersStore, - loadMask: {msg:_('ID_LOADING')}, - tbar : [ - new Ext.form.TextField ({ - id : 'usersSearchTxt', - ctCls :'pm_search_text_field', - allowBlank : true, - width : 170, - emptyText : _('ID_ENTER_SEARCH_TERM'), - listeners : { - specialkey: function(f,e){ - if (e.getKey() == e.ENTER) - usersSearch(); - } - } - }), { - text :'X', - ctCls :'pm_search_x_button', - handler : function(){ - usersStore.setBaseParam( 'search', ''); - usersStore.load({params:{start : 0 , limit : usersPanelLimit}}); - Ext.getCmp('usersSearchTxt').setValue(''); - } - }, { - text :TRANSLATIONS.ID_SEARCH, - handler : usersSearch - } - ] - /*, - bbar: [new Ext.PagingToolbar({ - pageSize : usersPanelLimit, - store : usersStore, - displayInfo: true, - displayMsg : '{2} Users', - emptyMsg : '' - })]*/ - }); - - adHocUsersStore = new Ext.data.Store({ - autoLoad: false, - proxy : new Ext.data.HttpProxy({ - url: 'processProxy/getUsers?start='+usersPanelStart+'&limit='+usersPanelLimit - }), - reader : new Ext.data.JsonReader( { - totalProperty: 'totalCount', - root: 'data', - fields : [ - {name : 'USR_UID'}, - {name : 'USER'}, - {name : 'USR_USERNAME'}, - {name : 'USR_FIRSTNAME'}, - {name : 'USR_LASTNAME'} - ] - }), - listeners: { - load: function(){ - adHocUsersActorsWin.setTitle(_('ID_ADHOC_USERS_ACTORS') + ' (' +adHocUsersStore.reader.jsonData.totalCount+ ')'); - } - } - }); - - adHocUsersGrid = new Ext.grid.GridPanel({ - id : 'adHocUsersGrid', - height : 180, - ddGroup : 'task-assignment', - enableDragDrop : true, - width: 150, - cm : new Ext.grid.ColumnModel({ - defaults: { - width: 200, - sortable: true - }, - columns : [ - {header: 'USR_UID', id:'USR_UID', dataIndex: 'USR_UID', hidden:true, hideable:false}, - {header: 'User', dataIndex: 'USER', width: 249, renderer:function(v,p,r){ - return _FNF(r.data.USR_USERNAME, r.data.USR_FIRSTNAME, r.data.USR_LASTNAME); - }} - ] - }), - store: adHocUsersStore, - loadMask: {msg:_('ID_LOADING')}, - tbar : [ - new Ext.form.TextField ({ - id : 'adHocUsersSearchTxt', - ctCls :'pm_search_text_field', - allowBlank : true, - width : 170, - emptyText : _('ID_ENTER_SEARCH_TERM'), - listeners : { - specialkey: function(f,e){ - if (e.getKey() == e.ENTER) - adHocUsersSearch(); - } - } - }), { - text :'X', - ctCls :'pm_search_x_button', - handler : function(){ - adHocUsersStore.setBaseParam( 'search', ''); - adHocUsersStore.load({params:{start : 0 , limit : usersPanelLimit}}); - Ext.getCmp('adHocUsersSearchTxt').setValue(''); - } - }, { - text :TRANSLATIONS.ID_SEARCH, - handler : adHocUsersSearch - } - ] - /*, - bbar: [new Ext.PagingToolbar({ - pageSize : usersPanelLimit, - store : usersStore, - displayInfo: true, - displayMsg : '{2} Users', - emptyMsg : '' - })]*/ - }); - - groupsStore = new Ext.data.Store( { - autoLoad: false, - proxy : new Ext.data.HttpProxy({ - url: 'processProxy/getGroups?start='+usersPanelStart+'&limit='+usersPanelLimit - }), - reader : new Ext.data.JsonReader( { - totalProperty: 'totalCount', - root: 'data', - fields : [ - {name : 'GRP_UID'}, - {name : 'CON_VALUE'} - ] - }), - listeners: { - load: function(){ - groupsActorsWin.setTitle(_('ID_GROUPS_ACTORS') + ' (' +groupsStore.reader.jsonData.totalCount+ ')'); - } - } - }); - - groupsGrid = new Ext.grid.GridPanel({ - id : 'groupsGrid', - ddGroup : 'task-assignment', - height : 180, - width : 150, - enableDragDrop : true, - cm : new Ext.grid.ColumnModel({ - defaults : { - width : 250, - sortable : true - }, - columns: [ - {id:'GRP_UID', dataIndex: 'GRP_UID', hidden:true, hideable:false}, - {header: 'Group', dataIndex: 'CON_VALUE', width: 249} - ] - }), - store : groupsStore, - loadMask: {msg:_('ID_LOADING')}, - tbar : [ - new Ext.form.TextField ({ - id : 'groupsSearchTxt', - ctCls :'pm_search_text_field', - allowBlank : true, - width : 170, - emptyText : _('ID_ENTER_SEARCH_TERM'), - listeners : { - specialkey: function(f,e){ - if (e.getKey() == e.ENTER) - groupsSearch(); - } - } - }), { - text :'X', - ctCls :'pm_search_x_button', - handler : function(){ - groupsStore.setBaseParam( 'search', ''); - groupsStore.load({params:{start : 0 , limit : usersPanelLimit}}); - Ext.getCmp('groupsSearchTxt').setValue(''); - } - }, { - text :TRANSLATIONS.ID_SEARCH, - handler : groupsSearch - } - ]/*, - bbar: [new Ext.PagingToolbar({ - pageSize : usersPanelLimit, - store : groupsStore, - displayInfo: true, - displayMsg : '{2} Groups', - emptyMsg : 'No records found' - })]*/ - }); - - adHocGroupsStore = new Ext.data.Store( { - autoLoad: false, - proxy : new Ext.data.HttpProxy({ - url: 'processProxy/getGroups?start='+usersPanelStart+'&limit='+usersPanelLimit - }), - reader : new Ext.data.JsonReader( { - totalProperty: 'totalCount', - root: 'data', - fields : [ - {name : 'GRP_UID'}, - {name : 'CON_VALUE'} - ] - }), - listeners: { - load: function(){ - adHocGroupsActorsWin.setTitle(_('ID_ADHOC_GROUPS_ACTORS') + ' (' +adHocGroupsStore.reader.jsonData.totalCount+ ')'); - } - } - }); - - adHocGroupsGrid = new Ext.grid.GridPanel({ - id : 'adHocGroupsGrid', - ddGroup : 'task-assignment', - height : 180, - width : 150, - enableDragDrop : true, - cm : new Ext.grid.ColumnModel({ - defaults : { - width : 250, - sortable : true - }, - columns: [ - {id:'GRP_UID', dataIndex: 'GRP_UID', hidden:true, hideable:false}, - {header: 'Group', dataIndex: 'CON_VALUE', width: 249} - ] - }), - store : adHocGroupsStore, - loadMask: {msg:_('ID_LOADING')}, - tbar : [ - new Ext.form.TextField ({ - id : 'adHocGroupsSearchTxt', - ctCls :'pm_search_text_field', - allowBlank : true, - width : 170, - emptyText : _('ID_ENTER_SEARCH_TERM'), - listeners : { - specialkey: function(f,e){ - if (e.getKey() == e.ENTER) - adHocGroupsSearch(); - } - } - }), { - text :'X', - ctCls :'pm_search_x_button', - handler : function(){ - adHocGroupsStore.setBaseParam( 'search', ''); - adHocGroupsStore.load({params:{start : 0 , limit : usersPanelLimit}}); - Ext.getCmp('adHocGroupsSearchTxt').setValue(''); - } - }, { - text :TRANSLATIONS.ID_SEARCH, - handler : adHocGroupsSearch - } - ]/*, - bbar: [new Ext.PagingToolbar({ - pageSize : usersPanelLimit, - store : groupsStore, - displayInfo: true, - displayMsg : '{2} Groups', - emptyMsg : 'No records found' - })]*/ - }); - - _onDropActors = function(ddSource, e, data) { - - var records = ddSource.dragData.selections; - var uids = Array(); - _TAS_UID = _targetTask.id; - - if( data.grid.id == 'usersGrid' || data.grid.id == 'groupsGrid') { - _TU_TYPE = 1; - } else { //some groups grid items were dropped - _TU_TYPE = 2; - } - - Ext.each(records, function(gridRow){ - if( data.grid.id == 'usersGrid' || data.grid.id == 'adHocUsersGrid') {//some users grid items were dropped - _RELATION = 1; - uids.push(gridRow.data.USR_UID); - } else { //some groups grid items were dropped - _RELATION = 2; - uids.push(gridRow.data.GRP_UID); - } - }); - - uids = uids.join(','); - - - Ext.getCmp('eastPanelCenter').setTitle(_('ID_TASK')+': '+_targetTask.name); - - Ext.Ajax.request({ - url: 'processProxy/assignActorsTask', - success: function(response){ - var result = Ext.util.JSON.decode(response.responseText); - if( result.success ) { - PMExt.notify(_('ID_RESPONSABILITIES_ASSIGNMENT'), result.msg); - - Ext.getCmp('eastPanel').show(); - Ext.getCmp('usersPanelTabs').getTabEl('usersTaskGrid').style.display = ''; - Ext.getCmp('usersPanelTabs').getTabEl('usersTaskAdHocGrid').style.display = ''; - Ext.getCmp('eastPanelTree').getNodeById(_TAS_UID).select(); - if( _TU_TYPE == 1 ) { - Ext.getCmp('usersPanelTabs').setActiveTab(1); - Ext.getCmp('usersTaskGrid').store.reload({params:{tas_uid: _TAS_UID, tu_type: 1}}); - } else { - Ext.getCmp('usersPanelTabs').setActiveTab(2); - Ext.getCmp('usersTaskAdHocGrid').store.reload({params:{tas_uid: _TAS_UID, tu_type: 2}}); - } - - } else { - PMExt.error(_('ID_ERROR'), result.msg); - } - }, - failure: function(){}, - params: { - TAS_UID : _TAS_UID, - TU_TYPE : _TU_TYPE, - TU_RELATION : _RELATION, - UIDS : uids - } - }); - } - - - //last - usersActorsWin = new Ext.Window({ - layout:'fit', - padding: '0 10 0 0', - iconCls: 'ICON_USERS', - width:260, x:45, y:55, - height:PMExt.getBrowser().screen.height/2 - 20, - closeAction:'hide', - plain: true, - plugins: [ new Ext.ux.WindowCascade() ], - offset: 50, - items: [usersGrid], - listeners:{ - beforerender:function(){ - usersGrid.store.load(); - } - } - }); - - adHocUsersActorsWin = new Ext.Window({ - layout:'fit', - padding: '0 10 0 0', - iconCls: 'ss_sprite ss_user_suit', - width:260, - height:PMExt.getBrowser().screen.height/2 - 20, - closeAction:'hide', - plain: true, - plugins: [ new Ext.ux.WindowCascade() ], - offset: 50, - items: [adHocUsersGrid], - listeners:{ - beforerender:function(){ - adHocUsersGrid.store.load(); - } - } - }); - - groupsActorsWin = new Ext.Window({ - layout:'fit', - padding: '0 10 0 0', - iconCls: 'ICON_GROUPS', - width:260, - height:PMExt.getBrowser().screen.height/2 - 20, - closeAction:'hide', - plain: true, - plugins: [ new Ext.ux.WindowCascade() ], - offset: 50, - items: [groupsGrid], - listeners:{ - beforerender:function(){ - groupsGrid.store.load(); - } - } - }); - - adHocGroupsActorsWin = new Ext.Window({ - layout:'fit', - padding: '0 10 0 0', - iconCls: 'ss_sprite ss_group_suit', - width:260, - height:PMExt.getBrowser().screen.height/2 - 20, - closeAction:'hide', - plain: true, - plugins: [ new Ext.ux.WindowCascade() ], - offset: 50, - items: [adHocGroupsGrid], - listeners:{ - beforerender:function(){ - adHocGroupsGrid.store.load(); - } - } - }); - -}); -//end onReady - - -function removeUsersTask(){ - - var usr_uid = Array(); - var tu_relation = Array(); - var rowsSelected = Ext.getCmp('usersTaskGrid').getSelectionModel().getSelections(); - - if( rowsSelected.length == 0 ) { - PMExt.error('', _('ID_NO_SELECTION_WARNING')); - return false; - } - - for(i=0; i