diff --git a/gulliver/system/class.filterForm.php b/gulliver/system/class.filterForm.php index ba1dee001..ef8dda3dd 100755 --- a/gulliver/system/class.filterForm.php +++ b/gulliver/system/class.filterForm.php @@ -1,11 +1,13 @@ . - * - * For more information, contact Colosa Inc, 2566 Le Jeune Rd., + * 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. - * + * */ - /** +/** + * * @package gulliver.system - **/ + * + */ class filterForm extends form { - var $cols = 3; - var $type = 'filterform'; - var $ajaxServer = '../gulliver/pagedTableAjax'; - - /** - * this function is putting the filters - * @author - * - * @access public - * @param string $template - * @param string $scriptContent - * @return string - */ - function render( $template, &$scriptContent ) - { - $this->cols=intVal($this->cols); - return parent::render( $template, $scriptContent ); - } -} \ No newline at end of file + public $cols = 3; + public $type = 'filterform'; + public $ajaxServer = '../gulliver/pagedTableAjax'; + + /** + * this function is putting the filters + * + * @author + * + * + * @access public + * @param string $template + * @param string $scriptContent + * @return string + */ + public function render ($template, &$scriptContent) + { + $this->cols = intVal( $this->cols ); + return parent::render( $template, $scriptContent ); + } +} + diff --git a/gulliver/system/class.publisher.php b/gulliver/system/class.publisher.php index d6aafd3a6..dce470ea7 100755 --- a/gulliver/system/class.publisher.php +++ b/gulliver/system/class.publisher.php @@ -1,7 +1,9 @@ . + * 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. * */ - /** +/** * Publisher class definition * It is to publish all content in a page + * * @package gulliver.system * @author Fernando Ontiveros Lira * @copyright (C) 2002 by Colosa Development Team. @@ -34,654 +37,602 @@ */ class Publisher { - var $Parts = NULL; - var $dbc = NULL; - var $scriptFile = ''; - var $publisherId = 'publisherContent'; - var $localMode = ''; + public $Parts = null; + public $dbc = null; + public $scriptFile = ''; + public $publisherId = 'publisherContent'; + public $localMode = ''; - var $publishType; - var $ROWS_PER_PAGE = null; + public $publishType; + public $ROWS_PER_PAGE = null; - /* PHP 4 doesn't provide destructor where to free $scriptFileHandler resource */ - //var $scriptFileHandler = FALSE; + /* PHP 4 doesn't provide destructor where to free $scriptFileHandler resource */ + //var $scriptFileHandler = false; - /** - * Add content in $Parts array - * @author Fernando Ontiveros Lira - * - * @param $strType - * @param $strLayout - * @param $strName - * @param $strContent - * @param $arrData - * @param $strTarget - * @return void - * - */ - function AddContent( $strType = "form", $strLayout = "form", $strName = "", $strContent = "", $arrData = NULL, $strTarget = "", $ajaxServer='', $mode='', $bAbsolutePath = false) - { - if($mode != '') { - $this->localMode = $mode; - } - $pos = 0; - if( is_array($this->Parts )) { - $pos = count($this->Parts); - } - $this->Parts[$pos] = array( - 'Type' => $strType, - 'Template' => $strLayout, - 'File' => $strName, - 'Content' => $strContent, - 'Data' => $arrData, - 'Target' => $strTarget, - 'ajaxServer' => $ajaxServer, - 'AbsolutePath' => $bAbsolutePath - ); - - //This is needed to prepare the "header content" - //before to send the body content. ($oHeadPublisher) - ob_start(); - - $this->RenderContent0($pos); - if ( (ob_get_contents()!=='') && ($this->publisherId!=='') && ($strType != 'template') ) { - $this->Parts[$pos]['RenderedContent'] = '
'; - $this->Parts[$pos]['RenderedContent'].= ob_get_contents(); - $this->Parts[$pos]['RenderedContent'].= '
'; - } - else { - $this->Parts[$pos]['RenderedContent']= ob_get_contents(); - } - ob_end_clean(); - } - - - - /** - * Function RenderContent - * @author David S. Callizaya S. - * @access public - * @parameter string intPos - * @parameter string showXMLFormName - * @return string - */ - function RenderContent( $intPos = 0) - { - print $this->Parts[$intPos]['RenderedContent']; - } - /** - * It Renders content according to Part['Type'] - * @author Fernando Ontiveros Lira - * - * @param intPos = 0 - * @return void - * - */ - function RenderContent0( $intPos = 0, $showXMLFormName = false) - { - global $G_FORM; - global $G_TABLE; - global $G_TMP_TARGET; - global $G_OP_MENU; - global $G_IMAGE_FILENAME; - global $G_IMAGE_PARTS; - global $_SESSION;//Changed from $HTTP_SESSION_VARS - global $G_OBJGRAPH;//For graphLayout component - $this->intPos = $intPos; - $Part = $this->Parts[ $intPos ]; - $this->publishType = $Part['Type']; - - switch( $this->publishType ) + * Add content in $Parts array + * + * @author Fernando Ontiveros Lira + * + * @param $strType + * @param $strLayout + * @param $strName + * @param $strContent + * @param $arrData + * @param $strTarget + * @return void + * + */ + public function AddContent ($strType = "form", $strLayout = "form", $strName = "", $strContent = "", $arrData = null, $strTarget = "", $ajaxServer = '', $mode = '', $bAbsolutePath = false) { - case 'externalContent': - $G_CONTENT = new Content; - if( $Part['Content'] != "" ) $G_CONTENT = G::LoadContent( $Part['Content'] ); - G::LoadTemplateExternal( $Part['Template'] ); - break; - - case 'image': - $G_IMAGE_FILENAME = $Part['File']; - $G_IMAGE_PARTS = $Part['Data']; - break; - - case 'appform': - global $APP_FORM; - $G_FORM = $APP_FORM; - break; - - case 'xmlform': - case 'dynaform': - - global $G_FORM; - - if ($Part['AbsolutePath']) { - $sPath = $Part['AbsolutePath']; - } - else { - if ($this->publishType == 'xmlform') - $sPath = PATH_XMLFORM; - else - $sPath = PATH_DYNAFORM; - } - - //if the xmlform file doesn't exists, then try with the plugins folders - if ( !is_file ( $sPath . $Part['File'].'.xml' ) ) { - $aux = explode ( PATH_SEP, $Part['File'] ); - //check if G_PLUGIN_CLASS is defined, because publisher can be called without an environment - if(count($aux) > 2){//Subfolders - $filename=array_pop($aux); - $aux0=implode(PATH_SEP,$aux); - $aux=array(); - $aux[0]=$aux0; - $aux[1]=$filename; + if ($mode != '') { + $this->localMode = $mode; } - if ( count($aux) == 2 && defined ( 'G_PLUGIN_CLASS' ) ) { - $oPluginRegistry =& PMPluginRegistry::getSingleton(); - if ( $response=$oPluginRegistry->isRegisteredFolder($aux[0]) ) { - if($response!==true){ - $sPath = PATH_PLUGINS.$response.PATH_SEP; - }else{ - $sPath = PATH_PLUGINS; - } + $pos = 0; + if (is_array( $this->Parts )) { + $pos = count( $this->Parts ); } - } - } - if (!class_exists($Part['Template']) || $Part['Template']==='xmlform') - $G_FORM = new Form ( $Part['File'] , $sPath , SYS_LANG, false ); - else - eval( '$G_FORM = new ' . $Part['Template'] . ' ( $Part[\'File\'] , "' . $sPath . '");'); + $this->Parts[$pos] = array ('Type' => $strType,'Template' => $strLayout,'File' => $strName,'Content' => $strContent,'Data' => $arrData,'Target' => $strTarget,'ajaxServer' => $ajaxServer,'AbsolutePath' => $bAbsolutePath + ); - if (($this->publishType == 'dynaform') && (($Part['Template'] == 'xmlform') || ($Part['Template'] == 'xmlform_preview')) ) - { - $dynaformShow=(isset($G_FORM->printdynaform) && ($G_FORM->printdynaform))?'gulliver/dynaforms_OptionsPrint':'gulliver/dynaforms_Options'; - $G_FORM->fields=G::array_merges( - array('__DYNAFORM_OPTIONS' => new XmlForm_Field_XmlMenu( - new Xml_Node( - '__DYNAFORM_OPTIONS', - 'complete', - '', - array('type'=>'xmlmenu','xmlfile'=>$dynaformShow) - ),SYS_LANG,PATH_XMLFORM,$G_FORM) ), - $G_FORM->fields); - } + //This is needed to prepare the "header content" + //before to send the body content. ($oHeadPublisher) + ob_start(); - //Needed to make ajax calls - - //The action in the form tag. - if ( defined ( 'ENABLE_ENCRYPT' ) && ENABLE_ENCRYPT == 'yes' ) - $G_FORM->action = urlencode( G::encrypt( $Part['Target'] ,URL_KEY ) ); - else - $G_FORM->action = $Part['Target']; - - if (!(isset($Part['ajaxServer']) && ($Part['ajaxServer']!==''))) - if ($this->publishType == 'dynaform') - $Part['ajaxServer']='../gulliver/defaultAjaxDynaform'; - else - $Part['ajaxServer']='../gulliver/defaultAjax'; - - if ( defined ( 'ENABLE_ENCRYPT' ) && ENABLE_ENCRYPT == 'yes' ) - $G_FORM->ajaxServer = urlencode( G::encrypt( $Part['ajaxServer'] ,URL_KEY ) ); - else - $G_FORM->ajaxServer = $Part['ajaxServer']; - - $G_FORM->setValues ($Part['Data']); - - $G_FORM->setValues ( array( 'G_FORM_ID' => $G_FORM->id ) ); - - //Asegurese de que no entre cuando $Part['Template']=="grid" - //de hecho soo deberia usarse cuando $Part['Template']=="xmlform" - if ((($this->publishType == 'dynaform') && $Part['Template']=="xmlform") || ($Part['Template']=="xmlform")) - { - $G_FORM->values=G::array_merges( - array('__DYNAFORM_OPTIONS' => isset($Part['Data']['__DYNAFORM_OPTIONS'])? $Part['Data']['__DYNAFORM_OPTIONS']:''), - $G_FORM->values); - if (isset($G_FORM->nextstepsave)) { - switch ($G_FORM->nextstepsave) { - // this condition validates if the next step link is configured to Save and Go the next step or show a prompt - case 'save': - // Save and Next only if there are no required fields can submit the form. - $G_FORM->values['__DYNAFORM_OPTIONS']['NEXT_ACTION'] = 'if (document.getElementById("' . $G_FORM->id . '")&&validateForm(document.getElementById(\'DynaformRequiredFields\').value)) {document.getElementById("' . $G_FORM->id . '").submit();}return false;'; - break; - case 'prompt': - // Show Prompt only if there are no required fields can submit the form. - $G_FORM->values['__DYNAFORM_OPTIONS']['NEXT_ACTION'] = 'if (document.getElementById("' . $G_FORM->id . '")&&validateForm(document.getElementById(\'DynaformRequiredFields\').value)) {new leimnud.module.app.confirm().make({label:"@G::LoadTranslation(ID_DYNAFORM_SAVE_CHANGES)",action:function(){document.getElementById("' . $G_FORM->id . '").submit();}.extend(this),cancel:function(){window.location = getField("DYN_FORWARD").href;}.extend(this)});return false;} return false;'; - break; - } + $this->RenderContent0( $pos ); + if ((ob_get_contents() !== '') && ($this->publisherId !== '') && ($strType != 'template')) { + $this->Parts[$pos]['RenderedContent'] = '
'; + $this->Parts[$pos]['RenderedContent'] .= ob_get_contents(); + $this->Parts[$pos]['RenderedContent'] .= '
'; + } else { + $this->Parts[$pos]['RenderedContent'] = ob_get_contents(); } - } - if (isset($_SESSION)) $_SESSION[$G_FORM->id]=$G_FORM->values; - // by default load the core template - if ($Part['Template'] == 'xmlform_preview') - $Part['Template'] = 'xmlform'; - - - $template = PATH_CORE . 'templates/' . $Part['Template'] . '.html'; - - //erik: new feature, now templates such as xmlform.html can be personalized via skins - if (defined('SYS_SKIN') && strtolower(SYS_SKIN) != 'classic') { - // first, verify if the template exists on base skins path - if (is_file(G::ExpandPath("skinEngine") . SYS_SKIN . PATH_SEP . $Part['Template'] . '.html')) { - $template = G::ExpandPath("skinEngine") . SYS_SKIN . PATH_SEP . $Part['Template'] . '.html'; - } - // second, verify if the template exists on user skins path - else if (is_file(PATH_CUSTOM_SKINS . SYS_SKIN . PATH_SEP . $Part['Template'] . '.html')) { - $template = PATH_CUSTOM_SKINS . SYS_SKIN . PATH_SEP . $Part['Template'] . '.html'; - } - } - //end new feature - - if ($Part['Template'] == 'grid') print ('
'); - $scriptCode=''; - - if($this->localMode != '') { // @# las modification by erik in 09/06/2008 - $G_FORM->mode = $this->localMode; - } - print $G_FORM->render( $template , $scriptCode ); - if ($Part['Template'] == 'grid') print ('
'); - $oHeadPublisher =& headPublisher::getSingleton(); - $oHeadPublisher->addScriptFile( $G_FORM->scriptURL ); - $oHeadPublisher->addScriptCode( $scriptCode ); - - /** - * We've implemented the conditional show hide fields.. - * @author Erik A. Ortiz - * @date Fri Feb 19, 2009 - */ - if($this->publishType == 'dynaform'){ - if( isset($_SESSION['CURRENT_DYN_UID']) ){ - require_once "classes/model/FieldCondition.php"; - $oFieldCondition = new FieldCondition(); - - #This dynaform has show/hide field conditions - $ConditionalShowHideRoutines = $oFieldCondition->getConditionScript($_SESSION['CURRENT_DYN_UID']); - - } - } - - if(isset($ConditionalShowHideRoutines) && $ConditionalShowHideRoutines){ - G::evalJScript($ConditionalShowHideRoutines); - } - break; - - case 'pagedtable': - global $G_FORM; - - //if the xmlform file doesn't exists, then try with the plugins folders - $sPath = PATH_XMLFORM; - if ( !is_file ( $sPath . $Part['File'] ) ) { - $aux = explode ( PATH_SEP, $Part['File'] ); - if ( count($aux) == 2 ) { - $oPluginRegistry =& PMPluginRegistry::getSingleton(); - if ( $oPluginRegistry->isRegisteredFolder($aux[0]) ) { - $sPath = PATH_PLUGINS; // . $aux[0] . PATH_SEP ; - } - } - } - $G_FORM = new Form ( $Part['File'] , $sPath, SYS_LANG, true ); - - if ( defined ( 'ENABLE_ENCRYPT' ) && ENABLE_ENCRYPT == 'yes' ) - $G_FORM->ajaxServer = urlencode( G::encrypt( $Part['ajaxServer'] ,URL_KEY ) ); - else - $G_FORM->ajaxServer = $Part['ajaxServer']; - - $G_FORM->setValues ($Part['Data']); - if (isset($_SESSION)) $_SESSION[$G_FORM->id]=$G_FORM->values; - - G::LoadSystem('pagedTable'); - $oTable = new pagedTable(); - $oTable->template = 'templates/'.$Part['Template'] . '.html'; - $G_FORM->xmlform = ''; - $G_FORM->xmlform->fileXml = $G_FORM->fileName; - $G_FORM->xmlform->home = $G_FORM->home; - $G_FORM->xmlform->tree->attribute = $G_FORM->tree->attributes; - $G_FORM->values = array_merge($G_FORM->values,$Part['Data']); - - $oTable->setupFromXmlform($G_FORM); - - if (isset($Part['ajaxServer']) && ($Part['ajaxServer']!=='')) - $oTable->ajaxServer = $Part['ajaxServer']; - /* Start Block: Load user configuration for the pagedTable */ - G::LoadClass('configuration'); - $objUID = $Part['File']; - $conf = new Configurations( ); - $conf->loadConfig($oTable,'pagedTable',$objUID,'',(isset($_SESSION['USER_LOGGED']) ? $_SESSION['USER_LOGGED'] : ''),''); - $oTable->__OBJ_UID=$objUID; - /* End Block */ - - /* Start Block: PagedTable Right Click */ - G::LoadClass('popupMenu'); - $pm=new popupMenu('gulliver/pagedTable_PopupMenu'); - $pm->name=$oTable->id; - $fields=array_keys($oTable->fields); - foreach($fields as $f) { - switch (strtolower($oTable->fields[$f]['Type'])) { - case 'javascript': - case 'button': - case 'private': - case 'hidden': - case 'cellmark': - break; - default: - $label = ($oTable->fields[$f]['Label']!='')?$oTable->fields[$f]['Label']:$f; - $label = str_replace("\n",' ',$label); - $pm->fields[$f] = new XmlForm_Field_popupOption(new Xml_Node($f, 'complete', '', array('label'=>$label,'type'=>'popupOption', - 'launch'=>$oTable->id.'.showHideField("'.$f.'")') ) ); - $pm->values[$f] = ''; - } - } - $sc = ''; - $pm->values['PAGED_TABLE_ID'] = $oTable->id; - print($pm->render(PATH_CORE . 'templates/popupMenu.html',$sc)); - /* End Block */ - - $oTable->renderTable(); - - /* Start Block: Load PagedTable Right Click */ - print(''); - /* End Block */ - break; - - case 'propeltable': - global $G_FORM; - - //if the xmlform file doesn't exists, then try with the plugins folders - if ($Part['AbsolutePath']) { - $sPath = ''; - } - else { - $sPath = PATH_XMLFORM; - } - if ( !is_file ( $sPath . $Part['File'] ) ) { - $aux = explode ( PATH_SEP, $Part['File'] ); - - //search in PLUGINS folder, probably the file is in plugin - if ( count($aux) == 2 ) { - $oPluginRegistry =& PMPluginRegistry::getSingleton(); - if ( $oPluginRegistry->isRegisteredFolder($aux[0]) ) { - $sPath = PATH_PLUGINS; // . $aux[0] . PATH_SEP ; - } - } - - //search in PATH_DYNAFORM folder - if ( !is_file ( $sPath . PATH_SEP. $Part['File'] . '.xml') ) { - $sPath = PATH_DYNAFORM; - } - - } - - //PATH_DATA_PUBLIC ??? - if ( !file_exists ($sPath .PATH_SEP. $Part['File'] . '.xml') && defined ( 'PATH_DATA_PUBLIC') ) { - $sPath = PATH_DATA_PUBLIC ; - } - - $G_FORM = new Form ( $Part['File'] , $sPath, SYS_LANG, true ); - - if ( defined ( 'ENABLE_ENCRYPT' ) && ENABLE_ENCRYPT == 'yes' ) - $G_FORM->ajaxServer = urlencode( G::encrypt( $Part['ajaxServer'] ,URL_KEY ) ); - else - $G_FORM->ajaxServer = $Part['ajaxServer']; - - if (isset($_SESSION)) $_SESSION[$G_FORM->id] = $G_FORM->values; - - G::LoadClass('propelTable'); - - $oTable = new propelTable(); - $oTable->template = $Part['Template'] ; - $oTable->criteria = $Part['Content']; - if ( isset($Part['ajaxServer'] ) && ( $Part['ajaxServer']!=='' )) - $oTable->ajaxServer = $Part['ajaxServer']; - $G_FORM->xmlform->fileXml = $G_FORM->fileName; - $G_FORM->xmlform->home = $G_FORM->home; - $G_FORM->xmlform->tree->attribute = $G_FORM->tree->attributes; - if ( is_array($Part['Data'] )) - $G_FORM->values = array_merge($G_FORM->values, $Part['Data'] ); - - $oTable->setupFromXmlform($G_FORM); - /* Start Block: Load user configuration for the pagedTable */ - G::LoadClass('configuration'); - $objUID = $Part['File']; - $conf = new Configurations( $oTable ); - $conf->loadConfig($oTable,'pagedTable',$objUID,'',(isset($_SESSION['USER_LOGGED']) ? $_SESSION['USER_LOGGED'] : ''),''); - $oTable->__OBJ_UID = $objUID; - - //$oTable->__OBJ_UID = ''; - /* End Block */ - - /* Start Block: PagedTable Right Click */ - G::LoadClass('popupMenu'); - $pm = new popupMenu( 'gulliver/pagedTable_PopupMenu' ); - $sc = $pm->renderPopup ( $oTable->id, $oTable->fields ); - /* End Block */ - //krumo ( $Part ); - - if( $this->ROWS_PER_PAGE ){ - $oTable->rowsPerPage = $this->ROWS_PER_PAGE; - } - try { - if ( is_array ( $Part['Data'] )) - $oTable->renderTable('', $Part['Data']); - else - $oTable->renderTable(); - print($sc); - } - catch ( Exception $e ) { - $aMessage['MESSAGE'] = $e->getMessage(); - $this->AddContent('xmlform', 'xmlform', 'login/showMessage', '', $aMessage ); - } - break; - - case 'panel-init': - global $mainPanelScript; - global $panelName; - global $tabCount; - G::LoadThirdParty('pear/json','class.json'); - $json=new Services_JSON(); - $tabCount = 0; - $panelName = $Part['Template']; - $data = $Part['File']; - if (!is_array($data)) $data=array(); - $data = G::array_merges( array( - 'title'=>'', - 'style'=>array(), - 'left'=>'getAbsoluteLeft(mycontent)', - 'top'=>'getAbsoluteTop(mycontent)', - 'width'=>700, - 'height'=>600, - 'drag'=>true, - 'close'=>true, - 'modal'=>true, - 'roll'=>false, - 'resize'=>false, - 'tabWidth'=>120, - 'tabStep'=>3, - 'blinkToFront'=>true, - 'tabSpace'=>10), $data ); - $mainPanelScript = 'var '.$panelName.'={},'.$panelName.'Tabs=[];'. - 'leimnud.event.add(window,"load",function(){'.$panelName.' = new leimnud.module.panel();'. - 'var mycontent=document.getElementById("'.$this->publisherId.'['.$intPos.']");'. - $panelName.'.options={'. - 'size:{w:'.$data['width'].',h:'.$data['height'].'},'. - 'position:{x:'.$data['left'].',y:'.$data['top'].'},'. - 'title:"'.addcslashes($data['title'],'\\"').'",'. - 'theme:"processmaker",'. - 'statusBar:true,'. - 'headerBar:true,'. - 'control:{'. - ' close:'.($data['close']?'true':'false').','. - ' roll:'.($data['roll']?'true':'false').','. - ' drag:'.($data['drag']?'true':'false').','. - ' resize:'.($data['resize']?'true':'false'). - '},'. - 'fx:{'. - ' drag:'.($data['drag']?'true':'false').','. - ' modal:'.($data['modal']?'true':'false').','. - ' blinkToFront:'.($data['blinkToFront']?'true':'false'). - '}'. - '};'. - $panelName.'.setStyle='.$json->encode($data['style']).';'. - $panelName.'.tab={'. - 'width:'.($data['tabWidth']+$data['tabSpace']).','. - 'optWidth:'.$data['tabWidth'].','. - 'step :'.$data['tabStep'].','. - 'options:[]'. - '};'; - print(' '); - break; - case 'panel-tab': - global $tabCount; - global $mainPanelScript; - global $panelName; - $onChange = $Part['Content']; - $beforeChange = $Part['Data']; - if(SYS_LANG=='es') - $mainPanelScript = str_replace("120","150",$mainPanelScript); - else - $mainPanelScript = str_replace("150","120",$mainPanelScript); - $mainPanelScript .= - $panelName.'Tabs['.$tabCount.']='. - 'document.getElementById("'.$Part['File'].'");'. - $panelName.'.tab.options['.$panelName.'.tab.options.length]='. - '{'. - 'title :"'.addcslashes($Part['Template'],'\\"').'",'. - 'noClear :true,'. - 'content :function(){'. - ($beforeChange!='' ? ('if (typeof('.$beforeChange.')!=="undefined") {'.$beforeChange.'();}'): ''). - $panelName.'Clear();'. - $panelName.'Tabs['.$tabCount.'].style.display="";'. -// 'this.addContent('.$panelName.'Tabs['.$tabCount.']);'. -// 'this.addContent(document.getElementById("'.$Part['File'].'"));'. -// $panelName.'Tabs['.$tabCount.']='.$panelName.'Tabs['.$tabCount.'].cloneNode( true );'. - ($onChange!='' ? ('if (typeof('.$onChange.')!=="undefined") {'.$onChange.'();}'): ''). - '}.extend('.$panelName.'),'. - 'selected:'.($tabCount==0 ? 'true' : 'false'). - '};'; - $tabCount++; - - break; - case 'panel-close': - global $mainPanelScript; - global $panelName; - global $tabCount; - $mainPanelScript .= $panelName.'.make();'; - $mainPanelScript .= 'for(var r=0;r<'.$tabCount.';r++)'. - 'if ('.$panelName.'Tabs[r])'.$panelName. - '.addContent('.$panelName.'Tabs[r]);'; - $mainPanelScript .= '});'; - $mainPanelScript .= 'function '.$panelName.'Clear(){'; - $mainPanelScript .= 'for(var r=0;r<'.$tabCount.';r++)'. - 'if ('.$panelName.'Tabs[r])'.$panelName.'Tabs[r].style.display="none";}'; - $oHeadPublisher =& headPublisher::getSingleton(); - $oHeadPublisher->addScriptCode( $mainPanelScript ); - - break; - case 'blank'; - print(' '); - break; - case 'varform': - global $G_FORM; - $G_FORM = new Form; - G::LoadSystem("varform"); - $xml = new varForm; - //$xml->parseFile ( ); - $xml->renderForm ($G_FORM, $Part['File']); - $G_FORM->Values = $Part['Data']; - $G_FORM->SetUp( $Part['Target'] ); - $G_FORM->width = 500; - break; - case 'table': - $G_TMP_TARGET = $Part['Target']; - $G_TABLE = G::LoadRawTable( $Part['File'], $this->dbc, $Part['Data'] ); - break; - case 'menu': - $G_TMP_TARGET = $Part['Target']; - $G_OP_MENU = new Menu; - $G_OP_MENU->Load( $Part['File'] ); - break; - - case 'smarty': //To do: Please check it 26/06/07 - $template = new Smarty(); - $template->compile_dir = PATH_SMARTY_C; - $template->cache_dir = PATH_SMARTY_CACHE; - $template->config_dir = PATH_THIRDPARTY . 'smarty/configs'; - $template->caching = false; - $dataArray = $Part['Data'] ; - - // verify if there are templates folders registered, template and method folders are the same - $folderTemplate = explode ( '/',$Part['Template'] ); - $oPluginRegistry =& PMPluginRegistry::getSingleton(); - if ( $oPluginRegistry->isRegisteredFolder( $folderTemplate[0] ) ) - $template->templateFile = PATH_PLUGINS . $Part['Template'] . '.html'; - else - $template->templateFile = PATH_TPL . $Part['Template'] . '.html'; - - // last change to load the template, maybe absolute path was given - if (!is_file($template->templateFile)) { - $template->templateFile = strpos($Part['Template'], '.html') !== false? $Part['Template']: $Part['Template'].'.html'; - } - - //assign the variables and use the template $template - $template->assign( $dataArray); - print $template->fetch($template->templateFile); - break; - - case 'template': //To do: Please check it 26/06/07 - if ( gettype( $Part['Data'] ) == 'array' ) { - G::LoadSystem ( 'template' ); //template phpBB - $template = new Template(); - $template->set_filenames(array('body' => $Part['Template'] . '.html') ); - $dataArray = $Part['Data'] ; - if ( is_array ( $dataArray ) ) { - foreach ( $dataArray as $key => $val ) - if ( is_array ( $val ) ) { - foreach ( $val as $key_val => $val_array ) - $template->assign_block_vars( $key, $val_array ); - } - else - $template->assign_vars( array ( $key => $val ) ); - } - $template->pparse('body' ); - } - if ( gettype( $Part['Data'] ) == 'object' && strtolower(get_class ( $Part['Data'] )) == 'templatepower' ) { - $Part['Data']->printToScreen(); - - } - return; - break; - case 'view': - case 'content' : - //check if G_PLUGIN_CLASS is defined, because publisher can be called without an environment - $aux = explode ( PATH_SEP, $Part['Template'] ); - if ( count($aux) == 2 && defined ( 'G_PLUGIN_CLASS' ) ) { - //if the template doesn't exists, then try it with the plugins folders, after the normal Template - $userTemplate = G::ExpandPath( 'templates' ) . $Part['Template']; - $globalTemplate = PATH_TEMPLATE . $Part['Template']; - if ( !is_file ($userTemplate) && !is_file ($globalTemplate) ) { - $oPluginRegistry =& PMPluginRegistry::getSingleton(); - if ( $oPluginRegistry->isRegisteredFolder($aux[0]) ) { - $pluginTemplate = PATH_PLUGINS. $Part['Template'] . '.php'; - include ($pluginTemplate); - - } - } - } - - break; - case 'graphLayout': //Added by JHL to render GraphLayout component - $G_OBJGRAPH = $Part['Data']; - $G_TMP_TARGET = $Part['Target']; - $G_TMP_FILE = $Part['File']; - break; + ob_end_clean(); } + /** + * Function RenderContent + * + * @author David S. Callizaya S. + * @access public + * @param eter string intPos + * @param eter string showXMLFormName + * @return string + */ + public function RenderContent ($intPos = 0) + { + print $this->Parts[$intPos]['RenderedContent']; + } - //krumo( $Part['Template'] ); - //check if this LoadTemplate is used, byOnti 12th Aug 2008 - G::LoadTemplate( $Part['Template'] ); - $G_TABLE = NULL; - } + /** + * It Renders content according to Part['Type'] + * + * @author Fernando Ontiveros Lira + * + * @param intPos = 0 + * @return void + * + */ + public function RenderContent0 ($intPos = 0, $showXMLFormName = false) + { + global $G_FORM; + global $G_TABLE; + global $G_TMP_TARGET; + global $G_OP_MENU; + global $G_IMAGE_FILENAME; + global $G_IMAGE_PARTS; + global $_SESSION; //Changed from $HTTP_SESSION_VARS + global $G_OBJGRAPH; //For graphLayout component + $this->intPos = $intPos; + $Part = $this->Parts[$intPos]; + $this->publishType = $Part['Type']; + + switch ($this->publishType) { + case 'externalContent': + $G_CONTENT = new Content(); + if ($Part['Content'] != "") { + $G_CONTENT = G::LoadContent( $Part['Content'] ); + } + G::LoadTemplateExternal( $Part['Template'] ); + break; + case 'image': + $G_IMAGE_FILENAME = $Part['File']; + $G_IMAGE_PARTS = $Part['Data']; + break; + case 'appform': + global $APP_FORM; + $G_FORM = $APP_FORM; + break; + case 'xmlform': + case 'dynaform': + global $G_FORM; + + if ($Part['AbsolutePath']) { + $sPath = $Part['AbsolutePath']; + } else { + if ($this->publishType == 'xmlform') { + $sPath = PATH_XMLFORM; + } else { + $sPath = PATH_DYNAFORM; + } + } + + //if the xmlform file doesn't exists, then try with the plugins folders + if (! is_file( $sPath . $Part['File'] . '.xml' )) { + $aux = explode( PATH_SEP, $Part['File'] ); + //check if G_PLUGIN_CLASS is defined, because publisher can be called without an environment + if (count( $aux ) > 2) { + //Subfolders + $filename = array_pop( $aux ); + $aux0 = implode( PATH_SEP, $aux ); + $aux = array (); + $aux[0] = $aux0; + $aux[1] = $filename; + } + if (count( $aux ) == 2 && defined( 'G_PLUGIN_CLASS' )) { + $oPluginRegistry = & PMPluginRegistry::getSingleton(); + if ($response = $oPluginRegistry->isRegisteredFolder( $aux[0] )) { + if ($response !== true) { + $sPath = PATH_PLUGINS . $response . PATH_SEP; + } else { + $sPath = PATH_PLUGINS; + } + } + } + } + if (! class_exists( $Part['Template'] ) || $Part['Template'] === 'xmlform') { + $G_FORM = new Form( $Part['File'], $sPath, SYS_LANG, false ); + } else { + eval( '$G_FORM = new ' . $Part['Template'] . ' ( $Part[\'File\'] , "' . $sPath . '");' ); + } + + if (($this->publishType == 'dynaform') && (($Part['Template'] == 'xmlform') || ($Part['Template'] == 'xmlform_preview'))) { + $dynaformShow = (isset( $G_FORM->printdynaform ) && ($G_FORM->printdynaform)) ? 'gulliver/dynaforms_OptionsPrint' : 'gulliver/dynaforms_Options'; + $G_FORM->fields = G::array_merges( array ('__DYNAFORM_OPTIONS' => new XmlForm_Field_XmlMenu( new Xml_Node( '__DYNAFORM_OPTIONS', 'complete', '', array ('type' => 'xmlmenu','xmlfile' => $dynaformShow + ) ), SYS_LANG, PATH_XMLFORM, $G_FORM ) + ), $G_FORM->fields ); + } + + //Needed to make ajax calls + + //The action in the form tag. + if (defined( 'ENABLE_ENCRYPT' ) && ENABLE_ENCRYPT == 'yes') { + $G_FORM->action = urlencode( G::encrypt( $Part['Target'], URL_KEY ) ); + } else { + $G_FORM->action = $Part['Target']; + } + + if (! (isset( $Part['ajaxServer'] ) && ($Part['ajaxServer'] !== ''))) { + if ($this->publishType == 'dynaform') { + $Part['ajaxServer'] = '../gulliver/defaultAjaxDynaform'; + } else { + $Part['ajaxServer'] = '../gulliver/defaultAjax'; + } + } + if (defined( 'ENABLE_ENCRYPT' ) && ENABLE_ENCRYPT == 'yes') { + $G_FORM->ajaxServer = urlencode( G::encrypt( $Part['ajaxServer'], URL_KEY ) ); + } else { + $G_FORM->ajaxServer = $Part['ajaxServer']; + } + + $G_FORM->setValues( $Part['Data'] ); + + $G_FORM->setValues( array ('G_FORM_ID' => $G_FORM->id ) ); + + //Asegurese de que no entre cuando $Part['Template']=="grid" + //de hecho soo deberia usarse cuando $Part['Template']=="xmlform" + if ((($this->publishType == 'dynaform') && $Part['Template'] == "xmlform") || ($Part['Template'] == "xmlform")) { + $G_FORM->values = G::array_merges( array ('__DYNAFORM_OPTIONS' => isset( $Part['Data']['__DYNAFORM_OPTIONS'] ) ? $Part['Data']['__DYNAFORM_OPTIONS'] : '' + ), $G_FORM->values ); + if (isset( $G_FORM->nextstepsave )) { + switch ($G_FORM->nextstepsave) { + // this condition validates if the next step link is configured to Save and Go the next step or show a prompt + case 'save': + // Save and Next only if there are no required fields can submit the form. + $G_FORM->values['__DYNAFORM_OPTIONS']['NEXT_ACTION'] = 'if (document.getElementById("' . $G_FORM->id . '")&&validateForm(document.getElementById(\'DynaformRequiredFields\').value)) {document.getElementById("' . $G_FORM->id . '").submit();}return false;'; + break; + case 'prompt': + // Show Prompt only if there are no required fields can submit the form. + $G_FORM->values['__DYNAFORM_OPTIONS']['NEXT_ACTION'] = 'if (document.getElementById("' . $G_FORM->id . '")&&validateForm(document.getElementById(\'DynaformRequiredFields\').value)) {new leimnud.module.app.confirm().make({label:"@G::LoadTranslation(ID_DYNAFORM_SAVE_CHANGES)",action:function(){document.getElementById("' . $G_FORM->id . '").submit();}.extend(this),cancel:function(){window.location = getField("DYN_FORWARD").href;}.extend(this)});return false;} return false;'; + break; + } + } + } + if (isset( $_SESSION )) { + $_SESSION[$G_FORM->id] = $G_FORM->values; + } + // by default load the core template + if ($Part['Template'] == 'xmlform_preview') { + $Part['Template'] = 'xmlform'; + } + + $template = PATH_CORE . 'templates/' . $Part['Template'] . '.html'; + + //erik: new feature, now templates such as xmlform.html can be personalized via skins + if (defined( 'SYS_SKIN' ) && strtolower( SYS_SKIN ) != 'classic') { + // first, verify if the template exists on base skins path + if (is_file( G::ExpandPath( "skinEngine" ) . SYS_SKIN . PATH_SEP . $Part['Template'] . '.html' )) { + $template = G::ExpandPath( "skinEngine" ) . SYS_SKIN . PATH_SEP . $Part['Template'] . '.html'; + // second, verify if the template exists on user skins path + } elseif (is_file( PATH_CUSTOM_SKINS . SYS_SKIN . PATH_SEP . $Part['Template'] . '.html' )) { + $template = PATH_CUSTOM_SKINS . SYS_SKIN . PATH_SEP . $Part['Template'] . '.html'; + } + } + //end new feature + + + if ($Part['Template'] == 'grid') { + print ('
') ; + } + $scriptCode = ''; + + if ($this->localMode != '') { + // @# las modification by erik in 09/06/2008 + $G_FORM->mode = $this->localMode; + } + print $G_FORM->render( $template, $scriptCode ); + if ($Part['Template'] == 'grid') { + print ('
') ; + } + $oHeadPublisher = & headPublisher::getSingleton(); + $oHeadPublisher->addScriptFile( $G_FORM->scriptURL ); + $oHeadPublisher->addScriptCode( $scriptCode ); + + /** + * We've implemented the conditional show hide fields.. + * + * @author Erik A. Ortiz + * @date Fri Feb 19, 2009 + */ + if ($this->publishType == 'dynaform') { + if (isset( $_SESSION['CURRENT_DYN_UID'] )) { + require_once "classes/model/FieldCondition.php"; + $oFieldCondition = new FieldCondition(); + + #This dynaform has show/hide field conditions + $ConditionalShowHideRoutines = $oFieldCondition->getConditionScript( $_SESSION['CURRENT_DYN_UID'] ); + } + } + + if (isset( $ConditionalShowHideRoutines ) && $ConditionalShowHideRoutines) { + G::evalJScript( $ConditionalShowHideRoutines ); + } + break; + case 'pagedtable': + global $G_FORM; + //if the xmlform file doesn't exists, then try with the plugins folders + $sPath = PATH_XMLFORM; + if (! is_file( $sPath . $Part['File'] )) { + $aux = explode( PATH_SEP, $Part['File'] ); + if (count( $aux ) == 2) { + $oPluginRegistry = & PMPluginRegistry::getSingleton(); + if ($oPluginRegistry->isRegisteredFolder( $aux[0] )) { + $sPath = PATH_PLUGINS; // . $aux[0] . PATH_SEP ; + } + } + } + $G_FORM = new Form( $Part['File'], $sPath, SYS_LANG, true ); + + if (defined( 'ENABLE_ENCRYPT' ) && ENABLE_ENCRYPT == 'yes') { + $G_FORM->ajaxServer = urlencode( G::encrypt( $Part['ajaxServer'], URL_KEY ) ); + } else { + $G_FORM->ajaxServer = $Part['ajaxServer']; + } + + $G_FORM->setValues( $Part['Data'] ); + if (isset( $_SESSION )) { + $_SESSION[$G_FORM->id] = $G_FORM->values; + } + + G::LoadSystem( 'pagedTable' ); + $oTable = new pagedTable(); + $oTable->template = 'templates/' . $Part['Template'] . '.html'; + $G_FORM->xmlform = ''; + $G_FORM->xmlform->fileXml = $G_FORM->fileName; + $G_FORM->xmlform->home = $G_FORM->home; + $G_FORM->xmlform->tree->attribute = $G_FORM->tree->attributes; + $G_FORM->values = array_merge( $G_FORM->values, $Part['Data'] ); + + $oTable->setupFromXmlform( $G_FORM ); + + if (isset( $Part['ajaxServer'] ) && ($Part['ajaxServer'] !== '')) { + $oTable->ajaxServer = $Part['ajaxServer']; + } + /* Start Block: Load user configuration for the pagedTable */ + G::LoadClass( 'configuration' ); + $objUID = $Part['File']; + $conf = new Configurations(); + $conf->loadConfig( $oTable, 'pagedTable', $objUID, '', (isset( $_SESSION['USER_LOGGED'] ) ? $_SESSION['USER_LOGGED'] : ''), '' ); + $oTable->__OBJ_UID = $objUID; + /* End Block */ + + /* Start Block: PagedTable Right Click */ + G::LoadClass( 'popupMenu' ); + $pm = new popupMenu( 'gulliver/pagedTable_PopupMenu' ); + $pm->name = $oTable->id; + $fields = array_keys( $oTable->fields ); + foreach ($fields as $f) { + switch (strtolower( $oTable->fields[$f]['Type'] )) { + case 'javascript': + case 'button': + case 'private': + case 'hidden': + case 'cellmark': + break; + default: + $label = ($oTable->fields[$f]['Label'] != '') ? $oTable->fields[$f]['Label'] : $f; + $label = str_replace( "\n", ' ', $label ); + $pm->fields[$f] = new XmlForm_Field_popupOption( new Xml_Node( $f, 'complete', '', array ('label' => $label,'type' => 'popupOption','launch' => $oTable->id . '.showHideField("' . $f . '")' ) ) ); + $pm->values[$f] = ''; + } + } + $sc = ''; + $pm->values['PAGED_TABLE_ID'] = $oTable->id; + print ($pm->render( PATH_CORE . 'templates/popupMenu.html', $sc )) ; + /* End Block */ + + $oTable->renderTable(); + + /* Start Block: Load PagedTable Right Click */ + print ('') ; + /* End Block */ + break; + case 'propeltable': + global $G_FORM; + //if the xmlform file doesn't exists, then try with the plugins folders + if ($Part['AbsolutePath']) { + $sPath = ''; + } else { + $sPath = PATH_XMLFORM; + } + if (! is_file( $sPath . $Part['File'] )) { + $aux = explode( PATH_SEP, $Part['File'] ); + + //search in PLUGINS folder, probably the file is in plugin + if (count( $aux ) == 2) { + $oPluginRegistry = & PMPluginRegistry::getSingleton(); + if ($oPluginRegistry->isRegisteredFolder( $aux[0] )) { + $sPath = PATH_PLUGINS; // . $aux[0] . PATH_SEP ; + } + } + + //search in PATH_DYNAFORM folder + if (! is_file( $sPath . PATH_SEP . $Part['File'] . '.xml' )) { + $sPath = PATH_DYNAFORM; + } + + } + + //PATH_DATA_PUBLIC ??? + if (! file_exists( $sPath . PATH_SEP . $Part['File'] . '.xml' ) && defined( 'PATH_DATA_PUBLIC' )) { + $sPath = PATH_DATA_PUBLIC; + } + + $G_FORM = new Form( $Part['File'], $sPath, SYS_LANG, true ); + + if (defined( 'ENABLE_ENCRYPT' ) && ENABLE_ENCRYPT == 'yes') { + $G_FORM->ajaxServer = urlencode( G::encrypt( $Part['ajaxServer'], URL_KEY ) ); + } else { + $G_FORM->ajaxServer = $Part['ajaxServer']; + } + + if (isset( $_SESSION )) { + $_SESSION[$G_FORM->id] = $G_FORM->values; + } + + G::LoadClass( 'propelTable' ); + + $oTable = new propelTable(); + $oTable->template = $Part['Template']; + $oTable->criteria = $Part['Content']; + if (isset( $Part['ajaxServer'] ) && ($Part['ajaxServer'] !== '')) { + $oTable->ajaxServer = $Part['ajaxServer']; + } + $G_FORM->xmlform->fileXml = $G_FORM->fileName; + $G_FORM->xmlform->home = $G_FORM->home; + $G_FORM->xmlform->tree->attribute = $G_FORM->tree->attributes; + if (is_array( $Part['Data'] )) { + $G_FORM->values = array_merge( $G_FORM->values, $Part['Data'] ); + } + + $oTable->setupFromXmlform( $G_FORM ); + /* Start Block: Load user configuration for the pagedTable */ + G::LoadClass( 'configuration' ); + $objUID = $Part['File']; + $conf = new Configurations( $oTable ); + $conf->loadConfig( $oTable, 'pagedTable', $objUID, '', (isset( $_SESSION['USER_LOGGED'] ) ? $_SESSION['USER_LOGGED'] : ''), '' ); + $oTable->__OBJ_UID = $objUID; + + //$oTable->__OBJ_UID = ''; + /* End Block */ + + /* Start Block: PagedTable Right Click */ + G::LoadClass( 'popupMenu' ); + $pm = new popupMenu( 'gulliver/pagedTable_PopupMenu' ); + $sc = $pm->renderPopup( $oTable->id, $oTable->fields ); + /* End Block */ + //krumo ( $Part ); + + + if ($this->ROWS_PER_PAGE) { + $oTable->rowsPerPage = $this->ROWS_PER_PAGE; + } + try { + if (is_array( $Part['Data'] )) { + $oTable->renderTable( '', $Part['Data'] ); + } else { + $oTable->renderTable(); + } + print ($sc) ; + } catch (Exception $e) { + $aMessage['MESSAGE'] = $e->getMessage(); + $this->AddContent( 'xmlform', 'xmlform', 'login/showMessage', '', $aMessage ); + } + break; + case 'panel-init': + global $mainPanelScript; + global $panelName; + global $tabCount; + G::LoadThirdParty( 'pear/json', 'class.json' ); + $json = new Services_JSON(); + $tabCount = 0; + $panelName = $Part['Template']; + $data = $Part['File']; + if (! is_array( $data )) { + $data = array (); + } + $data = G::array_merges( array ('title' => '','style' => array (),'left' => 'getAbsoluteLeft(mycontent)','top' => 'getAbsoluteTop(mycontent)','width' => 700,'height' => 600,'drag' => true,'close' => true,'modal' => true,'roll' => false,'resize' => false,'tabWidth' => 120,'tabStep' => 3,'blinkToFront' => true,'tabSpace' => 10 ), $data ); + $mainPanelScript = 'var ' . $panelName . '={},' . $panelName . 'Tabs=[];' . 'leimnud.event.add(window,"load",function(){' + . $panelName . ' = new leimnud.module.panel();' . 'var mycontent=document.getElementById("' . $this->publisherId . '[' + . $intPos . ']");' . $panelName . '.options={' . 'size:{w:' . $data['width'] . ',h:' . $data['height'] . '},' . 'position:{x:' + . $data['left'] . ',y:' . $data['top'] . '},' . 'title:"' . addcslashes( $data['title'], '\\"' ) . '",' . 'theme:"processmaker",' + . 'statusBar:true,' . 'headerBar:true,' . 'control:{' . ' close:' . ($data['close'] ? 'true' : 'false') . ',' . ' roll:' + . ($data['roll'] ? 'true' : 'false') . ',' . ' drag:' . ($data['drag'] ? 'true' : 'false') . ',' . ' resize:' + . ($data['resize'] ? 'true' : 'false') . '},' . 'fx:{' . ' drag:' . ($data['drag'] ? 'true' : 'false') . ',' . ' modal:' + . ($data['modal'] ? 'true' : 'false') . ',' . ' blinkToFront:' . ($data['blinkToFront'] ? 'true' : 'false') . '}' . '};' + . $panelName . '.setStyle=' . $json->encode( $data['style'] ) . ';' . $panelName . '.tab={' . 'width:' + . ($data['tabWidth'] + $data['tabSpace']) . ',' . 'optWidth:' . $data['tabWidth'] . ',' . 'step :' . $data['tabStep'] + . ',' . 'options:[]' . '};'; + print (' ') ; + break; + case 'panel-tab': + global $tabCount; + global $mainPanelScript; + global $panelName; + $onChange = $Part['Content']; + $beforeChange = $Part['Data']; + if (SYS_LANG == 'es') { + $mainPanelScript = str_replace( "120", "150", $mainPanelScript ); + } else { + $mainPanelScript = str_replace( "150", "120", $mainPanelScript ); + } + $mainPanelScript .= $panelName . 'Tabs[' . $tabCount . ']=' . 'document.getElementById("' . $Part['File'] . '");' . $panelName . '.tab.options[' . $panelName . '.tab.options.length]=' . '{' . 'title :"' . addcslashes( $Part['Template'], '\\"' ) . '",' . 'noClear :true,' . 'content :function(){' . ($beforeChange != '' ? ('if (typeof(' . $beforeChange . ')!=="undefined") {' . $beforeChange . '();}') : '') . $panelName . 'Clear();' . $panelName . 'Tabs[' . $tabCount . '].style.display="";' . + // 'this.addContent('.$panelName.'Tabs['.$tabCount.']);'. + // 'this.addContent(document.getElementById("'.$Part['File'].'"));'. + // $panelName.'Tabs['.$tabCount.']='.$panelName.'Tabs['.$tabCount.'].cloneNode( true );'. + ($onChange != '' ? ('if (typeof(' . $onChange . ')!=="undefined") {' . $onChange . '();}') : '') . '}.extend(' . $panelName . '),' . 'selected:' . ($tabCount == 0 ? 'true' : 'false') . '};'; + $tabCount ++; + + break; + case 'panel-close': + global $mainPanelScript; + global $panelName; + global $tabCount; + $mainPanelScript .= $panelName . '.make();'; + $mainPanelScript .= 'for(var r=0;r<' . $tabCount . ';r++)' . 'if (' . $panelName . 'Tabs[r])' . $panelName . '.addContent(' . $panelName . 'Tabs[r]);'; + $mainPanelScript .= '});'; + $mainPanelScript .= 'function ' . $panelName . 'Clear(){'; + $mainPanelScript .= 'for(var r=0;r<' . $tabCount . ';r++)' . 'if (' . $panelName . 'Tabs[r])' . $panelName . 'Tabs[r].style.display="none";}'; + $oHeadPublisher = & headPublisher::getSingleton(); + $oHeadPublisher->addScriptCode( $mainPanelScript ); + + break; + case 'blank': + print (' ') ; + break; + case 'varform': + global $G_FORM; + $G_FORM = new Form(); + G::LoadSystem( "varform" ); + $xml = new varForm(); + //$xml->parseFile ( ); + $xml->renderForm( $G_FORM, $Part['File'] ); + $G_FORM->Values = $Part['Data']; + $G_FORM->SetUp( $Part['Target'] ); + $G_FORM->width = 500; + break; + case 'table': + $G_TMP_TARGET = $Part['Target']; + $G_TABLE = G::LoadRawTable( $Part['File'], $this->dbc, $Part['Data'] ); + break; + case 'menu': + $G_TMP_TARGET = $Part['Target']; + $G_OP_MENU = new Menu(); + $G_OP_MENU->Load( $Part['File'] ); + break; + case 'smarty': //To do: Please check it 26/06/07 + $template = new Smarty(); + $template->compile_dir = PATH_SMARTY_C; + $template->cache_dir = PATH_SMARTY_CACHE; + $template->config_dir = PATH_THIRDPARTY . 'smarty/configs'; + $template->caching = false; + $dataArray = $Part['Data']; + + // verify if there are templates folders registered, template and method folders are the same + $folderTemplate = explode( '/', $Part['Template'] ); + $oPluginRegistry = & PMPluginRegistry::getSingleton(); + if ($oPluginRegistry->isRegisteredFolder( $folderTemplate[0] )) { + $template->templateFile = PATH_PLUGINS . $Part['Template'] . '.html'; + } else { + $template->templateFile = PATH_TPL . $Part['Template'] . '.html'; + } + // last change to load the template, maybe absolute path was given + if (! is_file( $template->templateFile )) { + $template->templateFile = strpos( $Part['Template'], '.html' ) !== false ? $Part['Template'] : $Part['Template'] . '.html'; + } + + //assign the variables and use the template $template + $template->assign( $dataArray ); + print $template->fetch( $template->templateFile ); + break; + case 'template': //To do: Please check it 26/06/07 + if (gettype( $Part['Data'] ) == 'array') { + G::LoadSystem( 'template' ); //template phpBB + $template = new Template(); + $template->set_filenames( array ('body' => $Part['Template'] . '.html' ) ); + $dataArray = $Part['Data']; + if (is_array( $dataArray )) { + foreach ($dataArray as $key => $val) { + if (is_array( $val )) { + foreach ($val as $key_val => $val_array) { + $template->assign_block_vars( $key, $val_array ); + } + } else { + $template->assign_vars( array ($key => $val ) ); + } + } + } + $template->pparse( 'body' ); + } + if (gettype( $Part['Data'] ) == 'object' && strtolower( get_class( $Part['Data'] ) ) == 'templatepower') { + $Part['Data']->printToScreen(); + } + return; + break; + case 'view': + case 'content': + //check if G_PLUGIN_CLASS is defined, because publisher can be called without an environment + $aux = explode( PATH_SEP, $Part['Template'] ); + if (count( $aux ) == 2 && defined( 'G_PLUGIN_CLASS' )) { + //if the template doesn't exists, then try it with the plugins folders, after the normal Template + $userTemplate = G::ExpandPath( 'templates' ) . $Part['Template']; + $globalTemplate = PATH_TEMPLATE . $Part['Template']; + if (! is_file( $userTemplate ) && ! is_file( $globalTemplate )) { + $oPluginRegistry = & PMPluginRegistry::getSingleton(); + if ($oPluginRegistry->isRegisteredFolder( $aux[0] )) { + $pluginTemplate = PATH_PLUGINS . $Part['Template'] . '.php'; + include ($pluginTemplate); + + } + } + } + + break; + case 'graphLayout': //Added by JHL to render GraphLayout component + $G_OBJGRAPH = $Part['Data']; + $G_TMP_TARGET = $Part['Target']; + $G_TMP_FILE = $Part['File']; + break; + } + + //krumo( $Part['Template'] ); + //check if this LoadTemplate is used, byOnti 12th Aug 2008 + G::LoadTemplate( $Part['Template'] ); + $G_TABLE = null; + } } + diff --git a/gulliver/system/class.xmlform.php b/gulliver/system/class.xmlform.php index 2af106b22..327e4f764 100755 --- a/gulliver/system/class.xmlform.php +++ b/gulliver/system/class.xmlform.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,2302 +27,2549 @@ */ /** * Class XmlForm_Field + * * @author David S. Callizaya S. * @package gulliver.system * @access public */ -class XmlForm_Field { - var $name = ''; - var $type = 'field'; - var $label = ''; - var $pmLabel = ''; - var $owner; - var $language; - var $group = 0; - var $mode = ''; - var $defaultValue = NULL; - var $gridFieldType = ''; - var $gridLabel = ''; - /* Hint value generic declaration */ - var $hint = ''; - /*to change the presentation*/ - var $enableHtml = false; - var $style = ''; - var $withoutLabel = false; - var $className = ''; - /*attributes for paged table*/ - var $colWidth = 140; - var $colAlign = 'left'; - var $colClassName = ''; - var $titleAlign = ''; - var $align = ''; - var $showInTable = ''; - /*Events*/ - var $onclick = ''; - /*attributes for data filtering*/ - /*dataCompareField = field to be compared with*/ - var $dataCompareField = ''; - /* $dataCompareType : '=' ,'<>' , 'like', ... , 'contains'(== ' like "%value%"') - */ - var $dataCompareType = '='; - var $sql = ''; - var $sqlConnection = ''; - //Attributes for PM Tables integration (only ProcessMaker for now) - var $pmtable = ''; - var $keys = ''; - var $pmconnection = ''; - var $pmfield = ''; +class XmlForm_Field +{ + public $name = ''; + public $type = 'field'; + public $label = ''; + public $pmLabel = ''; + public $owner; + public $language; + public $group = 0; + public $mode = ''; + public $defaultValue = null; + public $gridFieldType = ''; + public $gridLabel = ''; + /* Hint value generic declaration */ + public $hint = ''; + /*to change the presentation*/ + public $enableHtml = false; + public $style = ''; + public $withoutLabel = false; + public $className = ''; + /*attributes for paged table*/ + public $colWidth = 140; + public $colAlign = 'left'; + public $colClassName = ''; + public $titleAlign = ''; + public $align = ''; + public $showInTable = ''; + /*Events*/ + public $onclick = ''; + /*attributes for data filtering*/ + /*dataCompareField = field to be compared with*/ + public $dataCompareField = ''; + /* $dataCompareType : '=' ,'<>' , 'like', ... , 'contains'(== ' like "%value%"') + */ + public $dataCompareType = '='; + public $sql = ''; + public $sqlConnection = ''; + //Attributes for PM Tables integration (only ProcessMaker for now) + public $pmtable = ''; + public $keys = ''; + public $pmconnection = ''; + public $pmfield = ''; - // For mode cases Grid - var $modeGrid = ''; - var $modeForGrid = ''; - /** - * Function XmlForm_Field - * @author David S. Callizaya S. - * @access public - * @param string xmlNode - * @param string lang - * @param string home - * @return string - */ - function XmlForm_Field($xmlNode, $lang = 'en', $home = '', $owner = NULL) - { - //Loads any attribute that were defined in the xmlNode - //except name and label. - $myAttributes = get_class_vars ( get_class ( $this ) ); - foreach ( $myAttributes as $k => $v ) - $myAttributes [$k] = strtoupper ( $k ); - //$data: Includes labels and options. - $data = &$xmlNode->findNode ( $lang ); - if(!isset($data->value)){ //It seems that in the actual language there are no value for the current field, so get the value in English - $data = &$xmlNode->findNode ( "en" ); - if(!isset($data->value)){ //It seems that in the actual language there are no value for the current field, so get the value in First language - if(isset($xmlNode->children[0])){//Lets find first child - if((isset($xmlNode->children[0]->name))&&(strlen($xmlNode->children[0]->name)==2)){//Just to be sure that the node ocrresponds to a valid lang - $data = &$xmlNode->findNode ( $xmlNode->children[0]->name ); - } + // For mode cases Grid + public $modeGrid = ''; + public $modeForGrid = ''; + + /** + * Function XmlForm_Field + * + * @author David S. Callizaya S. + * @access public + * @param string xmlNode + * @param string lang + * @param string home + * @return string + */ + public function XmlForm_Field ($xmlNode, $lang = 'en', $home = '', $owner = null) + { + //Loads any attribute that were defined in the xmlNode + //except name and label. + $myAttributes = get_class_vars( get_class( $this ) ); + foreach ($myAttributes as $k => $v) { + $myAttributes[$k] = strtoupper( $k ); } - } - } - @$this->label = $this->pmLabel = $data->value; + //$data: Includes labels and options. + $data = &$xmlNode->findNode( $lang ); + if (! isset( $data->value )) { + //It seems that in the actual language there are no value for the current field, so get the value in English + $data = &$xmlNode->findNode( "en" ); + if (! isset( $data->value )) { + //It seems that in the actual language there are no value for the current field, so get the value in First language + if (isset( $xmlNode->children[0] )) { + //Lets find first child + if ((isset( $xmlNode->children[0]->name )) && (strlen( $xmlNode->children[0]->name ) == 2)) { + //Just to be sure that the node ocrresponds to a valid lang + $data = &$xmlNode->findNode( $xmlNode->children[0]->name ); + } + } + } + } + @$this->label = $this->pmLabel = $data->value; - - /*Loads the field attributes*/ - foreach ( $xmlNode->attributes as $k => $v ) { - $key = array_search ( strtoupper ( $k ), $myAttributes ); - if ($key) - eval ( '$this->' . $key . '=$v;' ); - } - //Loads the main attributes - $this->name = $xmlNode->name; - $this->type = strtolower ( $xmlNode->attributes ['type'] ); - preg_match ( '/\s*([^\s][\w\W]*)?/m', $xmlNode->value, $matches ); - $this->sql = (isset ( $matches [1] )) ? $matches [1] : ''; - //List Options - if (isset ( $data->children )) - foreach ( $data->children as $k => $v ) { - if ($v->type !== 'cdata') - $this->{$v->name} [$v->attributes ["name"]] = $v->value; - } - $this->options = (isset ( $this->option )) ? $this->option : array (); - //Sql Options : cause warning because values are not setted yet. - //if ($this->sql!=='') $this->executeSQL(); - if (isset($owner)) { - if (isset($owner->mode)) { - $ownerMode = $owner->mode; + /*Loads the field attributes*/ + foreach ($xmlNode->attributes as $k => $v) { + $key = array_search( strtoupper( $k ), $myAttributes ); + if ($key) { + eval( '$this->' . $key . '=$v;' ); + } + } + //Loads the main attributes + $this->name = $xmlNode->name; + $this->type = strtolower( $xmlNode->attributes['type'] ); + preg_match( '/\s*([^\s][\w\W]*)?/m', $xmlNode->value, $matches ); + $this->sql = (isset( $matches[1] )) ? $matches[1] : ''; + //List Options + if (isset( $data->children )) { + foreach ($data->children as $k => $v) { + if ($v->type !== 'cdata') { + $this->{$v->name}[$v->attributes["name"]] = $v->value; + } + } + } + $this->options = (isset( $this->option )) ? $this->option : array (); + //Sql Options : cause warning because values are not setted yet. + //if ($this->sql!=='') $this->executeSQL(); + if (isset( $owner )) { + if (isset( $owner->mode )) { + $ownerMode = $owner->mode; + } else { + $ownerMode = ''; + } } else { $ownerMode = ''; } - } else { - $ownerMode = ''; + if ($ownerMode != '') { + $this->mode = $ownerMode; + } + if ($this->mode == '') { + $this->mode = 'edit'; + } + $this->modeForGrid = $this->mode; } - if ($ownerMode != '') { - $this->mode = $ownerMode; - } - if ($this->mode == '') { - $this->mode = 'edit'; - } - $this->modeForGrid = $this->mode; - } - /** - * validate if a value is setted - * @param $value - * @return boolean true/false - */ - function validateValue($value) - { - return isset ( $value ); - } + /** + * validate if a value is setted + * + * @param $value + * @return boolean true/false + */ + public function validateValue ($value) + { + return isset( $value ); + } - /** - * execute a xml query - * @param &$owner reference of owner - * @param $row - * @return $result array of results - */ - private function executeXmlDB(&$owner, $row = -1) - { - if (! $this->sqlConnection) - $dbc = new DBConnection ( ); - else { - - if (defined ( 'DB_' . $this->sqlConnection . '_USER' )) { - if (defined ( 'DB_' . $this->sqlConnection . '_HOST' )) - eval ( '$res[\'DBC_SERVER\'] = DB_' . $this->sqlConnection . '_HOST;' ); - else - $res ['DBC_SERVER'] = DB_HOST; - if (defined ( 'DB_' . $this->sqlConnection . '_USER' )) - eval ( '$res[\'DBC_USERNAME\'] = DB_' . $this->sqlConnection . '_USER;' ); - if (defined ( 'DB_' . $this->sqlConnection . '_PASS' )) - eval ( '$res[\'DBC_PASSWORD\'] = DB_' . $this->sqlConnection . '_PASS;' ); - else - $res ['DBC_PASSWORD'] = DB_PASS; - if (defined ( 'DB_' . $this->sqlConnection . '_NAME' )) - eval ( '$res[\'DBC_DATABASE\'] = DB_' . $this->sqlConnection . '_NAME;' ); - else - $res ['DBC_DATABASE'] = DB_NAME; - if (defined ( 'DB_' . $this->sqlConnection . '_TYPE' )) - eval ( '$res[\'DBC_TYPE\'] = DB_' . $this->sqlConnection . '_TYPE;' ); - else - $res ['DBC_TYPE'] = defined ( 'DB_TYPE' ) ? DB_TYPE : 'mysql'; - $dbc = new DBConnection ( $res ['DBC_SERVER'], $res ['DBC_USERNAME'], $res ['DBC_PASSWORD'], $res ['DBC_DATABASE'], $res ['DBC_TYPE'] ); - } else { - $dbc0 = new DBConnection ( ); - $dbs0 = new DBSession ( $dbc0 ); - $res = $dbs0->execute ( "select * from DB_CONNECTION WHERE DBC_UID=" . $this->sqlConnection ); - $res = $res->read (); - $dbc = new DBConnection ( $res ['DBC_SERVER'], $res ['DBC_USERNAME'], $res ['DBC_PASSWORD'], $res ['DBC_DATABASE'] ); - } - } - $query = G::replaceDataField ( $this->sql, $owner->values ); - $dbs = new DBSession ( $dbc ); - $res = $dbs->execute ( $query ); - $result = array (); - while ( $row = $res->Read () ) { - $result [] = $row; - } - return $result; - } - /** - * Execute a propel query - * @param &$owner reference - * @param $row - * @return $result array of - */ - private function executePropel(&$owner, $row = -1) - { - //g::pr($row); - if (! isset ( $owner->values [$this->name] )) { - if ($row > - 1) { - $owner->values [$this->name] = array (); - } else { - $owner->values [$this->name] = ''; - } - } - if (! is_array ( $owner->values [$this->name] )) { - //echo '1'; - $query = G::replaceDataField ( $this->sql, $owner->values ); - } else { - $aAux = array (); - foreach ( $owner->values as $key => $data ) { - if (is_array ( $data )) { - //echo '3:'.$key.' '; - if (isset ( $data [$row] )){ - $qValue = $data [$row]; - }else{ - if (isset($owner->fields[$key]->selectedValue)){ - $qValue = $owner->fields[$key]->selectedValue; - }else{ - $qValue = ''; - } - } - $aAux [$key] = $qValue; - //$aAux [$key] = isset ( $data [$row] ) ? $data [$row] : ''; + /** + * execute a xml query + * + * @param &$owner reference of owner + * @param $row + * @return $result array of results + */ + private function executeXmlDB (&$owner, $row = -1) + { + if (! $this->sqlConnection) { + $dbc = new DBConnection(); } else { - //echo '4'.$key.' '; - $aAux [$key] = $data; - } - } - //echo '2'; - //g::pr($aAux); - $query = G::replaceDataField ( $this->sql, $aAux ); - } - //echo $query; - - $result = array (); - if ($this->sqlConnection == 'dbarray') { - try { - $con = Propel::getConnection ( $this->sqlConnection ); - $stmt = $con->createStatement (); - $rs = $con->executeQuery ( $query, ResultSet::FETCHMODE_NUM ); - } - catch ( Exception $e ) { //dismiss error because dbarray shouldnt be defined in some contexts. - return $result; - } - } - else { - try { - $con = Propel::getConnection ( $this->sqlConnection ); - $stmt = $con->createStatement (); - $rs = $stmt->executeQuery ( $query, ResultSet::FETCHMODE_NUM ); - } - catch ( Exception $e ) { //dismiss error because dbarray shouldnt be defined in some contexts. - return $result; - } - } - - $rs->next (); - $row = $rs->getRow (); - while ( is_array ( $row ) ) { - $result [] = $row; - $rs->next (); - $row = $rs->getRow (); - } - return $result; - } - /** - * Function executeSQL - * @author David S. Callizaya S. - * @access public - * @param string owner - * @return string - */ - function executeSQL(&$owner, $row = -1) { - if (! isset ( $this->sql )) - return 1; - if ($this->sql === '') - return 1; - if (! $this->sqlConnection) - $this->sqlConnection = 'workflow'; - - //Read the result of the query - if ($this->sqlConnection === "XMLDB") { - $result = $this->executeXmlDB ( $owner, $row ); - } else { - $result = $this->executePropel ( $owner, $row ); - } - $this->sqlOption = array (); - $this->options = array (); - if (isset ( $this->option )) { - foreach ( $this->option as $k => $v ) - $this->options [$k] = $v; - } - for($r = 0; $r < sizeof ( $result ); $r ++) { - $key = reset ( $result [$r] ); - $this->sqlOption [$key] = next ( $result [$r] ); - $this->options [$key] = $this->sqlOption [$key]; - } - - if ($this->type != 'listbox') { - if (isset ( $this->options ) && isset ( $this->owner ) && isset ( $this->owner->values [$this->name] )) { - if ((! is_array ( $this->owner->values [$this->name] )) && ! ((is_string ( $this->owner->values [$this->name] ) || is_int ( $this->owner->values [$this->name] )) && array_key_exists ( $this->owner->values [$this->name], $this->options ))) { - reset ( $this->options ); - $firstElement = key ( $this->options ); - if (isset ( $firstElement )) - $this->owner->values [$this->name] = $firstElement; - else - $this->owner->values [$this->name] = ''; - } - } - } - return 0; - } - - /** - * return the html entities of a value - * @param $value - * @param $flags - * @param $encoding - * @return - */ - - function htmlentities($value, $flags = ENT_QUOTES, $encoding = 'utf-8') - { - - if ($this->enableHtml){ - return $value;} - else{ - return htmlentities ( $value, $flags, $encoding ); - } - } - /** - * Function render - * @author David S. Callizaya S. - * @access public - * @param string value - * @return string - */ - function render($value = NULL) - { - //this is an unknown field type. - return $this->htmlentities ( $value != '' ? $value : $this->name, ENT_COMPAT, 'utf-8' ); - } - /** - * Function renderGrid - * @author David S. Callizaya S. - * @access public - * @param string values - * @return string - */ - function renderGrid($values = array(), $owner = NULL, $onlyValue = false, $therow = -1) - { - $result = array (); - $r = 1; - foreach ( $values as $v ) { - $result [] = $this->render ( $v, $owner, '[' . $owner->name . '][' . $r . ']', $onlyValue, $r, $therow ); - $r ++; - } - return $result; - } - /** - * render the field in a table - * @param $values - * @param $owner - * @param $onlyValue - * @return $result - */ - function renderTable($values = '', $owner = NULL, $onlyValue = false) - { - $r = 1; - $result = $this->render ( $values, $owner, '[' . $owner->name . '][' . $r . ']', $onlyValue ); - return $result; - } - - /** - * Function dependentOf - * @author David S. Callizaya S. - * @access public - * @return array - */ - function dependentOf() - { - $fields = array (); - if (isset ( $this->formula )) { - preg_match_all ( "/\b[a-zA-Z][a-zA-Z_0-9]*\b/", $this->formula, $matches, PREG_PATTERN_ORDER ); - /* if ($this->formula!=''){ - var_dump($this->formula); - var_dump($matches); - var_dump(array_keys($this->owner->fields)); - die; - }*/ - foreach ( $matches [0] as $field ) { - //if (array_key_exists( $this->owner->fields, $field )) - $fields [] = $field; - } - } - return $fields; - } - /** - * Function mask - * @author David S. Callizaya S. - * @access public - * @param string format - * @param string value - * @return string - */ - function mask($format, $value) - { - $value = explode ( '', $value ); - for($j = 0; $j < strlen ( $format ); $j ++) { - $result = ''; - $correct = TRUE; - for($i = $j; $i < strlen ( $format ); $i ++) { - $a = substr ( $format, $i, 1 ); - $e = $i < strlen ( $value ) ? substr ( $value, $i, 1 ) : ''; - //$e=$i ^...$ no parece pero no, o mejor si, donde # es \d?, en general todos - // es valida cuando no encuentra un caracter que no deberia estar, puede no terminar la mascara - // pero si sobran caracteres en el value entonces no se cumple la mascara. - return $correct ? $result : $correct; - } - /** - * Function getAttributes - * @author David S. Callizaya S. - * @access public - * @return string - */ - function getAttributes() - { - $attributes = array (); - $json = new Services_JSON ( ); - foreach ( $this as $attribute => $value ) { - switch ($attribute) { - case 'sql' : - case 'sqlConnection' : - case 'name' : - case 'type' : - case 'owner' : - break; - default : - if (substr ( $attribute, 0, 2 ) !== 'on') - $attributes [$attribute] = $value; - } - } - if (sizeof ( $attributes ) < 1) - return '{}'; - return $json->encode ( $attributes ); - } - /** - * Function getEvents - * @author David S. Callizaya S. - * @access public - * @return string - */ - function getEvents() - { - $events = array (); - $json = new Services_JSON ( ); - foreach ( $this as $attribute => $value ) { - if (substr ( $attribute, 0, 2 ) === 'on') - $events [$attribute] = $value; - } - if (sizeof ( $events ) < 1) - return '{}'; - return $json->encode ( $events ); - } - /** - * Function attachEvents: Attaches events to a control using - * leimnud.event.add - * @author David S. Callizaya S. - * @param $elementRef - * @access public - */ - function attachEvents($elementRef) - { - $events = ''; - foreach ( $this as $attribute => $value ) { - if (substr ( $attribute, 0, 2 ) == 'on') { - $events = 'if (' . $elementRef . ') leimnud.event.add(' . $elementRef . ',"' . substr ( $attribute, 2 ) . '",function(){' . $value . '});' . "\n"; - } - } - } - /** - * Function createXmlNode: Creates an Xml_Node object storing - * the data of $this Xml_Field. - * @author David S. Callizaya S. - * @access public - * @return Xml_Node - */ - function createXmlNode($includeDefaultValues = false) - { - /* Start Comment: Creates the corresponding XML Tag for $this - * object. - */ - $attributesList = $this->getXmlAttributes ( $includeDefaultValues ); - $node = new Xml_Node ( $this->name, 'open', $this->sql, $attributesList ); - /* End Comment */ - /* Start Comment: Creates the languages nodes and options - * if exist. - */ - $node->addChildNode ( new Xml_Node ( '', 'cdata', "\n" ) ); - $node->addChildNode ( new Xml_Node ( $this->language, 'open', $this->label ) ); - if (isset ( $this->option )) { - foreach ( $this->option as $k => $v ) - $node->children [1]->addChildNode ( new Xml_Node ( 'option', 'open', $v, array ('name' => $k ) ) ); - } - /* End Comment */ - return $node; - } - /** - * Function updateXmlNode: Updates and existing Xml_Node - * with the data of $this Xml_Field. - * @author David S. Callizaya S. - * @access public - * @param string value - * @return Xml_Node - */ - function &updateXmlNode(&$node, $includeDefaultValues = false) - { - /* Start Comment: Modify the node's attributes and value. - */ - $attributesList = $this->getXmlAttributes ( $includeDefaultValues ); - $node->name = $this->name; - $node->value = $this->sql; - $node->attributes = $attributesList; - /* End Comment */ - /* Start Comment: Modifies the languages nodes - */ - $langNode = & $node->findNode ( $this->language ); - $langNode->value = $this->label; - if (isset ( $this->option )) { - $langNode->children = array (); - foreach ( $this->option as $k => $v ) - $langNode->addChildNode ( new Xml_Node ( 'option', 'open', $v, array ('name' => $k ) ) ); - } - /* End Comment */ - return $node; - } - /** - * Function getXmlAttributes: Returns an associative array - * with the attributes of $this Xml_field (only the modified ones). - * @author David S. Callizaya S. - * @access public - * @param boolean includeDefaultValues Includes attributes - * with default values. - * @return Xml_Node - */ - function getXmlAttributes($includeDefaultValues = false) - { - $attributesList = array (); - $class = get_class ( $this ); - $default = new $class ( new Xml_Node ( 'DEFAULT', 'open', '', array ('type' => $this->type ) ) ); - foreach ( $this as $k => $v ) { - switch ($k) { - case 'owner' : - case 'name' : - case 'type' : - case 'language' : - case 'sql' : - break; - default : - if (($v !== $default->{$k}) || $includeDefaultValues) - $attributesList [$k] = $v; - } - } - return $attributesList; - } - /** Used in Form::validatePost - * @param $value - * @param &$owner - * @return $value - */ - function maskValue($value, &$owner) - { - return $value; - } - /*Close this object*/ - /** - * clone the current object - * @return - */ - function cloneObject() - { - //return unserialize( serialize( $this ) );//con este cambio los formularios ya no funcionan en php4 - return clone ($this); - } - - /** - * get a value from a PM Table - * @param $oOwner - * @return $sValue - */ - function getPMTableValue($oOwner) - { - $sValue = ''; - if (isset($oOwner->fields[$this->pmconnection])) { - if (defined('PATH_CORE')) { - if (file_exists(PATH_CORE . 'classes' . PATH_SEP . 'model' . PATH_SEP . 'AdditionalTables.php')) { - require_once PATH_CORE . 'classes' . PATH_SEP . 'model' . PATH_SEP . 'AdditionalTables.php'; - $oAdditionalTables = new AdditionalTables(); - try { - $aData = $oAdditionalTables->load($oOwner->fields[$this->pmconnection]->pmtable, true); - } - catch (Exception $oError) { - $aData = array('FIELDS' => array()); - } - $aKeys = array(); - $aValues = explode('|', $oOwner->fields[$this->pmconnection]->keys); - $i = 0; - foreach ($aData['FIELDS'] as $aField) { - if ($aField['FLD_KEY'] == '1') { - // note added by gustavo cruz gustavo[at]colosa[dot]com - // this additional [if] checks if a case variable has been set - // in the keys attribute, so it can be parsed and replaced for - // their respective value. - if (preg_match("/@#/", $aValues[$i])) { - // check if a case are running in order to prevent that preview is - // erroneous rendered. - if (isset($_SESSION['APPLICATION'])){ - G::LoadClass('case'); - $oApp= new Cases(); - if ($oApp->loadCase($_SESSION['APPLICATION'])!=null){ - $aFields = $oApp->loadCase($_SESSION['APPLICATION']); - $formVariable = substr($aValues[$i], 2); - if(isset($aFields['APP_DATA'][$formVariable])){ - $formVariableValue = $aFields['APP_DATA'][$formVariable]; - $aKeys[$aField['FLD_NAME']] = (isset($formVariableValue) ? G::replaceDataField($formVariableValue, $oOwner->values) : ''); - } else { - $aKeys[$aField['FLD_NAME']] = ''; - } - } else { - $aKeys[$aField['FLD_NAME']] = ''; - } + if (defined( 'DB_' . $this->sqlConnection . '_USER' )) { + if (defined( 'DB_' . $this->sqlConnection . '_HOST' )) { + eval( '$res[\'DBC_SERVER\'] = DB_' . $this->sqlConnection . '_HOST;' ); } else { - $aKeys[$aField['FLD_NAME']] = ''; + $res['DBC_SERVER'] = DB_HOST; } - } else { - $aKeys[$aField['FLD_NAME']] = (isset($aValues[$i]) ? G::replaceDataField($aValues[$i], $oOwner->values) : ''); - } - $i++; + if (defined( 'DB_' . $this->sqlConnection . '_USER' )) { + eval( '$res[\'DBC_USERNAME\'] = DB_' . $this->sqlConnection . '_USER;' ); + } + if (defined( 'DB_' . $this->sqlConnection . '_PASS' )) { + eval( '$res[\'DBC_PASSWORD\'] = DB_' . $this->sqlConnection . '_PASS;' ); + } else { + $res['DBC_PASSWORD'] = DB_PASS; + } + if (defined( 'DB_' . $this->sqlConnection . '_NAME' )) { + eval( '$res[\'DBC_DATABASE\'] = DB_' . $this->sqlConnection . '_NAME;' ); + } else { + $res['DBC_DATABASE'] = DB_NAME; + } + if (defined( 'DB_' . $this->sqlConnection . '_TYPE' )) { + eval( '$res[\'DBC_TYPE\'] = DB_' . $this->sqlConnection . '_TYPE;' ); + } else { + $res['DBC_TYPE'] = defined( 'DB_TYPE' ) ? DB_TYPE : 'mysql'; + } + $dbc = new DBConnection( $res['DBC_SERVER'], $res['DBC_USERNAME'], $res['DBC_PASSWORD'], $res['DBC_DATABASE'], $res['DBC_TYPE'] ); + } else { + $dbc0 = new DBConnection(); + $dbs0 = new DBSession( $dbc0 ); + $res = $dbs0->execute( "select * from DB_CONNECTION WHERE DBC_UID=" . $this->sqlConnection ); + $res = $res->read(); + $dbc = new DBConnection( $res['DBC_SERVER'], $res['DBC_USERNAME'], $res['DBC_PASSWORD'], $res['DBC_DATABASE'] ); } - } - try { - $aData = $oAdditionalTables->getDataTable($oOwner->fields[$this->pmconnection]->pmtable, $aKeys); - } - catch (Exception $oError) { - $aData = array(); - } - if (isset($aData[$this->pmfield])) { - $sValue = $aData[$this->pmfield]; - } } - } + $query = G::replaceDataField( $this->sql, $owner->values ); + $dbs = new DBSession( $dbc ); + $res = $dbs->execute( $query ); + $result = array (); + while ($row = $res->Read()) { + $result[] = $row; + } + return $result; } - return $sValue; - } - /** - * Prepares NS Required Value - * @author Enrique Ponce de Leon - * @param boolean optional (true = always show, false = show only if not empty) - * @return string - */ + /** + * Execute a propel query + * + * @param &$owner reference + * @param $row + * @return $result array of + */ + private function executePropel (&$owner, $row = -1) + { + //g::pr($row); + if (! isset( $owner->values[$this->name] )) { + if ($row > - 1) { + $owner->values[$this->name] = array (); + } else { + $owner->values[$this->name] = ''; + } + } + if (! is_array( $owner->values[$this->name] )) { + //echo '1'; + $query = G::replaceDataField( $this->sql, $owner->values ); + } else { + $aAux = array (); + foreach ($owner->values as $key => $data) { + if (is_array( $data )) { + //echo '3:'.$key.' '; + if (isset( $data[$row] )) { + $qValue = $data[$row]; + } else { + if (isset( $owner->fields[$key]->selectedValue )) { + $qValue = $owner->fields[$key]->selectedValue; + } else { + $qValue = ''; + } + } + $aAux[$key] = $qValue; + //$aAux [$key] = isset ( $data [$row] ) ? $data [$row] : ''; + } else { + //echo '4'.$key.' '; + $aAux[$key] = $data; + } + } - function NSRequiredValue($show = false){ - if (isset($this->required)){ - $req = ($this->required)? '1':'0'; - }else{ - $req = '0'; + //echo '2'; + //g::pr($aAux); + $query = G::replaceDataField( $this->sql, $aAux ); + } + //echo $query; + + $result = array (); + if ($this->sqlConnection == 'dbarray') { + try { + $con = Propel::getConnection( $this->sqlConnection ); + $stmt = $con->createStatement(); + $rs = $con->executeQuery( $query, ResultSet::FETCHMODE_NUM ); + } catch (Exception $e) { + //dismiss error because dbarray shouldnt be defined in some contexts. + return $result; + } + } else { + try { + $con = Propel::getConnection( $this->sqlConnection ); + $stmt = $con->createStatement(); + $rs = $stmt->executeQuery( $query, ResultSet::FETCHMODE_NUM ); + } catch (Exception $e) { + //dismiss error because dbarray shouldnt be defined in some contexts. + return $result; + } + } + + $rs->next(); + $row = $rs->getRow(); + while (is_array( $row )) { + $result[] = $row; + $rs->next(); + $row = $rs->getRow(); + } + return $result; } - $idv = 'pm:required="'.$req.'"'; - if ($show){ - return $idv; - }else{ - return ($req != '0')? $idv : ''; + + /** + * Function executeSQL + * + * @author David S. Callizaya S. + * @access public + * @param string owner + * @return string + */ + public function executeSQL (&$owner, $row = -1) + { + if (! isset( $this->sql )) { + return 1; + } + if ($this->sql === '') { + return 1; + } + if (! $this->sqlConnection) { + $this->sqlConnection = 'workflow'; + } + + //Read the result of the query + if ($this->sqlConnection === "XMLDB") { + $result = $this->executeXmlDB( $owner, $row ); + } else { + $result = $this->executePropel( $owner, $row ); + } + $this->sqlOption = array (); + $this->options = array (); + if (isset( $this->option )) { + foreach ($this->option as $k => $v) { + $this->options[$k] = $v; + } + } + for ($r = 0; $r < sizeof( $result ); $r ++) { + $key = reset( $result[$r] ); + $this->sqlOption[$key] = next( $result[$r] ); + $this->options[$key] = $this->sqlOption[$key]; + } + + if ($this->type != 'listbox') { + if (isset( $this->options ) && isset( $this->owner ) && isset( $this->owner->values[$this->name] )) { + if ((! is_array( $this->owner->values[$this->name] )) && ! ((is_string( $this->owner->values[$this->name] ) || is_int( $this->owner->values[$this->name] )) && array_key_exists( $this->owner->values[$this->name], $this->options ))) { + reset( $this->options ); + $firstElement = key( $this->options ); + if (isset( $firstElement )) { + $this->owner->values[$this->name] = $firstElement; + } else { + $this->owner->values[$this->name] = ''; + } + } + } + } + return 0; } - } + /** + * return the html entities of a value + * + * @param $value + * @param $flags + * @param $encoding + * @return + */ - /** - * Prepares NS Required Value - * @author Enrique Ponce de Leon - * @param boolean optional (true = always show, false = show only if not empty) - * @return string - */ + public function htmlentities ($value, $flags = ENT_QUOTES, $encoding = 'utf-8') + { - function NSGridLabel($show = false){ - $idv = 'pm:label="'.$this->pmLabel.'"'; - if ($show){ - return $idv; - }else{ - return ($this->pmLabel != '')? $idv : ''; + if ($this->enableHtml) { + return $value; + } else { + return htmlentities( $value, $flags, $encoding ); + } } - } - - /** - * Prepares NS Default Text - * @author Enrique Ponce de Leon - * @param boolean optional (true = always show, false = show only if not empty) - * @return string - */ - function NSDefaultValue($show = false){ - $idv = 'pm:defaultvalue="'.$this->defaultValue.'"'; - if ($show){ - return $idv; - }else{ - return ($this->defaultValue != '')? $idv : ''; + /** + * Function render + * + * @author David S. Callizaya S. + * @access public + * @param string value + * @return string + */ + public function render ($value = null) + { + //this is an unknown field type. + return $this->htmlentities( $value != '' ? $value : $this->name, ENT_COMPAT, 'utf-8' ); } - } - /** - * Prepares NS Grid Type - * @author Enrique Ponce de Leon - * @param boolean optional (true = always show, false = show only if not empty) - * @return string - */ - function NSGridType($show = false){ - $igt = 'pm:gridtype="'.$this->gridFieldType.'"'; - if ($show){ - return $igt; - }else{ - return ($this->gridFieldType != '')? $igt : ''; + /** + * Function renderGrid + * + * @author David S. Callizaya S. + * @access public + * @param string values + * @return string + */ + public function renderGrid ($values = array(), $owner = null, $onlyValue = false, $therow = -1) + { + $result = array (); + $r = 1; + foreach ($values as $v) { + $result[] = $this->render( $v, $owner, '[' . $owner->name . '][' . $r . ']', $onlyValue, $r, $therow ); + $r ++; + } + return $result; } - } - /** - * Prepares NS Grid Type - * @author Enrique Ponce de Leon - * @param boolean optional (true = always show, false = show only if not empty) - * @return string - */ - function NSDependentFields($show = false){ - $idf = 'pm:dependent="'.(($this->dependentFields != '')? '1':'0').'"'; - if ($show){ - return $idf; - }else{ - return ($this->dependentFields != '')? $idf : ''; + /** + * render the field in a table + * + * @param $values + * @param $owner + * @param $onlyValue + * @return $result + */ + public function renderTable ($values = '', $owner = null, $onlyValue = false) + { + $r = 1; + $result = $this->render( $values, $owner, '[' . $owner->name . '][' . $r . ']', $onlyValue ); + return $result; } - } - /** - * Prepares Hint HTML if hint value is defined - * @author Enrique Ponce de Leon - * @param void - * @return string - **/ + /** + * Function dependentOf + * + * @author David S. Callizaya S. + * @access public + * @return array + */ + public function dependentOf () + { + $fields = array (); + if (isset( $this->formula )) { + preg_match_all( "/\b[a-zA-Z][a-zA-Z_0-9]*\b/", $this->formula, $matches, PREG_PATTERN_ORDER ); + /* if ($this->formula!=''){ + var_dump($this->formula); + var_dump($matches); + var_dump(array_keys($this->owner->fields)); + die; + }*/ + foreach ($matches[0] as $field) { + //if (array_key_exists( $this->owner->fields, $field )) + $fields[] = $field; + } + } + return $fields; + } - function renderHint(){ - $_outHint = ''; - if ($this->hint != '' && $this->mode=='edit'){ - $_outHint = ' + /** + * Function mask + * + * @author David S. Callizaya S. + * @access public + * @param string format + * @param string value + * @return string + */ + public function mask ($format, $value) + { + $value = explode( '', $value ); + for ($j = 0; $j < strlen( $format ); $j ++) { + $result = ''; + $correct = true; + for ($i = $j; $i < strlen( $format ); $i ++) { + $a = substr( $format, $i, 1 ); + $e = $i < strlen( $value ) ? substr( $value, $i, 1 ) : ''; + //$e=$i ^...$ no parece pero no, o mejor si, donde # es \d?, en general todos + // es valida cuando no encuentra un caracter que no deberia estar, puede no terminar la mascara + // pero si sobran caracteres en el value entonces no se cumple la mascara. + return $correct ? $result : $correct; + } + + /** + * Function getAttributes + * + * @author David S. Callizaya S. + * @access public + * @return string + */ + public function getAttributes () + { + $attributes = array (); + $json = new Services_JSON(); + foreach ($this as $attribute => $value) { + switch ($attribute) { + case 'sql': + case 'sqlConnection': + case 'name': + case 'type': + case 'owner': + break; + default: + if (substr( $attribute, 0, 2 ) !== 'on') { + $attributes[$attribute] = $value; + } + } + } + if (sizeof( $attributes ) < 1) { + return '{}'; + } + return $json->encode( $attributes ); + } + + /** + * Function getEvents + * + * @author David S. Callizaya S. + * @access public + * @return string + */ + public function getEvents () + { + $events = array (); + $json = new Services_JSON(); + foreach ($this as $attribute => $value) { + if (substr( $attribute, 0, 2 ) === 'on') { + $events[$attribute] = $value; + } + } + if ($sizeof( $events ) < 1) { + return '{}'; + } + return $json->encode( $events ); + } + + /** + * Function attachEvents: Attaches events to a control using + * leimnud.event.add + * + * @author David S. Callizaya S. + * @param $elementRef + * @access public + */ + public function attachEvents ($elementRef) + { + $events = ''; + foreach ($this as $attribute => $value) { + if (substr( $attribute, 0, 2 ) == 'on') { + $events = 'if (' . $elementRef . ') leimnud.event.add(' . $elementRef . ',"' . substr( $attribute, 2 ) . '",function(){' . $value . '});' . "\n"; + } + } + } + + /** + * Function createXmlNode: Creates an Xml_Node object storing + * the data of $this Xml_Field. + * + * @author David S. Callizaya S. + * @access public + * @return Xml_Node + */ + public function createXmlNode ($includeDefaultValues = false) + { + /* Start Comment: Creates the corresponding XML Tag for $this + * object. + */ + $attributesList = $this->getXmlAttributes( $includeDefaultValues ); + $node = new Xml_Node( $this->name, 'open', $this->sql, $attributesList ); + /* End Comment */ + /* Start Comment: Creates the languages nodes and options + * if exist. + */ + $node->addChildNode( new Xml_Node( '', 'cdata', "\n" ) ); + $node->addChildNode( new Xml_Node( $this->language, 'open', $this->label ) ); + if (isset( $this->option )) { + foreach ($this->option as $k => $v) { + $node->children[1]->addChildNode( new Xml_Node( 'option', 'open', $v, array ('name' => $k + ) ) ); + } + } + /* End Comment */ + return $node; + } + + /** + * Function updateXmlNode: Updates and existing Xml_Node + * with the data of $this Xml_Field. + * + * @author David S. Callizaya S. + * @access public + * @param string value + * @return Xml_Node + */ + public function &updateXmlNode (&$node, $includeDefaultValues = false) + { + /* Start Comment: Modify the node's attributes and value. + */ + $attributesList = $this->getXmlAttributes( $includeDefaultValues ); + $node->name = $this->name; + $node->value = $this->sql; + $node->attributes = $attributesList; + /* End Comment */ + /* Start Comment: Modifies the languages nodes + */ + $langNode = & $node->findNode( $this->language ); + $langNode->value = $this->label; + if (isset( $this->option )) { + $langNode->children = array (); + foreach ($this->option as $k => $v) { + $langNode->addChildNode( new Xml_Node( 'option', 'open', $v, array ('name' => $k + ) ) ); + } + } + /* End Comment */ + return $node; + } + + /** + * Function getXmlAttributes: Returns an associative array + * with the attributes of $this Xml_field (only the modified ones). + * + * @author David S. Callizaya S. + * @access public + * @param boolean includeDefaultValues Includes attributes + * with default values. + * @return Xml_Node + */ + public function getXmlAttributes ($includeDefaultValues = false) + { + $attributesList = array (); + $class = get_class( $this ); + $default = new $class( new Xml_Node( 'DEFAULT', 'open', '', array ('type' => $this->type + ) ) ); + foreach ($this as $k => $v) { + switch ($k) { + case 'owner': + case 'name': + case 'type': + case 'language': + case 'sql': + break; + default: + if (($v !== $default->{$k}) || $includeDefaultValues) { + $attributesList[$k] = $v; + } + } + } + return $attributesList; + } + + /** + * Used in Form::validatePost + * + * @param $value + * @param &$owner + * @return $value + */ + public function maskValue ($value, &$owner) + { + return $value; + } + /*Close this object*/ + /** + * clone the current object + * + * @return + */ + public function cloneObject () + { + //return unserialize( serialize( $this ) );//con este cambio los formularios ya no funcionan en php4 + return clone ($this); + } + + /** + * get a value from a PM Table + * + * @param $oOwner + * @return $sValue + */ + public function getPMTableValue ($oOwner) + { + $sValue = ''; + if (isset( $oOwner->fields[$this->pmconnection] )) { + if (defined( 'PATH_CORE' )) { + if (file_exists( PATH_CORE . 'classes' . PATH_SEP . 'model' . PATH_SEP . 'AdditionalTables.php' )) { + require_once PATH_CORE . 'classes' . PATH_SEP . 'model' . PATH_SEP . 'AdditionalTables.php'; + $oAdditionalTables = new AdditionalTables(); + try { + $aData = $oAdditionalTables->load( $oOwner->fields[$this->pmconnection]->pmtable, true ); + } catch (Exception $oError) { + $aData = array ('FIELDS' => array ()); + } + $aKeys = array (); + $aValues = explode( '|', $oOwner->fields[$this->pmconnection]->keys ); + $i = 0; + foreach ($aData['FIELDS'] as $aField) { + if ($aField['FLD_KEY'] == '1') { + // note added by gustavo cruz gustavo[at]colosa[dot]com + // this additional [if] checks if a case variable has been set + // in the keys attribute, so it can be parsed and replaced for + // their respective value. + if (preg_match( "/@#/", $aValues[$i] )) { + // check if a case are running in order to prevent that preview is + // erroneous rendered. + if (isset( $_SESSION['APPLICATION'] )) { + G::LoadClass( 'case' ); + $oApp = new Cases(); + if ($oApp->loadCase( $_SESSION['APPLICATION'] ) != null) { + $aFields = $oApp->loadCase( $_SESSION['APPLICATION'] ); + $formVariable = substr( $aValues[$i], 2 ); + if (isset( $aFields['APP_DATA'][$formVariable] )) { + $formVariableValue = $aFields['APP_DATA'][$formVariable]; + $aKeys[$aField['FLD_NAME']] = (isset( $formVariableValue ) ? G::replaceDataField( $formVariableValue, $oOwner->values ) : ''); + } else { + $aKeys[$aField['FLD_NAME']] = ''; + } + } else { + $aKeys[$aField['FLD_NAME']] = ''; + } + } else { + $aKeys[$aField['FLD_NAME']] = ''; + } + } else { + $aKeys[$aField['FLD_NAME']] = (isset( $aValues[$i] ) ? G::replaceDataField( $aValues[$i], $oOwner->values ) : ''); + } + $i ++; + } + } + try { + $aData = $oAdditionalTables->getDataTable( $oOwner->fields[$this->pmconnection]->pmtable, $aKeys ); + } catch (Exception $oError) { + $aData = array (); + } + if (isset( $aData[$this->pmfield] )) { + $sValue = $aData[$this->pmfield]; + } + } + } + } + return $sValue; + } + + /** + * Prepares NS Required Value + * + * @author Enrique Ponce de Leon + * @param boolean optional (true = always show, false = show only if not empty) + * @return string + */ + + public function NSRequiredValue ($show = false) + { + if (isset( $this->required )) { + $req = ($this->required) ? '1' : '0'; + } else { + $req = '0'; + } + $idv = 'pm:required="' . $req . '"'; + if ($show) { + return $idv; + } else { + return ($req != '0') ? $idv : ''; + } + } + + /** + * Prepares NS Required Value + * + * @author Enrique Ponce de Leon + * @param boolean optional (true = always show, false = show only if not empty) + * @return string + */ + + public function NSGridLabel ($show = false) + { + $idv = 'pm:label="' . $this->pmLabel . '"'; + if ($show) { + return $idv; + } else { + return ($this->pmLabel != '') ? $idv : ''; + } + } + + /** + * Prepares NS Default Text + * + * @author Enrique Ponce de Leon + * @param boolean optional (true = always show, false = show only if not empty) + * @return string + */ + public function NSDefaultValue ($show = false) + { + $idv = 'pm:defaultvalue="' . $this->defaultValue . '"'; + if ($show) { + return $idv; + } else { + return ($this->defaultValue != '') ? $idv : ''; + } + } + + /** + * Prepares NS Grid Type + * + * @author Enrique Ponce de Leon + * @param boolean optional (true = always show, false = show only if not empty) + * @return string + */ + public function NSGridType ($show = false) + { + $igt = 'pm:gridtype="' . $this->gridFieldType . '"'; + if ($show) { + return $igt; + } else { + return ($this->gridFieldType != '') ? $igt : ''; + } + } + + /** + * Prepares NS Grid Type + * + * @author Enrique Ponce de Leon + * @param boolean optional (true = always show, false = show only if not empty) + * @return string + */ + public function NSDependentFields ($show = false) + { + $idf = 'pm:dependent="' . (($this->dependentFields != '') ? '1' : '0') . '"'; + if ($show) { + return $idf; + } else { + return ($this->dependentFields != '') ? $idf : ''; + } + } + + /** + * Prepares Hint HTML if hint value is defined + * + * @author Enrique Ponce de Leon + * @param void + * @return string + * + */ + + public function renderHint () + { + $_outHint = ''; + if ($this->hint != '' && $this->mode == 'edit') { + $_outHint = ' '; + } + return $_outHint; } - return $_outHint; - } - } + /** * Class XmlForm_Field_Title + * * @author David S. Callizaya S. * @package gulliver.system * @access public */ class XmlForm_Field_Title extends XmlForm_Field { - /** - * Function render - * @author David S. Callizaya S. - * @access public - * @param string value - * @return string - */ - function render($value = NULL, &$owner) { - $this->label = G::replaceDataField ( $this->label, $owner->values ); - return 'name . ']\' name=\'form[' . $this->name . ']\' >' . $this->htmlentities ( $this->label ) . ''; - } - /** - * A title node has no value - * @param $value - * @return false - */ - function validateValue($value) { - return false; - } + + /** + * Function render + * + * @author David S. Callizaya S. + * @access public + * @param string value + * @return string + */ + public function render ($value = null, &$owner = null) + { + $this->label = G::replaceDataField( $this->label, $owner->values ); + return 'name . ']\' name=\'form[' . $this->name . ']\' >' . $this->htmlentities( $this->label ) . ''; + } + + /** + * A title node has no value + * + * @param $value + * @return false + */ + public function validateValue ($value) + { + return false; + } } + /** * Class XmlForm_Field_Subtitle + * * @author David S. Callizaya S. * @package gulliver.system * @access public */ class XmlForm_Field_Subtitle extends XmlForm_Field { - /** - * Function render - * @author David S. Callizaya S. - * @access public - * @param string value - * @return string - */ - function render($value = NULL) - { - return 'name . ']\' name=\'form[' . $this->name . ']\' >' . $this->htmlentities ( $this->label ) . ''; - } - /** - * A subtitle node has no value - * @param $value - * @return false - */ - function validateValue($value) - { - return false; - } + + /** + * Function render + * + * @author David S. Callizaya S. + * @access public + * @param string value + * @return string + */ + public function render ($value = null) + { + return 'name . ']\' name=\'form[' . $this->name . ']\' >' . $this->htmlentities( $this->label ) . ''; + } + + /** + * A subtitle node has no value + * + * @param $value + * @return false + */ + public function validateValue ($value) + { + return false; + } } + /** * Class XmlForm_Field_SimpleText + * * @author David S. Callizaya S. * @package gulliver.system * @access public */ class XmlForm_Field_SimpleText extends XmlForm_Field { - var $size = 15; - var $maxLength = ''; - var $validate = 'Any'; - var $mask = ''; - /* Additional events */ - var $onkeypress = ''; - var $renderMode = ''; - /** - * Function render - * @author David S. Callizaya S. - * @access public - * @param string value - * @return string - */ - function render($value = NULL, &$owner) - { - if (($this->pmconnection != '') && ($this->pmfield != '') && $value == NULL) { - $value = $this->getPMTableValue($owner); - } - $onkeypress = G::replaceDataField ( $this->onkeypress, $owner->values ); - if ($this->mode === 'edit') { - if ($this->readOnly) - return 'maxLength ) ? ' maxlength="' . $this->maxLength . '"' : '') . ' value=\'' . htmlentities ( $value, ENT_COMPAT, 'utf-8' ) . '\' '.$this->NSRequiredValue().' readOnly="readOnly" style="' . htmlentities ( $this->style, ENT_COMPAT, 'utf-8' ) . '" onkeypress="' . htmlentities ( $onkeypress, ENT_COMPAT, 'utf-8' ) . '"/>'; - else - return 'maxLength ) ? ' maxlength="' . $this->maxLength . '"' : '') . ' value=\'' . htmlentities ( $value, ENT_COMPAT, 'utf-8' ) . '\' '.$this->NSRequiredValue().' style="' . htmlentities ( $this->style, ENT_COMPAT, 'utf-8' ) . '" onkeypress="' . htmlentities ( $onkeypress, ENT_COMPAT, 'utf-8' ) . '"/>'; - } elseif ($this->mode === 'view') { - return 'maxLength ) ? ' maxlength="' . $this->maxLength . '"' : '') . ' value=\'' . htmlentities ( $value, ENT_COMPAT, 'utf-8' ) . '\' '.$this->NSRequiredValue().' style="display:none;' . htmlentities ( $this->style, ENT_COMPAT, 'utf-8' ) . '" onkeypress="' . htmlentities ( $onkeypress, ENT_COMPAT, 'utf-8' ) . '"/>' . htmlentities ( $value, ENT_COMPAT, 'utf-8' ); - } else { - return $this->htmlentities ( $value, ENT_COMPAT, 'utf-8' ); - } - } - /** - * Function renderGrid - * @author David S. Callizaya S. - * @access public - * @param string values - * @param string owner - * @return string - */ - function renderGrid($values = array(), $owner) - { - $result = array (); - $r = 1; - if ($owner->mode != 'view') $this->renderMode = $this->modeForGrid; + public $size = 15; + public $maxLength = ''; + public $validate = 'Any'; + public $mask = ''; + /* Additional events */ + public $onkeypress = ''; + public $renderMode = ''; - foreach ( $values as $v ) { - $html = ''; - if ($this->renderMode === 'edit'){ //EDIT MODE - $readOnlyText = ($this->readOnly == 1 || $this->readOnly == '1') ? 'readOnly="readOnly"' : ''; - $html .= 'name.']['.$r.']['.$this->name.']" '; - $html .= 'name="form['.$owner->name.']['.$r.']['.$this->name.']" '; - $html .= 'type="text" size="'.$this->size.'" maxlength="'.$this->maxLength.'" '; - $html .= 'value="'.$this->htmlentities($v, ENT_QUOTES, 'utf-8').'" '; - $html .= 'style="'.$this->htmlentities($this->style, ENT_COMPAT, 'utf-8').'" '; - $html .= $this->NSDefaultValue().' '; - $html .= $this->NSRequiredValue().' '; - $html .= $this->NSGridType().' '; - $html .= $this->NSGridLabel().' '; - $html .= '/>'; - }else{ //VIEW MODE - $html .= $this->htmlentities($v, ENT_QUOTES, 'utf-8'); - $html .= 'name.']['.$r.']['.$this->name.']" '; - $html .= 'name="form['.$owner->name.']['.$r.']['.$this->name.']" '; - $html .= 'type="hidden" value="'.$this->htmlentities($v, ENT_QUOTES, 'utf-8').'" />'; - } - $result [] = $html; - $r ++; + /** + * Function render + * + * @author David S. Callizaya S. + * @access public + * @param string value + * @return string + */ + public function render ($value = null, &$owner = null) + { + if (($this->pmconnection != '') && ($this->pmfield != '') && $value == null) { + $value = $this->getPMTableValue( $owner ); + } + $onkeypress = G::replaceDataField( $this->onkeypress, $owner->values ); + if ($this->mode === 'edit') { + if ($this->readOnly) { + return 'maxLength ) ? ' maxlength="' . $this->maxLength . '"' : '') . ' value=\'' . htmlentities( $value, ENT_COMPAT, 'utf-8' ) . '\' ' . $this->NSRequiredValue() . ' readOnly="readOnly" style="' . htmlentities( $this->style, ENT_COMPAT, 'utf-8' ) . '" onkeypress="' . htmlentities( $onkeypress, ENT_COMPAT, 'utf-8' ) . '"/>'; + } else { + return 'maxLength ) ? ' maxlength="' . $this->maxLength . '"' : '') . ' value=\'' . htmlentities( $value, ENT_COMPAT, 'utf-8' ) . '\' ' . $this->NSRequiredValue() . ' style="' . htmlentities( $this->style, ENT_COMPAT, 'utf-8' ) . '" onkeypress="' . htmlentities( $onkeypress, ENT_COMPAT, 'utf-8' ) . '"/>'; + } + } elseif ($this->mode === 'view') { + return 'maxLength ) ? ' maxlength="' . $this->maxLength . '"' : '') . ' value=\'' . htmlentities( $value, ENT_COMPAT, 'utf-8' ) . '\' ' . $this->NSRequiredValue() . ' style="display:none;' . htmlentities( $this->style, ENT_COMPAT, 'utf-8' ) . '" onkeypress="' . htmlentities( $onkeypress, ENT_COMPAT, 'utf-8' ) . '"/>' . htmlentities( $value, ENT_COMPAT, 'utf-8' ); + } else { + return $this->htmlentities( $value, ENT_COMPAT, 'utf-8' ); + } + } + + /** + * Function renderGrid + * + * @author David S. Callizaya S. + * @access public + * @param string values + * @param string owner + * @return string + */ + public function renderGrid ($values = array(), $owner = null) + { + $result = array (); + $r = 1; + if ($owner->mode != 'view') { + $this->renderMode = $this->modeForGrid; + } + + foreach ($values as $v) { + $html = ''; + if ($this->renderMode === 'edit') { + //EDIT MODE + $readOnlyText = ($this->readOnly == 1 || $this->readOnly == '1') ? 'readOnly="readOnly"' : ''; + $html .= 'name . '][' . $r . '][' . $this->name . ']" '; + $html .= 'name="form[' . $owner->name . '][' . $r . '][' . $this->name . ']" '; + $html .= 'type="text" size="' . $this->size . '" maxlength="' . $this->maxLength . '" '; + $html .= 'value="' . $this->htmlentities( $v, ENT_QUOTES, 'utf-8' ) . '" '; + $html .= 'style="' . $this->htmlentities( $this->style, ENT_COMPAT, 'utf-8' ) . '" '; + $html .= $this->NSDefaultValue() . ' '; + $html .= $this->NSRequiredValue() . ' '; + $html .= $this->NSGridType() . ' '; + $html .= $this->NSGridLabel() . ' '; + $html .= '/>'; + } else { + //VIEW MODE + $html .= $this->htmlentities( $v, ENT_QUOTES, 'utf-8' ); + $html .= 'name . '][' . $r . '][' . $this->name . ']" '; + $html .= 'name="form[' . $owner->name . '][' . $r . '][' . $this->name . ']" '; + $html .= 'type="hidden" value="' . $this->htmlentities( $v, ENT_QUOTES, 'utf-8' ) . '" />'; + } + $result[] = $html; + $r ++; + } + return $result; } - return $result; - } } + /** * Class XmlForm_Field_Text + * * @author David S. Callizaya S. * @package gulliver.system * @access public */ class XmlForm_Field_Text extends XmlForm_Field_SimpleText { - var $size = 15; - var $maxLength = 64; - var $validate = 'Any'; - var $mask = ''; - var $defaultValue = ''; - var $required = false; - var $dependentFields = ''; - var $linkField = ''; - //Possible values:(-|UPPER|LOWER|CAPITALIZE) - var $strTo = ''; - var $readOnly = false; - var $sqlConnection = 0; - var $sql = ''; - var $sqlOption = array (); - //Attributes only for grids - var $formula = ''; - var $function = ''; - var $replaceTags = 0; - var $renderMode = ''; - var $comma_separator = '.'; + public $size = 15; + public $maxLength = 64; + public $validate = 'Any'; + public $mask = ''; + public $defaultValue = ''; + public $required = false; + public $dependentFields = ''; + public $linkField = ''; + //Possible values:(-|UPPER|LOWER|CAPITALIZE) + public $strTo = ''; + public $readOnly = false; + public $sqlConnection = 0; + public $sql = ''; + public $sqlOption = array (); + //Attributes only for grids + public $formula = ''; + public $function = ''; + public $replaceTags = 0; + public $renderMode = ''; + public $comma_separator = '.'; + /** + * Function render + * + * @author David S. Callizaya S. + * @access public + * @param string value + * @param string owner + * @return string + */ + public function render ($value = null, $owner = null) + { + if ($this->renderMode == '') { + $this->renderMode = $this->mode; + } + if (($this->pmconnection != '') && ($this->pmfield != '') && $value == null) { + $value = $this->getPMTableValue( $owner ); + } else { + $this->executeSQL( $owner ); + $firstElement = key( $this->sqlOption ); + if (isset( $firstElement )) { + $value = $firstElement; + } + } - /** - * Function render - * @author David S. Callizaya S. - * @access public - * @param string value - * @param string owner - * @return string - */ - function render($value = NULL, $owner = NULL) - { - if ($this->renderMode =='') $this->renderMode = $this->mode; - if (($this->pmconnection != '') && ($this->pmfield != '') && $value == NULL) { - $value = $this->getPMTableValue($owner); - } - else { - $this->executeSQL ( $owner ); - $firstElement = key ( $this->sqlOption ); - if (isset ( $firstElement )) - $value = $firstElement; + //NOTE: string functions must be in G class + if ($this->strTo === 'UPPER') { + $value = strtoupper( $value ); + } + if ($this->strTo === 'LOWER') { + $value = strtolower( $value ); + } + //if ($this->strTo==='CAPITALIZE') $value = strtocapitalize($value); + $onkeypress = G::replaceDataField( $this->onkeypress, $owner->values ); + if ($this->replaceTags == 1) { + $value = G::replaceDataField( $value, $owner->values ); + } + + $html = ''; + if ($this->renderMode == 'edit') { + //EDIT MODE + $readOnlyText = ($this->readOnly == 1 || $this->readOnly == '1') ? 'readOnly="readOnly"' : ''; + $html .= 'name . ']" '; + $html .= 'name="form[' . $this->name . ']" '; + $html .= 'type="text" size="' . $this->size . '" maxlength="' . $this->maxLength . '" '; + $html .= 'value="' . $this->htmlentities( $value, ENT_QUOTES, 'utf-8' ) . '" '; + $html .= 'style="' . $this->htmlentities( $this->style, ENT_COMPAT, 'utf-8' ) . '" '; + $html .= 'onkeypress="' . $this->htmlentities( $onkeypress, ENT_COMPAT, 'utf-8' ) . '" '; + $html .= $this->NSDefaultValue() . ' '; + $html .= $this->NSRequiredValue() . ' '; + $html .= 'pm:decimal_separator="' . $this->comma_separator . '" '; + $html .= '/>'; + } else { + //VIEW MODE + $html .= $this->htmlentities( $value, ENT_QUOTES, 'utf-8' ); + $html .= 'name . ']" '; + $html .= 'name="form[' . $this->name . ']" '; + $html .= 'type="hidden" value="' . $this->htmlentities( $value, ENT_QUOTES, 'utf-8' ) . '" />'; + } + + $html .= $this->renderHint(); + if (($this->readOnly == 1) && ($this->renderMode == 'edit')) { + $html = str_replace( "class=\"module_app_input___gray\"", "class=\"module_app_input___gray_readOnly\"", $html ); + } + + return $html; } - //NOTE: string functions must be in G class - if ($this->strTo === 'UPPER') $value = strtoupper ( $value ); - if ($this->strTo === 'LOWER') $value = strtolower ( $value ); - //if ($this->strTo==='CAPITALIZE') $value = strtocapitalize($value); - $onkeypress = G::replaceDataField ( $this->onkeypress, $owner->values ); - if ($this->replaceTags == 1) { - $value = G::replaceDataField ( $value, $owner->values ); + /** + * Function renderGrid + * + * @author David S. Callizaya S. + * @access public + * @param string values + * @param string owner + * @return string + */ + public function renderGrid ($values = array(), $owner = null) + { + $result = $aux = array (); + $r = 1; + if ($owner->mode != 'view') { + $this->renderMode = $this->modeForGrid; + } + + foreach ($values as $v) { + $this->executeSQL( $owner, $r ); + $firstElement = key( $this->sqlOption ); + if (isset( $firstElement )) { + $v = $firstElement; + } + if ($this->replaceTags == 1) { + $v = G::replaceDataField( $v, $owner->values ); + } + $aux[$r] = $v; + + $html = ''; + if ($this->renderMode == 'edit') { + //EDIT MODE + $readOnlyText = ($this->readOnly == 1 || $this->readOnly == '1') ? 'readOnly="readOnly"' : ''; + $html .= 'name . '][' . $r . '][' . $this->name . ']" '; + $html .= 'name="form[' . $owner->name . '][' . $r . '][' . $this->name . ']" '; + $html .= 'type="text" size="' . $this->size . '" maxlength="' . $this->maxLength . '" '; + $html .= 'value="' . $this->htmlentities( $v, ENT_QUOTES, 'utf-8' ) . '" '; + $html .= 'style="' . $this->htmlentities( $this->style, ENT_COMPAT, 'utf-8' ) . '" '; + $html .= $this->NSDefaultValue() . ' '; + $html .= $this->NSRequiredValue() . ' '; + $html .= $this->NSGridLabel() . ' '; + $html .= $this->NSGridType() . ' '; + $html .= $this->NSDependentFields() . ' '; + $html .= '/>'; + } else { + //VIEW MODE + $html .= $this->htmlentities( $v, ENT_QUOTES, 'utf-8' ); + $html .= 'name . '][' . $r . '][' . $this->name . ']" '; + $html .= 'name="form[' . $owner->name . '][' . $r . '][' . $this->name . ']" '; + $html .= $this->NSDefaultValue() . ' '; + $html .= 'type="hidden" value="' . $this->htmlentities( $v, ENT_QUOTES, 'utf-8' ) . '" />'; + } + + $result[] = $html; + $r ++; + } + $this->options = $aux; + return $result; } - $html = ''; - if ($this->renderMode == 'edit'){ //EDIT MODE - $readOnlyText = ($this->readOnly == 1 || $this->readOnly == '1') ? 'readOnly="readOnly"': ''; - $html .= 'name . ']" '; - $html .= 'name="form[' . $this->name . ']" '; - $html .= 'type="text" size="' . $this->size . '" maxlength="' . $this->maxLength . '" '; - $html .= 'value="'.$this->htmlentities ($value, ENT_QUOTES, 'utf-8').'" '; - $html .= 'style="'.$this->htmlentities($this->style, ENT_COMPAT, 'utf-8').'" '; - $html .= 'onkeypress="'.$this->htmlentities($onkeypress, ENT_COMPAT, 'utf-8').'" '; - $html .= $this->NSDefaultValue().' '; - $html .= $this->NSRequiredValue().' '; - $html .= 'pm:decimal_separator="' . $this->comma_separator . '" '; - $html .= '/>'; - }else{ //VIEW MODE - $html .= $this->htmlentities($value, ENT_QUOTES, 'utf-8'); - $html .= 'name . ']" '; - $html .= 'name="form[' . $this->name . ']" '; - $html .= 'type="hidden" value="'.$this->htmlentities($value, ENT_QUOTES, 'utf-8').'" />'; + public function renderTable ($values = '', $owner = null) + { + $result = $this->htmlentities( $values, ENT_COMPAT, 'utf-8' ); + return $result; } - - $html .= $this->renderHint(); - if (($this->readOnly == 1)&&($this->renderMode == 'edit')) - $html = str_replace("class=\"module_app_input___gray\"","class=\"module_app_input___gray_readOnly\"",$html); - - return $html; - } - - /** - * Function renderGrid - * @author David S. Callizaya S. - * @access public - * @param string values - * @param string owner - * @return string - */ - function renderGrid($values = array(), $owner) - { - $result = $aux = array (); - $r = 1; - if ($owner->mode != 'view') $this->renderMode = $this->modeForGrid; - - foreach ( $values as $v ) { - $this->executeSQL ( $owner, $r ); - $firstElement = key ( $this->sqlOption ); - if (isset ( $firstElement )) - $v = $firstElement; - if ($this->replaceTags == 1) { - $v = G::replaceDataField ( $v, $owner->values ); - } - $aux [$r] = $v; - - $html = ''; - if ($this->renderMode == 'edit'){ //EDIT MODE - $readOnlyText = ($this->readOnly == 1 || $this->readOnly == '1') ? 'readOnly="readOnly"': ''; - $html .= 'name.']['.$r.']['.$this->name.']" '; - $html .= 'name="form['.$owner->name.']['.$r.']['.$this->name.']" '; - $html .= 'type="text" size="' . $this->size . '" maxlength="' . $this->maxLength . '" '; - $html .= 'value="'.$this->htmlentities ($v, ENT_QUOTES, 'utf-8').'" '; - $html .= 'style="'.$this->htmlentities($this->style, ENT_COMPAT, 'utf-8').'" '; - $html .= $this->NSDefaultValue().' '; - $html .= $this->NSRequiredValue().' '; - $html .= $this->NSGridLabel().' '; - $html .= $this->NSGridType().' '; - $html .= $this->NSDependentFields().' '; - $html .= '/>'; - }else{ //VIEW MODE - $html .= $this->htmlentities($v, ENT_QUOTES, 'utf-8'); - $html .= 'name.']['.$r.']['.$this->name.']" '; - $html .= 'name="form['.$owner->name.']['.$r.']['.$this->name.']" '; - $html .= $this->NSDefaultValue().' '; - $html .= 'type="hidden" value="'.$this->htmlentities($v, ENT_QUOTES, 'utf-8').'" />'; - } - - $result [] = $html; - $r ++; - } - $this->options = $aux; - return $result; - } - - function renderTable($values = '', $owner) { - $result = $this->htmlentities ( $values, ENT_COMPAT, 'utf-8' ); - return $result; - } - } /** * Class XmlForm_Field_Suggest + * * @author Erik Amaru Ortiz * @package gulliver.system * @access public */ class XmlForm_Field_Suggest extends XmlForm_Field_SimpleText //by neyek { - var $size = 15; - var $maxLength = 64; - var $validate = 'Any'; - var $mask = ''; - var $defaultValue = ''; - var $required = false; - var $dependentFields = ''; - var $linkField = ''; - //Possible values:(-|UPPER|LOWER|CAPITALIZE) - var $strTo = ''; - var $readOnly = false; - var $sqlConnection = 0; - var $sql = ''; - var $sqlOption = array (); - //Atributes only for grids - var $formula = ''; - var $function = ''; - var $replaceTags = 0; + public $size = 15; + public $maxLength = 64; + public $validate = 'Any'; + public $mask = ''; + public $defaultValue = ''; + public $required = false; + public $dependentFields = ''; + public $linkField = ''; + //Possible values:(-|UPPER|LOWER|CAPITALIZE) + public $strTo = ''; + public $readOnly = false; + public $sqlConnection = 0; + public $sql = ''; + public $sqlOption = array (); + //Atributes only for grids + public $formula = ''; + public $function = ''; + public $replaceTags = 0; - var $ajaxServer = '../gulliver/genericAjax'; - var $maxresults = '6'; - var $savelabel = 1; - var $shownoresults; - var $callback = ''; + public $ajaxServer = '../gulliver/genericAjax'; + public $maxresults = '6'; + public $savelabel = 1; + public $shownoresults; + public $callback = ''; - var $store_new_entry = ''; - var $table = ''; - var $table_data = ''; - var $primary_key = ''; - var $primary_key_data = ''; - var $primary_key_type = ''; - var $primary_key_type_data = ''; + public $store_new_entry = ''; + public $table = ''; + public $table_data = ''; + public $primary_key = ''; + public $primary_key_data = ''; + public $primary_key_type = ''; + public $primary_key_type_data = ''; - var $field = ''; + public $field = ''; + /** + * Function render + * + * @author Erik A. Ortiz. + * @param $value + * @param $owner + * @return + */ + public function render ($value = null, $owner = null) + { - /** - * Function render - * @author Erik A. Ortiz. - * @param $value - * @param $owner - * @return - */ - function render($value = NULL, $owner = NULL) - { - - - if (! $this->sqlConnection) - $this->sqlConnection = 'workflow'; - - //NOTE: string functions must be in G class - if ($this->strTo === 'UPPER') - $value = strtoupper ( $value ); - if ($this->strTo === 'LOWER') - $value = strtolower ( $value ); - //if ($this->strTo==='CAPITALIZE') $value = strtocapitalize($value); - $onkeypress = G::replaceDataField ( $this->onkeypress, $owner->values ); - - if ($this->replaceTags == 1) { - $value = G::replaceDataField ( $value, $owner->values ); - } - - $aProperties = Array( - 'value' =>'""', - 'size' => '"'.$this->size.'"', - ); - - $storeEntry = null; - $storeEntryData = ", storeEntryData: [0]"; - - if ($this->store_new_entry) { - $storeEntry = ' title="' . G::LoadTranslation("ID_FIELD_DYNAFORM_SUGGEST_INPUT_TITLE") . '"'; - $storeEntryData = ", storeEntryData: [1, \"form[". $this->name . "_label]\", \"" . $this->sqlConnection . "\", \"" . $this->table . "\", \"" . $this->primary_key . "\", \"" . $this->primary_key_type . "\", \"" . $this->field . "\"]"; - } - - $formVariableValue = ''; - $formVariableKeyValue = ''; - G::LoadClass('case'); - $oApp= new Cases(); - if (isset($_SESSION['APPLICATION']) && ($_SESSION['APPLICATION'] != null && $oApp->loadCase($_SESSION['APPLICATION'])!=null) ) { - $aFields = $oApp->loadCase($_SESSION['APPLICATION']); - if(isset($aFields['APP_DATA'][$this->name . '_label'])){ - $formVariableValue = $aFields['APP_DATA'][$this->name . '_label']; - $formVariableKeyValue = $aFields['APP_DATA'][$this->name]; - } - } - - if ($this->mode === 'edit') { - if ($this->readOnly) { - return 'htmlentities ( $value, ENT_COMPAT, 'utf-8' ) . '\' readOnly="readOnly" style="' . htmlentities ( $this->style, ENT_COMPAT, 'utf-8' ) . '" onkeypress="' . htmlentities ( $onkeypress, ENT_COMPAT, 'utf-8' ) . '"/>'; - } else { -// $str = ''; - if(strlen(trim($formVariableValue))>0) { - $value = $formVariableValue; - } - $name = "'".$this->name."'"; - $str = 'NSDependentFields(true).' '; - $str .= '/>'; - $str .= 'name . ']" '; - $str .= 'name="form[' . $this->name . ']" '; - $str .= 'value="' . $this->htmlentities ( $formVariableKeyValue, ENT_COMPAT, 'utf-8' ) . '" ' ; - $str .= 'type="hidden" />'; - - $str .= $this->renderHint(); - if( trim($this->callback) != '' ) { - $sCallBack = 'try{'.$this->callback.'}catch(e){alert("Suggest Widget call back error: "+e)}'; - } else { - $sCallBack = ''; + if (! $this->sqlConnection) { + $this->sqlConnection = 'workflow'; } - $hash = str_rot13(base64_encode($this->sql.'@|'.$this->sqlConnection)); -// $sOptions = 'script:"'.$this->ajaxServer.'?request=suggest&json=true&limit='.$this->maxresults.'&hash='.$hash.'&dependentFields='. $this->dependentFields .'&field=" + getField(\''. $this->name .'\').value + "&",'; - $sSQL = $this->sql; - $nCount = preg_match_all('/\@(?:([\@\%\#\!Qq])([a-zA-Z\_]\w*)|([a-zA-Z\_][\w\-\>\:]*)\(((?:[^\\\\\)]*?)*)\))/', $sSQL, $match, PREG_PATTERN_ORDER | PREG_OFFSET_CAPTURE); + //NOTE: string functions must be in G class + if ($this->strTo === 'UPPER') { + $value = strtoupper( $value ); + } + if ($this->strTo === 'LOWER') { + $value = strtolower( $value ); + } + //if ($this->strTo==='CAPITALIZE') $value = strtocapitalize($value); + $onkeypress = G::replaceDataField( $this->onkeypress, $owner->values ); - $sResult = array(); - if($nCount){ - for($i=0; $i<$nCount; $i++){ - if (isset($match[0][$i][0]) && isset($match[2][$i][0])) { - $aResult[$match[0][$i][0]] = $match[2][$i][0]; + if ($this->replaceTags == 1) { + $value = G::replaceDataField( $value, $owner->values ); + } + + $aProperties = Array ('value' => '""','size' => '"' . $this->size . '"'); + + $storeEntry = null; + $storeEntryData = ", storeEntryData: [0]"; + + if ($this->store_new_entry) { + $storeEntry = ' title="' . G::LoadTranslation( "ID_FIELD_DYNAFORM_SUGGEST_INPUT_TITLE" ) . '"'; + $storeEntryData = ", storeEntryData: [1, \"form[" . $this->name . "_label]\", \"" . $this->sqlConnection . "\", \"" . $this->table . "\", \"" . $this->primary_key . "\", \"" . $this->primary_key_type . "\", \"" . $this->field . "\"]"; + } + + $formVariableValue = ''; + $formVariableKeyValue = ''; + G::LoadClass( 'case' ); + $oApp = new Cases(); + if (isset( $_SESSION['APPLICATION'] ) && ($_SESSION['APPLICATION'] != null && $oApp->loadCase( $_SESSION['APPLICATION'] ) != null)) { + $aFields = $oApp->loadCase( $_SESSION['APPLICATION'] ); + if (isset( $aFields['APP_DATA'][$this->name . '_label'] )) { + $formVariableValue = $aFields['APP_DATA'][$this->name . '_label']; + $formVariableKeyValue = $aFields['APP_DATA'][$this->name]; } - } } - $depValues = ''; - $i = 1; - if(isset($aResult) && $aResult ) { - $sResult = '"' . implode('","', $aResult) . '"'; - $aResultKeys = array_keys($aResult); - $sResultKeys = str_rot13(base64_encode(implode('|', $aResultKeys))); - - foreach($aResult as $key=>$field) { - $depValues .= 'getField(\''.$field.'\').value'; - if($i++dependentFields !== '') { - $dependentFields = explode(",",$this->dependentFields); - foreach ($dependentFields as $keyDependent => $valueDependent) { - $sqlDepField = $owner->fields[$valueDependent]->sql; - $count = preg_match_all('/\@(?:([\@\%\#\=\!Qq])([a-zA-Z\_]\w*)|([a-zA-Z\_][\w\-\>\:]*)\(((?:[^\\\\\)]*?)*)\))/', - $sqlDepField, $match, PREG_PATTERN_ORDER | PREG_OFFSET_CAPTURE); - for ($cnt = 0; $cnt < $count; $cnt++) { - $aDepFields[$cnt] = $match[2][$cnt][0]; + if ($this->mode === 'edit') { + if ($this->readOnly) { + return 'htmlentities( $value, ENT_COMPAT, 'utf-8' ) . '\' readOnly="readOnly" style="' . htmlentities( $this->style, ENT_COMPAT, 'utf-8' ) . '" onkeypress="' . htmlentities( $onkeypress, ENT_COMPAT, 'utf-8' ) . '"/>'; + } else { + // $str = ''; + if (strlen( trim( $formVariableValue ) ) > 0) { + $value = $formVariableValue; } - } - } + $name = "'" . $this->name . "'"; + $str = 'NSDependentFields( true ) . ' '; + $str .= '/>'; + $str .= 'name . ']" '; + $str .= 'name="form[' . $this->name . ']" '; + $str .= 'value="' . $this->htmlentities( $formVariableKeyValue, ENT_COMPAT, 'utf-8' ) . '" '; + $str .= 'type="hidden" />'; - $sOptions = 'script: function (input) { '; - $sOptions .= ' var inputValue = base64_encode(getField(\''. $this->name .'_label\').value); '; + $str .= $this->renderHint(); + if (trim( $this->callback ) != '') { + $sCallBack = 'try{' . $this->callback . '}catch(e){alert("Suggest Widget call back error: "+e)}'; + } else { + $sCallBack = ''; + } - $sOptions .= ' return "' . $this->ajaxServer . '?request=suggest&json=true&limit=' . $this->maxresults ; - $sOptions .= '&hash=' . $hash . '&dependentFieldsKeys=' . $sResultKeys . '&dependentFieldsValue="'; - $sOptions .= $depValues . '"&input="+inputValue+"&inputEnconde64=enable"; '; - $sOptions .= '},'; - $sOptions .= 'json: true,'; - $sOptions .= 'limit: '.$this->maxresults.','; + $hash = str_rot13( base64_encode( $this->sql . '@|' . $this->sqlConnection ) ); + // $sOptions = 'script:"'.$this->ajaxServer.'?request=suggest&json=true&limit='.$this->maxresults.'&hash='.$hash.'&dependentFields='. $this->dependentFields .'&field=" + getField(\''. $this->name .'\').value + "&",'; + $sSQL = $this->sql; + $nCount = preg_match_all( '/\@(?:([\@\%\#\!Qq])([a-zA-Z\_]\w*)|([a-zA-Z\_][\w\-\>\:]*)\(((?:[^\\\\\)]*?)*)\))/', $sSQL, $match, PREG_PATTERN_ORDER | PREG_OFFSET_CAPTURE ); - $sOptions .= 'shownoresults: ' . ($this->shownoresults ? 'true' : 'false') . ','; - $sOptions .= 'maxresults: '.$this->maxresults.','; - $sOptions .= 'chache: true,'; + $sResult = array (); + if ($nCount) { + for ($i = 0; $i < $nCount; $i ++) { + if (isset( $match[0][$i][0] ) && isset( $match[2][$i][0] )) { + $aResult[$match[0][$i][0]] = $match[2][$i][0]; + } + } + } - $setValue = ($this->savelabel == '1') ? 'obj.value' : 'obj.id'; + $depValues = ''; + $i = 1; + if (isset( $aResult ) && $aResult) { + $sResult = '"' . implode( '","', $aResult ) . '"'; + $aResultKeys = array_keys( $aResult ); + $sResultKeys = str_rot13( base64_encode( implode( '|', $aResultKeys ) ) ); - $sOptions .= 'callback: function (obj) { '; - $sOptions .= 'if (typeof obj != "undefined") { '; - $sOptions .= ' var jField = { };'; - $sOptions .= ' var sField = "[]"; '; + foreach ($aResult as $key => $field) { + $depValues .= 'getField(\'' . $field . '\').value'; + if ($i ++ < count( $aResult )) { + $depValues .= '+"|"+'; + } - if ($count > 0) { - for ($cnt = 0; $cnt < $count; $cnt++ ) { - $sOptions .= 'if ( "' . $this->name . '" == "' . $aDepFields[$cnt] . '" ) {'; - $sOptions .= ' jField[\'' . $aDepFields[$cnt] . '\'] = obj.id;'; + } + $depValues = '+' . $depValues . '+'; + } else { + $sResult = ''; + $sResultKeys = ''; + $depValues = '+'; + } + + $aDepFields = array (); + $count = 0; + if ($this->dependentFields !== '') { + $dependentFields = explode( ",", $this->dependentFields ); + foreach ($dependentFields as $keyDependent => $valueDependent) { + $sqlDepField = $owner->fields[$valueDependent]->sql; + $count = preg_match_all( '/\@(?:([\@\%\#\=\!Qq])([a-zA-Z\_]\w*)|([a-zA-Z\_][\w\-\>\:]*)\(((?:[^\\\\\)]*?)*)\))/', $sqlDepField, $match, PREG_PATTERN_ORDER | PREG_OFFSET_CAPTURE ); + for ($cnt = 0; $cnt < $count; $cnt ++) { + $aDepFields[$cnt] = $match[2][$cnt][0]; + } + } + } + + $sOptions = 'script: function (input) { '; + $sOptions .= ' var inputValue = base64_encode(getField(\'' . $this->name . '_label\').value); '; + + $sOptions .= ' return "' . $this->ajaxServer . '?request=suggest&json=true&limit=' . $this->maxresults; + $sOptions .= '&hash=' . $hash . '&dependentFieldsKeys=' . $sResultKeys . '&dependentFieldsValue="'; + $sOptions .= $depValues . '"&input="+inputValue+"&inputEnconde64=enable"; '; + $sOptions .= '},'; + $sOptions .= 'json: true,'; + $sOptions .= 'limit: ' . $this->maxresults . ','; + + $sOptions .= 'shownoresults: ' . ($this->shownoresults ? 'true' : 'false') . ','; + $sOptions .= 'maxresults: ' . $this->maxresults . ','; + $sOptions .= 'chache: true,'; + + $setValue = ($this->savelabel == '1') ? 'obj.value' : 'obj.id'; + + $sOptions .= 'callback: function (obj) { '; + $sOptions .= 'if (typeof obj != "undefined") { '; + $sOptions .= ' var jField = { };'; + $sOptions .= ' var sField = "[]"; '; + + if ($count > 0) { + for ($cnt = 0; $cnt < $count; $cnt ++) { + $sOptions .= 'if ( "' . $this->name . '" == "' . $aDepFields[$cnt] . '" ) {'; + $sOptions .= ' jField[\'' . $aDepFields[$cnt] . '\'] = obj.id;'; + $sOptions .= '} else { '; + $sOptions .= ' jField[\'' . $aDepFields[$cnt] . '\'] = getField(\'' . $aDepFields[$cnt] . '\').value; '; + $sOptions .= '}'; + } + } + + $sOptions .= ' var sField = "["+ encodeURIComponent(jField.toJSONString()) + "]"; '; + + $sOptions .= $sCallBack . '; getField("' . $this->name . '").value = obj.id;'; + $sOptions .= 'var response = ajax_function("../gulliver/defaultAjaxDynaform", "reloadField", '; + $sOptions .= ' "form=' . $owner->id . '&fields=" + sField, "POST"); '; + + $sOptions .= 'if (response.substr(0,1) === \'[\') { '; + $sOptions .= ' var newcont; '; + $sOptions .= ' eval(\'newcont=\' + response + \';\'); '; + $sOptions .= ' for(var i = 0; iname . '_label]\', {' . $sOptions . $storeEntryData . '});'; + $str .= ''; + + return $str; } + } else { + return $this->htmlentities( $formVariableValue, ENT_COMPAT, 'utf-8' ); } - - $sOptions .= ' var sField = "["+ encodeURIComponent(jField.toJSONString()) + "]"; '; - - $sOptions .= $sCallBack . '; getField("' . $this->name . '").value = obj.id;'; - $sOptions .= 'var response = ajax_function("../gulliver/defaultAjaxDynaform", "reloadField", '; - $sOptions .= ' "form=' . $owner->id . '&fields=" + sField, "POST"); '; - - $sOptions .= 'if (response.substr(0,1) === \'[\') { '; - $sOptions .= ' var newcont; '; - $sOptions .= ' eval(\'newcont=\' + response + \';\'); '; - $sOptions .= ' for(var i = 0; iname . '_label]\', {' . $sOptions . $storeEntryData . '});'; - $str .= ''; - - return $str; - } - } else { - return $this->htmlentities ( $formVariableValue, ENT_COMPAT, 'utf-8' ); } - } - /** - * Function renderGrid - * @author David S. Callizaya S. - * @access public - * @param string values - * @param string owner - * @return string - */ - function renderGrid($values = array(), $owner) - { - $result = array (); - $r = 1; - foreach ( $values as $v ) { - if ($this->replaceTags == 1) { - $v = G::replaceDataField ( $v, $owner->values ); - } - if ($this->mode === 'edit') { - if ($this->readOnly) - $result [] = ''; - else - $result [] = ''; - } elseif ($this->mode === 'view') { - $result [] = $this->htmlentities ( $v, ENT_COMPAT, 'utf-8' ); - } else { - $result [] = $this->htmlentities ( $v, ENT_COMPAT, 'utf-8' ); - } - $r ++; + + /** + * Function renderGrid + * + * @author David S. Callizaya S. + * @access public + * @param string values + * @param string owner + * @return string + */ + public function renderGrid ($values = array(), $owner = null) + { + $result = array (); + $r = 1; + foreach ($values as $v) { + if ($this->replaceTags == 1) { + $v = G::replaceDataField( $v, $owner->values ); + } + if ($this->mode === 'edit') { + if ($this->readOnly) { + $result[] = ''; + } else { + $result[] = ''; + } + } elseif ($this->mode === 'view') { + $result[] = $this->htmlentities( $v, ENT_COMPAT, 'utf-8' ); + } else { + $result[] = $this->htmlentities( $v, ENT_COMPAT, 'utf-8' ); + } + $r ++; + } + return $result; + } - return $result; - - } - - /** - * render in a table - * @param $values - * @param $owner - * @return $result - */ - function renderTable($values = '', $owner) { - $result = $this->htmlentities ( $values, ENT_COMPAT, 'utf-8' ); - return $result; - } + /** + * render in a table + * + * @param $values + * @param $owner + * @return $result + */ + public function renderTable ($values = '', $owner = null) + { + $result = $this->htmlentities( $values, ENT_COMPAT, 'utf-8' ); + return $result; + } } /** * prepare the field for printing + * * @package gulliver.system */ class XmlForm_Field_Print extends XmlForm_Field_SimpleText //by neyek { - //Instead of var --> link - var $link = ''; - var $value = ''; - var $target = ''; - var $colClassName = 'RowLink'; + //Instead of public --> link + public $link = ''; + public $value = ''; + public $target = ''; + public $colClassName = 'RowLink'; - //properties - var $width; - var $height; - var $top; - var $left; - var $resizable; + //properties + public $width; + public $height; + public $top; + public $left; + public $resizable; - /** - * Function render - * @param string value - * @return string - */ - //750, 450, 10, 32, 1 - function render($value = NULL, $owner = NULL) { - $onclick = G::replaceDataField ( $this->onclick, $owner->values ); - $link = G::replaceDataField ( $this->link, $owner->values ); - $target = G::replaceDataField ( $this->target, $owner->values ); - $value = G::replaceDataField ( $this->value, $owner->values ); - $label = G::replaceDataField ( $this->label, $owner->values ); + /** + * Function render + * + * @param string value + * @return string + */ + //750, 450, 10, 32, 1 + public function render ($value = null, $owner = null) + { + $onclick = G::replaceDataField( $this->onclick, $owner->values ); + $link = G::replaceDataField( $this->link, $owner->values ); + $target = G::replaceDataField( $this->target, $owner->values ); + $value = G::replaceDataField( $this->value, $owner->values ); + $label = G::replaceDataField( $this->label, $owner->values ); - - $html = ' - + $html = ' + '; - return $html; - } - + return $html; + } } /*DEPRECATED*/ /** * caption field for dynaforms + * * @package gulliver.system */ -class XmlForm_Field_Caption extends XmlForm_Field { +class XmlForm_Field_Caption extends XmlForm_Field +{ - var $defaultValue = ''; - var $required = false; - var $dependentFields = ''; - var $readonly = false; - var $option = array (); - var $sqlConnection = 0; - var $sql = ''; - var $sqlOption = array (); - var $saveLabel = 0; - //var $hint; + public $defaultValue = ''; + public $required = false; + public $dependentFields = ''; + public $readonly = false; + public $option = array (); + public $sqlConnection = 0; + public $sql = ''; + public $sqlOption = array (); + public $saveLabel = 0; + //public $hint; - /** - * @param $value - * @param $owner - * @return true - */ - function validateValue($value, &$owner) { - /*$this->executeSQL( $owner ); - return isset($value) && ( array_key_exists( $value , $this->options ) );*/ - return true; - } - /** - * Function render - * @author David S. Callizaya S. - * @access public - * @param string value - * @return string - * modified - */ - function render($value = NULL, $owner = NULL, $rowId = '', $onlyValue = false, $row = -1, $therow = -1) { - if (($this->pmconnection != '') && ($this->pmfield != '') && $value == NULL ) { - $value = $this->getPMTableValue($owner); + /** + * + * @param $value + * @param $owner + * @return true + */ + public function validateValue ($value, &$owner) + { + /*$this->executeSQL( $owner ); + return isset($value) && ( array_key_exists( $value , $this->options ) );*/ + return true; } - if ($therow == - 1) {//print_r($this->executeSQL ( $owner, $row ));print"
"; - $this->executeSQL ( $owner, $row ); - } else { - if ($row == $therow) { - $this->executeSQL ( $owner, $row ); - } - } - $html = ''; - if (! $onlyValue) { - foreach ( $this->option as $optionName => $option ) { - if($optionName == $value) - $value=$option; - } - foreach ( $this->sqlOption as $optionName => $option ) { - if($optionName == $value) - $value=$option; + /** + * Function render + * + * @author David S. Callizaya S. + * @access public + * @param string value + * @return string modified + */ + public function render ($value = null, $owner = null, $rowId = '', $onlyValue = false, $row = -1, $therow = -1) + { - } - - } else { - foreach ( $this->option as $optionName => $option ) { - if ($optionName == $value) { - $$value = $option; + if (($this->pmconnection != '') && ($this->pmfield != '') && $value == null) { + $value = $this->getPMTableValue( $owner ); } - } - foreach ( $this->sqlOption as $optionName => $option ) { - if ($optionName == $value) { - $value = $option; + if ($therow == - 1) { + //print_r($this->executeSQL ( $owner, $row ));print"
"; + $this->executeSQL( $owner, $row ); + } else { + if ($row == $therow) { + $this->executeSQL( $owner, $row ); + } } - } + $html = ''; + + if (! $onlyValue) { + foreach ($this->option as $optionName => $option) { + if ($optionName == $value) { + $value = $option; + } + } + foreach ($this->sqlOption as $optionName => $option) { + if ($optionName == $value) { + $value = $option; + } + } + + } else { + foreach ($this->option as $optionName => $option) { + if ($optionName == $value) { + $$value = $option; + } + } + foreach ($this->sqlOption as $optionName => $option) { + if ($optionName == $value) { + $value = $option; + } + } + } + $pID = "form[$this->name]"; + $htm = $this->htmlentities( $value, ENT_COMPAT, 'utf-8' ); + $htm .= ''; + return $htm; } - $pID= "form[$this->name]"; - $htm = $this->htmlentities ( $value, ENT_COMPAT, 'utf-8' ); - $htm .= ''; - return $htm; - } } + /** * Class XmlForm_Field_Password + * * @author David S. Callizaya S. * @package gulliver.system * @access public */ -class XmlForm_Field_Password extends XmlForm_Field { - var $size = 15; - var $maxLength = 15; - var $required = false; - var $readOnly = false; - var $autocomplete = "on"; - /** - * Function render - * @author David S. Callizaya S. - * @access public - * @param string value - * @return string - */ - function render($value = NULL) { - if($this->autocomplete==='1'){ - $this->autocomplete = "on"; - } - else{ - if($this->autocomplete==='0') { - $this->autocomplete ="off";} - } +class XmlForm_Field_Password extends XmlForm_Field +{ + public $size = 15; + public $maxLength = 15; + public $required = false; + public $readOnly = false; + public $autocomplete = "on"; - if ($this->mode === 'edit') { - if ($this->readOnly) - return 'htmlentities ( $value, ENT_COMPAT, 'utf-8' ) . '\' readOnly="readOnly"/>'; - else{ - $html='htmlentities ( $value, ENT_COMPAT, 'utf-8' ) . '\'/>'; - $html .= $this->renderHint(); - return $html; - } - } elseif ($this->mode === 'view') { - $html= 'htmlentities ( $value, ENT_COMPAT, 'utf-8' ) . '\' readOnly="readOnly"/>'; - $html.= $this->htmlentities ( str_repeat ( '*', 10 ), ENT_COMPAT, 'utf-8' ); - return $html; - } else { - return $this->htmlentities ( str_repeat ( '*', 10 ), ENT_COMPAT, 'utf-8' ); + /** + * Function render + * + * @author David S. Callizaya S. + * @access public + * @param string value + * @return string + */ + public function render ($value = null) + { + if ($this->autocomplete === '1') { + $this->autocomplete = "on"; + } else { + if ($this->autocomplete === '0') { + $this->autocomplete = "off"; + } + } + + if ($this->mode === 'edit') { + if ($this->readOnly) { + return 'htmlentities( $value, ENT_COMPAT, 'utf-8' ) . '\' readOnly="readOnly"/>'; + } else { + $html = 'htmlentities( $value, ENT_COMPAT, 'utf-8' ) . '\'/>'; + $html .= $this->renderHint(); + return $html; + } + } elseif ($this->mode === 'view') { + $html = 'htmlentities( $value, ENT_COMPAT, 'utf-8' ) . '\' readOnly="readOnly"/>'; + $html .= $this->htmlentities( str_repeat( '*', 10 ), ENT_COMPAT, 'utf-8' ); + return $html; + } else { + return $this->htmlentities( str_repeat( '*', 10 ), ENT_COMPAT, 'utf-8' ); + } } - } } + /** * Class XmlForm_Field_Textarea + * * @author David S. Callizaya S. * @package gulliver.system * @access public */ -class XmlForm_Field_Textarea extends XmlForm_Field { - var $rows = 12; - var $cols = 40; - var $required = false; - var $readOnly = false; - var $wrap = 'OFF'; - var $className; - var $renderMode = ''; +class XmlForm_Field_Textarea extends XmlForm_Field +{ + public $rows = 12; + public $cols = 40; + public $required = false; + public $readOnly = false; + public $wrap = 'OFF'; + public $className; + public $renderMode = ''; + /** + * Function render + * + * @author David S. Callizaya S. + * @access public + * @param string value + * @return string + */ + public function render ($value = null, $owner = null) + { - /** - * Function render - * @author David S. Callizaya S. - * @access public - * @param string value - * @return string - */ - function render($value = NULL, $owner) { + if (($this->pmconnection != '') && ($this->pmfield != '') && $value == null) { + $value = $this->getPMTableValue( $owner ); + } else { + $this->executeSQL( $owner ); + if (isset( $this->sqlOption )) { + $firstElement = key( $this->sqlOption ); + } + if (isset( $firstElement )) { + $value = $firstElement; + } + } - if (($this->pmconnection != '') && ($this->pmfield != '') && $value == NULL) { - $value = $this->getPMTableValue($owner); - } - else { - $this->executeSQL ( $owner ); - if (isset ( $this->sqlOption )) - $firstElement = key ( $this->sqlOption ); - if (isset ( $firstElement )) - $value = $firstElement; + $className = isset( $this->className ) ? $this->className : 'module_app_input___gray'; + + if ($this->renderMode == '') { + $this->renderMode = $this->mode; + } + + $html = ''; + $scrollStyle = $this->style . "overflow:scroll;overflow-y:scroll;overflow-x:hidden;overflow:-moz-scrollbars-vertical;"; + if ($this->renderMode == 'edit') { + //EDIT MODE + $readOnlyText = ($this->readOnly == 1 || $this->readOnly == '1') ? 'readOnly="readOnly"' : ''; + $html .= ''; + } else { + //VIEW MODE + $html .= ''; + } + + $html .= $this->renderHint(); + return $html; } - $className = isset($this->className) ? $this->className : 'module_app_input___gray'; + /** + * Function renderGrid + * + * @author David S. Callizaya S. + * @access public + * @param string value + * @param string owner + * @return string + */ + public function renderGrid ($values = null, $owner = null) + { + $this->gridFieldType = 'textarea'; - if ($this->renderMode == '') $this->renderMode = $this->mode; + if ($owner->mode != 'view') { + $this->renderMode = $this->modeForGrid; + } + $result = array (); + $r = 1; - $html = ''; - $scrollStyle = $this->style . "overflow:scroll;overflow-y:scroll;overflow-x:hidden;overflow:-moz-scrollbars-vertical;"; - if ($this->renderMode == 'edit'){ //EDIT MODE - $readOnlyText = ($this->readOnly == 1 || $this->readOnly == '1')? 'readOnly="readOnly"':''; - $html .= ''; - }else{ //VIEW MODE - $html .= ''; + foreach ($values as $v) { + $scrollStyle = $this->style . "overflow:scroll;overflow-y:scroll;overflow-x:hidden;overflow:-moz-scrollbars-vertical;"; + $html = ''; + if ($this->renderMode == 'edit') { + //EDIT MODE + $readOnlyText = ($this->readOnly == 1 || $this->readOnly == '1') ? 'readOnly="readOnly"' : ''; + $html .= ''; + } else { + //VIEW MODE + $html .= ''; + } + $result[] = $html; + $r ++; + } + return $result; } - - - $html .= $this->renderHint(); - return $html; - } - /** - * Function renderGrid - * @author David S. Callizaya S. - * @access public - * @param string value - * @param string owner - * @return string - */ - function renderGrid($values = NULL, $owner) { - $this->gridFieldType = 'textarea'; - - if ($owner->mode != 'view') $this->renderMode = $this->modeForGrid; - - $result = array (); - $r = 1; - - foreach ( $values as $v ) { - $scrollStyle = $this->style . "overflow:scroll;overflow-y:scroll;overflow-x:hidden;overflow:-moz-scrollbars-vertical;"; - $html = ''; - if ($this->renderMode == 'edit'){ //EDIT MODE - $readOnlyText = ($this->readOnly == 1 || $this->readOnly == '1')? 'readOnly="readOnly"':''; - $html .= ''; - }else{ //VIEW MODE - $html .= ''; - } - $result[] = $html; - $r ++; - } - return $result; - } } + /** * Class XmlForm_Field_Currency + * * @author David S. Callizaya S. * @package gulliver.system * @access public */ -class XmlForm_Field_Currency extends XmlForm_Field_SimpleText { - var $group = 0; - var $size = 15; - var $required = false; - var $linkField = ''; - var $readOnly = false; - var $maxLength = 15; +class XmlForm_Field_Currency extends XmlForm_Field_SimpleText +{ + public $group = 0; + public $size = 15; + public $required = false; + public $linkField = ''; + public $readOnly = false; + public $maxLength = 15; - var $mask = '_###,###,###,###;###,###,###,###.## $'; - var $currency = '$'; - //Atributes only for grids - var $formula = ''; - var $function = ''; - var $gridFieldType = 'currency'; - var $comma_separator = '.'; + public $mask = '_###,###,###,###;###,###,###,###.## $'; + public $currency = '$'; + //Atributes only for grids + public $formula = ''; + public $function = ''; + public $gridFieldType = 'currency'; + public $comma_separator = '.'; - /** - * render the field in a dynaform - * @param $value - * @param $owner - * @return - */ - function render( $value = NULL, $owner = NULL) { + /** + * render the field in a dynaform + * + * @param $value + * @param $owner + * @return + */ + public function render ($value = null, $owner = null) + { + if ($this->renderMode == '') { + $this->renderMode = $this->mode; + } + $onkeypress = G::replaceDataField( $this->onkeypress, $owner->values ); - if ($this->renderMode == '') $this->renderMode = $this->mode; - $onkeypress = G::replaceDataField ( $this->onkeypress, $owner->values ); + $html = ''; + $currency = preg_replace( '/([_;#,.])/', '', $this->mask ); + if (! $value) { + $value = $currency; + } + if ($this->renderMode == 'edit') { + //EDIT MODE + $readOnlyText = ($this->readOnly == 1 || $this->readOnly == '1') ? 'readOnly="readOnly"' : ''; + $html .= 'name . ']" '; + $html .= 'name="form[' . $this->name . ']" '; + $html .= 'type="text" size="' . $this->size . '" maxlength="' . $this->maxLength . '" '; + $html .= 'value="' . $this->htmlentities( $value, ENT_QUOTES, 'utf-8' ) . '" '; + $html .= 'style="' . $this->htmlentities( $this->style, ENT_COMPAT, 'utf-8' ) . '" '; + $html .= 'onkeypress="' . $this->htmlentities( $onkeypress, ENT_COMPAT, 'utf-8' ) . '" '; + $html .= $this->NSDefaultValue() . ' '; + $html .= $this->NSRequiredValue() . ' '; + $html .= $this->NSGridType() . ' '; + $html .= 'pm:decimal_separator="' . $this->comma_separator . '" '; + $html .= '/>'; + } else { + //VIEW MODE + $html .= $this->htmlentities( $value, ENT_COMPAT, 'utf-8' ); + $html .= 'name . ']" '; + $html .= 'name="form[' . $this->name . ']" '; + $html .= 'type="hidden" value="' . $this->htmlentities( $value, ENT_COMPAT, 'utf-8' ) . '" />'; + } + if (($this->readOnly == 1) && ($this->renderMode == 'edit')) { + $html = str_replace( "class=\"module_app_input___gray\"", "class=\"module_app_input___gray_readOnly\"", $html ); + } + $html .= $this->renderHint(); - $html = ''; - $currency = preg_replace( '/([_;#,.])/', '',$this->mask); - if (! $value) $value= $currency; + return $html; - if ($this->renderMode == 'edit'){ //EDIT MODE - $readOnlyText = ($this->readOnly == 1 || $this->readOnly == '1') ? 'readOnly="readOnly"' : ''; - $html .= 'name . ']" '; - $html .= 'name="form[' . $this->name . ']" '; - $html .= 'type="text" size="'.$this->size.'" maxlength="'.$this->maxLength.'" '; - $html .= 'value="'.$this->htmlentities($value, ENT_QUOTES, 'utf-8').'" '; - $html .= 'style="'.$this->htmlentities($this->style, ENT_COMPAT, 'utf-8').'" '; - $html .= 'onkeypress="'.$this->htmlentities($onkeypress, ENT_COMPAT, 'utf-8').'" '; - $html .= $this->NSDefaultValue().' '; - $html .= $this->NSRequiredValue().' '; - $html .= $this->NSGridType().' '; - $html .= 'pm:decimal_separator="' . $this->comma_separator . '" '; - $html .= '/>'; - }else{ //VIEW MODE - $html .= $this->htmlentities($value, ENT_COMPAT, 'utf-8'); - $html .= 'name . ']" '; - $html .= 'name="form[' . $this->name . ']" '; - $html .= 'type="hidden" value="'.$this->htmlentities($value, ENT_COMPAT, 'utf-8').'" />'; } - if (($this->readOnly == 1) && ($this->renderMode == 'edit')) { - $html = str_replace("class=\"module_app_input___gray\"", "class=\"module_app_input___gray_readOnly\"", $html); + + /** + * Function renderGrid + * + * @author alvaro campos sanchez + * @access public + * @param string values + * @param string owner + * @return string + */ + public function renderGrid ($values = array(), $owner = null) + { + $result = array (); + $r = 1; + if ($owner->mode != 'view') { + $this->renderMode = $this->modeForGrid; + } + + foreach ($values as $v) { + $html = ''; + $currency = preg_replace( '/([_;#,.])/', '', $this->mask ); + if (! $v) { + $v = $currency; + } + if ($this->renderMode === 'edit') { + //EDIT MODE + $readOnlyText = ($this->readOnly == 1 || $this->readOnly == '1') ? 'readOnly="readOnly"' : ''; + $html .= 'name . '][' . $r . '][' . $this->name . ']" '; + $html .= 'name="form[' . $owner->name . '][' . $r . '][' . $this->name . ']" '; + $html .= 'type="text" size="' . $this->size . '" maxlength="' . $this->maxLength . '" '; + $html .= 'value="' . $this->htmlentities( $v, ENT_QUOTES, 'utf-8' ) . '" '; + $html .= 'style="' . $this->htmlentities( $this->style, ENT_COMPAT, 'utf-8' ) . '" '; + $html .= $this->NSDefaultValue() . ' '; + $html .= $this->NSRequiredValue() . ' '; + $html .= $this->NSGridType() . ' '; + $html .= $this->NSGridLabel() . ' '; + $html .= '/>'; + } else { + //VIEW MODE + $html .= $this->htmlentities( $v, ENT_QUOTES, 'utf-8' ); + $html .= 'name . '][' . $r . '][' . $this->name . ']" '; + $html .= 'name="form[' . $owner->name . '][' . $r . '][' . $this->name . ']" '; + $html .= 'type="hidden" value="' . $this->htmlentities( $v, ENT_QUOTES, 'utf-8' ) . '" />'; + } + $result[] = $html; + $r ++; + } + return $result; } - $html .= $this->renderHint(); - - return $html; - - } - - /** - * Function renderGrid - * @author alvaro campos sanchez - * @access public - * @param string values - * @param string owner - * @return string - */ - function renderGrid($values = array(), $owner) - { - $result = array (); - $r = 1; - if ($owner->mode != 'view') $this->renderMode = $this->modeForGrid; - - foreach ( $values as $v ) { - $html = ''; - $currency = preg_replace( '/([_;#,.])/', '',$this->mask); - if (! $v) $v= $currency; - if ($this->renderMode === 'edit'){ //EDIT MODE - $readOnlyText = ($this->readOnly == 1 || $this->readOnly == '1') ? 'readOnly="readOnly"' : ''; - $html .= 'name.']['.$r.']['.$this->name.']" '; - $html .= 'name="form['.$owner->name.']['.$r.']['.$this->name.']" '; - $html .= 'type="text" size="'.$this->size.'" maxlength="'.$this->maxLength.'" '; - $html .= 'value="'.$this->htmlentities($v, ENT_QUOTES, 'utf-8').'" '; - $html .= 'style="'.$this->htmlentities($this->style, ENT_COMPAT, 'utf-8').'" '; - $html .= $this->NSDefaultValue().' '; - $html .= $this->NSRequiredValue().' '; - $html .= $this->NSGridType().' '; - $html .= $this->NSGridLabel().' '; - $html .= '/>'; - }else{ //VIEW MODE - $html .= $this->htmlentities($v, ENT_QUOTES, 'utf-8'); - $html .= 'name.']['.$r.']['.$this->name.']" '; - $html .= 'name="form['.$owner->name.']['.$r.']['.$this->name.']" '; - $html .= 'type="hidden" value="'.$this->htmlentities($v, ENT_QUOTES, 'utf-8').'" />'; - } - $result [] = $html; - $r ++; - } - return $result; - } } /*DEPRECATED*/ /** + * * @package gulliver.system */ -class XmlForm_Field_CaptionCurrency extends XmlForm_Field { - /** - * Function render - * @author David S. Callizaya S. - * @access public - * @param string value - * @return string - */ - function render($value = NULL) { - return '$ ' . $this->htmlentities ( $value, ENT_COMPAT, 'utf-8' ); - } +class XmlForm_Field_CaptionCurrency extends XmlForm_Field +{ + + /** + * Function render + * + * @author David S. Callizaya S. + * @access public + * @param string value + * @return string + */ + public function render ($value = null) + { + return '$ ' . $this->htmlentities( $value, ENT_COMPAT, 'utf-8' ); + } } + /** * Class XmlForm_Field_Percentage + * * @author David S. Callizaya S. * @package gulliver.system * @access public */ -class XmlForm_Field_Percentage extends XmlForm_Field_SimpleText { - var $size = 15; - var $required = false; - var $linkField = ''; - var $readOnly = false; - var $maxLength = 15; - var $mask = '###.## %'; - //Atributes only for grids - var $formula = ''; - var $function = ''; - var $gridFieldType = 'percentage'; - var $comma_separator = '.'; +class XmlForm_Field_Percentage extends XmlForm_Field_SimpleText +{ + public $size = 15; + public $required = false; + public $linkField = ''; + public $readOnly = false; + public $maxLength = 15; + public $mask = '###.## %'; + //Atributes only for grids + public $formula = ''; + public $function = ''; + public $gridFieldType = 'percentage'; + public $comma_separator = '.'; - function render( $value = NULL, $owner = NULL) { + public function render ($value = null, $owner = null) + { - if ($this->renderMode == '') $this->renderMode = $this->mode; - $onkeypress = G::replaceDataField ( $this->onkeypress, $owner->values ); + if ($this->renderMode == '') { + $this->renderMode = $this->mode; + } + $onkeypress = G::replaceDataField( $this->onkeypress, $owner->values ); + + $html = ''; + + if ($this->renderMode == 'edit') { + //EDIT MODE + $readOnlyText = ($this->readOnly == 1 || $this->readOnly == '1') ? 'readOnly="readOnly"' : ''; + $html .= 'name . ']" '; + $html .= 'name="form[' . $this->name . ']" '; + $html .= 'type="text" size="' . $this->size . '" maxlength="' . $this->maxLength . '" '; + $html .= 'value="' . $this->htmlentities( $value, ENT_QUOTES, 'utf-8' ) . '" '; + $html .= 'style="' . $this->htmlentities( $this->style, ENT_COMPAT, 'utf-8' ) . '" '; + $html .= 'onkeypress="' . $this->htmlentities( $onkeypress, ENT_COMPAT, 'utf-8' ) . '" '; + $html .= $this->NSDefaultValue() . ' '; + $html .= $this->NSRequiredValue() . ' '; + $html .= 'pm:decimal_separator="' . $this->comma_separator . '" '; + $html .= '/>'; + } else { + //VIEW MODE + $html .= $this->htmlentities( $value, ENT_COMPAT, 'utf-8' ); + $html .= 'name . ']" '; + $html .= 'name="form[' . $this->name . ']" '; + $html .= 'type="hidden" value="' . $this->htmlentities( $value, ENT_COMPAT, 'utf-8' ) . '" />'; + } + + if (($this->readOnly == 1) && ($this->renderMode == 'edit')) { + $html = str_replace( "class=\"module_app_input___gray\"", "class=\"module_app_input___gray_readOnly\"", $html ); + } + $html .= $this->renderHint(); + return $html; + + // $onkeypress = G::replaceDataField ( $this->onkeypress, $owner->values ); + // if ($this->mode === 'edit') { + // if ($this->readOnly) + // return 'htmlentities ( $value, ENT_QUOTES, 'utf-8' ) . '\' readOnly="readOnly" style="' . htmlentities ( $this->style, ENT_COMPAT, 'utf-8' ) . '" onkeypress="' . htmlentities ( $onkeypress, ENT_COMPAT, 'utf-8' ) . '"/>'; + // else { + // + // $html = 'htmlentities ( $value, ENT_QUOTES, 'utf-8' ) . '\' style="' . htmlentities ( $this->style, ENT_COMPAT, 'utf-8' ) . '" onkeypress="' . htmlentities ( $onkeypress, ENT_COMPAT, 'utf-8' ) . '"/>'; + // + // if($this->hint){ + // $html .= ' + // + // '; + // } + // + // return $html; + // } + // } elseif ($this->mode === 'view') { + // return 'htmlentities ( $value, ENT_QUOTES, 'utf-8' ) . '\' style="display:none;' . htmlentities ( $this->style, ENT_COMPAT, 'utf-8' ) . '" onkeypress="' . htmlentities ( $onkeypress, ENT_COMPAT, 'utf-8' ) . '"/>' . $this->htmlentities ( $value, ENT_COMPAT, 'utf-8' ); + // } else { + // return $this->htmlentities ( $value, ENT_QUOTES, 'utf-8' ); + // } - $html = ''; - if ($this->renderMode == 'edit'){ //EDIT MODE - $readOnlyText = ($this->readOnly == 1 || $this->readOnly == '1') ? 'readOnly="readOnly"' : ''; - $html .= 'name . ']" '; - $html .= 'name="form[' . $this->name . ']" '; - $html .= 'type="text" size="'.$this->size.'" maxlength="'.$this->maxLength.'" '; - $html .= 'value="'.$this->htmlentities($value, ENT_QUOTES, 'utf-8').'" '; - $html .= 'style="'.$this->htmlentities($this->style, ENT_COMPAT, 'utf-8').'" '; - $html .= 'onkeypress="'.$this->htmlentities($onkeypress, ENT_COMPAT, 'utf-8').'" '; - $html .= $this->NSDefaultValue().' '; - $html .= $this->NSRequiredValue().' '; - $html .= 'pm:decimal_separator="' . $this->comma_separator . '" '; - $html .= '/>'; - }else{ //VIEW MODE - $html .= $this->htmlentities($value, ENT_COMPAT, 'utf-8'); - $html .= 'name . ']" '; - $html .= 'name="form[' . $this->name . ']" '; - $html .= 'type="hidden" value="'.$this->htmlentities($value, ENT_COMPAT, 'utf-8').'" />'; } - - if (($this->readOnly == 1) && ($this->renderMode == 'edit')) { - $html = str_replace("class=\"module_app_input___gray\"", "class=\"module_app_input___gray_readOnly\"", $html); - } - $html .= $this->renderHint(); - return $html; - -// $onkeypress = G::replaceDataField ( $this->onkeypress, $owner->values ); -// if ($this->mode === 'edit') { -// if ($this->readOnly) -// return 'htmlentities ( $value, ENT_QUOTES, 'utf-8' ) . '\' readOnly="readOnly" style="' . htmlentities ( $this->style, ENT_COMPAT, 'utf-8' ) . '" onkeypress="' . htmlentities ( $onkeypress, ENT_COMPAT, 'utf-8' ) . '"/>'; -// else { -// -// $html = 'htmlentities ( $value, ENT_QUOTES, 'utf-8' ) . '\' style="' . htmlentities ( $this->style, ENT_COMPAT, 'utf-8' ) . '" onkeypress="' . htmlentities ( $onkeypress, ENT_COMPAT, 'utf-8' ) . '"/>'; -// -// if($this->hint){ -// $html .= ' -// -// '; -// } -// -// return $html; -// } -// } elseif ($this->mode === 'view') { -// return 'htmlentities ( $value, ENT_QUOTES, 'utf-8' ) . '\' style="display:none;' . htmlentities ( $this->style, ENT_COMPAT, 'utf-8' ) . '" onkeypress="' . htmlentities ( $onkeypress, ENT_COMPAT, 'utf-8' ) . '"/>' . $this->htmlentities ( $value, ENT_COMPAT, 'utf-8' ); -// } else { -// return $this->htmlentities ( $value, ENT_QUOTES, 'utf-8' ); -// } - - } - } /*DEPRECATED*/ /** + * * @package gulliver.system */ -class XmlForm_Field_CaptionPercentage extends XmlForm_Field { - function render($value = NULL) { - return $this->htmlentities ( $value, ENT_COMPAT, 'utf-8' ); - } +class XmlForm_Field_CaptionPercentage extends XmlForm_Field +{ + + public function render ($value = null) + { + return $this->htmlentities( $value, ENT_COMPAT, 'utf-8' ); + } } + /** * Class XmlForm_Field_Date + * * @author David S. Callizaya S. * @package gulliver.system * @access public */ -class XmlForm_Field_Date2 extends XmlForm_Field_SimpleText { - //Instead of size --> startDate - var $startDate = ''; - //Instead of maxLength --> endDate - var $endDate = ''; - //for dinamically dates, beforeDate << currentDate << afterDate - // beforeDate='1y' means one year before, beforeDate='3m' means 3 months before - // afterDate='5y' means five year after, afterDate='15d' means 15 days after - // startDate and endDate have priority over beforeDate and AfterDate. - var $afterDate = ''; - var $beforeDate = ''; - var $defaultValue = NULL; - var $format = 'Y-m-d'; - var $required = false; - var $readOnly = false; - var $mask = 'yyyy-mm-dd'; - var $dependentFields = ''; +class XmlForm_Field_Date2 extends XmlForm_Field_SimpleText +{ + //Instead of size --> startDate + public $startDate = ''; + //Instead of maxLength --> endDate + public $endDate = ''; + //for dinamically dates, beforeDate << currentDate << afterDate + // beforeDate='1y' means one year before, beforeDate='3m' means 3 months before + // afterDate='5y' means five year after, afterDate='15d' means 15 days after + // startDate and endDate have priority over beforeDate and AfterDate. + public $afterDate = ''; + public $beforeDate = ''; + public $defaultValue = null; + public $format = 'Y-m-d'; + public $required = false; + public $readOnly = false; + public $mask = 'yyyy-mm-dd'; + public $dependentFields = ''; - /** - * Verify the date format - * @param $date - * @return Boolean true/false - */ - function verifyDateFormat($date) { - $aux = explode ( '-', $date ); - if (count ( $aux ) != 3) - return false; - if (! (is_numeric ( $aux [0] ) && is_numeric ( $aux [1] ) && is_numeric ( $aux [2] ))) - return false; - if ($aux [0] < 1900 || $aux [0] > 2100) - return false; - return true; - } - - /** - * checks if a date has he correct format - * @param $date - * @return - */ - function isvalidBeforeFormat($date) { - $part1 = substr ( $date, 0, strlen ( $date ) - 1 ); - $part2 = substr ( $date, strlen ( $date ) - 1 ); - if ($part2 != 'd' && $part2 != 'm' && $part2 != 'y') - return false; - if (! is_numeric ( $part1 )) - return false; - return true; - } - - /** - * Calculate the date before the format - * @param $date - * @param $sign - * @return $res date based on the data insert - */ - function calculateBeforeFormat($date, $sign) { - $part1 = $sign * substr ( $date, 0, strlen ( $date ) - 1 ); - $part2 = substr ( $date, strlen ( $date ) - 1 ); - switch ($part2) { - case 'd' : - $res = date ( 'Y-m-d', mktime ( 0, 0, 0, date ( 'm' ), date ( 'd' ) + $part1, date ( 'Y' ) ) ); - break; - case 'm' : - $res = date ( 'Y-m-d', mktime ( 0, 0, 0, date ( 'm' ) + $part1, date ( 'd' ), date ( 'Y' ) ) ); - break; - case 'y' : - $res = date ( 'Y-m-d', mktime ( 0, 0, 0, date ( 'm' ), date ( 'd' ), date ( 'Y' ) + $part1 ) ); - break; - - } - return $res; - } - - /** - * render the field in a dynaform - * @param $value - * @param $owner - * @return - */ - function render($value = NULL, $owner = NULL) { - - $value = G::replaceDataField ( $value, $owner->values ); - $startDate = G::replaceDataField ( $this->startDate, $owner->values ); - $endDate = G::replaceDataField ( $this->endDate, $owner->values ); - $beforeDate = G::replaceDataField ( $this->beforeDate, $owner->values ); - $afterDate = G::replaceDataField ( $this->afterDate, $owner->values ); - //for backward compatibility size and maxlength - if ($startDate != '') { - if (! $this->verifyDateFormat ( $startDate )) - $startDate = ''; - } - if (isset ( $beforeDate ) && $beforeDate != '') { - if ($this->isvalidBeforeFormat ( $beforeDate )) - $startDate = $this->calculateBeforeFormat ( $beforeDate, - 1 ); + /** + * Verify the date format + * + * @param $date + * @return Boolean true/false + */ + public function verifyDateFormat ($date) + { + $aux = explode( '-', $date ); + if (count( $aux ) != 3) { + return false; + } + if (! (is_numeric( $aux[0] ) && is_numeric( $aux[1] ) && is_numeric( $aux[2] ))) { + return false; + } + if ($aux[0] < 1900 || $aux[0] > 2100) { + return false; + } + return true; } - if ($startDate == '' && isset ( $this->size ) && is_numeric ( $this->size ) && $this->size >= 1900 && $this->size <= 2100) { - $startDate = $this->size . '-01-01'; + /** + * checks if a date has he correct format + * + * @param $date + * @return + */ + public function isvalidBeforeFormat ($date) + { + $part1 = substr( $date, 0, strlen( $date ) - 1 ); + $part2 = substr( $date, strlen( $date ) - 1 ); + if ($part2 != 'd' && $part2 != 'm' && $part2 != 'y') { + return false; + } + if (! is_numeric( $part1 )) { + return false; + } + return true; } - if ($startDate == '') { - $startDate = date ( 'Y-m-d' ); // the default is the current date - } - - //for backward compatibility maxlength - //if ( $this->endDate == '') $this->finalYear = date('Y') + 8; - //for backward compatibility size and maxlength - if ($endDate != '') { - if (! $this->verifyDateFormat ( $endDate )) - $endDate = ''; - } - - if (isset ( $afterDate ) && $afterDate != '') { - if ($this->isvalidBeforeFormat ( $afterDate )) - $endDate = $this->calculateBeforeFormat ( $afterDate, + 1 ); - if($endDate){ - $sign='1'; - $date=$afterDate; - $part1 = $sign * substr ( $date, 0, strlen ( $date ) - 1 ); - $part2 = substr ( $date, strlen ( $date ) - 1 ); + /** + * Calculate the date before the format + * + * @param $date + * @param $sign + * @return $res date based on the data insert + */ + public function calculateBeforeFormat ($date, $sign) + { + $part1 = $sign * substr( $date, 0, strlen( $date ) - 1 ); + $part2 = substr( $date, strlen( $date ) - 1 ); switch ($part2) { - case 'd' : - $res = date ( 'Y-m-d', mktime ( 0, 0, 0, date ( 'm' ), date ( 'd' ) + $part1, date ( 'Y' ) ) ); - break; - case 'm' : - $res = date ( 'Y-m-d', mktime ( 0, 0, 0, date ( 'm' ) + $part1, date ( 'd' ) - 1, date ( 'Y' ) ) ); - break; - case 'y' : - $res = (intVal(date ( 'Y' )) + $part1) . '-' . date ( 'm' ) . '-' . date ( 'd' ); - break; - } - - $endDate=$res; + case 'd': + $res = date( 'Y-m-d', mktime( 0, 0, 0, date( 'm' ), date( 'd' ) + $part1, date( 'Y' ) ) ); + break; + case 'm': + $res = date( 'Y-m-d', mktime( 0, 0, 0, date( 'm' ) + $part1, date( 'd' ), date( 'Y' ) ) ); + break; + case 'y': + $res = date( 'Y-m-d', mktime( 0, 0, 0, date( 'm' ), date( 'd' ), date( 'Y' ) + $part1 ) ); + break; } + return $res; } - if (isset ( $this->maxlength ) && is_numeric ( $this->maxlength ) && $this->maxlength >= 1900 && $this->maxlength <= 2100) { - $endDate = $this->maxlength . '-01-01'; - } - if ($endDate == '') { - //$this->endDate = mktime ( 0,0,0,date('m'),date('d'),date('y') ); // the default is the current date + 2 years - $endDate = date ( 'Y-m-d', mktime ( 0, 0, 0, date ( 'm' ), date ( 'd' ), date ( 'Y' ) + 2 ) ); // the default is the current date + 2 years - } - if ($value == '') { - $value = date ( 'Y-m-d' ); - } - $html = ""; - $html .= "" . $value . " "; - if ($this->mode == 'edit') - $html .= "id . "', '" . $this->name . "', '" . $value . "', '" . $startDate . "', '" . $endDate . "'); return false;\" >"; - return $html; - } + /** + * render the field in a dynaform + * + * @param $value + * @param $owner + * @return + */ + public function render ($value = null, $owner = null) + { - /** - * render the field in a grid - * @param $values - * @param $owner - * @param $onlyValue - * @return - */ - function renderGrid($values = NULL, $owner = NULL, $onlyValue = false) { - $result = array (); - $r = 1; - foreach ( $values as $v ) { - $v = G::replaceDataField ( $v, $owner->values ); - $startDate = G::replaceDataField ( $this->startDate, $owner->values ); - $endDate = G::replaceDataField ( $this->endDate, $owner->values ); - $beforeDate = G::replaceDataField ( $this->beforeDate, $owner->values ); - $afterDate = G::replaceDataField ( $this->afterDate, $owner->values ); - //for backward compatibility size and maxlength - if ($startDate != '') { - if (! $this->verifyDateFormat ( $startDate )) - $startDate = ''; - } - if ($startDate == '' && isset ( $beforeDate ) && $beforeDate != '') { - if ($this->isvalidBeforeFormat ( $beforeDate )) - $startDate = $this->calculateBeforeFormat ( $beforeDate, - 1 ); - } - - if ($startDate == '' && isset ( $this->size ) && is_numeric ( $this->size ) && $this->size >= 1900 && $this->size <= 2100) { - $startDate = $this->size . '-01-01'; - } - - if ($startDate == '') { - $startDate = date ( 'Y-m-d' ); // the default is the current date - } - - //for backward compatibility maxlength - //if ( $this->endDate == '') $this->finalYear = date('Y') + 8; - //for backward compatibility size and maxlength - if ($endDate != '') { - if (! $this->verifyDateFormat ( $endDate )) - $endDate = ''; - } - - if ($endDate == '' && isset ( $afterDate ) && $afterDate != '') { - if ($this->isvalidBeforeFormat ( $afterDate )) - $endDate = $this->calculateBeforeFormat ( $afterDate, + 1 ); - } - - if ($endDate == '' && isset ( $this->maxlength ) && is_numeric ( $this->maxlength ) && $this->maxlength >= 1900 && $this->maxlength <= 2100) { - $endDate = $this->maxlength . '-01-01'; - } - if ($endDate == '') { - //$this->endDate = mktime ( 0,0,0,date('m'),date('d'),date('y') ); // the default is the current date + 2 years - $endDate = date ( 'Y-m-d', mktime ( 0, 0, 0, date ( 'm' ), date ( 'd' ), date ( 'Y' ) + 2 ) ); // the default is the current date + 2 years - } - if ($v == '') { - $v = date ( 'Y-m-d' ); - } - if (! $onlyValue) { - $html = "name . "]' name='form[" . $owner->name . '][' . $r . '][' . $this->name . "]' value='" . $v . "'>"; - if (isset ( $owner->owner->id )) { - $html .= "name . "]' name='span[" . $owner->owner->id . "][" . $owner->name . '][' . $r . '][' . $this->name . "]' style='border:1;border-color:#000;width:100px;'>" . $v . " "; - } else { - $html .= "name . "]' name='span[" . $owner->id . "][" . $owner->name . '][' . $r . '][' . $this->name . "]' style='border:1;border-color:#000;width:100px;'>" . $v . " "; + $value = G::replaceDataField( $value, $owner->values ); + $startDate = G::replaceDataField( $this->startDate, $owner->values ); + $endDate = G::replaceDataField( $this->endDate, $owner->values ); + $beforeDate = G::replaceDataField( $this->beforeDate, $owner->values ); + $afterDate = G::replaceDataField( $this->afterDate, $owner->values ); + //for backward compatibility size and maxlength + if ($startDate != '') { + if (! $this->verifyDateFormat( $startDate )) { + $startDate = ''; + } } + if (isset( $beforeDate ) && $beforeDate != '') { + if ($this->isvalidBeforeFormat( $beforeDate )) { + $startDate = $this->calculateBeforeFormat( $beforeDate, - 1 ); + } + } + + if ($startDate == '' && isset( $this->size ) && is_numeric( $this->size ) && $this->size >= 1900 && $this->size <= 2100) { + $startDate = $this->size . '-01-01'; + } + + if ($startDate == '') { + $startDate = date( 'Y-m-d' ); // the default is the current date + } + + //for backward compatibility maxlength + //if ( $this->endDate == '') $this->finalYear = date('Y') + 8; + //for backward compatibility size and maxlength + if ($endDate != '') { + if (! $this->verifyDateFormat( $endDate )) { + $endDate = ''; + } + } + + if (isset( $afterDate ) && $afterDate != '') { + if ($this->isvalidBeforeFormat( $afterDate )) { + $endDate = $this->calculateBeforeFormat( $afterDate, + 1 ); + } + if ($endDate) { + $sign = '1'; + $date = $afterDate; + $part1 = $sign * substr( $date, 0, strlen( $date ) - 1 ); + $part2 = substr( $date, strlen( $date ) - 1 ); + switch ($part2) { + case 'd': + $res = date( 'Y-m-d', mktime( 0, 0, 0, date( 'm' ), date( 'd' ) + $part1, date( 'Y' ) ) ); + break; + case 'm': + $res = date( 'Y-m-d', mktime( 0, 0, 0, date( 'm' ) + $part1, date( 'd' ) - 1, date( 'Y' ) ) ); + break; + case 'y': + $res = (intVal( date( 'Y' ) ) + $part1) . '-' . date( 'm' ) . '-' . date( 'd' ); + break; + } + + $endDate = $res; + + } + } + + if (isset( $this->maxlength ) && is_numeric( $this->maxlength ) && $this->maxlength >= 1900 && $this->maxlength <= 2100) { + $endDate = $this->maxlength . '-01-01'; + } + if ($endDate == '') { + //$this->endDate = mktime ( 0,0,0,date('m'),date('d'),date('y') ); // the default is the current date + 2 years + $endDate = date( 'Y-m-d', mktime( 0, 0, 0, date( 'm' ), date( 'd' ), date( 'Y' ) + 2 ) ); // the default is the current date + 2 years + } + if ($value == '') { + $value = date( 'Y-m-d' ); + } + $html = ""; + $html .= "" . $value . " "; if ($this->mode == 'edit') { - $html .= "owner ) ? $owner->owner->id : $owner->id) . "', '" . $owner->name . '][' . $r . '][' . $this->name . "', '" . $v . "', '" . $startDate . "', '" . $endDate . "'); return false;\" >"; + $html .= "id . "', '" . $this->name . "', '" . $value . "', '" . $startDate . "', '" . $endDate . "'); return false;\" >"; } - } else { - $html = $v; - } - $result [] = $html; - $r ++; + return $html; + } + + /** + * render the field in a grid + * + * @param $values + * @param $owner + * @param $onlyValue + * @return + */ + public function renderGrid ($values = null, $owner = null, $onlyValue = false) + { + $result = array (); + $r = 1; + foreach ($values as $v) { + $v = G::replaceDataField( $v, $owner->values ); + $startDate = G::replaceDataField( $this->startDate, $owner->values ); + $endDate = G::replaceDataField( $this->endDate, $owner->values ); + $beforeDate = G::replaceDataField( $this->beforeDate, $owner->values ); + $afterDate = G::replaceDataField( $this->afterDate, $owner->values ); + //for backward compatibility size and maxlength + if ($startDate != '') { + if (! $this->verifyDateFormat( $startDate )) { + $startDate = ''; + } + } + if ($startDate == '' && isset( $beforeDate ) && $beforeDate != '') { + if ($this->isvalidBeforeFormat( $beforeDate )) { + $startDate = $this->calculateBeforeFormat( $beforeDate, - 1 ); + } + } + + if ($startDate == '' && isset( $this->size ) && is_numeric( $this->size ) && $this->size >= 1900 && $this->size <= 2100) { + $startDate = $this->size . '-01-01'; + } + + if ($startDate == '') { + $startDate = date( 'Y-m-d' ); // the default is the current date + } + + //for backward compatibility maxlength + //if ( $this->endDate == '') $this->finalYear = date('Y') + 8; + //for backward compatibility size and maxlength + if ($endDate != '') { + if (! $this->verifyDateFormat( $endDate )) { + $endDate = ''; + } + } + + if ($endDate == '' && isset( $afterDate ) && $afterDate != '') { + if ($this->isvalidBeforeFormat( $afterDate )) { + $endDate = $this->calculateBeforeFormat( $afterDate, + 1 ); + } + } + + if ($endDate == '' && isset( $this->maxlength ) && is_numeric( $this->maxlength ) && $this->maxlength >= 1900 && $this->maxlength <= 2100) { + $endDate = $this->maxlength . '-01-01'; + } + if ($endDate == '') { + //$this->endDate = mktime ( 0,0,0,date('m'),date('d'),date('y') ); // the default is the current date + 2 years + $endDate = date( 'Y-m-d', mktime( 0, 0, 0, date( 'm' ), date( 'd' ), date( 'Y' ) + 2 ) ); // the default is the current date + 2 years + } + if ($v == '') { + $v = date( 'Y-m-d' ); + } + if (! $onlyValue) { + $html = "name . "]' name='form[" . $owner->name . '][' . $r . '][' . $this->name . "]' value='" . $v . "'>"; + if (isset( $owner->owner->id )) { + $html .= "name . "]' name='span[" . $owner->owner->id . "][" . $owner->name . '][' . $r . '][' . $this->name . "]' style='border:1;border-color:#000;width:100px;'>" . $v . " "; + } else { + $html .= "name . "]' name='span[" . $owner->id . "][" . $owner->name . '][' . $r . '][' . $this->name . "]' style='border:1;border-color:#000;width:100px;'>" . $v . " "; + } + if ($this->mode == 'edit') { + $html .= "owner ) ? $owner->owner->id : $owner->id) . "', '" . $owner->name . '][' . $r . '][' . $this->name . "', '" . $v . "', '" . $startDate . "', '" . $endDate . "'); return false;\" >"; + } + } else { + $html = $v; + } + $result[] = $html; + $r ++; + } + return $result; } - return $result; - } } /*DEPRECATED*/ /** + * * @package gulliver.system */ class XmlForm_Field_DateView extends XmlForm_Field { - function render($value = NULL) - { - return $this->htmlentities ( $value, ENT_COMPAT, 'utf-8' ); - } + + public function render ($value = null) + { + return $this->htmlentities( $value, ENT_COMPAT, 'utf-8' ); + } } + /** * Class XmlForm_Field_YesNo + * * @author David S. Callizaya S. * @package gulliver.system * @access public */ class XmlForm_Field_YesNo extends XmlForm_Field { - var $required = false; - var $readonly = false; - var $renderMode = ''; - /** - * Function render - * @author David S. Callizaya S. - * @access public - * @param string value - * @return string - */ - function render($value = NULL, $owner = NULL) - { - if (($this->pmconnection != '') && ($this->pmfield != '') && $value == NULL) { - $value = $this->getPMTableValue($owner); - } - if ($value == '') $value = '0'; - if ($this->renderMode == '') $this->renderMode = $this->mode; - $html = ''; - if ($this->renderMode == 'edit'){ //EDIT MODE - $readOnlyText = ($this->readonly == 1 || $this->readonly == '1') ? 'disabled' : ''; - $html .= ''; - if ($readOnlyText != ''){ - $html .= 'name.']" '; - $html .= 'name="form['.$this->name.']" '; - $html .= 'type="hidden" value="'.(($value==='0')? '0':'1').'" />'; - } - }else{ //VIEW MODE + public $required = false; + public $readonly = false; + public $renderMode = ''; - $html .= ''; - $html .= ($value==='0') ? G::LoadTranslation('ID_NO_VALUE') : G::LoadTranslation('ID_YES_VALUE'); - $html .= 'name.']" '; - $html .= 'name="form['.$this->name.']" '; - $html .= 'type="hidden" value="'.(($value==='0')? '0':'1').'" />'; - } - - $html .= $this->renderHint(); - return $html; - } - - /** - * render the field in a grid - * @param $values - * @param $owner - * @return - */ - function renderGrid($values = array(), $owner) { - $this->gridFieldType = 'yesno'; - $result = array (); - $r = 1; - if ($owner->mode != 'view') $this->renderMode = $this->modeForGrid; - - foreach ( $values as $v ) { - $html = ''; - if ($v == '') $v = '0'; - if ($this->renderMode == 'edit'){ //EDIT MODE - $readOnlyText = ($this->readonly == 1 || $this->readonly == '1') ? 'disabled' : ''; - $html .= ''; - if ($readOnlyText != ''){ - $html .= 'name.']['.$r.']['.$this->name.']" '; - $html .= 'name="form['.$owner->name.']['.$r.']['.$this->name.']" '; - $html .= 'type="hidden" value="'.(($v==='0')? '0':'1').'" />'; + /** + * Function render + * + * @author David S. Callizaya S. + * @access public + * @param string value + * @return string + */ + public function render ($value = null, $owner = null) + { + if (($this->pmconnection != '') && ($this->pmfield != '') && $value == null) { + $value = $this->getPMTableValue( $owner ); } - }else{ //VIEW MODE - $html .= ($v==='0') ? G::LoadTranslation('ID_NO_VALUE') : G::LoadTranslation('ID_YES_VALUE'); - $html .= 'name.']['.$r.']['.$this->name.']" '; - $html .= 'name="form['.$owner->name.']['.$r.']['.$this->name.']" '; - $html .= $this->NSGridType().' '; - $html .= 'type="hidden" value="'.(($v==='0')? '0':'1').'" />'; - } - $result [] = $html; - $r ++; + if ($value == '') { + $value = '0'; + } + if ($this->renderMode == '') { + $this->renderMode = $this->mode; + } + $html = ''; + if ($this->renderMode == 'edit') { + //EDIT MODE + $readOnlyText = ($this->readonly == 1 || $this->readonly == '1') ? 'disabled' : ''; + $html .= ''; + if ($readOnlyText != '') { + $html .= 'name . ']" '; + $html .= 'name="form[' . $this->name . ']" '; + $html .= 'type="hidden" value="' . (($value === '0') ? '0' : '1') . '" />'; + } + } else { + //VIEW MODE + $html .= ''; + $html .= ($value === '0') ? G::LoadTranslation( 'ID_NO_VALUE' ) : G::LoadTranslation( 'ID_YES_VALUE' ); + $html .= 'name . ']" '; + $html .= 'name="form[' . $this->name . ']" '; + $html .= 'type="hidden" value="' . (($value === '0') ? '0' : '1') . '" />'; + } + + $html .= $this->renderHint(); + return $html; + } + + /** + * render the field in a grid + * + * @param $values + * @param $owner + * @return + */ + public function renderGrid ($values = array(), $owner = null) + { + $this->gridFieldType = 'yesno'; + $result = array (); + $r = 1; + if ($owner->mode != 'view') { + $this->renderMode = $this->modeForGrid; + } + foreach ($values as $v) { + $html = ''; + if ($v == '') { + $v = '0'; + } + if ($this->renderMode == 'edit') { + //EDIT MODE + $readOnlyText = ($this->readonly == 1 || $this->readonly == '1') ? 'disabled' : ''; + $html .= ''; + if ($readOnlyText != '') { + $html .= 'name . '][' . $r . '][' . $this->name . ']" '; + $html .= 'name="form[' . $owner->name . '][' . $r . '][' . $this->name . ']" '; + $html .= 'type="hidden" value="' . (($v === '0') ? '0' : '1') . '" />'; + } + } else { + //VIEW MODE + $html .= ($v === '0') ? G::LoadTranslation( 'ID_NO_VALUE' ) : G::LoadTranslation( 'ID_YES_VALUE' ); + $html .= 'name . '][' . $r . '][' . $this->name . ']" '; + $html .= 'name="form[' . $owner->name . '][' . $r . '][' . $this->name . ']" '; + $html .= $this->NSGridType() . ' '; + $html .= 'type="hidden" value="' . (($v === '0') ? '0' : '1') . '" />'; + } + $result[] = $html; + $r ++; + } + return $result; } - return $result; - } } + /** * Class XmlForm_Field_Link + * * @author David S. Callizaya S. * @package gulliver.system * @access public */ -class XmlForm_Field_Link extends XmlForm_Field { - //Instead of var --> link - var $link = ''; - var $value = ''; - var $target = ''; - var $style = ''; - var $colClassName = 'RowLink'; - /** - * Function render - * @author David S. Callizaya S. - * @access public - * @param string value - * @return string - */ - function render($value = NULL, $owner = NULL) { - $onclick = G::replaceDataField ( $this->onclick, $owner->values ); - $link = G::replaceDataField ( $this->link, $owner->values ); - $target = G::replaceDataField ( $this->target, $owner->values ); - $value = G::replaceDataField ( $this->value, $owner->values ); - $label = G::replaceDataField ( $this->label, $owner->values ); - $html = 'htmlentities ( $link, ENT_QUOTES, 'utf-8' ) . '\''; - $html .= 'id="form[' . $this->name . ']" name="form[' . $this->name . ']" style="' . htmlentities ( $this->style, ENT_QUOTES, 'utf-8' ) .'" '; - $html .= (($this->onclick) ? ' onclick="' . htmlentities ( $onclick, ENT_QUOTES, 'utf-8' ) . '"' : '') ; - $html .= (($this->target) ? ' target="' . htmlentities ( $target, ENT_QUOTES, 'utf-8' ) . '"' : '') . '>'; - $html .= $this->htmlentities ( $this->value === '' ? $label : $value, ENT_QUOTES, 'utf-8' ) . ''; - $html .= $this->renderHint(); - return $html; - } +class XmlForm_Field_Link extends XmlForm_Field +{ + //Instead of var --> link + public $link = ''; + public $value = ''; + public $target = ''; + public $style = ''; + public $colClassName = 'RowLink'; - /** - * render the field in a grid - * @param $values - * @param $owner - * @return - */ - function renderGrid($values = array(), $owner = NULL) { - $result = array (); - $r = 1; - foreach ( $values as $v ) { - $_aData_ = (isset($owner->values[$owner->name][$r]) ? $owner->values[$owner->name][$r] : array()); - $onclick = G::replaceDataField ( $this->onclick, $_aData_ ); - $link = G::replaceDataField ( $this->link, $_aData_ ); - $target = G::replaceDataField ( $this->target, $_aData_ ); - $value = G::replaceDataField ( $this->value, $_aData_ ); - $label = G::replaceDataField ( $this->label, $_aData_ ); - $html = 'htmlentities ( $link, ENT_QUOTES, 'utf-8' ) . '\''; - $html .= 'id="form[' . $owner->name . '][' . $r . '][' . $this->name . ']"'; - $html .= 'name="form[' . $owner->name . '][' . $r . '][' . $this->name . ']"'; - $html .= (($this->onclick) ? ' onclick="' . htmlentities ( $onclick, ENT_QUOTES, 'utf-8' ) . '"' : ''); - $html .= (($this->target) ? ' target="' . htmlentities ( $target, ENT_QUOTES, 'utf-8' ) . '"' : '') ; - if ($this->mode == 'view') - $html .= 'style="color: #006699; text-decoration: none;font-weight: normal;"'; - $html .= '>'.$this->htmlentities ( $this->value === '' ? $label : $value, ENT_QUOTES, 'utf-8' ) . ''; - $result [] = $html; - $r ++; + /** + * Function render + * + * @author David S. Callizaya S. + * @access public + * @param string value + * @return string + */ + public function render ($value = null, $owner = null) + { + $onclick = G::replaceDataField( $this->onclick, $owner->values ); + $link = G::replaceDataField( $this->link, $owner->values ); + $target = G::replaceDataField( $this->target, $owner->values ); + $value = G::replaceDataField( $this->value, $owner->values ); + $label = G::replaceDataField( $this->label, $owner->values ); + $html = 'htmlentities( $link, ENT_QUOTES, 'utf-8' ) . '\''; + $html .= 'id="form[' . $this->name . ']" name="form[' . $this->name . ']" style="' . htmlentities( $this->style, ENT_QUOTES, 'utf-8' ) . '" '; + $html .= (($this->onclick) ? ' onclick="' . htmlentities( $onclick, ENT_QUOTES, 'utf-8' ) . '"' : ''); + $html .= (($this->target) ? ' target="' . htmlentities( $target, ENT_QUOTES, 'utf-8' ) . '"' : '') . '>'; + $html .= $this->htmlentities( $this->value === '' ? $label : $value, ENT_QUOTES, 'utf-8' ) . ''; + $html .= $this->renderHint(); + return $html; } - return $result; - } - /** - * render the field in a table - * @param $values - * @param $owner - * @return - */ - function renderTable($value = NULL, $owner = NULL) { - $onclick = $this->htmlentities ( G::replaceDataField ( $this->onclick, $owner->values ), ENT_QUOTES, 'utf-8' ); - $link = $this->htmlentities ( G::replaceDataField ( $this->link, $owner->values ), ENT_QUOTES, 'utf-8' ); - $target = G::replaceDataField ( $this->target, $owner->values ); - $value = G::replaceDataField ( $this->value, $owner->values ); - $label = G::replaceDataField ( $this->label, $owner->values ); - $aLabel = $this->htmlentities ( $this->value === '' ? $label : $value, ENT_QUOTES, 'utf-8' ); - if(isset($aLabel) && strlen($aLabel)>0) - return 'onclick) ? ' onclick="' . $onclick . '"' : '') . (($this->target) ? ' target="' . htmlentities ( $target, ENT_QUOTES, 'utf-8' ) . '"' : '') . '>' . $aLabel . ''; - else - return ''; - } + /** + * render the field in a grid + * + * @param $values + * @param $owner + * @return + */ + public function renderGrid ($values = array(), $owner = null) + { + $result = array (); + $r = 1; + foreach ($values as $v) { + $_aData_ = (isset( $owner->values[$owner->name][$r] ) ? $owner->values[$owner->name][$r] : array ()); + $onclick = G::replaceDataField( $this->onclick, $_aData_ ); + $link = G::replaceDataField( $this->link, $_aData_ ); + $target = G::replaceDataField( $this->target, $_aData_ ); + $value = G::replaceDataField( $this->value, $_aData_ ); + $label = G::replaceDataField( $this->label, $_aData_ ); + $html = 'htmlentities( $link, ENT_QUOTES, 'utf-8' ) . '\''; + $html .= 'id="form[' . $owner->name . '][' . $r . '][' . $this->name . ']"'; + $html .= 'name="form[' . $owner->name . '][' . $r . '][' . $this->name . ']"'; + $html .= (($this->onclick) ? ' onclick="' . htmlentities( $onclick, ENT_QUOTES, 'utf-8' ) . '"' : ''); + $html .= (($this->target) ? ' target="' . htmlentities( $target, ENT_QUOTES, 'utf-8' ) . '"' : ''); + if ($this->mode == 'view') { + $html .= 'style="color: #006699; text-decoration: none;font-weight: normal;"'; + } + $html .= '>' . $this->htmlentities( $this->value === '' ? $label : $value, ENT_QUOTES, 'utf-8' ) . ''; + $result[] = $html; + $r ++; + } + return $result; + } + + /** + * render the field in a table + * + * @param $values + * @param $owner + * @return + */ + public function renderTable ($value = null, $owner = null) + { + $onclick = $this->htmlentities( G::replaceDataField( $this->onclick, $owner->values ), ENT_QUOTES, 'utf-8' ); + $link = $this->htmlentities( G::replaceDataField( $this->link, $owner->values ), ENT_QUOTES, 'utf-8' ); + $target = G::replaceDataField( $this->target, $owner->values ); + $value = G::replaceDataField( $this->value, $owner->values ); + $label = G::replaceDataField( $this->label, $owner->values ); + $aLabel = $this->htmlentities( $this->value === '' ? $label : $value, ENT_QUOTES, 'utf-8' ); + if (isset( $aLabel ) && strlen( $aLabel ) > 0) { + return 'onclick) ? ' onclick="' . $onclick . '"' : '') . (($this->target) ? ' target="' . htmlentities( $target, ENT_QUOTES, 'utf-8' ) . '"' : '') . '>' . $aLabel . ''; + } else { + return ''; + } + } } /** * Class XmlForm_Field_File + * * @author David S. Callizaya S. * @package gulliver.system * @access public @@ -2332,43 +2581,39 @@ class XmlForm_Field_File extends XmlForm_Field /** * Function render + * * @author David S. Callizaya S. * @access public * @param string value * @return string */ - public function render($value=null, $owner=null, $rowId=null, $row=-1, $therow=-1) + public function render ($value = null, $owner = null, $rowId = null, $row = -1, $therow = -1) { $permission = false; $url = null; - if (isset($_SESSION["APPLICATION"]) && - isset($_SESSION["USER_LOGGED"]) && - isset($_SESSION["TASK"]) && - isset($this->input) && $this->input != null && - $this->mode == "view" - ) { + if (isset( $_SESSION["APPLICATION"] ) && isset( $_SESSION["USER_LOGGED"] ) && isset( $_SESSION["TASK"] ) && isset( $this->input ) && $this->input != null && $this->mode == "view") { require_once ("classes/model/AppDocument.php"); - G::LoadClass("case"); + G::LoadClass( "case" ); $case = new Cases(); - $arrayField = $case->loadCase($_SESSION["APPLICATION"]); - $arrayPermission = $case->getAllObjects($arrayField["PRO_UID"], $_SESSION["APPLICATION"], $_SESSION["TASK"], $_SESSION["USER_LOGGED"]); + $arrayField = $case->loadCase( $_SESSION["APPLICATION"] ); + $arrayPermission = $case->getAllObjects( $arrayField["PRO_UID"], $_SESSION["APPLICATION"], $_SESSION["TASK"], $_SESSION["USER_LOGGED"] ); $criteria = new Criteria(); - $criteria->add(AppDocumentPeer::APP_DOC_UID, $arrayPermission["INPUT_DOCUMENTS"], Criteria::IN); + $criteria->add( AppDocumentPeer::APP_DOC_UID, $arrayPermission["INPUT_DOCUMENTS"], Criteria::IN ); switch ($owner->type) { case "xmlform": break; case "grid": - $criteria->add(AppDocumentPeer::APP_DOC_FIELDNAME, $owner->name . "_" . $row . "_" . $this->name); + $criteria->add( AppDocumentPeer::APP_DOC_FIELDNAME, $owner->name . "_" . $row . "_" . $this->name ); break; } - $criteria->addDescendingOrderByColumn(AppDocumentPeer::APP_DOC_CREATE_DATE); - $rsCriteria = AppDocumentPeer::doSelectRS($criteria); - $rsCriteria->setFetchmode(ResultSet::FETCHMODE_ASSOC); + $criteria->addDescendingOrderByColumn( AppDocumentPeer::APP_DOC_CREATE_DATE ); + $rsCriteria = AppDocumentPeer::doSelectRS( $criteria ); + $rsCriteria->setFetchmode( ResultSet::FETCHMODE_ASSOC ); $sw = 0; while (($rsCriteria->next()) && $sw == 0) { @@ -2376,7 +2621,7 @@ class XmlForm_Field_File extends XmlForm_Field if ($row["DOC_UID"] == $this->input) { $permission = true; - $url = ((G::is_https())? "https://" : "http://") . $_SERVER["HTTP_HOST"] . dirname($_SERVER["REQUEST_URI"]) . "/cases_ShowDocument?a=" . $row["APP_DOC_UID"] . "&v=" . $row["DOC_VERSION"]; + $url = ((G::is_https()) ? "https://" : "http://") . $_SERVER["HTTP_HOST"] . dirname( $_SERVER["REQUEST_URI"] ) . "/cases_ShowDocument?a=" . $row["APP_DOC_UID"] . "&v=" . $row["DOC_VERSION"]; $sw = 1; } } @@ -2384,12 +2629,12 @@ class XmlForm_Field_File extends XmlForm_Field $html1 = null; $html2 = null; - $mode = ($this->mode == "view")? " disabled=\"disabled\"" : null; + $mode = ($this->mode == "view") ? " disabled=\"disabled\"" : null; $styleDisplay = null; if ($this->mode == "view") { if ($permission) { - $html1 = "type == "grid")? " class=\"tableOption\" style=\"color: #006699; text-decoration: none; font-weight: normal;\"" : null) . ">"; + $html1 = "type == "grid") ? " class=\"tableOption\" style=\"color: #006699; text-decoration: none; font-weight: normal;\"" : null) . ">"; $html2 = ""; } @@ -2399,17 +2644,17 @@ class XmlForm_Field_File extends XmlForm_Field $html = $html1 . "name . "]\" name=\"form" . $rowId . "[" . $this->name . "]\" value=\"" . $value . "\" class=\"module_app_input___gray_file\" style=\"" . $styleDisplay . "\"" . $mode . " />" . $html2; - if (isset($this->input) && $this->input != null) { + if (isset( $this->input ) && $this->input != null) { require_once ("classes/model/InputDocument.php"); try { $indoc = new InputDocument(); - $aDoc = $indoc->load($this->input); - $aDoc["INP_DOC_TITLE"] = (isset($aDoc["INP_DOC_TITLE"]))? $aDoc["INP_DOC_TITLE"] : null; - $html = $html . ""; + $aDoc = $indoc->load( $this->input ); + $aDoc["INP_DOC_TITLE"] = (isset( $aDoc["INP_DOC_TITLE"] )) ? $aDoc["INP_DOC_TITLE"] : null; + $html = $html . ""; } catch (Exception $e) { //Then the input document doesn"t exits, id referencial broken - $html = $html . " \"\"(" . G::loadTranslation("ID_INPUT_DOC_DOESNT_EXIST") . ")"; + $html = $html . " \"\"(" . G::loadTranslation( "ID_INPUT_DOC_DOESNT_EXIST" ) . ")"; } } @@ -2418,13 +2663,13 @@ class XmlForm_Field_File extends XmlForm_Field return $html; } - public function renderGrid($value=array(), $owner=null, $therow=-1) + public function renderGrid ($value = array(), $owner = null, $therow = -1) { - $arrayResult = array(); + $arrayResult = array (); $r = 1; foreach ($value as $v) { - $arrayResult[] = $this->render($v, $owner, "[" . $owner->name . "][" . $r . "]", $r, $therow); + $arrayResult[] = $this->render( $v, $owner, "[" . $owner->name . "][" . $r . "]", $r, $therow ); $r = $r + 1; } @@ -2435,1046 +2680,1147 @@ class XmlForm_Field_File extends XmlForm_Field /** * Class XmlForm_Field_Dropdownpt * hook, dropdown field for Propel table + * * @author Erik Amaru * @package gulliver.system * @access public */ -class XmlForm_Field_Dropdownpt extends XmlForm_Field { - var $value; +class XmlForm_Field_Dropdownpt extends XmlForm_Field +{ + public $value; - function render($value = NULL, $owner = NULL) { - $this->value = $value; + public function render ($value = null, $owner = null) + { + $this->value = $value; - $id = $this->value->id; - $value = isset($this->value->value)? $this->value->value: ''; - $items = $this->value->items; + $id = $this->value->id; + $value = isset( $this->value->value ) ? $this->value->value : ''; + $items = $this->value->items; - $res = '"; - return $res; - } + $res = '"; + return $res; + } - /* Used in Form::validatePost - */ - function maskValue($value, &$owner) { - return ($value === $this->value) ? $value : $this->falseValue; - } + /* Used in Form::validatePost + */ + public function maskValue ($value, &$owner) + { + return ($value === $this->value) ? $value : $this->falseValue; + } } /** * Class XmlForm_Field_Checkboxpt * checkbox field for Propel table + * * @author Erik Amaru * @package gulliver.system * @access public */ -class XmlForm_Field_Checkboxpt extends XmlForm_Field { - var $required = false; - var $value = 'on'; - var $falseValue = 'off'; - var $labelOnRight = true; +class XmlForm_Field_Checkboxpt extends XmlForm_Field +{ + public $required = false; + public $value = 'on'; + public $falseValue = 'off'; + public $labelOnRight = true; - /** - * Render the field in a dynaform - * @param $value - * @param $owner - * @return <> - */ - function render($value = NULL, $owner = NULL) { - if (($this->pmconnection != '') && ($this->pmfield != '') && $value == NULL) { - $value = $this->getPMTableValue($owner); + /** + * Render the field in a dynaform + * + * @param $value + * @param $owner + * @return <> + */ + public function render ($value = null, $owner = null) + { + if (($this->pmconnection != '') && ($this->pmfield != '') && $value == null) { + $value = $this->getPMTableValue( $owner ); + } + $checked = (isset( $value ) && ($value == $this->value)) ? 'checked' : ''; + $res = ""; + return $res; } - $checked = (isset ( $value ) && ($value == $this->value)) ? 'checked' : ''; - $res = ""; - return $res; - } - - /** - * Render the field in a grid - * @param $value - * @param $owner - * @return result - */ - function renderGrid($values = array(), $owner) { - $result = array (); - $r = 1; - foreach ( $values as $v ) { - $checked = (($v == $this->value) ? 'checked="checked"' : ''); - $disabled = (($this->value == 'view') ? 'disabled="disabled"' : ''); - $html = $res = ""; - $result [] = $html; - $r ++; + /** + * Render the field in a grid + * + * @param $value + * @param $owner + * @return result + */ + public function renderGrid ($values = array(), $owner = null) + { + $result = array (); + $r = 1; + foreach ($values as $v) { + $checked = (($v == $this->value) ? 'checked="checked"' : ''); + $disabled = (($this->value == 'view') ? 'disabled="disabled"' : ''); + $html = $res = ""; + $result[] = $html; + $r ++; + } + return $result; } - return $result; - } - /** - * Used in Form::validatePost - * @param $value - * @param &$owner - * @return either the value or falseValue attributes - */ - function maskValue($value, &$owner) { - return ($value === $this->value) ? $value : $this->falseValue; - } + /** + * Used in Form::validatePost + * + * @param $value + * @param &$owner + * @return either the value or falseValue attributes + */ + public function maskValue ($value, &$owner) + { + return ($value === $this->value) ? $value : $this->falseValue; + } } /** * Class XmlForm_Field_Checkbox + * * @author Erik Amaru * @package gulliver.system * @access public */ class XmlForm_Field_Checkbox extends XmlForm_Field { - var $required = false; - var $value = 'on'; - var $falseValue = 'off'; - var $labelOnRight = true; - var $readOnly = false; - /** - * Function render - * @author David S. Callizaya S. - * @access public - * @param string value - * @return string - */ - function render($value = NULL, $owner = NULL) - { - if (($this->pmconnection != '') && ($this->pmfield != '') && $value == NULL) { - $value = $this->getPMTableValue($owner); - } + public $required = false; + public $value = 'on'; + public $falseValue = 'off'; + public $labelOnRight = true; + public $readOnly = false; - $disabled = ''; - if($this->readOnly==='readonly' or $this->readOnly==='1' ){ - $readOnly = 'readonly="readonly" onclick="javascript: return false;"';//$disabled = "disabled"; - } - else{ - $readOnly = ''; - } + /** + * Function render + * + * @author David S. Callizaya S. + * @access public + * @param string value + * @return string + */ + public function render ($value = null, $owner = null) + { + if (($this->pmconnection != '') && ($this->pmfield != '') && $value == null) { + $value = $this->getPMTableValue( $owner ); + } - $checked = (isset ( $value ) && ($value == $this->value)) ? 'checked' : ''; - - if ($this->mode === 'edit') { - //$readOnly = isset ( $this->readOnly ) && $this->readOnly ? 'disabled' : ''; - if ($this->labelOnRight) { - $res = "" . $this->label . ''; - } else { - $res = ""; - } - $res .= $this->renderHint(); - - // $res = "" . $this->label ; - return $res; - } elseif ($this->mode === 'view') { - $checked = (isset ( $value ) && ($value == $this->value)) ? 'checked' : ''; - if ($this->labelOnRight) { - $html = ''; - $html = " - " . $this->label . ''; - } else { - $html = ""; - } - $html .= ""; -// if($this->hint){ -// $html .= ' -// -// '; -// } - return $html; - } - } - - /** - * Render the field in a grid - * @param $value - * @param $owner - * @return result - */ - function renderGrid($values = array(), $owner) - { - $this->gridFieldType = 'checkbox'; - $result = array (); - $r = 1; - foreach ( $values as $v ) { - $checked = (($v == $this->value) ? 'checked="checked"' : ''); - if($this->readOnly==='readonly' or $this->readOnly==='1' ) { - $disabled = "disabled"; - } - else { $disabled = ''; - } - if ($this->mode==='edit') { - $html = $res = "NSDefaultValue()." ".$this->NSGridType()."/>"; - $result [] = $html; - $r ++; - } - else { - //$disabled = (($this->value == 'view') ? 'disabled="disabled"' : ''); - $html = $res = "NSDefaultValue()." ".$this->NSGridType()."/>"; - $result [] = $html; - $r ++; - } + if ($this->readOnly === 'readonly' or $this->readOnly === '1') { + $readOnly = 'readonly="readonly" onclick="javascript: return false;"'; //$disabled = "disabled"; + } else { + $readOnly = ''; + } + + $checked = (isset( $value ) && ($value == $this->value)) ? 'checked' : ''; + + if ($this->mode === 'edit') { + //$readOnly = isset ( $this->readOnly ) && $this->readOnly ? 'disabled' : ''; + if ($this->labelOnRight) { + $res = "" . $this->label . ''; + } else { + $res = ""; + } + $res .= $this->renderHint(); + + // $res = "" . $this->label ; + return $res; + } elseif ($this->mode === 'view') { + $checked = (isset( $value ) && ($value == $this->value)) ? 'checked' : ''; + if ($this->labelOnRight) { + $html = ''; + $html = " + " . $this->label . ''; + } else { + $html = ""; + } + $html .= ""; + // if($this->hint){ + // $html .= ' + // + // '; + // } + return $html; + } + } + + /** + * Render the field in a grid + * + * @param $value + * @param $owner + * @return result + */ + public function renderGrid ($values = array(), $owner = null) + { + $this->gridFieldType = 'checkbox'; + $result = array (); + $r = 1; + foreach ($values as $v) { + $checked = (($v == $this->value) ? 'checked="checked"' : ''); + if ($this->readOnly === 'readonly' or $this->readOnly === '1') { + $disabled = "disabled"; + } else { + $disabled = ''; + } + if ($this->mode === 'edit') { + $html = $res = "NSDefaultValue() . " " . $this->NSGridType() . "/>"; + $result[] = $html; + $r ++; + } else { + //$disabled = (($this->value == 'view') ? 'disabled="disabled"' : ''); + $html = $res = "NSDefaultValue() . " " . $this->NSGridType() . "/>"; + $result[] = $html; + $r ++; + } + } + return $result; + } + + /** + * Used in Form::validatePost + * + * @param $value + * @param $owner + * @return either the value or falseValue + */ + public function maskValue ($value, &$owner) + { + return ($value === $this->value) ? $value : $this->falseValue; } - return $result; - } - /** - * Used in Form::validatePost - * @param $value - * @param $owner - * @return either the value or falseValue - */ - function maskValue($value, &$owner) - { - return ($value === $this->value) ? $value : $this->falseValue; - } } /*DEPRECATED*/ /** + * * @package gulliver.system */ -class XmlForm_Field_Checkbox2 extends XmlForm_Field { - var $required = false; - function render($value = NULL) { - return '' . $this->label . ''; - } +class XmlForm_Field_Checkbox2 extends XmlForm_Field +{ + public $required = false; + + public function render ($value = null) + { + return '' . $this->label . ''; + } } + /** * Class XmlForm_Field_Button + * * @author David S. Callizaya S. * @package gulliver.system * @access public */ class XmlForm_Field_Button extends XmlForm_Field { - var $onclick = ''; - var $align = 'center'; - var $style; - /** - * Function render - * @author David S. Callizaya S. - * @access public - * @param string value - * @return string - */ - function render($value = NULL, $owner = NULL) - { - $onclick = G::replaceDataField ( $this->onclick, $owner->values ); - $label = G::replaceDataField ( $this->label, $owner->values ); - if ($this->mode === 'edit') { - $re = "style}\" class='module_app_button___gray {$this->className}' id=\"form[{$this->name}]\" name=\"form[{$this->name}]\" type='button' value=\"{$label}\" " . (($this->onclick) ? 'onclick="' . htmlentities ( $onclick, ENT_COMPAT, 'utf-8' ) . '"' : '') . " />"; - return $re; - } elseif ($this->mode === 'view') { - return "style};display:none\" disabled='disabled' class='module_app_button___gray module_app_buttonDisabled___gray {$this->className}' id=\"form[{$this->name}]\" name=\"form[{$this->name}]\" type='button' value=\"{$label}\" " . (($this->onclick) ? 'onclick="' . htmlentities ( $onclick, ENT_COMPAT, 'utf-8' ) . '"' : '') . " />"; - } else { - return $this->htmlentities ( $value, ENT_COMPAT, 'utf-8' ); + public $onclick = ''; + public $align = 'center'; + public $style; + + /** + * Function render + * + * @author David S. Callizaya S. + * @access public + * @param string value + * @return string + */ + public function render ($value = null, $owner = null) + { + $onclick = G::replaceDataField( $this->onclick, $owner->values ); + $label = G::replaceDataField( $this->label, $owner->values ); + if ($this->mode === 'edit') { + $re = "style}\" class='module_app_button___gray {$this->className}' id=\"form[{$this->name}]\" name=\"form[{$this->name}]\" type='button' value=\"{$label}\" " . (($this->onclick) ? 'onclick="' . htmlentities( $onclick, ENT_COMPAT, 'utf-8' ) . '"' : '') . " />"; + return $re; + } elseif ($this->mode === 'view') { + return "style};display:none\" disabled='disabled' class='module_app_button___gray module_app_buttonDisabled___gray {$this->className}' id=\"form[{$this->name}]\" name=\"form[{$this->name}]\" type='button' value=\"{$label}\" " . (($this->onclick) ? 'onclick="' . htmlentities( $onclick, ENT_COMPAT, 'utf-8' ) . '"' : '') . " />"; + } else { + return $this->htmlentities( $value, ENT_COMPAT, 'utf-8' ); + } } - } } + /** * Class XmlForm_Field_Reset + * * @author David S. Callizaya S. * @package gulliver.system * @access public */ class XmlForm_Field_Reset extends XmlForm_Field { - /** - * Function render - * @author David S. Callizaya S. - * @access public - * @param string value - * @return string - */ - function render($value = NULL, $owner) - { - $onclick = G::replaceDataField ( $this->onclick, $owner->values ); - $mode = ($this->mode == 'view') ? ' disabled="disabled"' : ''; - //return ''; -// return "style}\" $mode class='module_app_button___gray {$this->className}' id=\"form[{$this->name}]\" name=\"form[{$this->name}]\" type='reset' value=\"{$this->label}\" " . (($this->onclick) ? 'onclick="' . htmlentities ( $onclick, ENT_COMPAT, 'utf-8' ) . '"' : '') . " />"; - if ($this->mode === 'edit') { - return "style}\" $mode class='module_app_button___gray {$this->className}' id=\"form[{$this->name}]\" name=\"form[{$this->name}]\" type='reset' value=\"{$this->label}\" " . (($this->onclick) ? 'onclick="' . htmlentities ( $onclick, ENT_COMPAT, 'utf-8' ) . '"' : '') . " />"; - } elseif ($this->mode === 'view') { - return "style};display:none\" $mode class='module_app_button___gray {$this->className}' id=\"form[{$this->name}]\" name=\"form[{$this->name}]\" type='reset' value=\"{$this->label}\" " . (($this->onclick) ? 'onclick="' . htmlentities ( $onclick, ENT_COMPAT, 'utf-8' ) . '"' : '') . " />"; - } else { - return $this->htmlentities ( $value, ENT_COMPAT, 'utf-8' ); - } - } + /** + * Function render + * + * @author David S. Callizaya S. + * @access public + * @param string value + * @return string + */ + public function render ($value = null, $owner = null) + { + $onclick = G::replaceDataField( $this->onclick, $owner->values ); + $mode = ($this->mode == 'view') ? ' disabled="disabled"' : ''; + //return ''; + // return "style}\" $mode class='module_app_button___gray {$this->className}' id=\"form[{$this->name}]\" name=\"form[{$this->name}]\" type='reset' value=\"{$this->label}\" " . (($this->onclick) ? 'onclick="' . htmlentities ( $onclick, ENT_COMPAT, 'utf-8' ) . '"' : '') . " />"; + if ($this->mode === 'edit') { + return "style}\" $mode class='module_app_button___gray {$this->className}' id=\"form[{$this->name}]\" name=\"form[{$this->name}]\" type='reset' value=\"{$this->label}\" " . (($this->onclick) ? 'onclick="' . htmlentities( $onclick, ENT_COMPAT, 'utf-8' ) . '"' : '') . " />"; + } elseif ($this->mode === 'view') { + return "style};display:none\" $mode class='module_app_button___gray {$this->className}' id=\"form[{$this->name}]\" name=\"form[{$this->name}]\" type='reset' value=\"{$this->label}\" " . (($this->onclick) ? 'onclick="' . htmlentities( $onclick, ENT_COMPAT, 'utf-8' ) . '"' : '') . " />"; + } else { + return $this->htmlentities( $value, ENT_COMPAT, 'utf-8' ); + } + + } } + /** * Class XmlForm_Field_Submit + * * @author David S. Callizaya S. * @package gulliver.system * @access public */ -class XmlForm_Field_Submit extends XmlForm_Field { - var $onclick = ''; - /** - * Function render - * @author David S. Callizaya S. - * @access public - * @param string value - * @return string - */ - function render($value = NULL, $owner) { - $onclick = G::replaceDataField ( $this->onclick, $owner->values ); - if ($this->mode === 'edit') { - // if ($this->readOnly) - // return 'label .'\' disabled/>'; - return "style}\" class='module_app_button___gray {$this->className}' id=\"form[{$this->name}]\" name=\"form[{$this->name}]\" type='submit' value=\"{$this->label}\" " . (($this->onclick) ? 'onclick="' . htmlentities ( $onclick, ENT_COMPAT, 'utf-8' ) . '"' : '') . " />"; - } elseif ($this->mode === 'view') { - // return "style};display:none\" disabled='disabled' class='module_app_button___gray module_app_buttonDisabled___gray {$this->className}' id=\"form[{$this->name}]\" name=\"form[{$this->name}]\" type='submit' value=\"{$this->label}\" " . (($this->onclick) ? 'onclick="' . htmlentities ( $onclick, ENT_COMPAT, 'utf-8' ) . '"' : '') . " />"; - //$sLinkNextStep = 'window.open("' . $owner->fields['__DYNAFORM_OPTIONS']->xmlMenu->values['NEXT_STEP'] . '", "_self");'; - $html = ''; - if (isset($_SESSION['CURRENT_DYN_UID'])) { - $sLinkNextStep = 'window.location=("casesSaveDataView?UID='.$_SESSION['CURRENT_DYN_UID'].'");'; - $html = ''; - } - $html .= 'name . ']" '; - $html .= 'name="form[' . $this->name . ']" '; - $html .= 'type="hidden" value="'. $this->htmlentities ( $this->label, ENT_QUOTES, 'utf-8' ) .'" />'; - return $html; - } else { - return $this->htmlentities ( $value, ENT_COMPAT, 'utf-8' ); +class XmlForm_Field_Submit extends XmlForm_Field +{ + public $onclick = ''; + + /** + * Function render + * + * @author David S. Callizaya S. + * @access public + * @param string value + * @return string + */ + public function render ($value = null, $owner = null) + { + $onclick = G::replaceDataField( $this->onclick, $owner->values ); + if ($this->mode === 'edit') { + // if ($this->readOnly) + // return 'label .'\' disabled/>'; + return "style}\" class='module_app_button___gray {$this->className}' id=\"form[{$this->name}]\" name=\"form[{$this->name}]\" type='submit' value=\"{$this->label}\" " . (($this->onclick) ? 'onclick="' . htmlentities( $onclick, ENT_COMPAT, 'utf-8' ) . '"' : '') . " />"; + } elseif ($this->mode === 'view') { + // return "style};display:none\" disabled='disabled' class='module_app_button___gray module_app_buttonDisabled___gray {$this->className}' id=\"form[{$this->name}]\" name=\"form[{$this->name}]\" type='submit' value=\"{$this->label}\" " . (($this->onclick) ? 'onclick="' . htmlentities ( $onclick, ENT_COMPAT, 'utf-8' ) . '"' : '') . " />"; + //$sLinkNextStep = 'window.open("' . $owner->fields['__DYNAFORM_OPTIONS']->xmlMenu->values['NEXT_STEP'] . '", "_self");'; + $html = ''; + if (isset( $_SESSION['CURRENT_DYN_UID'] )) { + $sLinkNextStep = 'window.location=("casesSaveDataView?UID=' . $_SESSION['CURRENT_DYN_UID'] . '");'; + $html = ''; + } + $html .= 'name . ']" '; + $html .= 'name="form[' . $this->name . ']" '; + $html .= 'type="hidden" value="' . $this->htmlentities( $this->label, ENT_QUOTES, 'utf-8' ) . '" />'; + return $html; + } else { + return $this->htmlentities( $value, ENT_COMPAT, 'utf-8' ); + } } - } } + /** * Class XmlForm_Field_Hidden + * * @author David S. Callizaya S. * @package gulliver.system * @access public */ class XmlForm_Field_Hidden extends XmlForm_Field { - var $sqlConnection = 0; - var $sql = ''; - var $sqlOption = array (); - var $dependentFields = ''; - /** - * Function render - * @author David S. Callizaya S. - * @access public - * @param string value - * @param string owner - * @return string - */ - function render($value = NULL, $owner) - { - if (($this->pmconnection != '') && ($this->pmfield != '') && $value == NULL) { - $value = $this->getPMTableValue($owner); - } - else { - $this->executeSQL ( $owner ); + public $sqlConnection = 0; + public $sql = ''; + public $sqlOption = array (); + public $dependentFields = ''; - if (isset ( $this->sqlOption )) { - reset ( $this->sqlOption ); - $firstElement = key ( $this->sqlOption ); - if (isset ( $firstElement )) - $value = $firstElement; - } - } - if ($this->mode === 'edit') { - return ''; - } elseif ($this->mode === 'view') { - //a button? who wants a hidden field be showed like a button?? very strange. - return ''; - } else { - return $this->htmlentities ( $value, ENT_COMPAT, 'utf-8' ); - } - } + /** + * Function render + * + * @author David S. Callizaya S. + * @access public + * @param string value + * @param string owner + * @return string + */ + public function render ($value = null, $owner = null) + { + if (($this->pmconnection != '') && ($this->pmfield != '') && $value == null) { + $value = $this->getPMTableValue( $owner ); + } else { + $this->executeSQL( $owner ); - /** - * Render the field in a grid - * @param $value - * @param $owner - * @return result - */ - function renderGrid($values = NULL, $owner) - { - $result = array (); - $r = 1; - foreach ( $values as $v ) { - $result [] = ''; - $r ++; + if (isset( $this->sqlOption )) { + reset( $this->sqlOption ); + $firstElement = key( $this->sqlOption ); + if (isset( $firstElement )) { + $value = $firstElement; + } + } + } + if ($this->mode === 'edit') { + return ''; + } elseif ($this->mode === 'view') { + //a button? who wants a hidden field be showed like a button?? very strange. + return ''; + } else { + return $this->htmlentities( $value, ENT_COMPAT, 'utf-8' ); + } } - return $result; - } + /** + * Render the field in a grid + * + * @param $value + * @param $owner + * @return result + */ + public function renderGrid ($values = null, $owner = null) + { + $result = array (); + $r = 1; + foreach ($values as $v) { + $result[] = ''; + $r ++; + } - /** - * Render the field in a table - * @param $value - * @param $owner - * @return result - */ - function renderTable($value = '', $owner) - { - return ''; - } + return $result; + } + /** + * Render the field in a table + * + * @param $value + * @param $owner + * @return result + */ + public function renderTable ($value = '', $owner = null) + { + return ''; + } } + /** * Class XmlForm_Field_Dropdown + * * @author David S. Callizaya S. * @package gulliver.system * @access public */ -class XmlForm_Field_Dropdown extends XmlForm_Field { - var $defaultValue = ''; - var $required = false; - var $dependentFields = ''; - var $readonly = false; - var $option = array (); - var $sqlConnection = 0; - var $sql = ''; - var $sqlOption = array (); - var $saveLabel = 0; - var $modeGridDrop = ''; - var $renderMode = ''; - var $selectedValue = ''; - function validateValue($value, &$owner) - { - /*$this->executeSQL( $owner ); - return isset($value) && ( array_key_exists( $value , $this->options ) );*/ - return true; - } +class XmlForm_Field_Dropdown extends XmlForm_Field +{ + public $defaultValue = ''; + public $required = false; + public $dependentFields = ''; + public $readonly = false; + public $option = array (); + public $sqlConnection = 0; + public $sql = ''; + public $sqlOption = array (); + public $saveLabel = 0; + public $modeGridDrop = ''; + public $renderMode = ''; + public $selectedValue = ''; - /** - * Function render - * @author David S. Callizaya S. - * @access public - * @param string value - * @param string owner - * @return string - */ - function render($value = NULL, $owner = NULL, $rowId = '', $onlyValue = false, $row = -1, $therow = -1) - { - $displayStyle = ''; - - //Returns value from a PMTable when it is exists. - if (($this->pmconnection != '') && ($this->pmfield != '') && $value == NULL) { - $value = $this->getPMTableValue($owner); - } - //Recalculate SQL options if $therow is not defined or the row id equal - if ($therow == -1) { - //echo 'Entro:'.$this->dependentFields; - $this->executeSQL ( $owner, $row ); - } else { - if ($row == $therow) { - $this->executeSQL ( $owner, $row ); - } + public function validateValue ($value, &$owner) + { + /*$this->executeSQL( $owner ); + return isset($value) && ( array_key_exists( $value , $this->options ) );*/ + return true; } - $html = ''; - $displayLabel = ''; + /** + * Function render + * + * @author David S. Callizaya S. + * @access public + * @param string value + * @param string owner + * @return string + */ + public function render ($value = null, $owner = null, $rowId = '', $onlyValue = false, $row = -1, $therow = -1) + { + $displayStyle = ''; - if ($this->renderMode == '') $this->renderMode = $this->mode; + //Returns value from a PMTable when it is exists. + if (($this->pmconnection != '') && ($this->pmfield != '') && $value == null) { + $value = $this->getPMTableValue( $owner ); + } + //Recalculate SQL options if $therow is not defined or the row id equal + if ($therow == - 1) { + //echo 'Entro:'.$this->dependentFields; + $this->executeSQL( $owner, $row ); + } else { + if ($row == $therow) { + $this->executeSQL( $owner, $row ); + } + } - if (!$onlyValue){ //Render Field if not defined onlyValue - if ($this->renderMode != 'edit') { //EDIT MODE - $displayStyle = 'display:none;'; - } - $readOnlyField = ($this->readonly == 1 || $this->readonly == '1') ? 'disabled' : ''; - $html = ''; - if ($readOnlyField != ''){ - $html .= 'name . ']" '; - $html .= 'name="form' . $rowId . '[' . $this->name . ']" '; - $html .= 'value="'.(($findValue != '') ? $findValue : $firstValue).'" />'; - } - $this->selectedValue = ($findValue != '') ? $findValue : ($cont==0)? $firstValue : ''; + $html = ''; + $displayLabel = ''; - }else{ //Render Field showing only value; - foreach ($this->option as $optValue => $optName) { - if ($optValue == $value) { - $html = $optName; + if ($this->renderMode == '') { + $this->renderMode = $this->mode; } - } - foreach ($this->sqlOption as $optValue => $optName) { - if ($optValue == $value) { - $html = $optName; + + if (! $onlyValue) { + //Render Field if not defined onlyValue + if ($this->renderMode != 'edit') { + //EDIT MODE + $displayStyle = 'display:none;'; + } + $readOnlyField = ($this->readonly == 1 || $this->readonly == '1') ? 'disabled' : ''; + $html = ''; + if ($readOnlyField != '') { + $html .= 'name . ']" '; + $html .= 'name="form' . $rowId . '[' . $this->name . ']" '; + $html .= 'value="' . (($findValue != '') ? $findValue : $firstValue) . '" />'; + } + $this->selectedValue = ($findValue != '') ? $findValue : ($cont == 0) ? $firstValue : ''; + + } else { + //Render Field showing only value; + foreach ($this->option as $optValue => $optName) { + if ($optValue == $value) { + $html = $optName; + } + } + foreach ($this->sqlOption as $optValue => $optName) { + if ($optValue == $value) { + $html = $optName; + } + } } - } + + if ($this->gridFieldType == '') { + $html .= $this->renderHint(); + } + if ($displayStyle != '') { + $html = $displayLabel . $html; + } + return $html; } - if ($this->gridFieldType == '') $html .= $this->renderHint(); - if ($displayStyle != '') $html = $displayLabel . $html; - return $html; - } + /** + * Function renderGrid + * + * @author David S. Callizaya S. + * @access public + * @param string values + * @return string + */ + public function renderGrid ($values = array(), $owner = null, $onlyValue = false, $therow = -1) + { + $this->gridFieldType = 'dropdown'; + $result = array (); + $r = 1; + if ($owner->mode != 'view') { + $this->renderMode = $this->modeForGrid; + } - /** - * Function renderGrid - * @author David S. Callizaya S. - * @access public - * @param string values - * @return string - */ - function renderGrid($values = array(), $owner = NULL, $onlyValue = false, $therow = -1) - { - $this->gridFieldType = 'dropdown'; - $result = array (); - $r = 1; - if ($owner->mode != 'view') $this->renderMode = $this->modeForGrid; - - foreach ( $values as $v ) { - $result [] = $this->render ( $v, $owner, '[' . $owner->name . '][' . $r . ']', $onlyValue, $r, $therow ); - $r ++; + foreach ($values as $v) { + $result[] = $this->render( $v, $owner, '[' . $owner->name . '][' . $r . ']', $onlyValue, $r, $therow ); + $r ++; + } + return $result; } - return $result; - } } + /** * Class XmlForm_Field_Listbox + * * @author David S. Callizaya S. * @package gulliver.system * @access public */ class XmlForm_Field_Listbox extends XmlForm_Field { - var $defaultValue = ''; - var $required = false; - var $option = array (); - var $sqlConnection = 0; - var $size = 4; - var $width = ''; - var $sql = ''; - var $sqlOption = array (); - function validateValue($value, $owner) - { - $this->executeSQL ( $owner ); - return true; // isset($value) && ( array_key_exists( $value , $this->options ) ); - } - /** - * Function render - * @author David S. Callizaya S. - * @access public - * @param string value - * @param string owner - * @return string - */ - function render($value = NULL, $owner = NULL) - { - if (($this->pmconnection != '') && ($this->pmfield != '') && $value == NULL) { - $value = $this->getPMTableValue($owner); - } - $this->executeSQL ( $owner ); - if (! is_array ( $value )) - $value = explode ( '|', $value ); - if ($this->mode === 'edit') { - $itemWidth = ''; - if ($this->width != '') { - $itemWidth = 'style="width:'.$this->width . '"'; - } - $html = ''; + public $defaultValue = ''; + public $required = false; + public $option = array (); + public $sqlConnection = 0; + public $size = 4; + public $width = ''; + public $sql = ''; + public $sqlOption = array (); - $html .= $this->renderHint(); - return $html; - } elseif ($this->mode === 'view') { - $html = ''; - foreach ( $this->option as $optionName => $option ) { - $html .= ''; - } - foreach ( $this->sqlOption as $optionName => $option ) { - $html .= ''; - } - return $html; - } else { - return $this->htmlentities ( $value, ENT_COMPAT, 'utf-8' ); + public function validateValue ($value, $owner) + { + $this->executeSQL( $owner ); + return true; // isset($value) && ( array_key_exists( $value , $this->options ) ); } - } - /** - * Render the field in a grid - * @param $value - * @param $owner - * @return result - */ - function renderGrid($value = NULL, $owner = NULL) - { - return $this->render ( $value, $owner ); - } + /** + * Function render + * + * @author David S. Callizaya S. + * @access public + * @param string value + * @param string owner + * @return string + */ + public function render ($value = null, $owner = null) + { + if (($this->pmconnection != '') && ($this->pmfield != '') && $value == null) { + $value = $this->getPMTableValue( $owner ); + } + $this->executeSQL( $owner ); + if (! is_array( $value )) { + $value = explode( '|', $value ); + } + if ($this->mode === 'edit') { + $itemWidth = ''; + if ($this->width != '') { + $itemWidth = 'style="width:' . $this->width . '"'; + } + $html = ''; + + $html .= $this->renderHint(); + return $html; + } elseif ($this->mode === 'view') { + $html = ''; + foreach ($this->option as $optionName => $option) { + $html .= ''; + } + foreach ($this->sqlOption as $optionName => $option) { + $html .= ''; + } + return $html; + } else { + return $this->htmlentities( $value, ENT_COMPAT, 'utf-8' ); + } + } + + /** + * Render the field in a grid + * + * @param $value + * @param $owner + * @return result + */ + public function renderGrid ($value = null, $owner = null) + { + return $this->render( $value, $owner ); + } } + /** * Class XmlForm_Field_RadioGroup + * * @author David S. Callizaya S. * @package gulliver.system * @access public */ -class XmlForm_Field_RadioGroup extends XmlForm_Field { - var $defaultValue = ''; - var $required = false; - var $option = array (); - var $sqlConnection = 0; - var $sql = ''; - var $sqlOption = array (); - var $viewAlign = 'vertical'; - var $linkType; +class XmlForm_Field_RadioGroup extends XmlForm_Field +{ + public $defaultValue = ''; + public $required = false; + public $option = array (); + public $sqlConnection = 0; + public $sql = ''; + public $sqlOption = array (); + public $viewAlign = 'vertical'; + public $linkType; - /** - * validate the execution of a query - * @param $value - * @param $owner - * @return $value - */ - function validateValue($value, $owner) - { - $this->executeSQL ( $owner ); - return isset ( $value ) && (array_key_exists ( $value, $this->options )); - } - - /** - * Function render - * @author David S. Callizaya S. - * @access public - * @param string value - * @param string owner - * @return string - */ - function render($value = NULL, $owner) - { - if (($this->pmconnection != '') && ($this->pmfield != '') && $value == NULL) { - $value = $this->getPMTableValue($owner); + /** + * validate the execution of a query + * + * @param $value + * @param $owner + * @return $value + */ + public function validateValue ($value, $owner) + { + $this->executeSQL( $owner ); + return isset( $value ) && (array_key_exists( $value, $this->options )); } - $this->executeSQL ( $owner ); - if ($this->mode === 'edit') { - $html = ''; - $i = 0; - foreach ( $this->options as $optionName => $option ) { - if( isset($this->linkType) && ($this->linkType == 1 || $this->linkType == "1") ){ - $html .= '' . $option . ''; + + /** + * Function render + * + * @author David S. Callizaya S. + * @access public + * @param string value + * @param string owner + * @return string + */ + public function render ($value = null, $owner = null) + { + if (($this->pmconnection != '') && ($this->pmfield != '') && $value == null) { + $value = $this->getPMTableValue( $owner ); + } + $this->executeSQL( $owner ); + if ($this->mode === 'edit') { + $html = ''; + $i = 0; + foreach ($this->options as $optionName => $option) { + if (isset( $this->linkType ) && ($this->linkType == 1 || $this->linkType == "1")) { + $html .= '' . $option . ''; + } else { + $html .= ''; + } + if (++ $i == count( $this->options )) { + $html .= '      ' . $this->renderHint(); + } + + if ($this->viewAlign == 'horizontal') { + $html .= ' '; + } else { + $html .= '
'; + } + } + return $html; + } elseif ($this->mode === 'view') { + $html = ''; + foreach ($this->options as $optionName => $option) { + $html .= '
'; + if ($optionName == $value) { + $html .= ''; + } + } + return $html; } else { - $html .= ''; + return $this->htmlentities( $value, ENT_COMPAT, 'utf-8' ); } - if(++$i==count($this->options)){ - $html .= '      '.$this->renderHint(); - } - - if($this->viewAlign == 'horizontal') - $html .=' '; - else - $html .='
'; - - } - return $html; - } elseif ($this->mode === 'view') { - $html = ''; - foreach ( $this->options as $optionName => $option ) { - $html .= '
'; - if($optionName == $value) - $html .= ''; - } - - return $html; - } else { - return $this->htmlentities ( $value, ENT_COMPAT, 'utf-8' ); } - } } /*DEPRECATED*/ /** + * * @package gulliver.system -*/ + * + */ class XmlForm_Field_RadioGroupView extends XmlForm_Field { - var $defaultValue = ''; - var $required = false; - var $option = array (); - var $sqlConnection = 0; - var $sql = ''; - var $sqlOption = array (); - /** - * Function render - * @author David S. Callizaya S. - * @access public - * @param string value - * @param string owner - * @return string - */ - function render($value = NULL, $owner = NULL) - { - $this->executeSQL ( $owner ); - $html = ''; - foreach ( $this->option as $optionName => $option ) { - $html .= '' . $option . '
'; + public $defaultValue = ''; + public $required = false; + public $option = array (); + public $sqlConnection = 0; + public $sql = ''; + public $sqlOption = array (); + + /** + * Function render + * + * @author David S. Callizaya S. + * @access public + * @param string value + * @param string owner + * @return string + */ + public function render ($value = null, $owner = null) + { + $this->executeSQL( $owner ); + $html = ''; + foreach ($this->option as $optionName => $option) { + $html .= '' . $option . '
'; + } + return $html; } - return $html; - } } /** * Class XmlForm_Field_CheckGroup + * * @author David S. Callizaya S. * @package gulliver.system * @access public */ class XmlForm_Field_CheckGroup extends XmlForm_Field { - var $required = false; - var $option = array (); - var $sqlConnection = 0; - var $sql = ''; - var $sqlOption = array (); - /*function validateValue( $value , $owner ) - { - $this->executeSQL( $owner ); - return isset($value) && ( array_key_exists( $value , $this->options ) ); - }*/ - /** - * Function render - * @author David S. Callizaya S. - * @access public - * @param string value - * @param string owner - * @return string - */ - function render($value = NULL, $owner = NULL) - { - if (($this->pmconnection != '') && ($this->pmfield != '') && $value == NULL) { - $value = $this->getPMTableValue($owner); - } - $this->executeSQL ( $owner ); - if (! is_array ( $value )) - $value = explode ( '|', $value ); - if ($this->mode === 'edit') { - $i=0; - $html = ''; - foreach ( $this->options as $optionName => $option ) { - $html .= ''; - if(++$i==count($this->options)){ - $html .= '      '.$this->renderHint(); + public $required = false; + public $option = array (); + public $sqlConnection = 0; + public $sql = ''; + public $sqlOption = array (); + /*function validateValue( $value , $owner ) + { + $this->executeSQL( $owner ); + return isset($value) && ( array_key_exists( $value , $this->options ) ); + }*/ + /** + * Function render + * + * @author David S. Callizaya S. + * @access public + * @param string value + * @param string owner + * @return string + */ + public function render ($value = null, $owner = null) + { + if (($this->pmconnection != '') && ($this->pmfield != '') && $value == null) { + $value = $this->getPMTableValue( $owner ); + } + $this->executeSQL( $owner ); + if (! is_array( $value )) { + $value = explode( '|', $value ); + } + if ($this->mode === 'edit') { + $i = 0; + $html = ''; + foreach ($this->options as $optionName => $option) { + $html .= ''; + if (++ $i == count( $this->options )) { + $html .= '      ' . $this->renderHint(); + } + $html .= '
'; + } //fin for + return $html; + } elseif ($this->mode === 'view') { + $html = ''; + foreach ($this->options as $optionName => $option) { + $html .= '
'; + $html .= ''; + } + return $html; + } else { + return $this->htmlentities( $value, ENT_COMPAT, 'utf-8' ); } - $html .= '
'; - }//fin for - return $html; - } elseif ($this->mode === 'view') { - $html = ''; - foreach ( $this->options as $optionName => $option ) { - $html .= '
'; - $html .= ''; - } - return $html; - } else { - return $this->htmlentities ( $value, ENT_COMPAT, 'utf-8' ); - } - } + } } /* TODO: DEPRECATED */ /** + * * @package gulliver.system -*/ + * + */ class XmlForm_Field_CheckGroupView extends XmlForm_Field { - var $option = array (); - var $sqlConnection = 0; - var $sql = ''; - var $sqlOption = array (); - /** - * Function render - * @author David S. Callizaya S. - * @access public - * @param string value - * @return string - */ - function render($value = NULL) - { - $html = ''; - foreach ( $this->option as $optionName => $option ) { - $html .= '' . $option . '
'; + public $option = array (); + public $sqlConnection = 0; + public $sql = ''; + public $sqlOption = array (); + + /** + * Function render + * + * @author David S. Callizaya S. + * @access public + * @param string value + * @return string + */ + public function render ($value = null) + { + $html = ''; + foreach ($this->option as $optionName => $option) { + $html .= '' . $option . '
'; + } + return $html; } - return $html; - } } + /** * Class XmlForm_Field_Grid + * * @author David S. Callizaya S. * @package gulliver.system * @access public */ class XmlForm_Field_Grid extends XmlForm_Field { - var $xmlGrid = ''; - var $initRows = 1; - var $group = 0; - var $addRow = "1"; - var $deleteRow = "1"; - var $editRow = "0"; - var $sql = ''; - //TODO: 0=doesn't excecute the query, 1=Only the first time, 2=Allways - var $fillType = 0; - var $fields = array (); - var $scriptURL; - var $id = ''; + public $xmlGrid = ''; + public $initRows = 1; + public $group = 0; + public $addRow = "1"; + public $deleteRow = "1"; + public $editRow = "0"; + public $sql = ''; + //TODO: 0=doesn't excecute the query, 1=Only the first time, 2=Allways + public $fillType = 0; + public $fields = array (); + public $scriptURL; + public $id = ''; - /** - * Function XmlForm_Field_Grid - * @author David S. Callizaya S. - * @access public - * @param string xmlnode - * @param string language - * @param string home - * @return string - */ - function XmlForm_Field_Grid($xmlnode, $language, $home) - { - parent::XmlForm_Field ( $xmlnode, $language ); - $this->parseFile ( $home, $language ); - } - - /** - * Function parseFile - * @author David S. Callizaya S. - * @access public - * @param string home - * @param string language - * @return string - */ - function parseFile($home, $language) - { - if (file_exists ( $home . $this->xmlGrid . '.xml' )) { - $this->xmlform = new XmlForm ( ); - $this->xmlform->home = $home; - $this->xmlform->parseFile ( $this->xmlGrid . '.xml', $language, false ); - $this->fields = $this->xmlform->fields; - $this->scriptURL = $this->xmlform->scriptURL; - $this->id = $this->xmlform->id; - $this->modeGrid = $this->xmlform->mode; - unset ( $this->xmlform ); - } - } - - /** - * Render the field in a dynaform - * @param $value - * @param $owner - * @return