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

PHP source code

Den fulde PHP kildekode for Td klassen

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

/**
* Generates a table Data column
* <code>
* +--------------------------------
* | data |
* +--------------------------------
* Usage:
*   $text = 'plain text'; // Optionally
*   $td = new Td($class, $valign, $colspan, $text, $width);
*   print $td->getHtml();
* Or
*   $td = new Td($class, $valign, $colspan, '', $width);
*   print $td->getStart();
*     :
*   print $td->getEnd();
* Or
*   Td::display($class, $valign, $colspan, $text, $width);
* Or
*   Td::start($class, $valign, $colspan, '', $width);
*   Raw::display($text);
*   Td::end();
* Or
*   $object = new Raw($text);
*   $td = new Td($class, $valign, $colspan, $object, $width);
*   print $td->getHtml();
* Or
*   Td::display($class, $valign, $colspan, $object, $width);
* Or
*   Td::start($class, $valign, $colspan, '', $width);
*      :
*   Td::end();
* </code>
* @package table
*/

class Td extends Html {
    
/**
     * @var String $class The CSS class name to use
     */
    
var $class   = '';

    
/**
     * @var String $valign The alignment to use
     */
    
var $valign  = '';

    
/**
     * @var String $colspan The colspan to use
     */
    
var $colspan = '';

    
/**
     * @var String $width The width to use for the TD, not XHTML 1.0 strict compliant
     */
    
var $width = '';

    
/**
     * Constructor
     * @param String $class   The class name
     * @param String $valign  The alignment of data
     * @param String $colspan The Column Span
     * @param String $text    The plain text or an object (optionally)
     * @param String $width   The width of the TD
     */
    
function Td($class='',$valign='',$colspan='',$text='', $width='') {
        
$this->Html();
        
$this->class   = $class;
        
$this->valign  = $valign!=''?$valign:'top';
        
$this->colspan = $colspan;
        
$this->width   = $width; // not XHTML 1.0 strict compliant
        
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 TD
     * @return String the html
     */
    
function getStart() {
        
$html  = "\t<td";
        
$html .= $this->getAttribute('class');
        
$html .= $this->getAttribute('valign');
        
$html .= $this->getAttribute('colspan');
        
$html .= $this->getAttribute('width');
        
$html .= ">";
        
$elements = $this->getElements();
        if (
$elements != '') {
            
$html .= $elements;
        } else {
            
$html .= '';
        }
        return
$html;
    }

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

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


    
/**
     * Get the start of the tag
     * <code>
     * Usage:
     *    $text = 'Plain text';
     *    Td::start($class, $valign, $colspan, $text, $width);
     * Or
     *    $object = new Raw($text);
     *    Td::start($class, $valign, $colspan, $object, $width);
     * Or
     *    Td::start($class, $valign, $colspan, '', $width);
     * </code>
     * @static
     * @param String $class   The class name
     * @param String $valign  The alignment of data
     * @param String $colspan The Column Span
     * @param String $text    The plain text or an object
     * @param String $width   The width of the TD
     */
    
function start($class='', $valign='', $colspan='', $text='', $width='') {
        
$html = new Td($class, $valign, $colspan, $text, $width);
        
$html->addHtml($html->getStart());
    }

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

    
/**
     * Display html
     * <code>
     * Usage:
     *    $text = 'Plain text';
     *    Td::display($class, $valign, $colspan, $text, $width);
     * Or
     *    $object = new Raw($text);
     *    Td::display($class, $valign, $colspan, $object, $width);
     * </code>
     * @static
     * @param String $class   The class name
     * @param String $valign  The alignment of data
     * @param String $colspan The Column Span
     * @param String $text    The plain text or an object
     * @param String $width   The width of the TD
     */
    
function display($class='', $valign='', $colspan='', $text='', $width='') {
        
$html = new Td($class, $valign, $colspan, $text, $width);
        
$html->addHtml();
    }
}
?>

HTML source code

Den fulde HTML kildekode for Td klassen

<?
    
<td valign="top"></td>

?>

Class methods

Her er 'klasse metoderne' for Td klassen:


Object vars

Her er 'objekt variable' for Td klassen:


Td Index
 
Tilbage

Navn : Td.php


Sample code, tutorial

Sådan benyttes komponenten Td klassen

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

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

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

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

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

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

Parent html

Sådan vises komponenten Td klassen

Td

Vis denne side på danmark

Vis denne side på Germany

Vis denne side på England

Vis denne side på France

Vis denne side på Italy

Vis denne side på Norge

Vis denne side på Sverige

Vis denne side på USA


 
Td