Sådan benyttes komponenten ViewBusinessCard klassen
Først skal du inkludere den fil der beskriver komponenten, som en klasse fil
<? require_once(HTML_PACKAGE_PATH.'/ViewBusinessCard.php'); ?>
Dernæst kan du enten benytte komponenten som et taglib (statiske metoder):
<? ViewBusinessCard::display($param1, $param2, $param3, ...); ?>
eller du kan lave en instance af komponenten og benytte metoderne direkte:
<? $object = new ViewBusinessCard($param1, $param2, $param3, ...); print $object->getHtml(); ?>
Sådan vises komponenten ViewBusinessCard klassen
Den fulde PHP kildekode for ViewBusinessCard klassen
<?php/** * @package mvc * @see HTML_MVC_VIEW_PATH.'/ViewBusinessCard.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_MVC_VIEW_PATH.'/ViewInfo.php');/** * Generates the html for a View like a business card look-a-like * <code> * Usage: * $view = new ViewBusinessCard($datareader, $text, $width, $class, $border, $cellpadding, $cellspacing, $summary, $caption, $layout); * print $view->getHtml(); * Or * ViewBusinessCard::display($datareader, $text, $width, $class, $border, $cellpadding, $cellspacing, $summary, $caption, $layout); * * Generates a complete View Business Card interface * +--------+ * | Header | * +--------+ * | data1 | * | data2 | * | ... | * +--------+ * </code> * @package mvc */class ViewBusinessCard extends ViewInfo { /** * 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 * @param String $layout The layout to use */ function __construct($datareader=null, $text='', $width='', $class='', $border='', $cellpadding='', $cellspacing='', $summary='', $caption='', $layout='') { $theText = $text != ''?$text:''; // Global table characteristics $theWidth = $width != '' ? $width : BUSINESS_CARD_VIEW_WIDTH; $theClass = $class != '' ? $class : BUSINESS_CARD_VIEW_CLASS; $theBorder = $border != '' ? $border : BUSINESS_CARD_VIEW_BORDER; $theCellPadding = $cellpadding != '' ? $cellpadding : BUSINESS_CARD_VIEW_CELLPADDING; $theCellSpacing = $cellspacing != '' ? $cellspacing : BUSINESS_CARD_VIEW_CELLSPACING; parent::__construct($datareader, $theText, $theWidth, $theClass, $theBorder, $theCellPadding, $theCellSpacing, $summary, $caption, $layout); } /** * Display html * <code> * Usage: * ViewBusinessCard::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 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 $layout The layout to use */ public static function display($datareader=null, $text='', $width='', $class='', $border='', $cellpadding='', $cellspacing='', $summary='', $caption='', $layout='') { $html = new ViewBusinessCard($datareader, $text, $width, $class, $border, $cellpadding, $cellspacing, $summary, $caption, $layout); $html->addHtml(); }}?>
Den fulde HTML kildekode for ViewBusinessCard klassen
<? <!-- DEBUG: ViewBusinessCard --> <table id="ViewBusinessCardId" width="400" class="tableBusinessCardView baseBorder" border="0" cellpadding="2" cellspacing="0"> <tr> <td valign="top">Privat telefon: 48246030<br /> Finn Rasmussen<br /> HvepseEksperten.dk ApS<br /> Kongens Vænge 79<br /> 3400 Hillerød<br /> Denmark<br /> </td> </tr> </table> ?>
Her er 'klasse metoderne' for ViewBusinessCard klassen:
Her er 'objekt variable' for ViewBusinessCard klassen: