Sådan benyttes komponenten EmailLink klassen
Først skal du inkludere den fil der beskriver komponenten, som en klasse fil
<? require_once(HTML_PACKAGE_PATH.'/EmailLink.php'); ?>
Dernæst kan du enten benytte komponenten som et taglib (statiske metoder):
<? EmailLink::display($param1, $param2, $param3, ...); ?>
eller du kan lave en instance af komponenten og benytte metoderne direkte:
<? $object = new EmailLink($param1, $param2, $param3, ...); print $object->getHtml(); ?>
Sådan vises komponenten EmailLink klassen
Den fulde PHP kildekode for EmailLink klassen
<?php/** * @package base * @see HTML_BASE_UTIL_PATH.'/EmailLink.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_BASE_COMMON_PATH.'/Html.php');require_once(HTML_BASE_UTIL_PATH.'/Link.php');/** * Returns a complete Email Link as HTML * The link may be terminated by a <br /> or surronded by <li> tags * as specified by the $aux parameter * * <code> * <a href="mailto:$href" title="$title" class="$class">$text</a> * Usage: * $text = "text to show"; * $href = "where@2mail.to"; * $class = "cssClassName"; * $title = "title to show" * $aux = LINK_LAYOUT_LI; * $target = "blank"; // Opens in a new window * $name = "TheNameOfLocalHrefs#"; * $tabindex = "3"; * $onclick = "alert('Hello')"; * $accesskey = "A"; * * $link = new EmailLink($text, $href, $class, $title, $aux, $target, $name, $tabindex, $onclick, $accesskey); * print $link->getHtml(); * Or * EmailLink::display($text, $href, $class, $title, $aux, $target, $name, $tabindex, $onclick, $accesskey); * </code> * @package base */class EmailLink extends Link { /** * Constructor * @param String $text The text for the link * @param String $href The url for the link * @param String $class The class of the link * @param String $title The tool tip of the link * @param String $aux Add 'br' or 'li' html tags, if required * @param String $target The target for the link I.e. _BLANK * @param String $name The name for the link * @param String $tabindex The name of the tab index * @param String $onclick The javascript onclick function name * @param String $accesskey The access key */ function __construct($text='', $href='', $class='', $title='', $aux='', $target='', $name='', $tabindex='', $onclick='', $accesskey='') { $mailto = 'mailto:'; $strHttp = 'http:/'.'/'; $strHttps = 'https:/'.'/'; if (strpos($href, $strHttp) !==false || strpos($href, $strHttps) !== false) { $mailto = ''; } if ($text == "") { $text = $href; } parent::__construct($text, $mailto.$href, $class, $title, $aux, $target, $name, $tabindex, $onclick, $accesskey); } /** * Display an email link * <code> * Usage: * EmailLink::display($text, $href, $class, $title, $aux, $target, $name, $tabindex, $onclick, $accesskey); * </code> * @static * @param String $text The text for the link * @param String $href The url for the link * @param String $class The css class of the link * @param String $title The tool tip of the link * @param String $aux Add 'br' or 'li' html tags, if required * @param String $target The target for the link. I.e. _BLANK * @param String $name The name for the link * @param String $tabindex The name of the tab index * @param String $onclick The javascript onclick function name * @param String $accesskey The access key */ public static function display($text='', $href='', $class='', $title='', $aux='', $target='', $name='', $tabindex='', $onclick='', $accesskey='') { $html = new EmailLink($text, $href, $class, $title, $aux, $target, $name, $tabindex, $onclick, $accesskey); $html->addHtml(); }}?>
Den fulde HTML kildekode for EmailLink klassen
<? <!-- DEBUG: EmailLink --> <!-- Report spam --><a class="baseLinkColor" href="mailto:int@spamklage.dk" title="Report spam">Report spam</a> ?>
Her er 'klasse metoderne' for EmailLink klassen:
Her er 'objekt variable' for EmailLink klassen: