Sådan benyttes komponenten ControlFileupload klassen
Først skal du inkludere den fil der beskriver komponenten, som en klasse fil
<? require_once(HTML_PACKAGE_PATH.'/ControlFileupload.php'); ?>
Dernæst kan du enten benytte komponenten som et taglib (statiske metoder):
<? ControlFileupload::display($param1, $param2, $param3, ...); ?>
eller du kan lave en instance af komponenten og benytte metoderne direkte:
<? $object = new ControlFileupload($param1, $param2, $param3, ...); print $object->getHtml(); ?>
Sådan vises komponenten ControlFileupload klassen
Den fulde PHP kildekode for ControlFileupload klassen
<?php/** * @package form-elements * @filesource * @see HTML_FORM_ELEMENTS_PAGE_PATH.'/ControlFileupload.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 Fileupload control * for a form. Ready to use. * NOTE: The form must be post and the right enctype * The validor must check for the following * - n.a. * <code> * Usage: * $label = new Label($text, $for, $accesskey, $class); * $control = new Fileupload($name, $class, $size, $maxlength, $disabled, $readonly, $onclick, $title, $tabindex, $accesskey, $accept); * $element = new ControlFileupload($label, $control); * print $element->getHtml(); * Or * ControlFileupload::display($label, $control); * </code> * @package form-elements */class ControlFileupload extends ControlCommon { /** * Constructor * @param Label $label The Label object * @param Fileupload $control The Fileupload 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 ControlFileupload(); * $rc = $element->isValid(); * </code> * @return boolean True if the data is valid else false */ function isValid() { return $this->isvalid; } /** * Display html * <code> * Usage: * $label = new Label($text, $for, $accesskey, $class); * $control = new Fileupload($name, $class, $size, $maxlength, $disabled, $readonly, $onclick, $title, $tabindex, $accesskey, $accept); * ControlFileupload::display($label, $control); * </code> * @static * @param Label $label The Label object * @param Fileupload $control The Control object */ public static function display($label='', $control='') { $html = new ControlFileupload($label, $control); $html->addHtml(); }}?>
Den fulde HTML kildekode for ControlFileupload klassen
<? <!-- DEBUG: ControlFileupload --> <!-- 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: Text --> <input type="text" name="Test" id="Label1" class="formXLARGE baseBorder baseBody" value="" tabindex="1" /><br /> ?>
Her er 'klasse metoderne' for ControlFileupload klassen:
Her er 'objekt variable' for ControlFileupload klassen: