Sådan benyttes komponenten MenuRight klassen
Først skal du inkludere den fil der beskriver komponenten, som en klasse fil
<? require_once(HTML_PACKAGE_PATH.'/MenuRight.php'); ?>
Dernæst kan du enten benytte komponenten som et taglib (statiske metoder):
<? MenuRight::display($param1, $param2, $param3, ...); ?>
eller du kan lave en instance af komponenten og benytte metoderne direkte:
<? $object = new MenuRight($param1, $param2, $param3, ...); print $object->getHtml(); ?>
Sådan vises komponenten MenuRight klassen
Den fulde PHP kildekode for MenuRight klassen
<?php/** * @package menu * @see HTML_MENU_PAGE_PATH.'/MenuRight.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_MENU_PAGE_PATH.'/MenuVertical.php');/** * Generates a Menu Right element * <code> * +----------------------------+---------+ * | | menu1 * | | menu2 * | | : * +----------------------------+---------+ * Usage: * $menu = new MenuRight($datareader, $text, $width, $class, $border, * $cellpadding, $cellspacing, $summary, $caption, $layout); * print $menu->getHtml(); * Or * MenuRight:display($datareader, $text, $width, $class, $border, * $cellpadding, $cellspacing, $summary, $caption, $layout); * </code> * @package menu */class MenuRight extends MenuVertical { /** * Constructor * @param DataReader / array $datareader The Data Reader object OR an array * @param String $text The text header for the table * @param String $width The Width for the table * @param String $class The CSS Class name to use * @param String $border The Border * @param String $cellpadding The CellSpacing * @param String $cellspacing The CellPadding * @param String $summary The Summary * @param String $caption The Caption * @param String $layout The layout to use */ function __construct($datareader=null, $text='', $width='', $class='', $border='', $cellpadding='', $cellspacing='', $summary='', $caption='', $layout='') { $theText = $text != ''?$text :MENU_RIGHT_TEXT; $theWidth = $width != ''?$width:MENU_RIGHT_VIEW_WIDTH; $theClass = $class != ''?$class:MENU_RIGHT_VIEW_CLASS; $theBorder = $border != ''?$border:MENU_RIGHT_VIEW_BORDER; $theCellpadding = $cellpadding != ''?$cellpadding:MENU_RIGHT_VIEW_CELLPADDING; $theCellspacing = $cellspacing != ''?$cellspacing:MENU_RIGHT_VIEW_CELLSPACING; $theLayout = $layout != ''?$layout:MENU_RIGHT_VIEW_LAYOUT; parent::__construct($datareader, $theText, $theWidth, $theClass, $theBorder, $theCellpadding, $theCellspacing, $summary, $caption, $theLayout); } /** * Get the CSS class Name for this component * @return String The CSS class name */ function getCssClass() { return CSS_MENU_RIGHT; } /** * Toogle the request parameters which will minimize or maximize this component * @return array The array of key=>value pair */ function getMinimize() { return $this->getToogle(REQUEST_LINK_SHOW, LINK_SHOW, LINK_SHOW_MENU_RIGHT); } /** * Get the html for the right menu links * @return String The html */ function getHtml() { $html = $this->html; if (LINK_SHOW & LINK_SHOW_MENU_RIGHT && HTTP_USER_AGENT!=HTTP_USER_AGENT_P900) { if (CACHE_MENU && $this->getCacheFileName(CACHE_MENU_PATH) != '' && file_exists($this->getCacheFileName(CACHE_MENU_PATH))) { $html .= $this->content($this->getCacheFileName(CACHE_MENU_PATH)); } else { $html .= "<!-- MenuRight -->\r\n"; $html .= $this->getColumns(); if (CACHE_MENU) { $this->save($html, CACHE_MENU_PATH); } } } else { $html .= $this->getMaximize(); } return $html; } /** * Display html * <code> * Usage: * MenuRight::display($datareader, $text, $width, $class, $border, * $cellpadding, $cellspacing, $summary, $caption, $layout); * </code> * @static * @param DataReader / array $datareader The Data Reader object OR an array * @param String $text The text header for the table * @param String $width The Width for the table * @param String $class The CSS Class name to use * @param String $border The Border * @param String $cellpadding The CellSpacing * @param String $cellspacing The CellPadding * @param String $summary The Summary * @param String $caption The Caption * @param String $layout The layout to use */ public static function display($datareader=null, $text='', $width='', $class='', $border='', $cellpadding='', $cellspacing='', $summary='', $caption='', $layout='') { $html = new MenuRight($datareader, $text, $width, $class, $border, $cellpadding, $cellspacing, $summary, $caption, $layout); $html->addHtml(); }}?>
Den fulde HTML kildekode for MenuRight klassen
<? <!-- DEBUG: MenuRight --> <!-- MenuRight --> <!-- DEBUG: TableHeader --> <table width="200" class="baseBorder" border="0" cellpadding="2" cellspacing="0"> <tr> <td class="baseArrowHeader" valign="middle"><!-- DEBUG: Link --> <a class="baseLinkColor" href="/source-code/menu/MenuRight/index.php" title="Klik her for at Minimere ... TableHeader"><!-- DEBUG: Images --> <img src="http://expert-guide.com/images/arrow-headline.gif" width="4" height="7" alt="arrow-headline.gif" /> </a> </td> <th class="baseColorHeader" valign="top" align="left">Artikler </th> </tr> </table> <table id="MenuRightId" width="200" class="baseBorder" border="0" cellpadding="0" cellspacing="0"> <tr> <td class="menuRight" valign="top">Der er ikke fundet noget </td> </tr> </table> ?>
Her er 'klasse metoderne' for MenuRight klassen:
Her er 'objekt variable' for MenuRight klassen: