Top  Branding  Banner 
blank.gif
blank.gif
triangle.gif Du er her: /  Forsiden  /  Kildekoden  /  Table  /  Tabletag   Login nu   Login
blank.gif
««« Se kilde koden
blank.gif
tl.gif Base tr.gif tl.gif Basic tr.gif tl.gif Dto tr.gif tl.gif Form tr.gif tl.gif Language tr.gif tl.gif Layout tr.gif tl.gif Menu tr.gif tl.gif Mvc tr.gif tl.gif Netbank.eksperter.dk tr.gif tl.gif Tab tr.gif tls.gif     Table  trs.gif tl.gif Util tr.gif
blank.gif
blank.gif
arrow-headline.gif Index
MenuLink  MenuLeft  
Tilbage

Skjul: Navn

TableTag.php


Vis: Sample code, tutorial

TableTag, Sample code, tutorial

Sådan benyttes komponenten TableTag klassen

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

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

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

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

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

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

Skjul: Sådan vises komponenten

TableTag, Sådan vises komponenten

Sådan vises komponenten TableTag klassen

 

Vis: PHP source code

TableTag, PHP source code

Den fulde PHP kildekode for TableTag klassen

<?php
/**
 * @package table
 * @filesource
 * @see HTML_TABLE_COMPONENT_PATH.'/TableTag.php'
 * @copyright (c) http://Finn-Rasmussen.com
 * @license http://Finn-Rasmussen.com/license/ myPHP License conditions
 * @author http://Finn-Rasmussen.com
 * @version 1.11
 * @since 27-nov-2009
 */

/**
 * The required files
 */
require_once(HTML_TABLE_COMPONENT_PATH.'/TableHeader.php');
require_once(
HTML_TABLE_COMPONENT_PATH.'/Table.php');
require_once(
HTML_TABLE_COMPONENT_PATH.'/Tr.php');
require_once(
HTML_TABLE_COMPONENT_PATH.'/Th.php');
require_once(
HTML_TABLE_COMPONENT_PATH.'/Td.php');
if (
defined('HTML_LOG_UTIL_PATH')) {
    require_once(
HTML_LOG_UTIL_PATH.'/Log.php');
}

/**
 * Generates the html for a table
 * <code>
 * Usage:
 *   $columns = array(
 *     array('class'=>CSS_COPYRIGHT, KEY_LINK=>LINK_COPYRIGHT,),
 *     array('class'=>CSS_COPYRIGHT, KEY_POWERED=>LINK_POWERED_BY,),
 *     array('class'=>CSS_COPYRIGHT, KEY_VERSION=>CURRENT_VERSION,),
 *   );
 *   $header  = ''; // The header meta data
 *   $default = ''; // The default meta data array
 *   $limit   = ''; // The limit to use for the array
 *   $sort    = true;
 *   $datareader = DataReaderFactory::newDataReader($columns, $header, $default, $limit, $sort);
 *   
 *   $tableTag = new TableTag($datareader, $text, $width, $class, $border, $cellpadding, $cellspacing, $summary, $caption, $id);
 *   print $tableTag->getHtml();
 * Or
 *   TableTag::display($datareader, $text, $width, $class, $border, $cellpadding, $cellspacing, $summary, $caption, $id);
 *
 * Generates a complete table interface
 * ---------------------------------
 * | Text header
 * ---------------------------------
 * | head1 | head2 | head3 | 
 * ---------------------------------
 * | dat_1 | dat_2 | dat_3 | 
 * ---------------------------------
 * </code>
 * @package table
 */

class TableTag extends Table {
    
/**
     * Constructor
     * @param DataReader / array $datareader The Data Reader object OR an array
     * @param String $text    The text header for the table
     * @param String $width   The Width for the table
     * @param String $class   The Class
     * @param String $border  The Border
     * @param String $cellpadding The CellSpacing
     * @param String $cellspacing The CellPadding
     * @param String $summary The Summary
     * @param String $caption The Caption 
     * @param String $id      The element ID
     */
    
function __construct($datareader=null$text=''$width=''$class=''$border=''$cellpadding=''$cellspacing=''$summary=''$caption=''$id='') {
        
parent::__construct($datareader$text$width$class$border$cellpadding$cellspacing$summary$caption$id);
    }

    
/**
     * Get the Row Start
     * @param  String $class The css class name for the row
     * @return String the html
     */
    
function getRowStart($class='') {
        
$html = new Tr($class);
        return 
$html->getStart();
    }

    
/**
     * Get the Column Start
     * @param  String $class   The class name
     * @param  String $valign  The alignment of data
     * @param  String $colspan The Column Span
     * @return String the html
     */
    
function getColumnStart($class=''$valign=''$colspan='') {
        
$html = new Td($class$valign$colspan);
        return 
$html->getStart();
    }

    
/**
     * Get the Column End
     * @return String the html
     */
    
function getColumnEnd() {
        
$td = new Td();
        return 
$td->getEnd();
    }

    
/**
     * Get the Row End
     * @return String the html
     */
    
function getRowEnd() {
        
$tr = new Tr();
        return 
$tr->getEnd();
    }

    
/**
     * Get the complete html for a table
     * @return String the html
     */
    
function getHtml() {
        
$html  $this->html;
        
$html .= $this->getTableHeader();
        
$html .= $this->getStart();
        if (
$this->getSizeof() == 0) {
            
$html .= " <tr><td><!-- ";
            if (
defined('TEXT_NO_DATA')) {
                
$html .= TEXT_NO_DATA;
            } else {
                
$html .= TABLE_TEXT_NO_DATA;
            }
            
$html .= " -->&nbsp;</td></tr>\r\n";
        } else {
            
$html .= $this->getElements();
        }
        
$html .= $this->getEnd();
        return 
$html;
    }

    
/**
     * Get the start of the table tag
     * <code>
     * Usage:
     *    Table::start($datareader, $text, $width, $class, $border, $cellpadding, $cellspacing, $summary, $caption, $id); 
     * </code>
     * @static
     * @param DataReader / array $datareader The Data Reader object OR an array
     * @param String $text    The text header for the table
     * @param String $width   The Width for the table
     * @param String $class   The Class
     * @param String $border  The Border
     * @param String $cellpadding The CellSpacing
     * @param String $cellspacing The CellPadding
     * @param String $summary The Summary
     * @param String $caption The Caption 
     * @param String $id      The element ID
     */
    
public static function start($datareader=null$text=''$width=''$class=''$border=''$cellpadding=''$cellspacing=''$summary=''$caption=''$id='') {
        switch (
$text) {
            case 
'tr':
                
Tr::start();
                break;
            case 
'td':
                
Td::start($class);
                break;
            case 
'th':
                
Th::start($class);
                break;
            case 
'table':
                
// fall through
            
default:
                
$html = new TableTag($datareader$text$width$class$border$cellpadding$cellspacing$summary$caption$id);
                
$html->addHtml($html->getStart());
                break;
        }
    }

    
/**
     * Get the end of the table tag
     * <code>
     * Usage:
     *    Table::end($type);
     * </code>
     * @static
     * @param String $type 'table', 'tr', 'td' or 'th' or empty 
     */
    
public static function end($type='') {
        switch (
$type) {
            case 
'tr':
                
Tr::end();
                break;
            case 
'td':
                
Td::end();
                break;
            case 
'th':
                
Th::end();
                break;
            case 
'table':
                
// fall through
            
default:
                
$html = new TableTag();
                
$html->addHtml($html->getEnd());
                break;
        }
    }

    
/**
     * Get the start of the TR tag
     * <code>
     * Usage:
     *    Table::trstart($class); 
     * </code>
     * @static
     * @param String $class The class name
     */
    
public static function trstart($class='') {
        
Tr::start($class);
    }

    
/**
     * Display html for the TR tag
     * <code>
     * Usage:
     *    Table::tr($class); 
     * </code>
     * @static
     * @param String $class The class name
     */
    
public static function tr($class='') {
        
Tr::start($class);
    }

    
/**
     * Get the end of the TR tag
     * <code>
     * Usage:
     *    Table::trend(); 
     * </code>
     * @static
     */
    
public static function trend() {
        
Tr::end();
    }

    
/**
     * Get the start of the TD tag
     * <code>
     * Usage:
     *    Table::tdstart($class, $valign); 
     * </code>
     * @static
     * @param String $class  The class name
     * @param String $valign The alignment of data
     */
    
public static function tdstart($class=''$valign='') {
        
Td::start($class$valign);
    }

    
/**
     * Display html for the TD tag
     * <code>
     * Usage:
     *    Table::td($class, $valign); 
     * </code>
     * @static
     * @param String $class  The class name
     * @param String $valign The alignment of data
     */
    
public static function td($class=''$valign='') {
        
Td::start($class$valign);
    }

    
/**
     * Get the end of the TD tag
     * <code>
     * Usage:
     *    Table::tdend(); 
     * </code>
     * @static
     */
    
public static function tdend() {
        
Td::end();
    }

    
/**
     * Get the start of the TH tag
     * <code>
     * Usage:
     *    Table::thstart($class, $valign, $align); 
     * </code>
     * @static
     * @param String $class  The class name
     * @param String $valign The valignment of data
     * @param String $align  The alignment of data
     */
    
public static function thstart($class=''$valign=''$align='') {
        
Th::start($class$valign$align);
    }

    
/**
     * Display html for a TH
     * <code>
     * Usage:
     *    Table::th($class, $valign, $align); 
     * </code>
     * @static
     * @param String $class  The class name
     * @param String $valign The valignment of data
     * @param String $align  The alignment of data
     */
    
public static function th($class=''$valign=''$align='') {
        
Th::start($class$valign$align);
    }

    
/**
     * Get the end of the TH tag
     * <code>
     * Usage:
     *    Table::thend(); 
     * </code>
     * @static
     */
    
public static function thend() {
        
Th::end();
    }

    
/**
     * Display html
     * <code>
     * Usage:
     *    TableTag::display($datareader, $text, $width, $class, $border, $cellpadding, $cellspacing, $summary, $caption, $id); 
     * </code>
     * @static
     * @param DataReader / array $datareader The Data Reader object OR an array
     * @param String $text    The text header for the table
     * @param String $width   The width of the table
     * @param String $class   The class of the table
     * @param String $border  The border of the table
     * @param String $cellpadding The CellSpacing
     * @param String $cellspacing The CellPadding
     * @param String $summary The Summary
     * @param String $caption The Caption 
     * @param String $id      The element ID
     */
    
public static function display($datareader=null$text=''$width=''$class=''$border=''$cellpadding=''$cellspacing=''$summary=''$caption=''$id='') {
        
$html = new TableTag($datareader$text$width$class$border$cellpadding$cellspacing$summary$caption);
        
$html->addHtml();
    }
}
?>

Vis: HTML source code

TableTag, HTML source code

Den fulde HTML kildekode for TableTag klassen

<?
<!-- DEBUGTableTag -->
<!-- 
DEBUGTableHeader -->
<!-- 
No text in TableHeader -->

<
table width="100%" class="theTable" border="0" cellpadding="2" cellspacing="0">
 <
tr><td><!-- Der er ikke fundet noget -->&nbsp;</td></tr>
</
table>

?>

Vis: Class methods

TableTag, Class methods

Her er 'klasse metoderne' for TableTag klassen:

  • __construct
  • getRowStart
  • getColumnStart
  • getColumnEnd
  • getRowEnd
  • getHtml
  • start
  • end
  • trstart
  • tr
  • trend
  • tdstart
  • td
  • tdend
  • thstart
  • th
  • thend
  • display
  • newTextRow
  • getTableHeader
  • getStart
  • getEnd
  • setObject
  • set
  • get
  • getAttribute
  • getTag
  • add
  • getSizeof
  • getElement
  • getElements
  • getToogle
  • getMaximize
  • getMinimize
  • newTriangle
  • getStartHtml
  • getEndHtml
  • showsource
  • getClassName
  • getMsg
  • addHtml
  • __toString
  • getCacheFileName
  • save
  • content

Vis: Object vars

TableTag, Object vars

Her er 'objekt variable' for TableTag klassen:

  • html =>
  • sql =>

MenuRight 
triangle.gif

Dansk

Deutch

English (UK)

France

Italy

Norsk

Svensk

English (USA)


 
blank.gif
MenuBottom 
triangle.gif Copyright @ 1999-2010 www.Finn-Rasmussen.com Powered by myPHP Version (5.2.6-1+lenny8) 1.11
blank.gif