Sådan benyttes komponenten Icons klassen
Først skal du inkludere den fil der beskriver komponenten, som en klasse fil
<? require_once(HTML_PACKAGE_PATH.'/Icons.php'); ?>
Dernæst kan du enten benytte komponenten som et taglib (statiske metoder):
<? Icons::display($param1, $param2, $param3, ...); ?>
eller du kan lave en instance af komponenten og benytte metoderne direkte:
<? $object = new Icons($param1, $param2, $param3, ...); print $object->getHtml(); ?>
Sådan vises komponenten Icons klassen
Print Siden
Søg
Email
Retur
Den fulde PHP kildekode for Icons klassen
<?php/** * @package menu * @see HTML_MENU_PAGE_PATH.'/Icons.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.'/Links.php');require_once(HTML_BASE_UTIL_PATH.'/Images.php');if (defined('HTML_LOG_UTIL_PATH')) { require_once(HTML_LOG_UTIL_PATH.'/Log.php');}/** * Generates the Icons to show * <code> * Usage: * $icons = new Icons($class, $layout); * print $icons->getHtml(); * Or * Icons::display($class, $layout); * </code> * @package menu */class Icons extends Html { protected $class = ''; protected $layout = ''; /** * Constructor * @param String $class The CSS Class name to use * @param String $layout The html layout <p> or <br /> or space */ function __construct($class='', $layout='') { parent::__construct(); $this->class = $class != '' ? $class : CSS_MENU_RIGHT; $this->layout = $layout != '' ? $layout : ICONS_LAYOUT_PARAGRAPH; } /** * Builds the html for the link / image to show * @param String $linkid The id of the Link * @param String $imageid The id of the Image * @return String The html */ function getLinkImage($linkid, $imageid) { $html = ''; $class = "$this->class"; $aux = $this->layout === ICONS_LAYOUT_VERTICAL ? LINK_LAYOUT_BR : ''; $text = ""; $href = ""; $title = ""; $link = new Links($linkid, $text, $href, $class, $title, $aux); $width = ""; $height = ""; $alt = ""; $link->add(new Images($imageid, $width, $height, $alt, $class)); switch ($this->layout) { case ICONS_LAYOUT_VERTICAL: $html .= "<br />\r\n"; // Intentionally fall through case ICONS_LAYOUT_HORIZONTAL: $html .= ' '.$link->getHtml().' '; break; case ICONS_LAYOUT_PARAGRAPH: $html .= '<p class="'.$class.'">'.$link->getHtml()."</p>\r\n"; break; default: $msg = $this->getClassName().'getLinkImage($link, $image) Unknown layout type found, layout='.$this->layout; if (defined('HTML_LOG_UTIL_PATH')) { Log::fatal($msg, __FILE__, __LINE__); $this->getMsg(LOG_LEVEL_FATAL, $msg); } else { die('File: '.__FILE__."<br />\r\nLine: ".__LINE__."<br />\r\n".$msg); } break; } return $html; } /** * Builds the html for the icons to show * @return String The html */ function getHtml() { $html = $this->html; if (HTTP_USER_AGENT != HTTP_USER_AGENT_P900) { if (LINK_SHOW & LINK_SHOW_ICONS) { $html .= $this->getLinkImage(LINK_PRINT , IMAGE_PRINT); $html .= $this->getLinkImage(LINK_FIND , IMAGE_FIND); $html .= $this->getLinkImage(LINK_MAIL , IMAGE_MAIL); $html .= $this->getLinkImage(LINK_RETURN, IMAGE_RETURN); $html .= "<hr />\r\n"; } else { if (defined('DEBUG_LEVEL_SHOW_INFO') && DEBUG_LEVEL & DEBUG_LEVEL_SHOW_INFO) { $html .= "<!-- ".$this->getClassName()." disabled -->\r\n"; } } } else { if (defined('DEBUG_LEVEL_SHOW_INFO') && DEBUG_LEVEL & DEBUG_LEVEL_SHOW_INFO) { $html .= "<!-- P900 -->\r\n"; } } return $html; } /** * Display html * <code> * Usage: * Icons::display($class, $layout); * </code> * @static * @param String $class The CSS Class name to use * @param String $layout The html layout <p> or */ public static function display($class='', $layout='') { $html = new Icons($class, $layout); $html->addHtml(); }}?>
Den fulde HTML kildekode for Icons klassen
<? <!-- DEBUG: Icons --> <p class="menuRight"><!-- DEBUG: Links --> <!-- Print Siden --><a class="menuRight" href="?basePRINTER=6793442c5639c751f555b2c9852f263c&componentSHOW=1&layoutLAYOUT_SHOW=129&menuLINK_SHOW=1&tabShow=1&cmsSHOW=769&tableSKELETON_SHOW=4&googleadsSHOW=1" title="Printer Venlig Side"><!-- DEBUG: Images --> <img src="http://kakerlakker.info/images/print.gif" width="32" height="24" alt="Printer Venlig Side" class="menuRight" /> Print Siden</a></p> <p class="menuRight"><!-- DEBUG: Links --> <!-- Søg --><a class="menuRight" href="/search/" title="Søg efter ..."><!-- DEBUG: Images --> <img src="http://kakerlakker.info/images/find.gif" width="32" height="32" alt="Søg efter ..." class="menuRight" /> Søg</a></p> <p class="menuRight"><!-- DEBUG: Links --> <!-- Email --><a class="menuRight" href="http://www.hvepseeksperten.dk/FormMail/" title="Send email"><!-- DEBUG: Images --> <img src="http://kakerlakker.info/images/mail.gif" width="32" height="32" alt="Kontakt via email
" class="menuRight" /> Email</a></p> <p class="menuRight"><!-- DEBUG: Links --> <!-- Retur --><a class="menuRight" href="/" title="Retur til forrige side"><!-- DEBUG: Images --> <img src="http://kakerlakker.info/images/return.gif" width="24" height="24" alt="Gå tilbage" class="menuRight" /> Retur</a></p> <hr /> ?>
Her er 'klasse metoderne' for Icons klassen:
Her er 'objekt variable' for Icons klassen: