Sådan benyttes komponenten Line klassen
Først skal du inkludere den fil der beskriver komponenten, som en klasse fil
<? require_once(HTML_PACKAGE_PATH.'/Line.php'); ?>
Dernæst kan du enten benytte komponenten som et taglib (statiske metoder):
<? Line::display($param1, $param2, $param3, ...); ?>
eller du kan lave en instance af komponenten og benytte metoderne direkte:
<? $object = new Line($param1, $param2, $param3, ...); print $object->getHtml(); ?>
Sådan vises komponenten Line klassen
Den fulde PHP kildekode for Line klassen
<?php/** * @package layout * @see HTML_LAYOUT_UTIL_PATH.'/Line.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_BASE_UTIL_PATH.'/Images.php');/** * Used to draw a line, in order to show some visual effects * <code> * Usage: * $datareader = null; * $text = "10px"; // In fact, this is the height of the gif * $width = "100%"; * $class = "theTable"; * $border = "1"; * $cellpadding = "5" * $cellspacing = "0"; * $summary = ""; * $caption = ""; * $id = ""; * * $line = new Line($datareader, $text, $width, $class, $border, $cellpadding, $cellspacing, $summary, $caption, $id); * print $line->getHtml(); * Or * Line::display($datareader, $text, $width, $class, $border, $cellpadding, $cellspacing, $summary, $caption, $id); * </code> * @package layout */class Line extends Table { private $height = ''; private $lineclass = ''; /** * 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 of the table, default 100% * @param String $class The css class to use * @param String $border The table 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 = ''; // NOT USED, because it is in fact the 'height' parameter $theClass = CSS_PRINTER; $theWidth = $width != '' ? $width : LINE_VIEW_WIDTH; $theBorder = $border != '' ? $border : LINE_VIEW_BORDER; $theId = $id != '' ? $id : $this->getClassName()."Id"; $theCellPadding = $cellpadding != '' ? $cellpadding : LINE_VIEW_CELLPADDING; $theCellSpacing = $cellspacing != '' ? $cellspacing : LINE_VIEW_CELLSPACING; parent::__construct($datareader, $theText, $theWidth, $theClass, $theBorder, $theCellPadding, $theCellSpacing, $summary, $caption, $theId); $this->height = $text != '' ? $text : LINE_VIEW_HEIGHT; $this->lineclass = $class != '' ? LINE_VIEW_CLASS.' '.$class : LINE_VIEW_CLASS; } /** * Get the CSS class Name for this component * @return String The CSS class name */ function getCssClass() { return $this->lineclass; } /** * Return the content as an object * Note: have to subtract 2px from the width, because of the border on the table * @return Object The content as an object */ function newContent() { $tr = new Tr(); $border = $this->border; // Like border="10", however problem if 10px etc. if ($border === "" || $border === 0 || $border === "0") { $border = 0; } else { } $img = new Images(IMAGE_BLANK, $this->width - 2 - (2 * $border), $this->height); $td = new Raw('<td class="'.$this->getCssClass().'">'.$img->getHtml().'</td>'); $tr->add($td); return $tr; } /** * Builds the html, and return it for a Line object * @return String The html */ function getHtml() { $html = $this->html; if (defined('LAYOUT_SHOW') && LAYOUT_SHOW & LAYOUT_SHOW_LINE && HTTP_USER_AGENT!=HTTP_USER_AGENT_P900) { $this->add($this->newContent()); // Render it if ($this->text != '') { $html .= $this->getTableHeader(); } $html .= $this->getStart(); $html .= $this->getEnd(); } return $html; } /** * Display html * <code> * Usage: * Line::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 $height The height of the line * @param String $width The width of the table, default 100% * @param String $class The css class to use * @param String $border The table border * @param String $cellpadding The CellSpacing * @param String $cellspacing The CellPadding * @param String $summary The Summary * @param String $caption The Caption */ public static function display($datareader=null, $text='', $width='', $class='', $border='', $cellpadding='', $cellspacing='', $summary='', $caption='', $id='') { $html = new Line($datareader, $text, $width, $class, $border, $cellpadding, $cellspacing, $summary, $caption, $id); $html->addHtml(); }}?>
Den fulde HTML kildekode for Line klassen
<? <!-- DEBUG: Line --> <table id="LineId" width="100%" class="basePrinter" border="1" cellpadding="0" cellspacing="0"> <tr> <td class="tableBorderLeft tableBorderRight basePrinter layoutLineBanner"><!-- DEBUG: Images --> <img src="http://myrer.info/images/blank.gif" width="96" height="5px" alt="blank.gif" /></td> </tr> </table> ?>
Her er 'klasse metoderne' for Line klassen:
Her er 'objekt variable' for Line klassen: