Sådan benyttes komponenten EngineCustomer klassen
Først skal du inkludere den fil der beskriver komponenten, som en klasse fil
<? require_once(HTML_PACKAGE_PATH.'/EngineCustomer.php'); ?>
Dernæst kan du enten benytte komponenten som et taglib (statiske metoder):
<? EngineCustomer::display($param1, $param2, $param3, ...); ?>
eller du kan lave en instance af komponenten og benytte metoderne direkte:
<? $object = new EngineCustomer($param1, $param2, $param3, ...); print $object->getHtml(); ?>
Sådan vises komponenten EngineCustomer klassen
Den fulde PHP kildekode for EngineCustomer klassen
<?php/** * @package db-customer * @see HTML_DB_CUSTOMER_CONTROLLER_PATH.'/EngineCustomer.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_CONTROLLER_PATH.'/Engine.php');require_once(HTML_DB_CUSTOMER_QUERY_PATH.'/QueryCustomer.php');require_once(HTML_DB_CUSTOMER_UTIL_PATH.'/DefaultValidatorCustomer.php');/** * The DB Customer parsing engine * This is the controller for a Customer * <code> * Usage: * $table = DATABASE_PREFIX.TABLE_NAME_CUSTOMER; * $query = new QueryCustomer($table); * $name = ENGINE_NAME_CUSTOMER; * $view = GRID_LAYOUT_VIEW_LIST; * $sort = true; * $validators = ""; * * $engine = new EngineCustomer($table, $query, $name, $view, $sort, $validators); * print $engine->getHtml(); * Or * EngineCustomer::display($table, $query, $name, $view, $sort, $validators); * </code> * @package db-customer */class EngineCustomer extends Engine { /** * Constructor * @param String $table The table to use * @param Query $query The Query Object to use * @param String $name The Engine Name to use * @param String $view The View to use * @param boolean $sort The DataReader object may be sorted * @param array $validators The validators to use */ function __construct($table='', $query='', $name='', $view='', $sort='', $validators='') { $theTable = $table != '' ? $table : DATABASE_PREFIX.TABLE_NAME_CUSTOMER; $theQuery = $query != '' ? $query : new QueryCustomer($theTable); $theName = $name != '' ? $name : ENGINE_NAME_CUSTOMER; $theView = $view != '' ? $view : GRID_LAYOUT_VIEW_CUSTOMER_LIST; $theSort = $sort != '' ? $sort : true; $theValidators = $validators != '' ? $validators : DefaultValidatorCustomer::get(); parent::__construct($theTable, $theQuery, $theName, $theView, $theSort, $theValidators); } /** * Display html * <code> * Usage: * EngineCustomer::display($table, $query, $name, $view, $sort, $validators); * </code> * @static * @param String $table The table to use * @param Query $query The Query Object to use * @param String $name The Engine Name to use * @param String $view The View to use * @param boolean $sort The DataReader object may be sorted * @param array $validators The validators to use */ public static function display($table='', $query='', $name='', $view='', $sort='', $validators='') { $html = new EngineCustomer($table, $query, $name, $view, $sort, $validators); $html->addHtml(); }}?>
Den fulde HTML kildekode for EngineCustomer klassen
<? <!-- DEBUG: EngineCustomer --> <!-- DEBUG: ViewLimit --> <!-- ViewLimit->getHtml(), (numRows:1) (rows/max:0.0025) (max:400) --> <!-- 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/EngineCustomer/index.php" title="Klik her for at Minimere ... TableHeader"><!-- DEBUG: Images --> <img src="http://finn-rasmussen.com/images/arrow-headline.gif" width="4" height="7" alt="arrow-headline.gif" /> </a> </td> <th class="baseColorHeader" valign="top" align="left">EngineCustomer (1) </th> </tr> </table> <table id="ViewCustomerListId" width="100%" class="customerListView baseBorder" border="0" cellpadding="2" cellspacing="0"> <tr> <th class="baseColorHeader" valign="top"><!-- DEBUG: Style --> <style type="text/css"> .widthHeader{width:47px}</style> <div class="widthHeader"><!-- DEBUG: ImageLink --> <!-- DEBUG: Link --> <a class="baseColorHeader" href="/source-code/db-customer/EngineCustomer/index.php?baseCOMMAND=05dc0c5f6ee78feac35b0fb4159651a0&dbTABLE=QVpkZW1vX2N1c3RvbWVyWkE" title="CRUD_VIEW_FORM_CREATE Indsæt ny"><!-- DEBUG: Images --> <img src="http://finn-rasmussen.com/images/new.gif" width="13" height="13" alt="CRUD_VIEW_FORM_CREATE Indsæt ny" class="baseColorHeader" /> </a> <!-- DEBUG: ImageLink --> <!-- DEBUG: Link --> <a class="baseColorHeader" href="#" title="CRUD_VIEW_FORM_REMOVE Slet det hele" onclick="if (confirm('Slet det hele? ()')) {location.href='/source-code/db-customer/EngineCustomer/index.php?baseCOMMAND=28d7757d7e61c9c340fc714d6077a767&dbTABLE=QVpkZW1vX2N1c3RvbWVyWkE=';}"><!-- DEBUG: Images --> <img src="http://finn-rasmussen.com/images/remove.gif" width="13" height="13" alt="CRUD_VIEW_FORM_REMOVE Slet det hele" class="baseColorHeader" /> </a> </div> </th> <th class="baseColorHeader baseNoWrap" valign="top"> <!-- Email 100 string demo_customer not_null --> <!-- DEBUG: Sortby --> <!-- Email --><a class="baseColorHeader" href="/source-code/db-customer/EngineCustomer/index.php?dbTABLE=QVpkZW1vX2N1c3RvbWVyWkE&mvcSORT_BY=asc&mvcORDER_BY=email" title="Mvcorder_by desc">Email</a> </th> <th class="baseColorHeader baseNoWrap" valign="top"> <!-- Kontakt person 100 string demo_customer not_null --> <!-- DEBUG: Sortby --> <!-- Kontakt person --><a class="baseColorHeader" href="/source-code/db-customer/EngineCustomer/index.php?dbTABLE=QVpkZW1vX2N1c3RvbWVyWkE&mvcSORT_BY=asc&mvcORDER_BY=contact_person" title="Mvcorder_by desc">Kontakt person</a> </th> <th class="baseColorHeader baseNoWrap" valign="top"> <!-- Firmanavn 100 string demo_customer --> <!-- DEBUG: Sortby --> <!-- Firmanavn --><a class="baseColorHeader" href="/source-code/db-customer/EngineCustomer/index.php?dbTABLE=QVpkZW1vX2N1c3RvbWVyWkE&mvcSORT_BY=asc&mvcORDER_BY=company_name" title="Mvcorder_by desc">Firmanavn</a> </th> <th class="baseColorHeader baseNoWrap" valign="top"> <!-- Adresse 255 string demo_customer not_null --> <!-- DEBUG: Sortby --> <!-- Adresse --><a class="baseColorHeader" href="/source-code/db-customer/EngineCustomer/index.php?dbTABLE=QVpkZW1vX2N1c3RvbWVyWkE&mvcSORT_BY=asc&mvcORDER_BY=address" title="Mvcorder_by desc">Adresse</a> </th> <th class="baseColorHeader baseNoWrap baseAlignRight" valign="top" align="right"> <!-- Postnr 4 int demo_customer not_null --> <!-- DEBUG: Sortby --> <!-- Postnr --><a class="baseColorHeader" href="/source-code/db-customer/EngineCustomer/index.php?dbTABLE=QVpkZW1vX2N1c3RvbWVyWkE&mvcSORT_BY=asc&mvcORDER_BY=zip" title="Mvcorder_by desc">Postnr</a> </th> <th class="baseColorHeader baseNoWrap" valign="top"> <!-- By 32 string demo_customer not_null --> <!-- DEBUG: Sortby --> <!-- By --><a class="baseColorHeader" href="/source-code/db-customer/EngineCustomer/index.php?dbTABLE=QVpkZW1vX2N1c3RvbWVyWkE&mvcSORT_BY=asc&mvcORDER_BY=city" title="Mvcorder_by desc">By</a> </th> <th class="baseColorHeader baseNoWrap" valign="top"> <!-- Privat telefon 13 string demo_customer --> <!-- DEBUG: Sortby --> <!-- Privat telefon --><a class="baseColorHeader" href="/source-code/db-customer/EngineCustomer/index.php?dbTABLE=QVpkZW1vX2N1c3RvbWVyWkE&mvcSORT_BY=asc&mvcORDER_BY=private_phone" title="Mvcorder_by desc">Privat telefon</a> </th> <th class="baseColorHeader baseNoWrap" valign="top"> <!-- Mobil telefon 13 string demo_customer --> <!-- DEBUG: Sortby --> <!-- Mobil telefon --><a class="baseColorHeader" href="/source-code/db-customer/EngineCustomer/index.php?dbTABLE=QVpkZW1vX2N1c3RvbWVyWkE&mvcSORT_BY=asc&mvcORDER_BY=mobile_phone" title="Mvcorder_by desc">Mobil telefon</a> </th> <th class="baseColorHeader baseNoWrap" valign="top"> <!-- Firma telefon 13 string demo_customer --> <!-- DEBUG: Sortby --> <!-- Firma telefon --><a class="baseColorHeader" href="/source-code/db-customer/EngineCustomer/index.php?dbTABLE=QVpkZW1vX2N1c3RvbWVyWkE&mvcSORT_BY=asc&mvcORDER_BY=business_phone" title="Mvcorder_by desc">Firma telefon</a> </th> <th class="baseColorHeader baseNoWrap" valign="top"> <!-- EAN 13 string demo_customer --> <!-- DEBUG: Sortby --> <!-- EAN --><a class="baseColorHeader" href="/source-code/db-customer/EngineCustomer/index.php?dbTABLE=QVpkZW1vX2N1c3RvbWVyWkE&mvcSORT_BY=asc&mvcORDER_BY=ean" title="Mvcorder_by desc">EAN</a> </th> </tr> <tr> <td class="baseColorDark" valign="top"><!-- DEBUG: ImageLink --> <!-- DEBUG: Link --> <a class="baseColorDark" href="/source-code/db-customer/EngineCustomer/index.php?baseCOMMAND=dbec4b60abeb38e24fa03fc93c627b3b&utilID=QVoxWkE&dbTABLE=QVpkZW1vX2N1c3RvbWVyWkE" title="CRUD_VIEW_FORM_DETAIL Vis"><!-- DEBUG: Images --> <img src="http://finn-rasmussen.com/images/detail.gif" width="13" height="13" alt="CRUD_VIEW_FORM_DETAIL Vis" class="baseColorDark" /> </a> <!-- DEBUG: ImageLink --> <!-- DEBUG: Link --> <a class="baseColorDark" href="/source-code/db-customer/EngineCustomer/index.php?baseCOMMAND=2858fe72529afe98e6a89b2a89175f47&utilID=QVoxWkE&dbTABLE=QVpkZW1vX2N1c3RvbWVyWkE" title="CRUD_VIEW_FORM_UPDATE Opdater information"><!-- DEBUG: Images --> <img src="http://finn-rasmussen.com/images/update.gif" width="13" height="13" alt="CRUD_VIEW_FORM_UPDATE Opdater information" class="baseColorDark" /> </a> <!-- DEBUG: ImageLink --> <!-- DEBUG: Link --> <a class="baseColorDark" href="/source-code/db-customer/EngineCustomer/index.php?baseCOMMAND=6b65666eed0eabec518783233ed1465b&utilID=QVoxWkE&dbTABLE=QVpkZW1vX2N1c3RvbWVyWkE" title="CRUD_VIEW_FORM_DELETE Slet denne"><!-- DEBUG: Images --> <img src="http://finn-rasmussen.com/images/delete.gif" width="13" height="13" alt="CRUD_VIEW_FORM_DELETE Slet denne" class="baseColorDark" /> </a> </td> <td class="baseColorDark" valign="top">does_NOT_WORK@finnrasmussen.com </td> <td class="baseColorDark" valign="top">Finn Rasmussen </td> <td class="baseColorDark" valign="top">HvepseEksperten.dk </td> <td class="baseColorDark" valign="top">do not edit </td> <td class="baseColorDark baseAlignRight" valign="top">3400 </td> <td class="baseColorDark" valign="top">Hillerød </td> <td class="baseColorDark" valign="top">48246037 </td> <td class="baseColorDark" valign="top">40506069 </td> <td class="baseColorDark" valign="top">48246030 </td> <td class="baseColorDark" valign="top">9876543210123 </td> </tr> </table> <!-- DEBUG: ViewLimit --> <!-- ViewLimit->getHtml(), (numRows:1) (rows/max:0.0025) (max:400) --> ?>
Her er 'klasse metoderne' for EngineCustomer klassen:
Her er 'objekt variable' for EngineCustomer klassen: