««« Se kilde koden
triangle.gif Basic Base  Component Db Dto Form Form-elements Jquery Layout Menu Menu-fisheye Mvc Tab Table Template Util
 
arrow-headline.gif Index
 
 Tilbage

Navn : Fieldset.php


Sample code, tutorial

Sådan benyttes komponenten Fieldset klassen

Først skal du inkludere den fil der beskriver komponenten, som en klasse fil

  • <?
    require_once(HTML_PACKAGE_PATH.'/Fieldset.php');
    ?>

Dernæst kan du enten benytte komponenten som et taglib (statiske metoder):

  • <?
    Fieldset
    ::display($param1, $param2, $param3, ...);
    ?>

eller du kan lave en instance af komponenten og benytte metoderne direkte:

  • <?
    $object
    = new Fieldset($param1, $param2, $param3, ...);
    print
    $object->getHtml();
    ?>

Parent html

Sådan vises komponenten Fieldset klassen

  Finn-Rasmusssen.com   

Demo of the myPHP taglib and the CMS system written in PHP (also available in C# and java)



PHP source code

Den fulde PHP kildekode for Fieldset klassen

<?
/**
* @package base
* @see HTML_BASE_UTIL_PATH.'/Fieldset.php'
* @copyright (c) http://Finn-Rasmussen.com
* @license http://Finn-Rasmussen.com/license/ myPHP License conditions
* @author http://Finn-Rasmussen.com
* @version 1.10
* @since 22-feb-2007
*/

/**
* The required files
*/
require_once(HTML_BASE_COMMON_PATH.'/Html.php');
require_once(
HTML_BASE_UTIL_PATH.'/Legend.php');

/**
* Generates an FIELDSET form element
* <code>
* Usage:
*   $legend   = new Legend($text);   
*   $fieldset = new Fieldset($legend,$class);
*   $element  = new Select('theSelect1');
*   $fieldset->add($element);
*   print $fieldset->getHtml();
* Or
*   Fieldset::display(new Legend($legend,$class));
* </code>
* @package base
*/

class Fieldset extends Html {
    
/**
     * @var String $legend The legend to show
     */
    
var $legend = NULL;

    
/**
     * @var String $class The CSS class name
     */
    
var $class  = '';

    
/**
     * Constructor
     * @param Object $legend The legend object to use
     * @param String $class  The css class of the link
     */
    
function Fieldset($legend='',$class='') {
        
$this->Html();
        
$this->class = $class!=''?$class:CSS_FIELDSET;
        if (
$legend!='') {
            if (
is_object($legend)) {
                
$this->setObject('legend',$legend);
            } else {
                
$msg = $this->getClassName().'(), object expected, unknown type='.gettype($legend);
                
Log::fatal(__FILE__,__LINE__,$msg); // Should be debug
                //$this->getMsg(LOG_LEVEL_FATAL, $msg);
                
$this->legend = new Legend($legend); // Assume text
            
}
        }
    }

    
/**
     * Returns the start html for the fieldset control
     * @return String the complete html
     */
    
function getStart() {
        
$html  = '';
        
$html .= '<fieldset';
        
$html .= $this->getAttribute('class');
        
$html .= ">";
        if (
$this->legend!=NULL && is_object($this->legend)) {
            
$html .= $this->legend->getHtml();
        }
        
$html .= "\r\n";
        
$html .= $this->getElements(); // as html
        
return $html;
    }

    
/**
     * Returns the end html for the fieldset control
     * @return String the complete html
     */
    
function getEnd() {
        return
"</fieldset><br />\r\n";
    }

    
/**
     * Returns the html for the fieldset control
     * @return String the complete html
     */
    
function getHtml() {
        
$html  = $this->html;
        
$html .= $this->getStart();
        
$html .= $this->getEnd();
        return
$html;
    }

    
/**
     * Start of tag
     * <code>
     * Usage:
     *    Fieldset::start($legend,$class);
     * </code>
     * @static
     * @param Object $legend The legend object to use
     * @param String $class  The css class of the link
     */
    
function start($legend='',$class='') {
        
$html = new Fieldset($legend,$class);
        
$html->addHtml($html->getStart());
    }

    
/**
     * End of tag
     * <code>
     * Usage:
     *    Fieldset::end();
    * </code>
    * @static
     */
    
function end() {
        
$html = new Html();
        
$html->addHtml(Fieldset::getEnd());
    }

    
/**
     * Display html
     * <code>
     * Usage:
     *    Fieldset::display($legend,$class);
     * </code>
     * @static
     * @param Object $legend The legend object to use
     * @param String $class  The css class of the link
     */
    
function display($legend='',$class='') {
        
$html = new Fieldset($legend,$class);
        
$html->addHtml();
    }
}
?>

HTML source code

Den fulde HTML kildekode for Fieldset klassen

<?
<fieldset class="baseFieldset">
<
legend class="baseLegend">&nbsp;<b>&nbsp;Finn-Rasmusssen.com&nbsp;</b>&nbsp;&nbsp;</legend>

<
p>Demo of the myPHP taglib and the CMS system written in PHP (also available in C# and java)</p>
</fieldset><br />

?>

Class methods

Her er 'klasse metoderne' for Fieldset klassen:

  • object
  • getclassname
  • getmsg
  • addhtml
  • gethtml
  • tostring
  • getcachefilename
  • save
  • content
  • html
  • setobject
  • set
  • get
  • getattribute
  • gettag
  • add
  • getsizeof
  • getelement
  • getelements
  • gettoogle
  • getmaximize
  • getminimize
  • newtriangle
  • display
  • showsource
  • fieldset
  • getstart
  • getend
  • start
  • end

Object vars

Her er 'objekt variable' for Fieldset klassen:

  • html =>
  • sql =>
  • elements => Array
  • sizeof => 2
  • legend =>
  • class => baseFieldset

  triangle.gif

danmark

Germany

England

France

Italy

Norge

Sverige

USA