Adjustment to establish mode the Grids Tables, and elements
This commit is contained in:
@@ -66,6 +66,9 @@ class XmlForm_Field {
|
||||
var $pmconnection = '';
|
||||
var $pmfield = '';
|
||||
|
||||
// For mode cases Grid
|
||||
var $modeGrid = '';
|
||||
var $modeForGrid = '';
|
||||
/**
|
||||
* Function XmlForm_Field
|
||||
* @author David S. Callizaya S. <davidsantos@colosa.com>
|
||||
@@ -83,7 +86,6 @@ class XmlForm_Field {
|
||||
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" );
|
||||
@@ -122,6 +124,7 @@ class XmlForm_Field {
|
||||
$ownerMode = isset ( $owner->mode ) ? $owner->mode : 'edit';
|
||||
if ($this->mode === '')
|
||||
$this->mode = $ownerMode !== '' ? $ownerMode : 'edit';
|
||||
$this->modeForGrid = $this->mode ;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -779,19 +782,20 @@ class XmlForm_Field_SimpleText extends XmlForm_Field
|
||||
} else {
|
||||
$isRequired = '0';
|
||||
}
|
||||
|
||||
$result = array ();
|
||||
$r = 1;
|
||||
if( ! isset($owner->modeGrid)) $owner->modeGrid = '';
|
||||
// Note added by Gustavo Cruz
|
||||
// also the fields rendered in a grid needs now have an attribute required set to 0 or 1
|
||||
// that it means not required or required respectively.
|
||||
$this->mode = $this->modeForGrid;
|
||||
foreach ( $values as $v ) {
|
||||
if ($this->mode === 'edit') {
|
||||
if ($this->mode === 'edit' && $owner->modeGrid != 'view') {
|
||||
if ($this->readOnly)
|
||||
$result [] = '<input class="module_app_input___gray" id="form[' . $owner->name . '][' . $r . '][' . $this->name . ']" name="form[' . $owner->name . '][' . $r . '][' . $this->name . ']" type ="text" size="' . $this->size . '" maxlength="' . $this->maxLength . '" value=\'' . htmlentities ( $v, ENT_COMPAT, 'utf-8' ) . '\' required="' . $isRequired . '" readOnly="readOnly" style="' . htmlentities ( $this->style, ENT_COMPAT, 'utf-8' ) . '"/>';
|
||||
else
|
||||
$result [] = '<input class="module_app_input___gray" id="form[' . $owner->name . '][' . $r . '][' . $this->name . ']" name="form[' . $owner->name . '][' . $r . '][' . $this->name . ']" type ="text" size="' . $this->size . '" maxlength="' . $this->maxLength . '" value=\'' . htmlentities ( $v, ENT_COMPAT, 'utf-8' ) . '\' required="' . $isRequired . '"style="' . htmlentities ( $this->style, ENT_COMPAT, 'utf-8' ) . '"/>';
|
||||
} elseif ($this->mode === 'view') {
|
||||
} elseif ($this->mode === 'view' || $owner->modeGrid === 'view') {
|
||||
$result [] = '<input class="module_app_input___gray" id="form[' . $owner->name . '][' . $r . '][' . $this->name . ']" name="form[' . $owner->name . '][' . $r . '][' . $this->name . ']" type ="text" size="' . $this->size . '" maxlength="' . $this->maxLength . '" value=\'' . htmlentities ( $v, ENT_COMPAT, 'utf-8' ) . '\' required="' . $isRequired . '"style="display:none;' . htmlentities ( $this->style, ENT_COMPAT, 'utf-8' ) . '"/>' . htmlentities ( $v, ENT_COMPAT, 'utf-8' );
|
||||
} else {
|
||||
$result [] = $this->htmlentities ( $v, ENT_COMPAT, 'utf-8' );
|
||||
@@ -828,6 +832,8 @@ class XmlForm_Field_Text extends XmlForm_Field_SimpleText
|
||||
var $function = '';
|
||||
var $replaceTags = 0;
|
||||
var $hint;
|
||||
|
||||
|
||||
/**
|
||||
* Function render
|
||||
* @author David S. Callizaya S. <davidsantos@colosa.com>
|
||||
@@ -888,6 +894,7 @@ class XmlForm_Field_Text extends XmlForm_Field_SimpleText
|
||||
{
|
||||
$result = $aux = array ();
|
||||
$r = 1;
|
||||
if( ! isset($owner->modeGrid)) $owner->modeGrid = '';
|
||||
// Note added by Gustavo Cruz
|
||||
// set the variable isRequired if the needs to be validated
|
||||
if ($this->required){
|
||||
@@ -898,6 +905,7 @@ class XmlForm_Field_Text extends XmlForm_Field_SimpleText
|
||||
// Note added by Gustavo Cruz
|
||||
// also the fields rendered in a grid needs now have an attribute required set to 0 or 1
|
||||
// that it means not required or required respectively.
|
||||
$this->mode = $this->modeForGrid;
|
||||
foreach ( $values as $v ) {
|
||||
$this->executeSQL ( $owner, $r );
|
||||
$firstElement = key ( $this->sqlOption );
|
||||
@@ -908,12 +916,12 @@ class XmlForm_Field_Text extends XmlForm_Field_SimpleText
|
||||
}
|
||||
$aux [$r] = $v;
|
||||
$v =($v!='')?$v:$this->defaultValue;
|
||||
if ($this->mode === 'edit') {
|
||||
if ($this->mode === 'edit' && $owner->modeGrid != 'view') {
|
||||
if ($this->readOnly)
|
||||
$result [] = '<input class="module_app_input___gray" id="form[' . $owner->name . '][' . $r . '][' . $this->name . ']" name="form[' . $owner->name . '][' . $r . '][' . $this->name . ']" type ="text" size="' . $this->size . '" maxlength="' . $this->maxLength . '" value="' . $this->htmlentities ( $v, ENT_COMPAT, 'utf-8' ) . '" required="' . $isRequired . '" readOnly="readOnly" style="' . htmlentities ( $this->style, ENT_COMPAT, 'utf-8' ) . '" pm:defaultvalue="'.$this->defaultValue.'"/>';
|
||||
else
|
||||
$result [] = '<input class="module_app_input___gray" id="form[' . $owner->name . '][' . $r . '][' . $this->name . ']" name="form[' . $owner->name . '][' . $r . '][' . $this->name . ']" type ="text" size="' . $this->size . '" maxlength="' . $this->maxLength . '" value="' . $this->htmlentities ( $v, ENT_COMPAT, 'utf-8' ) . '" required="' . $isRequired . '" style="' . htmlentities ( $this->style, ENT_COMPAT, 'utf-8' ) . '" pm:defaultvalue="'.$this->defaultValue.'"/>';
|
||||
} elseif ($this->mode === 'view') {
|
||||
} elseif ($this->mode === 'view' || $owner->modeGrid === 'view') {
|
||||
$result [] = '<input class="module_app_input___gray" id="form[' . $owner->name . '][' . $r . '][' . $this->name . ']" name="form[' . $owner->name . '][' . $r . '][' . $this->name . ']" type ="text" size="' . $this->size . '" maxlength="' . $this->maxLength . '" value="' . $this->htmlentities ( $v, ENT_COMPAT, 'utf-8' ) . '" required="' . $isRequired . '" style="display:none;' . htmlentities ( $this->style, ENT_COMPAT, 'utf-8' ) . '"/>' . htmlentities ( $v, ENT_COMPAT, 'utf-8' );
|
||||
} else {
|
||||
$result [] = $this->htmlentities ( $v, ENT_COMPAT, 'utf-8' );
|
||||
@@ -1336,17 +1344,18 @@ class XmlForm_Field_Textarea extends XmlForm_Field {
|
||||
// Note added by Gustavo Cruz
|
||||
// also the fields rendered in a grid needs now have an attribute required set to 0 or 1
|
||||
// that it means not required or required respectively.
|
||||
|
||||
$result = array ();
|
||||
$r = 1;
|
||||
if( ! isset($owner->modeGrid)) $owner->modeGrid = '';
|
||||
$this->mode = $this->modeForGrid;
|
||||
foreach ( $values as $v ) {
|
||||
if ($this->mode === 'edit') {
|
||||
if ($this->mode === 'edit' && $owner->modeGrid != 'view') {
|
||||
|
||||
if ($this->readOnly)
|
||||
$result [] = '<textarea class="module_app_input___gray" id="form[' . $owner->name . '][' . $r . '][' . $this->name . ']" name="form[' . $owner->name . '][' . $r . '][' . $this->name . ']" wrap="hard" rows="' . $this->rows . '"cols="'.$this->cols.'" required="' . $isRequired . '" readOnly="readOnly">'.$this->htmlentities ( $v, ENT_COMPAT, 'utf-8' ).'</textarea>';
|
||||
else
|
||||
$result [] = '<textarea class="module_app_input___gray" id="form[' . $owner->name . '][' . $r . '][' . $this->name . ']" name="form[' . $owner->name . '][' . $r . '][' . $this->name . ']" wrap="hard" rows="' . $this->rows . '"cols="'.$this->cols.'" required="' . $isRequired . '">'.$this->htmlentities ( $v, ENT_COMPAT, 'utf-8' ).'</textarea>';
|
||||
} elseif ($this->mode === 'view') {
|
||||
} elseif ($this->mode === 'view' || $owner->modeGrid === 'view') {
|
||||
|
||||
if (stristr ( $_SERVER ['HTTP_USER_AGENT'], 'iPhone' )) {
|
||||
//$result[] = '<div style="overflow:hidden;height:25px;padding:0px;margin:0px;">'.$this->htmlentities( $v , ENT_COMPAT, 'utf-8').'</div>';
|
||||
@@ -1395,7 +1404,6 @@ class XmlForm_Field_Currency extends XmlForm_Field_SimpleText {
|
||||
*/
|
||||
function render( $value = NULL, $owner = NULL) {
|
||||
$onkeypress = G::replaceDataField ( $this->onkeypress, $owner->values );
|
||||
|
||||
if ($this->mode === 'edit') {
|
||||
if ($this->readOnly)
|
||||
return '<input class="module_app_input___gray" id="form[' . $this->name . ']" name="form[' . $this->name . ']" type ="text" size="' . $this->size . '" maxlength="' . $this->maxLength . '" value=\'' . $this->htmlentities ( $value, ENT_QUOTES, 'utf-8' ) . '\' readOnly="readOnly" style="' . htmlentities ( $this->style, ENT_COMPAT, 'utf-8' ) . '" onkeypress="' . htmlentities ( $onkeypress, ENT_COMPAT, 'utf-8' ) . '"/>';
|
||||
@@ -1771,8 +1779,9 @@ class XmlForm_Field_YesNo extends XmlForm_Field
|
||||
function renderGrid($values = array(), $owner) {
|
||||
$result = array ();
|
||||
$r = 1;
|
||||
$this->mode = $this->modeForGrid;
|
||||
foreach ( $values as $v ) {
|
||||
$html = ($this->mode == 'view' ? ($v === '0' ? 'NO' : 'YES') : '') . '<select id="form[' . $owner->name . '][' . $r . '][' . $this->name . ']" name="form[' . $owner->name . '][' . $r . '][' . $this->name . ']"' . ($this->mode == 'view' ? ' style="display:none;"' : '') . '>';
|
||||
$html = (($this->mode == 'view' || $owner->modeGrid == 'view')? ($v === '0' ? 'NO' : 'YES') : '') . '<select id="form[' . $owner->name . '][' . $r . '][' . $this->name . ']" name="form[' . $owner->name . '][' . $r . '][' . $this->name . ']"' . (($this->mode == 'view' || $owner->modeGrid == 'view')? ' style="display:none;"' : '') . '>';
|
||||
$html .= '<option value="' . '0' . '"' . ($v === '0' ? ' selected' : '') . '>' . 'NO' . '</input>';
|
||||
$html .= '<option value="' . '1' . '"' . ($v === '1' ? ' selected' : '') . '>' . 'YES' . '</input>';
|
||||
$html .= '</select>';
|
||||
@@ -2278,6 +2287,7 @@ class XmlForm_Field_Dropdown extends XmlForm_Field {
|
||||
var $sqlOption = array ();
|
||||
var $saveLabel = 0;
|
||||
var $hint;
|
||||
var $modeGridDrop = '';
|
||||
function validateValue($value, &$owner)
|
||||
{
|
||||
/*$this->executeSQL( $owner );
|
||||
@@ -2315,7 +2325,7 @@ class XmlForm_Field_Dropdown extends XmlForm_Field {
|
||||
}
|
||||
//end
|
||||
// added by Gustavo Cruz
|
||||
if($this->readonly == true){
|
||||
if($this->readonly == true || $this->modeGridDrop === 'view'){
|
||||
$readOnlyField = "disabled";
|
||||
} else $readOnlyField = "";
|
||||
// added end
|
||||
@@ -2372,10 +2382,29 @@ class XmlForm_Field_Dropdown extends XmlForm_Field {
|
||||
$html.='<div style="display:none">'.$html1.'</div>';
|
||||
}
|
||||
//end add
|
||||
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function renderGrid
|
||||
* @author David S. Callizaya S. <davidsantos@colosa.com>
|
||||
* @access public
|
||||
* @param string values
|
||||
* @return string
|
||||
*/
|
||||
function renderGrid($values = array(), $owner = NULL, $onlyValue = false, $therow = -1)
|
||||
{
|
||||
$result = array ();
|
||||
$r = 1;
|
||||
$this->modeGridDrop = $owner->modeGrid;
|
||||
$this->mode = $this->modeForGrid;
|
||||
foreach ( $values as $v ) {
|
||||
$result [] = $this->render ( $v, $owner, '[' . $owner->name . '][' . $r . ']', $onlyValue, $r, $therow );
|
||||
$r ++;
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
}
|
||||
/**
|
||||
* Class XmlForm_Field_Listbox
|
||||
@@ -2619,8 +2648,6 @@ class XmlForm_Field_CheckGroup extends XmlForm_Field
|
||||
$html = '';
|
||||
foreach ( $this->options as $optionName => $option ) {
|
||||
$html .= '<input class="FormCheck" id="form[' . $this->name . '][' . $optionName . ']" name="form[' . $this->name . '][]" type=\'checkbox\' value="' . $optionName . '"' . (in_array ( $optionName, $value ) ? 'checked' : '') . ' disabled><span class="FormCheck">' . $option . '</span></input><br>';
|
||||
if(in_array ( $optionName, $value ))
|
||||
$html .= '<input id="form[' . $this->name . '][' . $optionName . ']" name="form[' . $this->name . '][]" type=\'hidden\' value="' . $optionName .'"</input>';
|
||||
}
|
||||
return $html;
|
||||
} else {
|
||||
@@ -2709,6 +2736,7 @@ class XmlForm_Field_Grid extends XmlForm_Field
|
||||
$this->fields = $this->xmlform->fields;
|
||||
$this->scriptURL = $this->xmlform->scriptURL;
|
||||
$this->id = $this->xmlform->id;
|
||||
$this->modeGrid = $this->xmlform->mode;
|
||||
unset ( $this->xmlform );
|
||||
}
|
||||
}
|
||||
@@ -2737,7 +2765,6 @@ class XmlForm_Field_Grid extends XmlForm_Field
|
||||
function renderGrid($values, $owner = NULL, $therow = -1)
|
||||
{
|
||||
$this->id = $this->owner->id . $this->name;
|
||||
|
||||
$using_template = "grid";
|
||||
|
||||
### added by Erik <erik@colosa.com>
|
||||
@@ -2746,8 +2773,8 @@ class XmlForm_Field_Grid extends XmlForm_Field
|
||||
$using_template = "grid_{$this->owner->visual_frontend}";
|
||||
}
|
||||
|
||||
if( $this->mode == 'view' ){
|
||||
$using_template = "grid_view";
|
||||
if( $this->mode == 'view' || $this->modeGrid === 'view' ){
|
||||
$using_template = "grid_view";
|
||||
}
|
||||
|
||||
$tpl = new xmlformTemplate ( $this, PATH_CORE . "templates/{$using_template}.html" );
|
||||
@@ -2998,10 +3025,12 @@ class XmlForm_Field_Date extends XmlForm_Field_SimpleText
|
||||
{
|
||||
$result = array ();
|
||||
$r = 1;
|
||||
if( ! isset($owner->modeGrid)) $owner->modeGrid = '';
|
||||
$this->mode = $this->modeForGrid;
|
||||
foreach ( $values as $v ) {
|
||||
$v = G::replaceDataField ( $v, $owner->values );
|
||||
if (! $onlyValue) {
|
||||
if($this->mode === 'view') {
|
||||
if($this->mode === 'view' || $owner->modeGrid === 'view') {
|
||||
if ($this->required){
|
||||
$isRequired = '1';
|
||||
} else {
|
||||
@@ -3135,34 +3164,35 @@ class XmlForm_Field_Date extends XmlForm_Field_SimpleText
|
||||
$onchange = '';
|
||||
|
||||
#the validations field was moved to javascript routines ;)
|
||||
|
||||
if( $startDate=='1969-12-31' ) {
|
||||
$startDate='';
|
||||
$endDate='';
|
||||
}
|
||||
$maskleng=strlen($mask);
|
||||
$hour = '%H';$min = '%M';$sec = '%S';
|
||||
$sizehour = strpos($mask, $hour);
|
||||
$sizemin = strpos($mask, $hour);
|
||||
$sizesec = strpos($mask, $hour);
|
||||
|
||||
$Time = 'false';
|
||||
if (($sizehour !== false)&&($sizemin !== false)&&($sizesec !== false)) {
|
||||
$sizeend = $maskleng + 2;
|
||||
$Time = 'true';
|
||||
} else {
|
||||
$sizeend = $maskleng + 2;
|
||||
}
|
||||
if($valueaux=='today'){
|
||||
$valueaux=masktophp ($mask);
|
||||
}
|
||||
$value1=$value;
|
||||
$value=$valueaux;
|
||||
if(($value==NULL)||($value=='')){
|
||||
$value=$value1;
|
||||
}
|
||||
|
||||
|
||||
if ($this->mode == 'edit') {
|
||||
if( $startDate=='1969-12-31' ) {
|
||||
$startDate='';
|
||||
$endDate='';
|
||||
}
|
||||
$maskleng=strlen($mask);
|
||||
$hour = '%H';$min = '%M';$sec = '%S';
|
||||
$sizehour = strpos($mask, $hour);
|
||||
$sizemin = strpos($mask, $hour);
|
||||
$sizesec = strpos($mask, $hour);
|
||||
|
||||
$Time = 'false';
|
||||
if (($sizehour !== false)&&($sizemin !== false)&&($sizesec !== false)) {
|
||||
$sizeend = $maskleng + 2;
|
||||
$Time = 'true';
|
||||
} else {
|
||||
$sizeend = $maskleng + 2;
|
||||
}
|
||||
|
||||
if($valueaux=='today'){
|
||||
$valueaux=masktophp ($mask);
|
||||
}
|
||||
$value1=$value;
|
||||
$value=$valueaux;
|
||||
if(($value==NULL)||($value=='')){
|
||||
$value=$value1;
|
||||
}
|
||||
|
||||
|
||||
if ( $this->editable != "0") {
|
||||
$html = '<input id="'.$pID.'" name="'.$pID.'" pm:mask="'.$mask.'" pm:start="'.$startDate.'" pm:end="'.$endDate.'" pm:time="'.$Time.'" '.$onchange.' class="module_app_input___gray" size="'.$sizeend.'" value="'.$value.'" pm:defaultvalue="'.$value1.'"/>'
|
||||
@@ -3180,9 +3210,10 @@ class XmlForm_Field_Date extends XmlForm_Field_SimpleText
|
||||
|
||||
} else {
|
||||
//$html = "<span style='border:1;border-color:#000;width:100px;' name='" . $pID . "'>$value</span>";
|
||||
|
||||
$html = '<input class="module_app_input___gray" id="form[' . $this->name . ']" name="form[' . $this->name . ']" type ="text" size="' . $this->size . '" ' . (isset ( $this->maxLength ) ? ' maxlength="' . $this->maxLength . '"' : '') . ' value=\'' . htmlentities ( $value, ENT_COMPAT, 'utf-8' ) . '\' style="display:none;' . htmlentities ( $this->style, ENT_COMPAT, 'utf-8' ) . '" />' . htmlentities ( $value, ENT_COMPAT, 'utf-8' );
|
||||
}
|
||||
///-- $html = '<input class="module_app_input___gray" id="form[' . $this->name . ']" name="form[' . $this->name . ']" type ="text" size="' . $this->size . '" ' . (isset ( $this->maxLength ) ? ' maxlength="' . $this->maxLength . '"' : '') . ' value=\'' . htmlentities ( $value, ENT_COMPAT, 'utf-8' ) . '\' style="display:none;' . htmlentities ( $this->style, ENT_COMPAT, 'utf-8' ) . '" />' . htmlentities ( $value, ENT_COMPAT, 'utf-8' );
|
||||
|
||||
$html = "<span style='border:1;border-color:#000;width:100px;' name='" . $pID . "'>$value</span>";
|
||||
}
|
||||
|
||||
if($this->hint){
|
||||
$html .= '<a href="#" onmouseout="hideTooltip()" onmouseover="showTooltip(event, \''.$this->hint.'\');return false;">'
|
||||
|
||||
Reference in New Issue
Block a user