<?php
 
/**
 
 *  Funzioni utili per la formattazione HTML
 
 *
 
 * @author Dario Mazzeo <[email protected]>
 
 * @version 1.0.0
 
 * @copyright Freesoftware Italia - www.freesoftwareitalia.it
 
 */
 
 
/**
 
 * Questa funzione imposta lo stile di un campo
 
 *
 
 * Esempio:
 
 *
 
 * <code>
 
 * $table = new sTable('ciao');
 
 * $titoli = array(html_label('campo1', '', '300px', 'lime'),
 
 *                 html_label('campo2', 'right', '300px', 'yellow', 'blue'), 
 
 *                 html_label('campo3', 'left', '300px', '', 'red', 'block'));
 
 * $campi[] = array('valore1-1', 'valore\'<>1-2', 'valore1-3');
 
 * $campi[] = array('valore2-1', 'valore2-2', 'valore2-3');
 
 * $campi[] = array('valore3-1', 'valore3-2', 'valore3-3');
 
 * str_array($campi, str_html);
 
 *
 
 * for ($i=0; $i<count($campi); $i++)
 
 *     $campi[$i][1]=html_label($campi[$i][1], 'right');
 
 * 
 
 * $table->addThead($titoli);
 
 * $table->addBody($campi, false);
 
 * echo $table;
 
 * </code>
 
 *
 
 * @param string $value Valore da formattare
 
 * @param string $float Allineamento blocco/testo
 
 * @param string $width Larghezza blocco
 
 * @param string $color Colore testo
 
 * @param string $backgroundcolor Colore sfondo
 
 * @param string $display Opzione display
 
 * @return string Stringa formattata in HTML/CSS
 
 */
 
function html_label($value, $float='', $width='', $color='', $backgroundcolor='', $display=''){
 
    if ($float!='' && $width!='') $tmp='text-align:'.$float.';';
 
    if ($float!='' && $width=='') $tmp='float:'.$float.';';
 
    if ($width!='') $tmp.='width:'.$width.';';
 
    if ($color!='') $tmp.='color:'.$color.';';
 
    if ($backgroundcolor!='') $tmp.='background-color:'.$backgroundcolor.';';
 
    if ($display!='') $tmp.='display:'.$display.';';
 
    return "<label style='{".$tmp."}'>".$value."</label>";
 
}
 
?>
 
 
 |