phpDocumentor VFront
Function-Libraries
[ class tree: VFront ] [ index: VFront ] [ all elements ]

Source for file func.campi_submask.php

Documentation is available at func.campi_submask.php

  1. <?php
  2. /**
  3. * Libreria di funzioni per i campi delle sottomaschere.
  4. * Queste funzioni generano il codice per i campi delle sottomaschere
  5. @package VFront
  6. @subpackage Function-Libraries
  7. @author Mario Marcello Verona <marcelloverona@gmail.com>
  8. @copyright 2007 Mario Marcello Verona
  9. @version 0.90
  10. @license http://www.gnu.org/licenses/gpl.html GNU Public License
  11. */
  12.  
  13.  
  14.  
  15.  
  16.  
  17. /**
  18.  * Funzione di analisi e generazione del codice per i campi delle sottomaschere
  19.  *
  20.  * @param int $n 
  21.  * @param string $valore 
  22.  * @param array $info 
  23.  * @param string $tipo_vista (tabella | vista)
  24.  * @return unknown 
  25.  */
  26. function tipo_campo_submask($n,$valore,$info,$tipo_vista='tabella'){
  27.     
  28.     global $_VARIABILI;
  29.     
  30.     
  31.     
  32.     
  33.     extract($info);
  34.     
  35.     if(!isset($maxsize)) $maxsize=0;
  36.     if(!isset($in_search)) $in_search='';
  37.  
  38.     
  39.  
  40.     // SE IMPOSTATO, sovrascrivo il tipo sovraimposto a quello di default
  41.     
  42.      $data_type ($in_tipo=='' || $in_tipo==null$data_type $in_tipo;
  43.     
  44.  
  45. //    var_dump($data_type);
  46.      
  47.     // Impostazioni del campo
  48.     
  49.     
  50.     // tipo speciale TINYINT 1 (BOOLEANI)
  51.     if($data_type=='bool'){
  52.         
  53.         $check=($valore"checked=\"checked\"" "";
  54.         
  55.         $input="<input type=\"checkbox\" onclick=\"this.value=(this.value==0 || this.value=='')?1:0; mod(this.id);\"  class=\"off\" name=\"dati[$n][".$column_name."]\" ".
  56.                "id=\"dati__{$n}__{$column_name}\" value=\"0\" disabled=\"disabled\" $check />";
  57.                
  58.         $riga_singola=false;
  59.         
  60.     }
  61.     
  62.     
  63.     
  64.     // INTEGER O DOUBLE
  65.     elseif(($data_type=='int' || $data_type=='tinyint' || $data_type=='mediumint' ||  $data_type=='float' ||  $data_type=='double' ||  $data_type=='integer')){
  66.         
  67.         $size=10;
  68.         $v=$valore;
  69.         
  70.         $input="<input onkeypress=\"mod(this.id);\" class=\"off\" name=\"dati[$n][".$column_name."]\" ".
  71.                "id=\"dati__{$n}__{$column_name}\" value=\"$valore\" size=\"$size\" readonly=\"readonly\" type=\"text\" />";
  72.     }
  73.     
  74.     
  75.     
  76.     // TESTO
  77.     
  78.     elseif($data_type=='varchar' || $data_type=='char'){
  79.         
  80.         if($maxsize>100){
  81.             if($maxsize<=80$size=$maxsize;
  82.             else $size=135;
  83.             $riga_singola=true;
  84.         }
  85.         else $size=59;
  86.         
  87.         $input="<input onkeypress=\"mod(this.id);\" class=\"off\" name=\"dati[$n][".$column_name."]\" ".
  88.                "id=\"dati__{$n}__{$column_name}\" value=\"$valore\" size=\"$size\" readonly=\"readonly\" type=\"text\" />";
  89.                
  90.                
  91.         // IMPOSTAZIONI SUGGEST PER LA RICERCA -----------------------
  92.         
  93.         /*if($in_search=="1"  && $in_suggest=="1"){
  94.         
  95.             $input.=<<<SUGGEST
  96.             <div id="suggest-{$column_name}" class="campo-update" style="display:none;border:1px solid black;background-color:white;"></div>'
  97.                     <script type="text/javascript" language="javascript" charset="iso-8859-1">
  98.                         new Ajax.Autocompleter('dati_{$column_name}','suggest-{$column_name}','rpc.suggest.php?t={$data_tab['table_name']}',{});
  99.                     </script>
  100.             
  101. SUGGEST;
  102.         
  103.         }*/
  104.         
  105.         
  106.         // -----------------------------------------------------------
  107.                
  108.     }
  109.     
  110.     
  111.     // TESTO LUNGO
  112.     
  113.     elseif($data_type=='text'){
  114.         
  115.         $riga_singola=true;
  116.         
  117.         $input="<textarea onkeypress=\"mod(this.id);\" class=\"off\" name=\"dati[$n][".$column_name."]\" ".
  118.                "id=\"dati__{$n}__{$column_name}\" cols=\"132\" rows=\"9\" readonly=\"readonly\" >$valore</textarea>";
  119.     }
  120.     
  121.     // TESTO LUNGO
  122.     
  123.     elseif($data_type=='password'){
  124.         
  125.         $riga_singola=false;
  126.         
  127.         $input="<input onkeypress=\"mod(this.id);\" class=\"off\" name=\"dati[$n][".$column_name."]\" ".
  128.                "id=\"dati__{$n}__{$column_name}\" value=\"$valore\" size=\"59\" readonly=\"readonly\" type=\"password\" />";
  129.     }
  130.     
  131.     
  132.     
  133.     
  134.     // tipo speciale hidden
  135.     elseif($data_type=='hidden'){
  136.         
  137.         $label=false;
  138.         
  139.         $valore_hidden=false;
  140.         
  141.         // Cerca variabili nel campo hidden
  142.         if(isset($in_default)){
  143.             
  144.             $valore_hidden variabili_campi($in_default);
  145.             
  146.             
  147.             if($valore_hidden==false){
  148.                 $valore_hidden=$in_default;
  149.             }
  150.                 
  151.         }
  152.         
  153.         $input="<input name=\"dati[".$column_name."]\" ".
  154.                "id=\"dati__{$n}__{$column_name}\" value=\"$valore_hidden\" type=\"hidden\" />";
  155.     }
  156.     // tipo speciale SELECT
  157.     elseif($data_type=='select'){
  158.         
  159.         $valori=array();
  160.         
  161.         $input="<select onchange=\"mod(this.id);\" class=\"off\" name=\"dati[$n][".$column_name."]\" ".
  162.                "id=\"dati__{$n}__{$column_name}\" disabled=\"disabled\" >";
  163.                
  164.         
  165.                
  166.         $valori explode("[|]",$in_default);
  167.         
  168.         foreach($valori as $k=>$val){
  169.             
  170.             $sel =($val==$valore"selected=\"selected\"" "";
  171.             
  172.             // se sono stati messi i separatori chiave, valore
  173.             if(ereg('=',$val)){
  174.                 list($kk,$val)=explode("=",$val);
  175.             }
  176.             else $kk=$val;
  177.             
  178.             $input.="<option value=\"$kk\" $sel>$val</option>";
  179.         }
  180.         
  181.         $input.="</select>";
  182.         
  183.     }
  184.     
  185.     // tipo speciale SELECT FROM
  186.     elseif($data_type=='select_from'){
  187.         
  188.         $valori=array();
  189.         
  190.         $riga_singola=true;
  191.         
  192.         
  193.         $IFRAME new hash_iframe($column_name,$in_default,true,$n);
  194.         
  195.         
  196.         
  197.         
  198.         $input="<div id=\"target_{$n}_".$column_name."\"></div>";
  199.  
  200.         $input.="<iframe style=\"width:1px;height:1px;border:0;\" 
  201.                 id=\"i_id_".$column_name."\" 
  202.                 src=\"".FRONT_DOCROOT."/html/{$IFRAME->hash_html}.html\"    
  203.                 ></iframe>";
  204.         
  205.         $GLOBALS['TRIGGER_ASSEGNAZIONE'].="  carica_valore('{$n}__$column_name','$valore');\n";
  206.     
  207.         // cancello l'istanza
  208.         unset($IFRAME);
  209.         
  210.     }
  211.     
  212.     
  213.     //- FINE SELECT_FROM -----------------------------------------------------------------------------
  214.     
  215.     
  216.     
  217.     elseif($data_type=='date' && $_VARIABILI['usa_calendari']==1){
  218.         
  219.         
  220.     
  221.         $carica_calendario true;
  222.         
  223.         $input="<input onkeypress=\"mod(this.id);\" class=\"off\" name=\"dati[$n][".$column_name."]\" ".
  224.                "id=\"dati__{$n}__{$column_name}\" value=\"$valore\" size=\"24\" readonly=\"readonly\" type=\"text\" />";
  225.         
  226.         $input.=<<<CAL
  227.         
  228.    <script type="text/javascript">
  229.     
  230.    Calendar.setup({
  231.         inputField     :    "dati__{$n}__{$column_name}",   // id of the input field
  232.         firstDay       :    1,
  233.         ifFormat       :    "%Y-%m-%d",       // format of the input field
  234.         showsTime      :    false,
  235.         timeFormat     :    "24",
  236.         onUpdate       :    catcalc
  237.     });    
  238.     
  239.  
  240.     </script>
  241.   
  242. CAL;        
  243.     }
  244.     
  245.     elseif($data_type=='datetime' && $_VARIABILI['usa_calendari']==1){
  246.     
  247.         
  248.         $carica_calendario true;
  249.         
  250.         $input="<input onkeypress=\"mod(this.id);\" class=\"off\" name=\"dati[$n][".$column_name."]\" ".
  251.                "id=\"dati__{$n}__{$column_name}\" value=\"$valore\" size=\"24\" readonly=\"readonly\" type=\"text\" />";
  252.         
  253.         $input.=<<<CAL
  254.         
  255.    <script type="text/javascript">
  256.     
  257.    Calendar.setup({
  258.         inputField     :    "dati__{$n}__{$column_name}",   // id of the input field
  259.         firstDay       :    1,
  260.         ifFormat       :    "%Y-%m-%d",       // format of the input field
  261.         showsTime      :    true,
  262.         timeFormat     :    "24",
  263.         onUpdate       :    catcalc
  264.     });    
  265.     
  266.  
  267.     </script>
  268.   
  269. CAL;        
  270.     }
  271.     // Caso sconosciuto
  272.     else {
  273.         $size=30;
  274.         $label=true;
  275.         $input="<input onkeypress=\"mod(this.id);\" class=\"off\" name=\"dati[$n][".$column_name."]\" ".
  276.                "id=\"dati__{$n}__{$column_name}\" value=\"$valore\" size=\"$size\" readonly=\"readonly\" type=\"text\" />";
  277.     }
  278.     
  279.  
  280.     if($tipo_vista=='tabella'){
  281.         return "<td>".$input."</td>";
  282.     }
  283.     else{
  284.         return $input;
  285.     }
  286.     
  287.     
  288. }
  289.  
  290.  
  291.  
  292.  
  293. ?>

Documentation generated on Sat, 22 Sep 2007 11:50:06 +0200 by phpDocumentor 1.4.0a2