Sådan benyttes komponenten ViewCustomerList klassen
Først skal du inkludere den fil der beskriver komponenten, som en klasse fil
<? require_once(HTML_PACKAGE_PATH.'/ViewCustomerList.php'); ?>
Dernæst kan du enten benytte komponenten som et taglib (statiske metoder):
<? ViewCustomerList::display($param1, $param2, $param3, ...); ?>
eller du kan lave en instance af komponenten og benytte metoderne direkte:
<? $object = new ViewCustomerList($param1, $param2, $param3, ...); print $object->getHtml(); ?>
Sådan vises komponenten ViewCustomerList klassen
Den fulde PHP kildekode for ViewCustomerList klassen
<?php/** * @package db-customer * @see HTML_DB_CUSTOMER_VIEW_PATH.'/ViewCustomerList.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.'/ViewList.php');/** * Generates the html for a View Customer * <code> * Usage: * $view = new ViewCustomerList($datareader, $text, $width, $class, $border, $cellpadding, $cellspacing, $summary, $caption, $layout); * print $view->getHtml(); * Or * ViewCustomerList::display($datareader, $text, $width, $class, $border, $cellpadding, $cellspacing, $summary, $caption, $layout); * * Generates a complete View List interface * +-------------------------------- * | Text header * +-------------------------------- * | head1 | head2 | head3 | etc. * +-------------------------------- * | dat_1 | dat_2 | dat_3 | etc. * +-------------------------------- * </code> * @package db-customer */class ViewCustomerList extends ViewList { /** * 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 : $this->getClassName(); // Global table characteristics $theWidth = $width != '' ? $width : CUSTOMER_LIST_VIEW_WIDTH; $theClass = $class != '' ? $class : CUSTOMER_LIST_VIEW_CLASS; $theBorder = $border != '' ? $border : CUSTOMER_LIST_VIEW_BORDER; $theCellPadding = $cellpadding != '' ? $cellpadding : CUSTOMER_LIST_VIEW_CELLPADDING; $theCellSpacing = $cellspacing != '' ? $cellspacing : CUSTOMER_LIST_VIEW_CELLSPACING; parent::__construct($datareader, $theText, $theWidth, $theClass, $theBorder, $theCellPadding, $theCellSpacing, $summary, $caption, $layout); } /** * Display html * <code> * Usage: * ViewCustomerList::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 ViewCustomerList($datareader, $text, $width, $class, $border, $cellpadding, $cellspacing, $summary, $caption, $layout); $html->addHtml(); }}?>
Den fulde HTML kildekode for ViewCustomerList klassen
<? <!-- DEBUG: ViewCustomerList --> <!-- DEBUG: TableHeader --> <table width="100%" class="customerListView baseBorder" border="0" cellpadding="2" cellspacing="0"> <tr> <td class="baseArrowHeader" valign="middle"><!-- DEBUG: Link --> <a class="baseLinkColor" href="/source-code/db-customer/ViewCustomerList/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">ViewCustomerList (3) </th> </tr> </table> <table id="ViewCustomerListId" width="100%" class="customerListView baseBorder" border="0" cellpadding="2" cellspacing="0"> <tr> <th class="baseColorHeader baseNoWrap" valign="top"> <!-- company_name 100 string --> <!-- DEBUG: Sortby --> <!-- Firmanavn --><a class="baseColorHeader" href="/source-code/db-customer/ViewCustomerList/index.php?mvcSORT_BY=asc&mvcORDER_BY=company_name" title="Mvcorder_by desc">Firmanavn</a> </th> <th class="baseColorHeader baseNoWrap" valign="top"> <!-- address 100 string --> <!-- DEBUG: Sortby --> <!-- Adresse --><a class="baseColorHeader" href="/source-code/db-customer/ViewCustomerList/index.php?mvcSORT_BY=asc&mvcORDER_BY=address" title="Mvcorder_by desc">Adresse</a> </th> <th class="baseColorHeader baseNoWrap" valign="top"> <!-- zip 100 string --> <!-- DEBUG: Sortby --> <!-- Postnr --><a class="baseColorHeader" href="/source-code/db-customer/ViewCustomerList/index.php?mvcSORT_BY=asc&mvcORDER_BY=zip" title="Mvcorder_by desc">Postnr</a> </th> <th class="baseColorHeader baseNoWrap" valign="top"> <!-- city 100 string --> <!-- DEBUG: Sortby --> <!-- By --><a class="baseColorHeader" href="/source-code/db-customer/ViewCustomerList/index.php?mvcSORT_BY=asc&mvcORDER_BY=city" title="Mvcorder_by desc">By</a> </th> <th class="baseColorHeader baseNoWrap" valign="top"> <!-- contact_person 100 string --> <!-- DEBUG: Sortby --> <!-- Kontakt person --><a class="baseColorHeader" href="/source-code/db-customer/ViewCustomerList/index.php?mvcSORT_BY=asc&mvcORDER_BY=contact_person" title="Mvcorder_by desc">Kontakt person</a> </th> <th class="baseColorHeader baseNoWrap" valign="top"> <!-- mobile_phone 100 string --> <!-- DEBUG: Sortby --> <!-- Mobil telefon --><a class="baseColorHeader" href="/source-code/db-customer/ViewCustomerList/index.php?mvcSORT_BY=asc&mvcORDER_BY=mobile_phone" title="Mvcorder_by desc">Mobil telefon</a> </th> <th class="baseColorHeader baseNoWrap" valign="top"> <!-- email 100 string --> <!-- DEBUG: Sortby --> <!-- Email --><a class="baseColorHeader" href="/source-code/db-customer/ViewCustomerList/index.php?mvcSORT_BY=asc&mvcORDER_BY=email" title="Mvcorder_by desc">Email</a> </th> </tr> <tr> <td class="baseColorDark" valign="top">HvepseEksperten.dk ApS </td> <td class="baseColorDark" valign="top">Kongens Vænge 79 </td> <td class="baseColorDark" valign="top">3400 </td> <td class="baseColorDark" valign="top">Hillerød </td> <td class="baseColorDark" valign="top">Finn Rasmussen </td> <td class="baseColorDark" valign="top">40506069 </td> <td class="baseColorDark" valign="top">test@hvepse-eksperten.dk </td> </tr> <tr> <td class="baseColorLight" valign="top">vin.eksperter.dk </td> <td class="baseColorLight" valign="top">Kongens Vænge 79 </td> <td class="baseColorLight" valign="top">3400 </td> <td class="baseColorLight" valign="top">Hillerød </td> <td class="baseColorLight" valign="top">Zita Christensen </td> <td class="baseColorLight" valign="top">48246037 </td> <td class="baseColorLight" valign="top">vin@eksperter.dk </td> </tr> <tr> <td class="baseColorDark" valign="top">foto.eksperter.dk </td> <td class="baseColorDark" valign="top">Kongens Vænge 79 </td> <td class="baseColorDark" valign="top">3400 </td> <td class="baseColorDark" valign="top">Hillerød </td> <td class="baseColorDark" valign="top">Fotograf </td> <td class="baseColorDark" valign="top">48246030 </td> <td class="baseColorDark" valign="top">foto@eksperter.dk </td> </tr> </table> ?>
Her er 'klasse metoderne' for ViewCustomerList klassen:
Her er 'objekt variable' for ViewCustomerList klassen: