Sådan benyttes komponenten TabBody klassen
Først skal du inkludere den fil der beskriver komponenten, som en klasse fil
<? require_once(HTML_PACKAGE_PATH.'/TabBody.php'); ?>
Dernæst kan du enten benytte komponenten som et taglib (statiske metoder):
<? TabBody::display($param1, $param2, $param3, ...); ?>
eller du kan lave en instance af komponenten og benytte metoderne direkte:
<? $object = new TabBody($param1, $param2, $param3, ...); print $object->getHtml(); ?>
Sådan vises komponenten TabBody klassen
Den fulde PHP kildekode for TabBody klassen
<?php/** * @package tab * @see HTML_TAB_PAGE_PATH.'/TabBody.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');/** * Generates a Tab navigation menu * <code> * ______________+-------+_________________ * | link1 |link2 | link3 | link4 | | * +--------------+ +-----------------+ * | | * | Tab Body | * | | * +-------- tab end -----------------------+ * Usage: * $datareader = null; * $text = "Text header"; * $width = "100%"; * $class = "theTable"; * $border = "1"; * $cellpadding = "5" * $cellspacing = "0"; * $summary = ""; * $caption = ""; * $id = ""; * * $html = new TabBody($datareader, $text, $width, $class, $border, $cellpadding, $cellspacing, $summary, $caption, $id); * print $html->getStart(); * print "The tab body"; * print $html->getEnd(); * Or * TabBody::start($datareader, $text, $width, $class, $border, $cellpadding, $cellspacing, $summary, $caption, $id); * Raw::display"The tab body"); * TabBody::end(); * Or * TabBody::display($datareader, $text, $width, $class, $border, $cellpadding, $cellspacing, $summary, $caption, $id); * </code> * @package tab */class TabBody 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 */ function __construct($datareader=null, $text='', $width='', $class='', $border='', $cellpadding='', $cellspacing='', $summary='', $caption='', $id='') { $theText = $text != '' ? $text : ''; $theWidth = $width != '' ? $width : TAB_BODY_WIDTH; $theClass = $class != '' ? $class : TAB_BODY_CLASS; $theBorder = $border != '' ? $border : TAB_BODY_BORDER; $theId = $id != '' ? $id : $this->getClassName()."Id"; $thePadding = $cellpadding != '' ? $cellpadding : TAB_BODY_CELL_PADDING; $theSpacing = $cellspacing != '' ? $cellspacing : TAB_BODY_CELL_SPACING; parent::__construct($datareader, $theText, $theWidth, $theClass, $theBorder, $thePadding, $theSpacing, $summary, $caption, $theId); } /** * Get the content as an object * @return Object The content */ function newContent() { $object = new Tr(); $object->add(new Td(CSS_TAB_BODY)); return $object; } /** * Builds the html for a Tab menu, and return it * @return String The tab menu as html */ function getHtml() { $html = $this->html; if (defined('TAB_SHOW') && TAB_SHOW & TAB_SHOW_MENU_TAB) { if (CACHE_TAB && $this->getCacheFileName(CACHE_TAB_PATH) != '' && file_exists($this->getCacheFileName(CACHE_TAB_PATH))) { $html .= $this->content($this->getCacheFileName(CACHE_TAB_PATH)); } else { $this->add($this->newContent()); // Render it if ($this->text != '') { $html .= $this->getTableHeader(); } $html .= $this->getStart(); $html .= $this->getEnd(); if (CACHE_TAB) { $this->save($html, CACHE_TAB_PATH); } } } return $html; } /** * Get the start of the table tag * <code> * Usage: * TableBody::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='') { $html = new TabBody($datareader, $text, $width, $class, $border, $cellpadding, $cellspacing, $summary, $caption, $id); if ($text != '') { $html->addHtml($html->getTableHeader()); } $html->addHtml($html->getStart()); // Note: you must write the start TR + TD your self } /** * Get the end of the table tag * <code> * Usage: * TableBody::end($type); * </code> * @static */ public static function end() { $html = new TabBody(); // Note: you must write the end TD + TR your self $html->addHtml($html->getEnd()); } /** * Display the html * <code> * Usage: * TabBody::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 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 display($datareader=null, $text='', $width='', $class='', $border='', $cellpadding='', $cellspacing='', $summary='', $caption='', $id='') { $html = new TabBody($datareader, $text, $width, $class, $border, $cellpadding, $cellspacing, $summary, $caption, $id); $html->addHtml(); }}?>
Den fulde HTML kildekode for TabBody klassen
<? <!-- DEBUG: TabBody --> <table id="TabBodyId" width="100%" class="baseNONE" border="0" cellpadding="5" cellspacing="0"> <tr> <td class="tabTabBody" valign="top"></td> </tr> </table> ?>
Her er 'klasse metoderne' for TabBody klassen:
Her er 'objekt variable' for TabBody klassen: