Sådan benyttes komponenten CssTab klassen
Først skal du inkludere den fil der beskriver komponenten, som en klasse fil
<? require_once(HTML_PACKAGE_PATH.'/CssTab.php'); ?>
Dernæst kan du enten benytte komponenten som et taglib (statiske metoder):
<? CssTab::display($param1, $param2, $param3, ...); ?>
eller du kan lave en instance af komponenten og benytte metoderne direkte:
<? $object = new CssTab($param1, $param2, $param3, ...); print $object->getHtml(); ?>
Sådan vises komponenten CssTab klassen
Den fulde PHP kildekode for CssTab klassen
<?php/** * @package tab * @see HTML_TAB_UTIL_PATH.'/CssTab.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_PAGE_PATH.'/Css.php');/** * Generates the Tab CSS * <code> * Usage: * $href = "tab.css"; * $css = new CssTab($href); * print $css->getHtml(); * Or: * CssTab::display($href); * </code> * @package tab */class CssTab extends Css { /** * Constructor * @param String $href The url to the css filename (i.e. tab.css) */ function __construct($href='') { parent::__construct($href != '' ? $href : CSS_FILE_NAME_TAB); } /** * Returns the css class details for an active Tab in a component * @param String $name The Name of the CSS class * @param String $color The Color of the class * @param String $backgroundcolor The Background Color of the class * @param String $bordercolor The Color of the border * @param String $cssPx The CSS border width * @return String the complete css */ function getTabActive($name, $color='', $backgroundcolor='', $bordercolor='', $cssPx='') { $html = ''; $html .= $this->getStart("$name"); if ($color != '') { $html .= $this->getCss(CSS_NAME_COLOR, "#$color"); } if ($backgroundcolor != '') { $html .= $this->getCss(CSS_NAME_BACKGROUND_COLOR, "#$backgroundcolor"); } $borderColor = $bordercolor != ''?$bordercolor:CSS_TAB_COLOR; $html .= $this->getCss(CSS_NAME_BORDER, "#$borderColor ".CSS_1PX.' '.CSS_BORDER_STYLE_SOLID); $html .= $this->getBorderLine(CSS_NAME_TOP , $bordercolor, $cssPx,CSS_BORDER_STYLE_SOLID); $html .= $this->getBorderLine(CSS_NAME_LEFT , $bordercolor, $cssPx,CSS_BORDER_STYLE_SOLID); $html .= $this->getBorderLine(CSS_NAME_RIGHT , $bordercolor, $cssPx,CSS_BORDER_STYLE_SOLID); $html .= $this->getBorderLine(CSS_NAME_BOTTOM, $bordercolor,CSS_0PX,CSS_BORDER_STYLE_SOLID); $html .= $this->getCss(CSS_NAME_TEXT_ALIGN, CSS_TEXT_ALIGN_CENTER); $html .= $this->getEnd(); return $html; } /** * Returns the css class details for a Tab Body in a component * @param String $name The Name of the CSS class * @param String $color The Color of the class * @param String $backgroundcolor The Background Color of the class * @param String $bordercolor The Color of the border * @param String $cssPx The CSS border width * @return String the complete css */ function getTabBody($name, $color='', $backgroundcolor='', $bordercolor='', $cssPx='') { $html = ''; $html .= $this->getStart("$name"); if ($color != '') { $html .= $this->getCss(CSS_NAME_COLOR, "#$color"); } if ($backgroundcolor != '') { $html .= $this->getCss(CSS_NAME_BACKGROUND_COLOR, "#$backgroundcolor"); } $borderColor = $bordercolor != ''?$bordercolor:CSS_TAB_COLOR; $html .= $this->getCss(CSS_NAME_BORDER, "#000 ".CSS_0PX.' '.CSS_BORDER_STYLE_SOLID); $html .= $this->getBorderLine(CSS_NAME_TOP , $bordercolor,CSS_0PX,CSS_BORDER_STYLE_SOLID); $html .= $this->getBorderLine(CSS_NAME_LEFT , $borderColor, $cssPx,CSS_BORDER_STYLE_SOLID); $html .= $this->getBorderLine(CSS_NAME_RIGHT , $borderColor, $cssPx,CSS_BORDER_STYLE_SOLID); $html .= $this->getBorderLine(CSS_NAME_BOTTOM, $borderColor, $cssPx,CSS_BORDER_STYLE_SOLID); $html .= $this->getEnd(); return $html; } /** * Returns the css class details for a Tab in a component * @param String $name The Name of the CSS class * @param String $color The Color of the class * @param String $backgroundcolor The Background Color of the class * @param String $bordercolor The Color of the border * @param String $cssPx The CSS border width * @return String the complete css */ function getTab($name, $color='', $backgroundcolor='', $bordercolor='', $cssPx='') { $html = ''; $html .= $this->getStart("$name"); if ($color != '') { $html .= $this->getCss(CSS_NAME_COLOR, "#$color"); } if ($backgroundcolor != '') { $html .= $this->getCss(CSS_NAME_BACKGROUND_COLOR, "#$backgroundcolor"); } $borderColor = $bordercolor != ''?$bordercolor:CSS_TAB_COLOR; $html .= $this->getCss(CSS_NAME_BORDER, "#$borderColor ".CSS_0PX.' '.CSS_BORDER_STYLE_SOLID); $html .= $this->getBorderLine(CSS_NAME_TOP , $borderColor, $cssPx,CSS_BORDER_STYLE_SOLID); $html .= $this->getBorderLine(CSS_NAME_LEFT , $borderColor, $cssPx,CSS_BORDER_STYLE_SOLID); $html .= $this->getBorderLine(CSS_NAME_RIGHT , $borderColor, $cssPx,CSS_BORDER_STYLE_SOLID); $html .= $this->getBorderLine(CSS_NAME_BOTTOM, $bordercolor, $cssPx,CSS_BORDER_STYLE_SOLID); $html .= $this->getCss("text-align","center"); $html .= $this->getEnd(); return $html; } /** * Returns the css Table components * @return String the complete css */ function getCustom() { $html = ''; $html .= $this->getHeader($this->getClassName()); $html .= $this->getComponent('.'.CSS_TAB_MENU,CSS_TAB_MENU_COLOR,CSS_TAB_MENU_BACKGROUND,'','',CSS_TEXT_DECORATION_NONE); // Tab and TabBody $html .= $this->getTab('.'.CSS_TAB,CSS_TAB_COLOR,CSS_TAB_BACKGROUND, CSS_TAB_BORDER_COLOR, CSS_TAB_BORDER_WIDTH); $html .= $this->getTabActive('.'.CSS_TAB_ACTIVE,CSS_TAB_ACTIVE_COLOR,CSS_TAB_ACTIVE_BACKGROUND, CSS_TAB_ACTIVE_BORDER_COLOR, CSS_TAB_ACTIVE_BORDER_WIDTH); $html .= $this->getTabBody('.'.CSS_TAB_BODY,CSS_TAB_BODY_COLOR,CSS_TAB_BODY_BACKGROUND, CSS_TAB_BODY_BORDER_COLOR, CSS_TAB_BODY_BORDER_WIDTH); $html .= $this->getComponent('.'.CSS_ATAB,CSS_ATAB_COLOR,CSS_ATAB_BACKGROUND,'','',CSS_TEXT_DECORATION_NONE); $html .= $this->getComponent('.'.CSS_ATAB_BODY,CSS_ATAB_BODY_COLOR,CSS_ATAB_BODY_BACKGROUND); // Bugfix for Firefox $html .= $this->getSingle('.'.CSS_ATAB,'white-space','nowrap'); $html .= $this->getSingle('.'.CSS_TAB_ACTIVE,'white-space','nowrap'); $html .= $this->getSingle('.'.CSS_TAB,'white-space','nowrap'); if (defined('IMAGE_TAB_BACK')) { // Add an image to the TD $image = new Images(IMAGE_TAB_BACK); $position = ""; $html .= $this->getImage('.'.CSS_TAB, $image->get('src'), CSS_REPEAT_X, $position); // Add an image to the link $image = new Images(IMAGE_TAB_BACK); $position = "center"; $html .= $this->getImage('.'.CSS_ATAB, $image->get('src'), CSS_REPEAT_X, $position); } if (defined('IMAGE_TAB_BACK_SELECTED')) { // Add an image to the TD background $image = new Images(IMAGE_TAB_BACK_SELECTED); $position = ""; $html .= $this->getImage('.'.CSS_TAB_ACTIVE, $image->get('src'), CSS_REPEAT_X, $position); //$html .= $this->getSingle('img','float','left'); } // if (defined('IMAGE_BACKGROUND')) {// // Add an image to the FillOut// $image = new Images(IMAGE_BACKGROUND); // $position = "";// $html .= $this->getImage('.'.CSS_FILL_OUT, $image->get('src'), CSS_REPEAT_X, $position);// } return $html; } /** * Display the html * <code> * Usage: * $href = "tab.css"; * CssTab::display($href); * </code> * @static * @param String $href, The url to the css file (i.e. tab.css) */ public static function display($href='') { $html = new CssTab($href); $html->addHtml(); }}?>
Den fulde HTML kildekode for CssTab klassen
<? <!-- DEBUG: CssTab --> <style type="text/css"> /*********************************************************** * * AUTOGENERATED file, DO NOT CHANGE OR EDIT, the full source code is here _____________________________________________________ ________| |________ \ | http://Finn-Rasmussen.com Phone (+45) 40 50 60 69 | / \ | Kongens Vænge 79, 3400 Hillerød, Denmark | / / |_____________________________________________________| \ /___________) (__________\ * * @version : 1.11 * @since : 14-Aug-2011 21:46:52 * @copyright : Copyright © 1999-2010 http://Finn-Rasmussen.com * * Email : Please, phone me for my email address * Web : http://Finn-Rasmussen.com * : This website was created by the myPHP taglib and CMS * : Download a free demo of the myPHP taglib here ... * : http://Finn-Rasmussen.com/myPHP/ * @domain : finnrasmussen.dk * @language : da * @webmaster : DEFAULT_CMS_LOGIN_USERNAME(+)finnrasmussen.dk * @file : /cache/files/finnrasmussen.dk-tab.css (Autocreated cache file) * @classname : CssTab ***********************************************************/ .tabMenu{ color : #000; background-color : #fff; } a:link.tabMenu,a:visited.tabMenu,a:active.tabMenu{ color : #000; background-color : #fff; font-size : 11px; font-weight : bold; text-decoration : none; } a:hover.tabMenu{ color : #fff; background-color : #000; font-size : 11px; font-weight : bold; text-decoration : none; } img.tabMenu{ color : #fffffe; background-color : #fff; border-style : none; } .tabTab{ color : #fff; background-color : #f00; border : #000 0px solid; border-top-color : #000; border-top-width : 0px; border-top-style : solid; border-left-color : #000; border-left-width : 0px; border-left-style : solid; border-right-color : #000; border-right-width : 0px; border-right-style : solid; border-bottom-color : #000; border-bottom-width : 0px; border-bottom-style : solid; text-align : center; } .tabTabActive{ color : #000; background-color : #fff; border : #000 1px solid; border-top-color : #000; border-top-width : 0px; border-top-style : solid; border-left-color : #000; border-left-width : 0px; border-left-style : solid; border-right-color : #000; border-right-width : 0px; border-right-style : solid; border-bottom-color : #000; border-bottom-width : 0px; border-bottom-style : solid; text-align : center; } .tabTabBody{ color : #000; background-color : #fff; border : #000 0px solid; border-top-color : #fff; border-top-width : 0px; border-top-style : solid; border-left-color : #fff; border-left-width : 1px; border-left-style : solid; border-right-color : #fff; border-right-width : 1px; border-right-style : solid; border-bottom-color : #fff; border-bottom-width : 1px; border-bottom-style : solid; } .tabATab{ color : #fff; background-color : #f00; } a:link.tabATab,a:visited.tabATab,a:active.tabATab{ color : #fff; background-color : #f00; font-size : 11px; font-weight : bold; text-decoration : none; } a:hover.tabATab{ color : #f00; background-color : #fff; font-size : 11px; font-weight : bold; text-decoration : none; } img.tabATab{ color : #ff0001; background-color : #f00; border-style : none; } .tabATabBody{ color : #000; background-color : #fff; } a:link.tabATabBody,a:visited.tabATabBody,a:active.tabATabBody{ color : #000; background-color : #fff; font-size : 11px; font-weight : bold; text-decoration : underline; } a:hover.tabATabBody{ color : #fff; background-color : #000; font-size : 11px; font-weight : bold; text-decoration : underline; } img.tabATabBody{ color : #fffffe; background-color : #fff; border-style : none; } .tabATab{ white-space : nowrap; } .tabTabActive{ white-space : nowrap; } .tabTab{ white-space : nowrap; } .tabTab{ background-image : url('/myphp-1.11/myphp-1.11-netbank.eksperter.dk/html/images/tb.gif'); background-repeat : repeat-x; } .tabATab{ background-image : url('/myphp-1.11/myphp-1.11-netbank.eksperter.dk/html/images/tb.gif'); background-repeat : repeat-x; background-position : center; } .tabTabActive{ background-image : url('/myphp-1.11/myphp-1.11-netbank.eksperter.dk/html/images/tbs.gif'); background-repeat : repeat-x; } /* DEBUG, Not cached, CSS Custom file : /cache/css/finnrasmussen.dk-tab.css */ </style> ?>
Her er 'klasse metoderne' for CssTab klassen:
Her er 'objekt variable' for CssTab klassen: