Sådan benyttes komponenten Index klassen
Først skal du inkludere den fil der beskriver komponenten, som en klasse fil
<? require_once(HTML_PACKAGE_PATH.'/Index.php'); ?>
Dernæst kan du enten benytte komponenten som et taglib (statiske metoder):
<? Index::display($param1, $param2, $param3, ...); ?>
eller du kan lave en instance af komponenten og benytte metoderne direkte:
<? $object = new Index($param1, $param2, $param3, ...); print $object->getHtml(); ?>
Sådan vises komponenten Index klassen
Den fulde PHP kildekode for Index klassen
<?php/** * @package tab * @see HTML_TAB_PAGE_PATH/Index.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.'/MenuVertical.php');/** * Generates a list of links, like in an Index * <code> * Usage: * $rows = array( 'b'=>array('tab'=>'b',...),array('tab'=>'b',...)); * $header = ''; // The header meta data * $default = ''; // The default meta data array * $limit = ''; // The limit to use for the array * $sort = true; * * $datareader = DatareaderFactory::newDataReader($rows, $header, $default, $limit, $sort); * $menu = new Index($datareader, $text, $width, $class, $border, * $cellpadding, $cellspacing, $summary, $caption, $layout); * print $menu->getHtml(); * Or * Index:display($datareader, $text, $width, $class, $border, * $cellpadding, $cellspacing, $summary, $caption, $layout); * </code> * @package tab */class Index extends MenuVertical { /** * 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 : MENU_INDEX_TEXT; $theWidth = $width != '' ? $width : TAB_INDEX_VIEW_WIDTH; $theClass = $class != '' ? $class : TAB_INDEX_VIEW_CLASS; $theBorder = $border != '' ? $border : TAB_INDEX_VIEW_BORDER; $theCellpadding = $cellpadding != '' ? $cellpadding : TAB_INDEX_VIEW_CELLPADDING; $theCellspacing = $cellspacing != '' ? $cellspacing : TAB_INDEX_VIEW_CELLSPACING; $theLayout = $layout != '' ? $layout : TAB_INDEX_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_TAB_MENU; } /** * 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_INDEX); } /** * Returns the html for the Index * @return String the complete html */ function getHtml() { $html = $this->html; if (defined('TAB_SHOW') && TAB_SHOW & TAB_SHOW_MENU_INDEX) { 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 .= "<!-- Index -->\r\n";; $html .= $this->getColumns(); if (CACHE_TAB) { $this->save($html, CACHE_TAB_PATH); } } } else { $html .= $this->getMaximize(); } return $html; } /** * Display the html * <code> * Usage: * Index::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 Index($datareader, $text, $width, $class, $border, $cellpadding, $cellspacing, $summary, $caption, $layout); $html->addHtml(); }}?>
Den fulde HTML kildekode for Index klassen
<? <!-- DEBUG: Index --> <!-- Index --> <!-- DEBUG: TableHeader --> <table width="200" class="baseBorder" border="0" cellpadding="2" cellspacing="0"> <tr> <td class="baseArrowHeader" valign="middle"><!-- DEBUG: Link --> <a class="baseLinkColor" href="/source-code/tab/Index/index.php" title="Klik her for at Minimere ... TableHeader"><!-- DEBUG: Images --> <img src="http://finnrasmussen.dk/images/arrow-headline.gif" width="4" height="7" alt="arrow-headline.gif" /> </a> </td> <th class="baseColorHeader" valign="top" align="left">Index </th> </tr> </table> <table id="IndexId" width="200" class="baseBorder" border="0" cellpadding="0" cellspacing="0"> <tr> <td class="tabMenu" valign="top"><!-- LINK_LAYOUT_XX=16408 --> <!-- DEBUG: Ul --> <ul class="tabMenu"> <!-- DEBUG: Link --> <li class="tabMenu"><a class="tabMenu" href="?tabShow=4139" title="Klik her for at Minimere ... Index"><!-- DEBUG: Images --> <img src="http://finnrasmussen.dk/images/triangle.gif" width="10" height="10" alt="triangle.gif" class="tabMenu" /> </a></li> <!-- DEBUG: Link --> <!-- Forsiden --> <li class="tabMenu"><a class="tabMenu" href="/" title="Til forsiden">Forsiden</a></li> <!-- DEBUG: Link --> <!-- Kontakt --> <li class="tabMenu"><a class="tabMenu" href="http://www.hvepseeksperten.dk/FormMail/" title="Kontakt via email
">Kontakt</a></li> </ul> </td> </tr> </table> ?>
Her er 'klasse metoderne' for Index klassen:
Her er 'objekt variable' for Index klassen: