Sådan benyttes komponenten Logo klassen
Først skal du inkludere den fil der beskriver komponenten, som en klasse fil
<? require_once(HTML_PACKAGE_PATH.'/Logo.php'); ?>
Dernæst kan du enten benytte komponenten som et taglib (statiske metoder):
<? Logo::display($param1, $param2, $param3, ...); ?>
eller du kan lave en instance af komponenten og benytte metoderne direkte:
<? $object = new Logo($param1, $param2, $param3, ...); print $object->getHtml(); ?>
Sådan vises komponenten Logo klassen
Den fulde PHP kildekode for Logo klassen
<?php/** * @package base * @see HTML_LAYOUT_PAGE_PATH.'/Logo.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_UTIL_PATH.'/Links.php');require_once(HTML_BASE_UTIL_PATH.'/Div.php');/** * Generates the hidden Info as html * <code> * Usage: * $html = new Logo($text, $class, $align, $id); * print $html->getHtml(); * Or: * Logo::display($text, $class, $align, $id); * </code> * @package base */class Logo extends Div { /** * Constructor * @param String $text The text for the div or an object * @param String $class The css class of the div * @param String $align The align attribute * @param String $id The ID attribute */ function __construct($text='', $class='', $align='', $id='') { parent::__construct($text, $class, $align, $id); } /** * Returns the html object for the Info * @return Object the link and logo as an object */ function newContent() { $text = ""; $href = ""; $class = CSS_CANVAS; $object = new Links(LINK_LOGO, $text, $href, $class); $width = ""; $height = ""; $alt = ""; $object->add(new Images(IMAGE_LOGO, $width, $height, $alt, $class)); return $object; } /** * Returns the html for the Info * @return String the complete html */ function getHtml() { $html = ''; if (LAYOUT_SHOW & LAYOUT_SHOW_LOGO && HTTP_USER_AGENT!=HTTP_USER_AGENT_P900) { if (defined('CREATE_RUNTIME_KERNEL') && CREATE_RUNTIME_KERNEL) { $html .= '<?php'.ucfirst($this->getClassName()).'::display()?>'; } else { if (defined('LOGIN_USERNAME') && LOGIN_USERNAME==='' && CACHE_LAYOUT && $this->getCacheFileName(CACHE_LAYOUT_PATH) != '' && file_exists($this->getCacheFileName(CACHE_LAYOUT_PATH))) { $html .= $this->content($this->getCacheFileName(CACHE_LAYOUT_PATH)); } else { $this->add($this->newContent()); $html .= $this->getStart(); $html .= $this->getEnd(); if (CACHE_LAYOUT && defined('LOGIN_USERNAME') && LOGIN_USERNAME==='') { $this->save($html, CACHE_LAYOUT_PATH); } } } } return $html; } /** * Display html * <code> * Usage: * Logo::display($text, $class, $align, $id); * </code> * @static * @param String $text The text for the div or an object * @param String $class The css class of the div * @param String $align The align attribute * @param String $id The ID attribute */ public static function display($text='', $class='', $align='', $id='') { $html = new Logo($text, $class, $align, $id); $html->addHtml(); }}?>
Den fulde HTML kildekode for Logo klassen
<? <div><!-- DEBUG: Links --> <a class="baseCanvas" href="/source-code/layout/Logo/index.php"><!-- DEBUG: Images --> <img src="/myphp-1.11/myphp-1.11-netbank.eksperter.dk/html/images/netbank.eksperter.dk-logo.gif" alt="netbank.eksperter.dk-logo.gif" class="baseCanvas" /> </a> </div> ?>
Her er 'klasse metoderne' for Logo klassen:
Her er 'objekt variable' for Logo klassen: