Sådan benyttes komponenten ViewLogin klassen
Først skal du inkludere den fil der beskriver komponenten, som en klasse fil
<? require_once(HTML_PACKAGE_PATH.'/ViewLogin.php'); ?>
Dernæst kan du enten benytte komponenten som et taglib (statiske metoder):
<? ViewLogin::display($param1, $param2, $param3, ...); ?>
eller du kan lave en instance af komponenten og benytte metoderne direkte:
<? $object = new ViewLogin($param1, $param2, $param3, ...); print $object->getHtml(); ?>
Sådan vises komponenten ViewLogin klassen
Den fulde PHP kildekode for ViewLogin klassen
<?php/** * @package db-login * @see HTML_DB_LOGIN_VIEW_PATH.'/ViewLogin.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.'/ViewForm.php');require_once(HTML_UTIL_COMPONENT_PATH.'/Server.php');if (defined('HTML_LOG_UTIL_PATH')) { require_once(HTML_LOG_UTIL_PATH.'/Log.php');}/** * Generates the html for a View Login Form * <code> * Usage: * $view = new ViewLogin($datareader, $text, $width, $class, $border, $cellpadding, $cellspacing, $summary, $caption, $method); * print $view->getHtml(); * Or * ViewLogin::display($datareader, $text, $width, $class, $border, $cellpadding, $cellspacing, $summary, $caption, $method); * * Generates a complete View Form interface * +---------------+ * | Text header | * +---------------- * | Label | * | Text field | * +--------------- * | Buttons | * +---------------+ * </code> * @package db-login */class ViewLogin extends ViewForm { /** * 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 $method The form submission metod [ post | get ] default is 'post' */ function __construct($datareader=null, $text='', $width='', $class='', $border='', $cellpadding='', $cellspacing='', $summary='', $caption='', $method='') { $theText = $text != '' ? $text : @TEXT_TABLE_LOGIN; // Global table characteristics $theWidth = $width != '' ? $width : FORM_VIEW_WIDTH; $theClass = $class != '' ? $class : FORM_VIEW_CLASS; $theBorder = $border != '' ? $border : FORM_VIEW_BORDER; $theCellPadding = $cellpadding != '' ? $cellpadding : FORM_VIEW_CELLPADDING; $theCellSpacing = $cellspacing != '' ? $cellspacing : FORM_VIEW_CELLSPACING; parent::__construct($datareader, $theText, $theWidth, $theClass, $theBorder, $theCellPadding, $theCellSpacing, $summary, $caption, $method); } /** * You may override this methode in order to create your own hiddens * If no request parameters are supplied, then popup the login form * Return the Hiddens as an object * @abstract * @param String $default The default value to use for yhe REQUEST_COMMAND * @return Object The Hiddens as an Object */ function newHiddens($default='') { $keyValue = array(); $keyValue[REQUEST_COMMAND] = Request::get(REQUEST_COMMAND, VIEW_LOGIN_FORM, __FILE__, __LINE__, true); $keyValue[REQUEST_REFERER] = Server::getReferer(); return new Hiddens($keyValue, VIEW_LOGIN_FORM, $this->getClassName()); // VIEW_LOGIN_FORM } /** * Display html * <code> * Usage: * ViewLogin::display($datareader, $text, $width, $class, $border, $cellpadding, $cellspacing, $summary, $caption, $method); * </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 $method The form submission metod [ post | get ] default is 'post' */ public static function display($datareader=null, $text='', $width='', $class='', $border='', $cellpadding='', $cellspacing='', $summary='', $caption='', $method='') { $html = new ViewLogin($datareader, $text, $width, $class, $border, $cellpadding, $cellspacing, $summary, $caption, $method); $html->addHtml(); }}?>
Den fulde HTML kildekode for ViewLogin klassen
<? <!-- DEBUG: ViewLogin --> <!-- DEBUG: TableHeader --> <table width="323" class="formView baseBorder" border="0" cellpadding="2" cellspacing="0"> <tr> <td class="baseArrowHeader" valign="middle"><!-- DEBUG: Link --> <a class="baseLinkColor" href="/source-code/db-login/ViewLogin/index.php" title="Klik her for at Minimere ... TableHeader"><!-- DEBUG: Images --> <img src="http://humlebier.info/images/arrow-headline.gif" width="4" height="7" alt="arrow-headline.gif" /> </a> </td> <th class="baseColorHeader" valign="top" align="left">Login (1) </th> </tr> </table> <table id="ViewLoginId" width="323" class="formView baseBorder" border="0" cellpadding="10" cellspacing="0"> <tr> <td valign="top"><!-- DEBUG: Script --> <script type="text/javascript"> //<![CDATA[ function onSubmitViewLogin(theForm) { var isValid = true; var messages = ''; var focusMe = ''; if (!isValid) { var msg = "Udfyld felterne:\r\n"; msg += '===================\r\n'; msg += messages; alert(msg); } else { var submitId = document.getElementById('submitButtonViewLoginId'); submitId.value = ' ...'; submitId.disabled = true; submitId.className = 'formButton baseBorder baseBody formXXSmall formButtonBee'; } if (!isValid && focusMe !== '') { theForm[focusMe].focus(); } return isValid; } //]]> </script> <!-- DEBUG: Form --> <form action="/source-code/db-login/ViewLogin/index.php" method="post" name="ViewLogin" id="Form3" onsubmit="return onSubmitViewLogin(this);"> <div class="baseAlignRight" align="right">No help</div> <!-- DEBUG: Hiddens --> <!-- Hiddens ViewLogin --> <!-- DEBUG: Hidden --> <input type="hidden" name="baseCOMMAND" value="85d3993b942fa1ea46c94653aac9400f" title="85d3993b942fa1ea46c94653aac9400f (ViewLogin)" /> <!-- --> <!-- DEBUG: Label --> <label for="Label1" accesskey="B" title="Accelerator key, use (Alt + B)"> <b><span class="baseColorDark">B</span>rugernavn eller Nr.</b> (Alt + B) </label><br /> <!-- DEBUG: Text --> <input type="text" id="Label1" class="formXLARGE baseBorder baseBody" value="" title="



" tabindex="1" /><br /> <!-- --> <!-- DEBUG: Label --> <label for="Label2" accesskey="A" title="Accelerator key, use (Alt + A)"> <b><span class="baseColorDark">A</span>dgangskode</b> (Alt + A) </label><br /> <!-- DEBUG: Text --> <input type="text" id="Label2" class="formXLARGE baseBorder baseBody" value="" title="



" tabindex="2" /><br /> <!-- DEBUG: Buttons --> <p><div class="baseAlignCenter"> <!-- BUTTON_LOGIN_TEXT --> <!-- DEBUG: SubmitButton --> <input type="submit" id="submitButtonViewLoginId" class="formButton baseBorder baseBody formXXSmall" value="Login" title="Login (Alt + L)" tabindex="3" accesskey="L" /> </div> </p> </form> <!-- DEBUG: Focus --> <script type="text/javascript"> //<![CDATA[ function setFocus_ViewLoginusername() { if (typeof document.ViewLogin == 'object') { if (typeof document.ViewLogin.username == 'object') { document.ViewLogin.username.focus(); document.ViewLogin.username.select(); } } } if (typeof focusIsDefined == 'undefined') { function onload1Body() { var onloadCurrent = window.onload; if (typeof onloadCurrent !== 'function') { window.onload = setFocus_ViewLoginusername; } else { window.onload = function() { onloadCurrent(); setFocus_ViewLoginusername(); } } } onload1Body(); focusIsDefined = true; } //]]> </script> </td> </tr> </table> ?>
Her er 'klasse metoderne' for ViewLogin klassen:
Her er 'objekt variable' for ViewLogin klassen: