Top  Branding  Banner 
blank.gif
blank.gif
triangle.gif Du er her: /  Forsiden  /  Kildekoden  /  Tab  /  Tabmenu   Login nu   Login
blank.gif
««« Se kilde koden
blank.gif
tl.gif Base tr.gif tl.gif Basic tr.gif tl.gif Dto tr.gif tl.gif Form tr.gif tl.gif Language tr.gif tl.gif Layout tr.gif tl.gif Menu tr.gif tl.gif Mvc tr.gif tl.gif Netbank.eksperter.dk tr.gif tls.gif     Tab  trs.gif tl.gif Table tr.gif tl.gif Util tr.gif
blank.gif
blank.gif
arrow-headline.gif Index
MenuLink  MenuLeft  
Tilbage

Skjul: Navn

TabMenu.php


Vis: Sample code, tutorial

TabMenu, Sample code, tutorial

Sådan benyttes komponenten TabMenu klassen

Først skal du inkludere den fil der beskriver komponenten, som en klasse fil

  • <?
    require_once(HTML_PACKAGE_PATH.'/TabMenu.php');
    ?>

Dernæst kan du enten benytte komponenten som et taglib (statiske metoder):

  • <?
    TabMenu
    ::display($param1$param2$param3, ...);
    ?>

eller du kan lave en instance af komponenten og benytte metoderne direkte:

  • <?
    $object 
    = new TabMenu($param1$param2$param3, ...);
    print 
    $object->getHtml();
    ?>

Skjul: Sådan vises komponenten

TabMenu, Sådan vises komponenten

Sådan vises komponenten TabMenu klassen

basic) text=>basic href=>http://finnrasmussen.dk/source-code/basic aux=>16
base) text=>base href=>http://finnrasmussen.dk/source-code/base aux=>16
table) text=>table href=>http://finnrasmussen.dk/source-code/table aux=>16
template) text=>template href=>http://finnrasmussen.dk/source-code/template aux=>16

Vis: PHP source code

TabMenu, PHP source code

Den fulde PHP kildekode for TabMenu klassen

<?php
/**
 * @package tab
 * @see HTML_TAB_PAGE_PATH/TabMenu.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_UTIL_COMPONENT_PATH.'/Request.php');

/**
 * Generates a list of links, like in a tab
 * <code>
 * Usage:
 *   $documents = array(
 *      MYPHP_BASIC_NAME, MYPHP_BASE_NAME, MYPHP_COMPONENT_NAME, MYPHP_DB_NAME, // etc.
 *   );
 *   $tabMenuLinks = TabMenu:links($documents);
 * Or
 *   $file = TabMenu::file($PACKAGES);
 * </code>
 * @package tab
 */

class TabMenu {
    
/**
     * Constructor
     */
    
function __construct() {
    }

    
/**
     * Get the filename name for the Tab source code
     * The global package name is expected
     * @see $PACKAGES
     * <code>
     * Usage:
     *    $file = TabMenu::file($PACKAGES);
     * </code>
     * @static
     * @param  array   $packages  The array of packages
     * @return String The filename to include or empty if not found
     */
    
public static function file($packages) {
        
$filename '';
        
$tabSourceCode TAB_INDEX;
        if (
defined('TAB_SHOW') && TAB_SHOW TAB_SHOW_URL) {
            
$tabSourceCode Request::get(REQUEST_TABTAB_INDEX);
        }
        foreach(
$packages as $key=>$package) {
//            print "Xrequire $key $package<br />\r\n";
            
if (defined($package)) {
                
$file constant($package).DEFAULT_HTML_DOC_PATH.$tabSourceCode.".php";
                if (
file_exists($file)) {
                    
$text substr(basename(constant($package)), strlen(MYPHP_PREFIX.CURRENT_VERSION));
                    if ( 
$text == $tabSourceCode ) {
                        
$filename $file;
                        
//print "require $key $file<br />\r\n";
                        
break;
                    } else {
                        
// Ignore
                        //print "Ignore $text $key $file<br />\r\n";
                    
}
                } else {
                    
// Ok
                    //print "Not exists $key $file<br />\r\n";
                
}
            } else {
                
// Ok, not part of the packages
                //print "Not part of package $key $package<br />\r\n";
            
}
        }
        return 
$filename;
    }

    
/**
     * Get the array of index menu links
     * <code>
     * Usage:
     *   $documents = array(
     *      MYPHP_BASIC_NAME, MYPHP_BASE_NAME, MYPHP_COMPONENT_NAME, MYPHP_DB_NAME, // etc.
     *   );
     *    $tabMenuLinks = TabMenu::links($documents);
     * </code>
     * @static
     * @param  array $documents The array of tab links
     * @return array The rows of array links for the Index.php
     */
    
public static function links($documents) {
        
$tabmenuLinks = array(); 
        
$isRequest false;
        if (
defined('TAB_SHOW') && TAB_SHOW TAB_SHOW_URL) {
            
$isRequest true;
        }
        
$port Server::getServerPort();
        if (
$port != '80') {
            
$port ":$port";
        } else {
            
$port '';
        }
        
$domainNameSourceCode 'http:/'.'/'.(DOMAIN_NAME!='localhost'?DOMAIN_NAME_SOURCE_CODE:DOMAIN_NAME).$port;
        foreach(
$documents as $document) {
            
$text substr(basename($document), strlen(MYPHP_PREFIX.CURRENT_VERSION));
            if (
$isRequest) {
                
$tabmenuLinks[$text] = array('text'=>$text,'href'=>$domainNameSourceCode.'?'.REQUEST_TAB.'='.$text,'aux'=>LINK_LAYOUT_LI);
            } else {
                
$urlencode true;
                
$params Params::get(array(), $urlencode__FILE____LINE__);
                
$tabmenuLinks[$text] = array('text'=>$text,'href'=>$domainNameSourceCode.$GLOBALS[LINK_NAME_HREF ][LINK_SOURCE_CODE].'/'.$text.$params,'aux'=>LINK_LAYOUT_LI);
            }
        }
        return 
$tabmenuLinks;
    }
    
    
/**
     * Builds the html for an Tab menu, and return it 
     * @return String The Index menu as html
     */
    
function getHtml() {
        
$html '';
        
$documents = array(MYPHP_BASIC_NAMEMYPHP_BASE_NAMEMYPHP_TABLE_NAMEMYPHP_TEMPLATE_NAME,);
        
$tabmenuLinks TabMenu::links($documents);
        foreach(
$tabmenuLinks as $no=>$links) {
            
$row '';
            foreach(
$links as $key=>$value) {
                
$row .= "$key=>$value ";
            }
            
$html .= "$no$row<br />\r\n";
        }
        return 
$html;
    }
}
?>

Vis: HTML source code

TabMenu, HTML source code

Den fulde HTML kildekode for TabMenu klassen

<?
basic
text=>basic href=>http://finnrasmussen.dk/source-code/basic aux=>16 <br />
basetext=>base href=>http://finnrasmussen.dk/source-code/base aux=>16 <br />
tabletext=>table href=>http://finnrasmussen.dk/source-code/table aux=>16 <br />
templatetext=>template href=>http://finnrasmussen.dk/source-code/template aux=>16 <br />

?>

Vis: Class methods

TabMenu, Class methods

Her er 'klasse metoderne' for TabMenu klassen:

  • __construct
  • file
  • links
  • getHtml

Vis: Object vars

TabMenu, Object vars

Her er 'objekt variable' for TabMenu klassen:


MenuRight 
triangle.gif

Dansk

Deutch

English (UK)

France

Italy

Norsk

Svensk

English (USA)


 
blank.gif
MenuBottom 
triangle.gif Copyright @ 1999-2010 www.Finn-Rasmussen.com Powered by myPHP Version (5.3.3-7+squeeze9) 1.11
blank.gif