CODE STYLE class.dynaFormField.php
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
/**
|
/**
|
||||||
* class.dynaFormField.php
|
* class.dynaFormField.php
|
||||||
|
*
|
||||||
* @package workflow.engine.classes
|
* @package workflow.engine.classes
|
||||||
*
|
*
|
||||||
* ProcessMaker Open Source Edition
|
* ProcessMaker Open Source Edition
|
||||||
@@ -13,191 +14,167 @@
|
|||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU Affero General Public License for more details.
|
* GNU Affero General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU Affero General Public License
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*
|
*
|
||||||
* For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
|
* For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
|
||||||
* Coral Gables, FL, 33134, USA, or email info@colosa.com.
|
* Coral Gables, FL, 33134, USA, or email info@colosa.com.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
G::LoadClass('xmlDb');
|
G::LoadClass( 'xmlDb' );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Dynaform Field - DynaformField class
|
* Dynaform Field - DynaformField class
|
||||||
|
*
|
||||||
* @package workflow.engine.classes
|
* @package workflow.engine.classes
|
||||||
*/
|
*/
|
||||||
class DynaFormField extends DBTable
|
class DynaFormField extends DBTable
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* Function SetTo
|
/**
|
||||||
* @param string $objConnection
|
* Function SetTo
|
||||||
* @return void
|
*
|
||||||
*/
|
* @param string $objConnection
|
||||||
function SetTo( $objConnection )
|
* @return void
|
||||||
{
|
*/
|
||||||
DBTable::SetTo( $objConnection, 'dynaForm', array('XMLNODE_NAME') );
|
function SetTo ($objConnection)
|
||||||
}
|
{
|
||||||
|
DBTable::SetTo( $objConnection, 'dynaForm', array ('XMLNODE_NAME'
|
||||||
/**
|
) );
|
||||||
* Load a dynaForm
|
}
|
||||||
* @param string $sUID
|
|
||||||
* @return void
|
/**
|
||||||
*/
|
* Load a dynaForm
|
||||||
function Load( $sUID )
|
*
|
||||||
{
|
* @param string $sUID
|
||||||
parent::Load( $sUID );
|
* @return void
|
||||||
if (is_array($this->Fields)) {
|
*/
|
||||||
foreach( $this->Fields as $name => $value ){
|
function Load ($sUID)
|
||||||
if (strcasecmp($name,'dependentfields')==0) {
|
{
|
||||||
$this->Fields[$name]=explode(',', $value );
|
parent::Load( $sUID );
|
||||||
|
if (is_array( $this->Fields )) {
|
||||||
|
foreach ($this->Fields as $name => $value) {
|
||||||
|
if (strcasecmp( $name, 'dependentfields' ) == 0) {
|
||||||
|
$this->Fields[$name] = explode( ',', $value );
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Delete Fields of a dynaForm
|
|
||||||
* @param string $uid
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
function Delete ( $uid )
|
|
||||||
{
|
|
||||||
$this->Fields['XMLNODE_NAME'] = $uid;
|
|
||||||
parent::Delete();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Save Fields of a dynaform
|
* Delete Fields of a dynaForm
|
||||||
* @param array $Fields
|
*
|
||||||
* @param array $labels
|
* @param string $uid
|
||||||
* @param array $options
|
* @return void
|
||||||
* @return void
|
*/
|
||||||
*/
|
function Delete ($uid)
|
||||||
function Save ( $Fields , $labels=array() , $options=array() )
|
{
|
||||||
{
|
$this->Fields['XMLNODE_NAME'] = $uid;
|
||||||
|
parent::Delete();
|
||||||
|
}
|
||||||
|
|
||||||
if ($Fields['TYPE'] === 'javascript'){
|
/**
|
||||||
$Fields['XMLNODE_VALUE'] = $Fields['CODE'];
|
* Save Fields of a dynaform
|
||||||
unset($Fields['CODE']);
|
*
|
||||||
$labels = array();
|
* @param array $Fields
|
||||||
}
|
* @param array $labels
|
||||||
if ($Fields['XMLNODE_NAME_OLD'] == '') {
|
* @param array $options
|
||||||
if (($Fields['XMLNODE_NAME'][0] == '1') || ($Fields['XMLNODE_NAME'][0] == '2') ||
|
* @return void
|
||||||
($Fields['XMLNODE_NAME'][0] == '3') || ($Fields['XMLNODE_NAME'][0] == '4') ||
|
*/
|
||||||
($Fields['XMLNODE_NAME'][0] == '5') || ($Fields['XMLNODE_NAME'][0] == '6') ||
|
function Save ($Fields, $labels = array(), $options = array())
|
||||||
($Fields['XMLNODE_NAME'][0] == '7') || ($Fields['XMLNODE_NAME'][0] == '8') ||
|
{
|
||||||
($Fields['XMLNODE_NAME'][0] == '9') || ($Fields['XMLNODE_NAME'][0] == '10')) {
|
|
||||||
$Fields['XMLNODE_NAME'] = '_' . $Fields['XMLNODE_NAME'];
|
if ($Fields['TYPE'] === 'javascript') {
|
||||||
}
|
$Fields['XMLNODE_VALUE'] = $Fields['CODE'];
|
||||||
$res = $this->_dbses->Execute('SELECT * FROM dynaForm WHERE XMLNODE_NAME="'.$Fields['XMLNODE_NAME'].'"');
|
unset( $Fields['CODE'] );
|
||||||
}
|
$labels = array ();
|
||||||
else {
|
}
|
||||||
if (($Fields['XMLNODE_NAME_OLD'][0] == '1') || ($Fields['XMLNODE_NAME_OLD'][0] == '2') ||
|
if ($Fields['XMLNODE_NAME_OLD'] == '') {
|
||||||
($Fields['XMLNODE_NAME_OLD'][0] == '3') || ($Fields['XMLNODE_NAME_OLD'][0] == '4') ||
|
if (($Fields['XMLNODE_NAME'][0] == '1') || ($Fields['XMLNODE_NAME'][0] == '2') || ($Fields['XMLNODE_NAME'][0] == '3') || ($Fields['XMLNODE_NAME'][0] == '4') || ($Fields['XMLNODE_NAME'][0] == '5') || ($Fields['XMLNODE_NAME'][0] == '6') || ($Fields['XMLNODE_NAME'][0] == '7') || ($Fields['XMLNODE_NAME'][0] == '8') || ($Fields['XMLNODE_NAME'][0] == '9') || ($Fields['XMLNODE_NAME'][0] == '10')) {
|
||||||
($Fields['XMLNODE_NAME_OLD'][0] == '5') || ($Fields['XMLNODE_NAME_OLD'][0] == '6') ||
|
$Fields['XMLNODE_NAME'] = '_' . $Fields['XMLNODE_NAME'];
|
||||||
($Fields['XMLNODE_NAME_OLD'][0] == '7') || ($Fields['XMLNODE_NAME_OLD'][0] == '8') ||
|
}
|
||||||
($Fields['XMLNODE_NAME_OLD'][0] == '9') || ($Fields['XMLNODE_NAME_OLD'][0] == '10')) {
|
$res = $this->_dbses->Execute( 'SELECT * FROM dynaForm WHERE XMLNODE_NAME="' . $Fields['XMLNODE_NAME'] . '"' );
|
||||||
$Fields['XMLNODE_NAME_OLD'] = '_' . $Fields['XMLNODE_NAME_OLD'];
|
} else {
|
||||||
}
|
if (($Fields['XMLNODE_NAME_OLD'][0] == '1') || ($Fields['XMLNODE_NAME_OLD'][0] == '2') || ($Fields['XMLNODE_NAME_OLD'][0] == '3') || ($Fields['XMLNODE_NAME_OLD'][0] == '4') || ($Fields['XMLNODE_NAME_OLD'][0] == '5') || ($Fields['XMLNODE_NAME_OLD'][0] == '6') || ($Fields['XMLNODE_NAME_OLD'][0] == '7') || ($Fields['XMLNODE_NAME_OLD'][0] == '8') || ($Fields['XMLNODE_NAME_OLD'][0] == '9') || ($Fields['XMLNODE_NAME_OLD'][0] == '10')) {
|
||||||
$res = $this->_dbses->Execute('SELECT * FROM dynaForm WHERE XMLNODE_NAME="'.$Fields['XMLNODE_NAME_OLD'].'"');
|
$Fields['XMLNODE_NAME_OLD'] = '_' . $Fields['XMLNODE_NAME_OLD'];
|
||||||
}
|
}
|
||||||
$this->is_new = ($res->count()==0);
|
$res = $this->_dbses->Execute( 'SELECT * FROM dynaForm WHERE XMLNODE_NAME="' . $Fields['XMLNODE_NAME_OLD'] . '"' );
|
||||||
$this->Fields = $Fields;
|
}
|
||||||
unset($this->Fields['XMLNODE_NAME_OLD']);
|
$this->is_new = ($res->count() == 0);
|
||||||
/*
|
$this->Fields = $Fields;
|
||||||
|
unset( $this->Fields['XMLNODE_NAME_OLD'] );
|
||||||
|
/*
|
||||||
* MPD-10 to create fields that do not appear many attributes, only the main ones?
|
* MPD-10 to create fields that do not appear many attributes, only the main ones?
|
||||||
* The show those who are not white
|
* The show those who are not white
|
||||||
*/
|
*/
|
||||||
if ($this->is_new){
|
if ($this->is_new) {
|
||||||
foreach($this->Fields as $key => $value){
|
foreach ($this->Fields as $key => $value) {
|
||||||
if ($value=="")
|
if ($value == "")
|
||||||
unset( $this->Fields[$key] );
|
unset( $this->Fields[$key] );
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
$this->Fields['XMLNODE_NAME'] = $Fields['XMLNODE_NAME_OLD'];
|
||||||
$this->Fields['XMLNODE_NAME'] = $Fields['XMLNODE_NAME_OLD'];
|
}
|
||||||
}
|
/*$res = $this->_dbses->Execute('INSERT INTO dynaForm'.
|
||||||
/*$res = $this->_dbses->Execute('INSERT INTO dynaForm'.
|
|
||||||
' (XMLNODE_TYPE,XMLNODE_VALUE)'.
|
' (XMLNODE_TYPE,XMLNODE_VALUE)'.
|
||||||
' VALUES ("cdata", "'."\n".'")');*/
|
' VALUES ("cdata", "'."\n".'")');*/
|
||||||
parent::Save();
|
parent::Save();
|
||||||
if ($this->is_new) {
|
if ($this->is_new) {
|
||||||
/*
|
/*
|
||||||
* Create a new field.
|
* Create a new field.
|
||||||
*/
|
*/
|
||||||
foreach( $labels as $lang => $value ) {
|
foreach ($labels as $lang => $value) {
|
||||||
/*$res = $this->_dbses->Execute('INSERT INTO dynaForm'.
|
/*$res = $this->_dbses->Execute('INSERT INTO dynaForm'.
|
||||||
' (XMLNODE_TYPE,XMLNODE_VALUE)'.
|
' (XMLNODE_TYPE,XMLNODE_VALUE)'.
|
||||||
' VALUES ("cdata", "'."\n".'")');*/
|
' VALUES ("cdata", "'."\n".'")');*/
|
||||||
$res = $this->_dbses->Execute('INSERT INTO dynaForm.'
|
$res = $this->_dbses->Execute( 'INSERT INTO dynaForm.' . $Fields['XMLNODE_NAME'] . ' (XMLNODE_NAME,XMLNODE_VALUE,XMLNODE_TYPE) ' . 'VALUES ("","' . "\n " . '","cdata")' );
|
||||||
.$Fields['XMLNODE_NAME'].' (XMLNODE_NAME,XMLNODE_VALUE,XMLNODE_TYPE) '
|
$res = $this->_dbses->Execute( 'INSERT INTO dynaForm.' . $Fields['XMLNODE_NAME'] . ' (XMLNODE_NAME,XMLNODE_VALUE) ' . 'VALUES ("' . $lang . '","' . str_replace( '"', '""', $value )/*."\n "*/.'")' );
|
||||||
.'VALUES ("","'."\n ".'","cdata")');
|
if (isset( $options[$lang] )) {
|
||||||
$res = $this->_dbses->Execute('INSERT INTO dynaForm.'
|
foreach ($options[$lang] as $option => $text) {
|
||||||
.$Fields['XMLNODE_NAME'].' (XMLNODE_NAME,XMLNODE_VALUE) '
|
$res = $this->_dbses->Execute( 'INSERT INTO dynaForm.' . $Fields['XMLNODE_NAME'] . '.' . $lang . ' (XMLNODE_NAME,XMLNODE_VALUE,XMLNODE_TYPE) ' . 'VALUES ("","' . " " . '","cdata")' );
|
||||||
.'VALUES ("'.$lang.'","'.str_replace('"','""',$value)/*."\n "*/.'")');
|
$res = $this->_dbses->Execute( 'INSERT INTO dynaForm.' . $Fields['XMLNODE_NAME'] . '.' . $lang . ' (XMLNODE_NAME,XMLNODE_VALUE,name) ' . 'VALUES ("option","' . str_replace( '"', '""', $text ) . '","' . str_replace( '"', '""', $option ) . '")' );
|
||||||
if (isset($options[$lang])) {
|
$res = $this->_dbses->Execute( 'INSERT INTO dynaForm.' . $Fields['XMLNODE_NAME'] . '.' . $lang . ' (XMLNODE_NAME,XMLNODE_VALUE,XMLNODE_TYPE) ' . 'VALUES ("","' . "\n " . '","cdata")' );
|
||||||
foreach($options[$lang] as $option => $text ) {
|
}
|
||||||
$res = $this->_dbses->Execute('INSERT INTO dynaForm.'
|
}
|
||||||
.$Fields['XMLNODE_NAME'].'.'.$lang.' (XMLNODE_NAME,XMLNODE_VALUE,XMLNODE_TYPE) '
|
$res = $this->_dbses->Execute( 'INSERT INTO dynaForm.' . $Fields['XMLNODE_NAME'] . ' (XMLNODE_NAME,XMLNODE_VALUE,XMLNODE_TYPE) ' . 'VALUES ("","' . "\n" . '","cdata")' );
|
||||||
.'VALUES ("","'." ".'","cdata")');
|
}
|
||||||
$res = $this->_dbses->Execute('INSERT INTO dynaForm.'
|
$res = $this->_dbses->Execute( 'INSERT INTO dynaForm' . ' (XMLNODE_TYPE,XMLNODE_VALUE)' . ' VALUES ("cdata", "' . "\n" . '")' );
|
||||||
.$Fields['XMLNODE_NAME'].'.'.$lang.' (XMLNODE_NAME,XMLNODE_VALUE,name) '
|
} else {
|
||||||
.'VALUES ("option","'.str_replace('"','""',$text).'","'.str_replace('"','""',$option).'")');
|
/*
|
||||||
$res = $this->_dbses->Execute('INSERT INTO dynaForm.'
|
|
||||||
.$Fields['XMLNODE_NAME'].'.'.$lang.' (XMLNODE_NAME,XMLNODE_VALUE,XMLNODE_TYPE) '
|
|
||||||
.'VALUES ("","'."\n ".'","cdata")');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$res = $this->_dbses->Execute('INSERT INTO dynaForm.'
|
|
||||||
.$Fields['XMLNODE_NAME'].' (XMLNODE_NAME,XMLNODE_VALUE,XMLNODE_TYPE) '
|
|
||||||
.'VALUES ("","'."\n".'","cdata")');
|
|
||||||
}
|
|
||||||
$res = $this->_dbses->Execute('INSERT INTO dynaForm'.
|
|
||||||
' (XMLNODE_TYPE,XMLNODE_VALUE)'.
|
|
||||||
' VALUES ("cdata", "'."\n".'")');
|
|
||||||
} else {
|
|
||||||
/*
|
|
||||||
* Update an existing field.
|
* Update an existing field.
|
||||||
*/
|
*/
|
||||||
$this->_dbses->Execute('UPDATE dynaForm SET XMLNODE_NAME = "' . $Fields['XMLNODE_NAME'] . '" WHERE XMLNODE_NAME = "' . $Fields['XMLNODE_NAME_OLD'] . '"');
|
$this->_dbses->Execute( 'UPDATE dynaForm SET XMLNODE_NAME = "' . $Fields['XMLNODE_NAME'] . '" WHERE XMLNODE_NAME = "' . $Fields['XMLNODE_NAME_OLD'] . '"' );
|
||||||
foreach( $labels as $lang => $value ) {
|
foreach ($labels as $lang => $value) {
|
||||||
$res = $this->_dbses->Execute('SELECT * FROM dynaForm.'
|
$res = $this->_dbses->Execute( 'SELECT * FROM dynaForm.' . $Fields['XMLNODE_NAME'] . ' WHERE XMLNODE_NAME ="' . $lang . '"' );
|
||||||
.$Fields['XMLNODE_NAME'].' WHERE XMLNODE_NAME ="'.$lang.'"');
|
if ($res->count() > 0) {
|
||||||
if ($res->count()>0) {
|
$res = $this->_dbses->Execute( 'UPDATE dynaForm.' . $Fields['XMLNODE_NAME'] . ' SET XMLNODE_VALUE = ' . '"' . str_replace( '"', '""', $value ) . '" WHERE XMLNODE_NAME ="' . $lang . '"' );
|
||||||
$res = $this->_dbses->Execute('UPDATE dynaForm.'
|
} else {
|
||||||
.$Fields['XMLNODE_NAME'].' SET XMLNODE_VALUE = '
|
$res = $this->_dbses->Execute( 'INSERT INTO dynaForm.' . $Fields['XMLNODE_NAME'] . ' (XMLNODE_NAME,XMLNODE_VALUE) ' . 'VALUES ("' . $lang . '","' . str_replace( '"', '""', $value ) . '")' );
|
||||||
.'"'.str_replace('"','""',$value).'" WHERE XMLNODE_NAME ="'.$lang.'"');
|
}
|
||||||
} else {
|
if (isset( $options[$lang] )) {
|
||||||
$res = $this->_dbses->Execute('INSERT INTO dynaForm.'
|
$res = $this->_dbses->Execute( 'DELETE FROM dynaForm.' . $Fields['XMLNODE_NAME'] . '.' . $lang . ' WHERE 1' );
|
||||||
.$Fields['XMLNODE_NAME'].' (XMLNODE_NAME,XMLNODE_VALUE) '
|
foreach ($options[$lang] as $option => $text) {
|
||||||
.'VALUES ("'.$lang.'","'.str_replace('"','""',$value).'")');
|
$res = $this->_dbses->Execute( 'INSERT INTO dynaForm.' . $Fields['XMLNODE_NAME'] . '.' . $lang . ' (XMLNODE_NAME,XMLNODE_VALUE,name) ' . 'VALUES ("option","' . str_replace( '"', '""', $text ) . '","' . str_replace( '"', '""', $option ) . '")' );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (isset($options[$lang])) {
|
|
||||||
$res = $this->_dbses->Execute('DELETE FROM dynaForm.'
|
|
||||||
.$Fields['XMLNODE_NAME'].'.'.$lang.' WHERE 1');
|
|
||||||
foreach($options[$lang] as $option => $text ) {
|
|
||||||
$res = $this->_dbses->Execute('INSERT INTO dynaForm.'
|
|
||||||
.$Fields['XMLNODE_NAME'].'.'.$lang.' (XMLNODE_NAME,XMLNODE_VALUE,name) '
|
|
||||||
.'VALUES ("option","'.str_replace('"','""',$text).'","'.str_replace('"','""',$option).'")');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
/**
|
||||||
/**
|
* Verify if is New the Field
|
||||||
* Verify if is New the Field
|
*
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
function isNew()
|
function isNew ()
|
||||||
{
|
{
|
||||||
$res = $this->_dbses->Execute('SELECT * FROM dynaForm WHERE XMLNODE_NAME="'.$this->Fields['XMLNODE_NAME'].'"');
|
$res = $this->_dbses->Execute( 'SELECT * FROM dynaForm WHERE XMLNODE_NAME="' . $this->Fields['XMLNODE_NAME'] . '"' );
|
||||||
return ($res->count()==0);
|
return ($res->count() == 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
Reference in New Issue
Block a user