Sådan benyttes komponenten MenuFisheye klassen
Først skal du inkludere den fil der beskriver komponenten, som en klasse fil
<? require_once(HTML_PACKAGE_PATH.'/MenuFisheye.php'); ?>
Dernæst kan du enten benytte komponenten som et taglib (statiske metoder):
<? MenuFisheye::display($param1, $param2, $param3, ...); ?>
eller du kan lave en instance af komponenten og benytte metoderne direkte:
<? $object = new MenuFisheye($param1, $param2, $param3, ...); print $object->getHtml(); ?>
Sådan vises komponenten MenuFisheye klassen
Den fulde PHP kildekode for MenuFisheye klassen
<?php/** * @package menu-fisheye * @see HTML_MENU_FISHEYE_PAGE_PATH.'/MenuFisheye.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_DTO_UTIL_PATH.'/HelperDataReader.php');require_once(HTML_DTO_UTIL_PATH.'/DivDataReader.php');require_once(HTML_BASE_UTIL_PATH.'/Script.php');/** * Generates a Menu Fisheye element * <code> * +-------------------------------------+ * | menu1 | menu2 | menu3 | ... | menux | * +-------------------------------------+ * Usage: * $menu = new MenuFisheye($datareader, $text, $class, $align, $id, $limit, $layout); * print $menu->getHtml(); * Or * MenuFisheye:display($datareader, $text, $class, $align, $id, $limit, $layout); * </code> * @package menu-fisheye */class MenuFisheye extends DivDataReader { /** * Constructor * @param DataReader / array $datareader The Data Reader object OR an array * @param String $text The text header for the table * @param String $class The CSS Class name to use * @param String $align The align attribute * @param String $id The ID attribute * @param String $layout The layout to use * @param int $limit The limit to use for the array * @param String $layout The layout to use */ function __construct($datareader, $text='', $class='', $align='', $id='', $layout='', $limit='', $layout='') { $theText = $text != '' ? $text : MENU_FISHEYE_TEXT; $theClass = $class != '' ? $class : MENU_FISHEYE_VIEW_CLASS; $theId = $id != '' ? $id : ''; $theLimit = $limit != '' ? $limit : ''; $theLayout = $layout != '' ? $layout : MENU_FISHEYE_VIEW_LAYOUT; parent::__construct($datareader, $theText, $theClass, $align, $theId, $theLimit, $theLayout); } /** * Get the url to the javascript files * @static * @param String $filename The name of the javascript file * @return String The url to the javascript files */ public static function urlJavascript($filename) { $filePath = HTML_MENU_FISHEYE_JAVASCRIPT_PATH; $packageName = MYPHP_MENU_FISHEYE_NAME; $packagePath = HTML_MENU_FISHEYE_PATH; return Url::src($filename, $filePath, $packageName, $packagePath); } /** * Get the url to the images * <code> * Usage: * $domainname = 'http:/'.'/'.DOMAIN_NAME; * if (defined('HTML_UTIL_COMPONENT_PATH')) { * $domainname = Url::subdomain(DOMAIN_NAME); // Strip off subdomain names * } * * $fisheyemenuLinks = array( * array( 'src'=>$domainname.MenuFisheye::urlImages("home.png"),), * ); * </code> * @static * @param String $fileName The name of the image file. I.e. 'home.png' * @return String The url to the images */ public static function urlImages($fileName='') { $filePath = HTML_MENU_FISHEYE_IMAGES_PATH; $packageName = MYPHP_MENU_FISHEYE_NAME; $packagePath = HTML_MENU_FISHEYE_PATH; return Url::src($fileName, $filePath, $packageName, $packagePath); } /** * Get the javascript JQuery for this component * @return String The CSS class name */ public static function init() { if (MENU_FISHEYE_SHOW & (MENU_FISHEYE_SHOW_TOP | MENU_FISHEYE_SHOW_BOTTOM | MENU_FISHEYE_SHOW_CONTENT)) { $html = new Html(); $js = new Raw("<!-- MenuFisheye::init() JQuery is disabled -->\r\n"); if (defined('HTML_JQUERY_PAGE_PATH')) { $js = new Script(MenuFisheye::urlJavascript('init.js')); } $html->addHtml($js->getHtml()); } } /** * Get the CSS class Name for this component * @return String The CSS class name */ function getCssClass() { return CSS_FISHEYE_ITEM; } /** * 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_MENU_FISHEYE_SHOW, MENU_FISHEYE_SHOW, MENU_FISHEYE_SHOW_TOP); } /** * Get the html for the FISHEYE menu links * @return String The html */ function getHtml() { $html = $this->html; if (MENU_FISHEYE_SHOW & (MENU_FISHEYE_SHOW_TOP | MENU_FISHEYE_SHOW_BOTTOM | MENU_FISHEYE_SHOW_CONTENT) ) { $html .= "<!-- MenuFisheye -->\r\n"; if (CACHE_MENU_FISHEYE && $this->getCacheFileName(CACHE_MENU_FISHEYE_PATH) != '' && file_exists($this->getCacheFileName(CACHE_MENU_FISHEYE_PATH))) { $html .= $this->content($this->getCacheFileName(CACHE_MENU_FISHEYE_PATH)); } else { $div = new Div('',CSS_FISHEYE,'',ID_FISHEYE); $html .= $div->getStart(); $html .= $this->getColumns(); $html .= $div->getEnd(); if (CACHE_MENU_FISHEYE) { $this->save($html, CACHE_MENU_FISHEYE_PATH); } } } else { $html .= $this->getMaximize(); } return $html; } /** * Display html * <code> * Usage: * MenuFisheye::display($datareader, $text, $class, $align, $id, $limit, $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 $class The CSS Class name to use * @param String $align The align attribute * @param String $id The ID attribute * @param String $layout The layout to use * @param int $limit The limit to use for the array * @param String $layout The layout to use */ public static function display($datareader=null, $text='', $class='', $align='', $id='', $layout='', $limit='', $layout='') { $html = new MenuFisheye($datareader, $text, $class, $align, $id, $layout, $limit, $layout); $html->addHtml(); }}?>
Den fulde HTML kildekode for MenuFisheye klassen
<? <!-- DEBUG: MenuFisheye --> <!-- MenuFisheye --> <div id="fisheye" class="fisheye"><div class="fisheyeContainter basePrinter"><!-- DEBUG: Link --> <a class="fisheyeItem" href="http://www.hvepseeksperten.dk/FormMail/?baseEMNE=" title="Kontakt via email
"><span>Kontakt</span></a> <!-- DEBUG: Link --> <a class="fisheyeItem" href="http://www.hvepseeksperten.dk/hvepseboguide/About/" title="Hvem er vi egentlig?"><span>Firma profil</span></a> </div> </div> ?>
Her er 'klasse metoderne' for MenuFisheye klassen:
Her er 'objekt variable' for MenuFisheye klassen: