Sådan benyttes komponenten Tab klassen
Først skal du inkludere den fil der beskriver komponenten, som en klasse fil
<? require_once(HTML_PACKAGE_PATH.'/Tab.php'); ?>
Dernæst kan du enten benytte komponenten som et taglib (statiske metoder):
<? Tab::display($param1, $param2, $param3, ...); ?>
eller du kan lave en instance af komponenten og benytte metoderne direkte:
<? $object = new Tab($param1, $param2, $param3, ...); print $object->getHtml(); ?>
Sådan vises komponenten Tab klassen
Den fulde PHP kildekode for Tab klassen
<?php/** * @package tab * @see HTML_TAB_PAGE_PATH/Tab.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_MENU_PAGE_PATH.'/MenuHorizontal.php');require_once(HTML_TABLE_COMPONENT_PATH.'/TableHeader.php');require_once(HTML_TABLE_COMPONENT_PATH.'/Table.php');require_once(HTML_BASE_UTIL_PATH.'/Link.php');if (defined('HTML_LANGUAGE_UTIL_PATH')) { require_once(HTML_LANGUAGE_UTIL_PATH.'/Translate.php');}if (defined('HTML_LOG_UTIL_PATH')) { require_once(HTML_LOG_UTIL_PATH.'/Log.php');}/** * Generates a Tab navigation menu * <code> * +______________+-------+_________________ * | link1 |link2 | link3 | link4 | ... | * +--------------+ +-----------------+ * Usage: * $menu = new Tab($datareader, $text, $width, $class, $border, * $cellpadding, $cellspacing, $summary, $caption, $layout); * print $menu->getHtml(); * Or * Tab:display($datareader, $text, $width, $class, $border, * $cellpadding, $cellspacing, $summary, $caption, $layout); * </code> * @package tab */class Tab extends MenuHorizontal { /** * 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 $layout The layout to use */ function __construct($datareader=null, $text='', $width='', $class='', $border='', $cellpadding='', $cellspacing='', $summary='', $caption='', $layout='') { $theText = $text != '' ? $text : TAB_MENU_TEXT; $theWidth = $width != '' ? $width : TAB_MENU_VIEW_WIDTH; $theClass = $class != '' ? $class : TAB_MENU_VIEW_CLASS; $theBorder = $border != '' ? $border : TAB_MENU_VIEW_BORDER; $theCellpadding = $cellpadding != '' ? $cellpadding : TAB_MENU_VIEW_CELLPADDING; $theCellspacing = $cellspacing != '' ? $cellspacing : TAB_MENU_VIEW_CELLSPACING; $theLayout = $layout != '' ? $layout : TAB_MENU_VIEW_LAYOUT; parent::__construct($datareader, $theText, $theWidth, $theClass, $theBorder, $theCellpadding, $theCellspacing, $summary, $caption, $theLayout); } /** * Get the CSS class Name for this component * @return String The CSS class name */ function getCssClass() { return CSS_ATAB; } /** * Toogle the request parameters which will minimize or maximize this component * @return array The array of key=>value pair */ function getMinimize() { return $this->getToogle(REQUEST_TAB_SHOW, TAB_SHOW, TAB_SHOW_MENU_TAB); } /** * 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 { $html .= $this->getColumns(); if (CACHE_TAB) { $this->save($html, CACHE_TAB_PATH); } } } else { $html .= $this->getMaximize(); } return $html; } /** * Display the html * <code> * Usage: * Tab::display($datareader, $text, $width, $class, $border, * $cellpadding, $cellspacing, $summary, $caption, $layout); * </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 $layout The layout to use */ public static function display($datareader=null, $text='', $width='', $class='', $border='', $cellpadding='', $cellspacing='', $summary='', $caption='', $layout='') { $html = new Tab($datareader, $text, $width, $class, $border, $cellpadding, $cellspacing, $summary, $caption, $layout); $html->addHtml(); }}?>
Den fulde HTML kildekode for Tab klassen
<? <!-- DEBUG: Tab --> <table id="TabId" width="100%" class="tableBorderLeft tableBorderRight basePrinter" border="0" cellpadding="0" cellspacing="0"> <tr> <td valign="top" width="1px" title="tl"><!-- DEBUG: Images --> <img src="/myphp-1.11/myphp-1.11-netbank.eksperter.dk/html/images/tl.gif" width="9" height="41" alt="tl.gif" class="baseFloatLeft" border="0" /> </td> <td class="tabTab" valign="middle"><!-- DEBUG: Link --> <!-- Base --><a class="tabATab" href="http://finnrasmussen.dk/source-code/base" title="Base">Base</a> </td> <td valign="top" width="1px" title="tr"><!-- DEBUG: Images --> <img src="/myphp-1.11/myphp-1.11-netbank.eksperter.dk/html/images/tr.gif" width="9" height="41" alt="tr.gif" class="baseFloatLeft" border="0" /> </td> <td valign="top" width="1px" title="tl"><!-- DEBUG: Images --> <img src="/myphp-1.11/myphp-1.11-netbank.eksperter.dk/html/images/tl.gif" width="9" height="41" alt="tl.gif" class="baseFloatLeft" border="0" /> </td> <td class="tabTab" valign="middle"><!-- DEBUG: Link --> <!-- Basic --><a class="tabATab" href="http://finnrasmussen.dk/source-code/basic" title="Basic">Basic</a> </td> <td valign="top" width="1px" title="tr"><!-- DEBUG: Images --> <img src="/myphp-1.11/myphp-1.11-netbank.eksperter.dk/html/images/tr.gif" width="9" height="41" alt="tr.gif" class="baseFloatLeft" border="0" /> </td> <td valign="top" width="1px" title="tl"><!-- DEBUG: Images --> <img src="/myphp-1.11/myphp-1.11-netbank.eksperter.dk/html/images/tl.gif" width="9" height="41" alt="tl.gif" class="baseFloatLeft" border="0" /> </td> <td class="tabTab" valign="middle"><!-- DEBUG: Link --> <!-- Dto --><a class="tabATab" href="http://finnrasmussen.dk/source-code/dto" title="Dto">Dto</a> </td> <td valign="top" width="1px" title="tr"><!-- DEBUG: Images --> <img src="/myphp-1.11/myphp-1.11-netbank.eksperter.dk/html/images/tr.gif" width="9" height="41" alt="tr.gif" class="baseFloatLeft" border="0" /> </td> <td valign="top" width="1px" title="tl"><!-- DEBUG: Images --> <img src="/myphp-1.11/myphp-1.11-netbank.eksperter.dk/html/images/tl.gif" width="9" height="41" alt="tl.gif" class="baseFloatLeft" border="0" /> </td> <td class="tabTab" valign="middle"><!-- DEBUG: Link --> <!-- Form --><a class="tabATab" href="http://finnrasmussen.dk/source-code/form" title="Form">Form</a> </td> <td valign="top" width="1px" title="tr"><!-- DEBUG: Images --> <img src="/myphp-1.11/myphp-1.11-netbank.eksperter.dk/html/images/tr.gif" width="9" height="41" alt="tr.gif" class="baseFloatLeft" border="0" /> </td> <td valign="top" width="1px" title="tl"><!-- DEBUG: Images --> <img src="/myphp-1.11/myphp-1.11-netbank.eksperter.dk/html/images/tl.gif" width="9" height="41" alt="tl.gif" class="baseFloatLeft" border="0" /> </td> <td class="tabTab" valign="middle"><!-- DEBUG: Link --> <!-- Language --><a class="tabATab" href="http://finnrasmussen.dk/source-code/language" title="Language">Language</a> </td> <td valign="top" width="1px" title="tr"><!-- DEBUG: Images --> <img src="/myphp-1.11/myphp-1.11-netbank.eksperter.dk/html/images/tr.gif" width="9" height="41" alt="tr.gif" class="baseFloatLeft" border="0" /> </td> <td valign="top" width="1px" title="tl"><!-- DEBUG: Images --> <img src="/myphp-1.11/myphp-1.11-netbank.eksperter.dk/html/images/tl.gif" width="9" height="41" alt="tl.gif" class="baseFloatLeft" border="0" /> </td> <td class="tabTab" valign="middle"><!-- DEBUG: Link --> <!-- Layout --><a class="tabATab" href="http://finnrasmussen.dk/source-code/layout" title="Layout">Layout</a> </td> <td valign="top" width="1px" title="tr"><!-- DEBUG: Images --> <img src="/myphp-1.11/myphp-1.11-netbank.eksperter.dk/html/images/tr.gif" width="9" height="41" alt="tr.gif" class="baseFloatLeft" border="0" /> </td> <td valign="top" width="1px" title="tl"><!-- DEBUG: Images --> <img src="/myphp-1.11/myphp-1.11-netbank.eksperter.dk/html/images/tl.gif" width="9" height="41" alt="tl.gif" class="baseFloatLeft" border="0" /> </td> <td class="tabTab" valign="middle"><!-- DEBUG: Link --> <!-- Menu --><a class="tabATab" href="http://finnrasmussen.dk/source-code/menu" title="Menu">Menu</a> </td> <td valign="top" width="1px" title="tr"><!-- DEBUG: Images --> <img src="/myphp-1.11/myphp-1.11-netbank.eksperter.dk/html/images/tr.gif" width="9" height="41" alt="tr.gif" class="baseFloatLeft" border="0" /> </td> <td valign="top" width="1px" title="tl"><!-- DEBUG: Images --> <img src="/myphp-1.11/myphp-1.11-netbank.eksperter.dk/html/images/tl.gif" width="9" height="41" alt="tl.gif" class="baseFloatLeft" border="0" /> </td> <td class="tabTab" valign="middle"><!-- DEBUG: Link --> <!-- Mvc --><a class="tabATab" href="http://finnrasmussen.dk/source-code/mvc" title="Mvc">Mvc</a> </td> <td valign="top" width="1px" title="tr"><!-- DEBUG: Images --> <img src="/myphp-1.11/myphp-1.11-netbank.eksperter.dk/html/images/tr.gif" width="9" height="41" alt="tr.gif" class="baseFloatLeft" border="0" /> </td> <td valign="top" width="1px" title="tl"><!-- DEBUG: Images --> <img src="/myphp-1.11/myphp-1.11-netbank.eksperter.dk/html/images/tl.gif" width="9" height="41" alt="tl.gif" class="baseFloatLeft" border="0" /> </td> <td class="tabTab" valign="middle"><!-- DEBUG: Link --> <!-- Netbank.eksperter.dk --><a class="tabATab" href="http://finnrasmussen.dk/source-code/netbank.eksperter.dk" title="Netbank.eksperter.dk">Netbank.eksperter.dk</a> </td> <td valign="top" width="1px" title="tr"><!-- DEBUG: Images --> <img src="/myphp-1.11/myphp-1.11-netbank.eksperter.dk/html/images/tr.gif" width="9" height="41" alt="tr.gif" class="baseFloatLeft" border="0" /> </td> <td valign="top" width="1px" title="tls"><!-- DEBUG: Images --> <img src="/myphp-1.11/myphp-1.11-netbank.eksperter.dk/html/images/tls.gif" width="9" height="41" alt="tls.gif" class="baseFloatLeft" border="0" /> </td> <td class="tabTabActive" valign="middle"> <b class="tabATabActive">Tab</b> </td> <td valign="top" width="1px" title="trs"><!-- DEBUG: Images --> <img src="/myphp-1.11/myphp-1.11-netbank.eksperter.dk/html/images/trs.gif" width="9" height="41" alt="trs.gif" class="baseFloatLeft" border="0" /> </td> <td valign="top" width="1px" title="tl"><!-- DEBUG: Images --> <img src="/myphp-1.11/myphp-1.11-netbank.eksperter.dk/html/images/tl.gif" width="9" height="41" alt="tl.gif" class="baseFloatLeft" border="0" /> </td> <td class="tabTab" valign="middle"><!-- DEBUG: Link --> <!-- Table --><a class="tabATab" href="http://finnrasmussen.dk/source-code/table" title="Table">Table</a> </td> <td valign="top" width="1px" title="tr"><!-- DEBUG: Images --> <img src="/myphp-1.11/myphp-1.11-netbank.eksperter.dk/html/images/tr.gif" width="9" height="41" alt="tr.gif" class="baseFloatLeft" border="0" /> </td> <td valign="top" width="1px" title="tl"><!-- DEBUG: Images --> <img src="/myphp-1.11/myphp-1.11-netbank.eksperter.dk/html/images/tl.gif" width="9" height="41" alt="tl.gif" class="baseFloatLeft" border="0" /> </td> <td class="tabTab" valign="middle"><!-- DEBUG: Link --> <!-- Util --><a class="tabATab" href="http://finnrasmussen.dk/source-code/util" title="Util">Util</a> </td> <td valign="top" width="1px" title="tr"><!-- DEBUG: Images --> <img src="/myphp-1.11/myphp-1.11-netbank.eksperter.dk/html/images/tr.gif" width="9" height="41" alt="tr.gif" class="baseFloatLeft" border="0" /> </td> </tr> </table> ?>
Her er 'klasse metoderne' for Tab klassen:
Her er 'objekt variable' for Tab klassen: