blank.gif
triangle.gif Du er her: /  Forsiden  /  Kildekoden  /  Table  /  Th   Login nu   Login
blank.gif
 ««« Se kilde koden
blank.gif
triangle.gif Basic Base Component Db Dto Form Form-elements Jquery Layout Menu Menu-fisheye Mvc Tab Table  Template Util
blank.gif
blank.gif

PHP source code

Den fulde PHP kildekode for Th klassen

<?
/**
* @package table
* @filesource
* @see HTML_TABLE_COMPONENT_PATH.'/Th.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.'/Raw.php');

/**
* The Table Header Data.
* Generates a table Header column
* <code>
* +--------------------------------
* | header_1 |
* +--------------------------------
* Usage:
*   $text = 'plain text'; // Optionally
*   $th = new Th($class,$valign,$align,$text);
*   print $th->getHtml();
* Or
*   $th= new Th($class,$valign,$align);
*   print $th->getStart();
*     :
*   print $th->getEnd();
* Or
*   Th::display($class,$valign,$align,$text);
* Or
*   Th::start($class,$valign,$align);
*   Raw::display($text);
*   Th::end();
* Or
*   $object = new Raw($text);
*   $th = new Th($class,$valign,$align,$object);
*   print $th->getHtml();
* Or
*   Th::display($class,$valign,$align,$object);
* Or
*   Th::start($class,$valign,$align);
*      :
*   Th::end();
* </code>
* @package table
*/

class Th extends Html {
    
/**
     * @var String $class The CSS class name for the TH
     */
    
var $class  = '';

    
/**
     * @var String $valign The html THr valign attribute
     */
    
var $valign = '';

    
/**
     * @var String $align The html TH align attribute
     */
    
var $align  = '';

    
/**
     * Constructor
     * @param String $class  The class name
     * @param String $valign The valignment of data
     * @param String $align  The alignment of data
     * @param String $text   The plain text or an object (optionally)
     */
    
function Th($class='',$valign='',$align='',$text='') {
        
$this->Html();
        
$this->class  = $class!=''?$class:'';
        
$this->valign = $valign!=''?$valign:'top';
        
$this->align  = $align!=''?$align:'';
        if (
$text!= '') {
            if (
is_object($text)) {
                
$this->add($text);
            } else {
                
$this->add(new Raw($text)); // Plain text object
            
}
        } else {
            
// Ignore
        
}
    }

    
/**
     * Get the start html for a TH
     * @return String the html
     */
    
function getStart() {
        
$html  = '  <th';
        
$html .= $this->getAttribute('class');
        
$html .= $this->getAttribute('valign');
        
$html .= $this->getAttribute('align');
        
$html .= ">";
        
$elements = $this->getElements();
        if (
$elements != '') {
            
$html .= $elements;
        } else {
            
$html .= '&nbsp;';
        }
        return
$html;
    }

    
/**
     * Get the end html for a TH
     * @return String the html
     */
    
function getEnd() {
        return
"</th>\r\n";
    }

    
/**
     * Get the complete html for a TH
     * @return String the html
     */
    
function getHtml() {
        
$html  = '';
        
$html .= $this->getStart();
        
$html .= $this->getEnd();
        return
$html;
    }


    
/**
     * Get the start of the tag
     * <code>
     * Usage:
     *    Th::start($class,$valign,$align,$text);
     * </code>
     * @static
     * @param String $class  The class name
     * @param String $valign The valignment of data
     * @param String $align  The alignment of data
     * @param String $text   The plain text or an object (optionally)
     */
    
function start($class='',$valign='',$align='',$text='') {
        
$html = new Th($class,$valign,$align,$text);
        
$html->addHtml($html->getStart());
    }

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

    
/**
     * Display html
     * <code>
     * Usage:
     *    Th::display($class,$valign,$align,$text);
     * </code>
     * @static
     * @param String $class  The class name
     * @param String $valign The valignment of data
     * @param String $align  The alignment of data
     * @param String $text   The plain text or an object (optionally)
     */
    
function display($class='',$valign='',$align='',$text='') {
        
$html = new Th($class,$valign,$align,$text);
        
$html->addHtml();
    }
}
?>

HTML source code

Den fulde HTML kildekode for Th klassen

<?
  
<th valign="top">&nbsp;</th>

?>

Class methods

Her er 'klasse metoderne' for Th klassen:


Object vars

Her er 'objekt variable' for Th klassen:


 
arrow-headline.gif Index
 
  Tilbage

Navn : Th.php


Sample code, tutorial

Sådan benyttes komponenten Th klassen

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

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

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

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

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

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

Parent html

Sådan vises komponenten Th klassen

   
triangle.gif

danmark

Germany

England

France

Italy

Norge

Sverige

USA


 
blank.gif