Sådan benyttes komponenten ControlPassword klassen
Først skal du inkludere den fil der beskriver komponenten, som en klasse fil
<? require_once(HTML_PACKAGE_PATH.'/ControlPassword.php'); ?>
Dernæst kan du enten benytte komponenten som et taglib (statiske metoder):
<? ControlPassword::display($param1, $param2, $param3, ...); ?>
eller du kan lave en instance af komponenten og benytte metoderne direkte:
<? $object = new ControlPassword($param1, $param2, $param3, ...); print $object->getHtml(); ?>
Sådan vises komponenten ControlPassword klassen
Den fulde PHP kildekode for ControlPassword klassen
<?php/** * @package form-elements * @filesource * @see HTML_FORM_ELEMENTS_PAGE_PATH.'/ControlPassword.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_FORM_ELEMENTS_PAGE_PATH.'/ControlCommon.php');/** * Generates a a complete plug-n-play Password control * for a form. Ready to use * The validor must check for the following * - Not empty, which means is required * - in range, min,max number of characters * <code> * Usage: * $label = new Label($text, $for, $accesskey, $class); * $control = new Password($name, $value, $class, $size, $maxlength, $disabled, $readonly, $onclick, $title, $tabindex, $accesskey); * * $element = new ControlPassword($label, $control); * print $element->getHtml(); * Or * ControlPassword::display($label, $control); * </code> * @package form-elements */class ControlPassword extends ControlCommon { /** * Constructor * @param Label $label The Label object * @param Password $control The Control object */ function __construct($label='', $control='') { parent::__construct($label, $control); } /** * Check the control if is valid data and updates the ValidatorErrorList * <code> * Usage: * $element = new ControlPassword(); * $rc = $element->isValid(); * </code> * @return boolean True if the data is valid else false */ function isValid() { $this->isvalid &= $this->isRequired(); $this->isvalid &= $this->inRange(); return $this->isvalid; } /** * Display html * <code> * Usage: * $label = new Label($text, $for, $accesskey, $class); * $control = new Password($name, $value, $class, $size, $maxlength, $disabled, $readonly, $onclick, $title, $tabindex, $accesskey); * ControlPassword::display($label, $control); * </code> * @static * @param Label $label The Label object * @param Password $control The Password Control object */ public static function display($label='', $control='') { $html = new ControlPassword($label, $control); $html->addHtml(); }}?>
Den fulde HTML kildekode for ControlPassword klassen
<? <!-- DEBUG: ControlPassword --> <!-- DEBUG: Label --> <label for="Label1" accesskey="T" title="Accelerator key, use (Alt + T)"> <b><span class="baseColorDark">T</span>est</b> (Alt + T) </label><br /> <!-- DEBUG: Password --> <input type="password" name="Test" id="Label1" class="formXLARGE baseBorder baseBody" maxlength="10" value="" tabindex="1" /><br /> ?>
Her er 'klasse metoderne' for ControlPassword klassen:
Her er 'objekt variable' for ControlPassword klassen: