explode by plabudda
//VERSION 2012-04-24 , added decimal(58,8) for search purps
global $thiss;
if (strstr($TYPE, "enum")) {
list($SMIEC, $TYPE) = explode("(", $TYPE, 2);
list($TYPE, $SMIEC) = explode(")", $TYPE, 2);
$TYPE = explode(",", $TYPE);
$html_field_name = $NAME;
$attr_multiple = '';
if (isset($params['multiple']) && $params['multiple'] == true) {
$attr_multiple = ' multiple ';
$html_field_name .= '[]';
}
echo'';
}
else if ((strstr($TYPE, "char")) || (strstr($TYPE, "int")) || (strstr($TYPE, "decimal")) ) {
//echo "THIS IS CHAR";
list($SMIEC, $TYPE) = explode("(", $TYPE, 2);
list($TYPE, $SMIEC) = explode(")", $TYPE, 2);
$SIZE = strlen($VALUE) + 5;
if (!$_SESSION['CURRENT_MENU']) {
if (strlen($VALUE) == 0) $SIZE = strlen($VALUE) + 10;
else $SIZE = strlen($VALUE) + 5;
}
if ($_SESSION['CURRENT_MENU'] == 'NEW_RECORD') $SIZE = $TYPE;
if ($SIZE > 50) $SIZE = 50;
$SIZE = "size=$SIZE";
if (in_array($_SESSION['CURRENT_MENU'], array('USERS','TELBOXES','DEVICES','BUILDINGS'))) if(!($VALUE)) $VALUE = "%";
echo'';
}
else if ((strstr($TYPE, "datetime")) || (strstr($TYPE, "date") || strstr($TYPE, "timestamp"))) {
if(strstr($TYPE,'(')) { //@2012-10-12 by sqix : warning byly , chyba typ powinien byc w nawiasie, a jak nie jest to else...
list($SMIEC, $TYPE) = explode("(", $TYPE, 2);
list($TYPE, $SMIEC) = explode(")", $TYPE, 2);
} else $TYPE=10;
$VALUE = substr($VALUE, 0, 10);
$SIZE = 10;
$SIZE="size=$SIZE";
echo'';
}
else if(strstr($TYPE,"double") || strstr($TYPE,"float")) {
list($SMIEC,$TYPE)=explode("(",$TYPE,2);
list($TYPE,$SMIEC)=explode(")",$TYPE,2);
$VALUE=substr($VALUE,0,10);
$SIZE = 4;
$SIZE="size=$SIZE";
echo'';
}
else if(strstr($TYPE,"text")) {
//echo "THIS IS CHAR";
//$SIZE = strlen($VALUE) + 50;
//$SIZE="size=$SIZE";
if(in_array($_SESSION['CURRENT_MENU'],array('USERS','TELBOXES','DEVICES','BUILDINGS'))) if(!($VALUE)) $VALUE = "%";
echo'';
}
else {
echo "THIS IS TEXT_OR_OTHER $TYPE";
}
}
function GETFORMITEM2( $name, $sql_type, $value = '' ) {
//VERSION 2006-03-20 , ale na l2 moze byc swiezsze
//VERSION 2008-11-25 , added shorted substr for enum type by sqix
//VERSION 2010-06-10 , rm ' from enum, split(depreciated) -> explode by plabudda
//VERSION 2010-10-13 , add % in enum, add @param $name by plabudda
// TODO: add DEAFULT and not null to TYPE
$ret = '';
//$type = $_SESSION[$table_column]['TYPE'][$field];
$type = $sql_type;
//$name = $field;//$_SESSION[$table_column]['DESC'][ $_SESSION[$table_column]['DESC_TO_KEY'][$field] ];
//if ($_SESSION['CURRENT_MENU']=='NEW_RECORD') $name = 'NEW_RECORD['.$name.']';
if(strstr($type,"enum")) {
$type = end( explode("(",$type) );
$type = reset( explode(")",$type) );
$type = explode(",", $type);
$ret .= '';
}
else if((strstr($type,"char")) || (strstr($type,"int"))) {
$type = end( explode("(",$type) );
$type = reset( explode(")",$type) );
$SIZE = ($type > 50)? 50 : $type;
$SIZE="size=$SIZE";
$ret .= '';
}
else if((strstr($type,"datetime"))||(strstr($type,"date")||strstr($type,"timestamp"))) {
$type = end( explode("(",$type) );
$type = reset( explode(")",$type) );
$value = substr($value, 0, 10);
$SIZE="size=10";
$ret .= '';
}
else if(strstr($type,"double") || strstr($type,"float")) {
$type = end( explode("(",$type) );
$type = reset( explode(")",$type) );
$value=substr($value,0,10);
$SIZE="size=6";
$ret .= '';
}
else if(strstr($type,"text")) {
$ret .= '';
}
else {
$ret .= "UNKNOWN $type";
}
return $ret;
}
/*
function GETFORMITEM($VALUE,$TYPE,$NAME) {
//VERSION 2006-03-20 , ale na l2 moze byc swiezsze
//VERSION 2008-11-25 , added shorted substr for enum type by sqix
global $thiss;
//echo "***************$VALUE,,,,$TYPE";
if(strstr($TYPE,"enum")) {
list($SMIEC,$TYPE)=split("\(",$TYPE);
list($TYPE,$SMIEC)=split("\)",$TYPE);
list($TYPE1,$SMIEC1)=split(",",$TYPE);
$TYPE=explode(",",$TYPE);
echo "";
} else if((strstr($TYPE,"char")) || (strstr($TYPE,"int"))) {
//echo "THIS IS CHAR";
list($SMIEC,$TYPE)=split("\(",$TYPE);
list($TYPE,$SMIEC)=split("\)",$TYPE);
$SIZE = strlen($VALUE) + 5;
if(!$_SESSION[CURRENT_MENU]) {
if(strlen($VALUE)=='0') $SIZE=strlen($VALUE)+10 ;
else $SIZE=strlen($VALUE)+5;
}
if($_SESSION[CURRENT_MENU]=='NEW_RECORD') $SIZE=$TYPE;
$SIZE="size=$SIZE";
if(($_SESSION[CURRENT_MENU]==USERS) || ($_SESSION[CURRENT_MENU]==TELBOXES) || ($_SESSION[CURRENT_MENU]==DEVICES) || ($_SESSION[CURRENT_MENU]==BUILDINGS) ) if(!($VALUE)) $VALUE = "%";
echo "";
} else if((strstr($TYPE,"datetime"))||(strstr($TYPE,"date")||strstr($TYPE,"timestamp"))) {
list($SMIEC,$TYPE)=split("\(",$TYPE);
list($TYPE,$SMIEC)=split("\)",$TYPE);
$VALUE=substr($VALUE,0,10);
$SIZE = 10 ;
$SIZE="size=$SIZE";
echo "";
} else if(strstr($TYPE,"double")) {
list($SMIEC,$TYPE)=split("\(",$TYPE);
list($TYPE,$SMIEC)=split("\)",$TYPE);
$VALUE=substr($VALUE,0,10);
$SIZE = 4 ;
$SIZE="size=$SIZE";
echo "";
} else if(strstr($TYPE,"text")) {
//echo "THIS IS CHAR";
//$SIZE = strlen($VALUE) + 50;
//$SIZE="size=$SIZE";
if(($_SESSION[CURRENT_MENU]==USERS) || ($_SESSION[CURRENT_MENU]==TELBOXES) || ($_SESSION[CURRENT_MENU]==DEVICES) || ($_SESSION[CURRENT_MENU]==BUILDINGS) ) if(!($VALUE)) $VALUE = "%";
echo "";
}else {
echo "THIS IS TEXT_OR_OTHER $TYPE";
}
}
*/