blank.gif
triangle.gif Du er her: /  Forsiden  /  Kildekoden  /  Tab  /  Indexmenu   Login nu   Login
blank.gif
 ««« Se kilde koden
blank.gif
triangle.gif Basic Base Component Db Dto Form Form-elements Jquery Layout Menu Menu-fisheye Mvc Tab  Table Template Util
blank.gif
blank.gif
 
arrow-headline.gif Index
 
  Tilbage

Navn : IndexMenu.php


Sample code, tutorial

Sådan benyttes komponenten IndexMenu klassen

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

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

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

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

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

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

Parent html

Sådan vises komponenten IndexMenu klassen

0) text=>Oversigt href=>/source-code/tab aux=>16 class=> title=>Klik her for at se oversigten ...
1) text=>Message href=>/source-code/tab/Message aux=>16
2) text=>MessageList href=>/source-code/tab/MessageList aux=>16
3) text=>Redirect href=>/source-code/tab/Redirect aux=>16
4) text=>Rowcolor href=>/source-code/tab/Rowcolor aux=>16
5) text=>Singleton href=>/source-code/tab/Singleton aux=>16

PHP source code

Den fulde PHP kildekode for IndexMenu klassen

<?
/**
* @package tab
* @see HTML_TAB_PAGE_PATH/IndexMenu.php
* @copyright (c) http://Finn-Rasmussen.com
* @license http://Finn-Rasmussen.com/license/ myPHP License conditions
* @author http://Finn-Rasmussen.com
* @version 1.10
* @since 22-feb-2007
*/

/**
* The required files
*/
require_once(HTML_UTIL_COMPONENT_PATH.'/Request.php');

/**
* Generates a list of links, like in an Index
* <code>
* Usage:
*   $documents = array('Message','MessageList','Redirect','Rowcolor','Singleton',);
*   $indexMenuLinks = IndexMenu:links($documents);
* Or
*   $file = IndexMenu::file($PACKAGES);
* </code>
* @package tab
*/

class IndexMenu {
    
/**
     * Constructor
     */
    
function IndexMenu() {
    }


    
/**
     * Get the filename name for the Index source code
     * The global package name is expected
     * @see $PACKAGES
     * <code>
     * Usage:
     *    $file = IndexMenu::file($PACKAGES);
     * </code>
     * @static
     * @param  array  $packages The array of packages
     * @param  String $phpFile  The php filename to use
     * @return String The filename to include or empty if not found
     */
    
function file($packages, $phpFile) {
        
$filename = '';
        
$indexSourceCode = INDEX_DEFAULT;
        
$tabSourceCode   = TAB_INDEX;
        if (
defined('TAB_SHOW') && TAB_SHOW & TAB_SHOW_URL) {
            
$indexSourceCode = Request::get(REQUEST_INDEX, INDEX_DEFAULT);
            
$tabSourceCode   = Request::get(REQUEST_TAB, TAB_INDEX);
        }
        foreach(
$packages as $key=>$package) {
            if (
defined($package)) {
                
$file = constant($package).DEFAULT_HTML_DOC_PATH.($indexSourceCode!=''?"$indexSourceCode":'')."/".$phpFile;
                if (!
file_exists($file)) {
                    
//print "not $file<br />";
                    
$file = constant($package).DEFAULT_HTML_DOC_PATH.$phpFile;
                } else {
                    
//
                
}
                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('Message','MessageList','Redirect','Rowcolor','Singleton',);
     *    $indexMenuLinks = IndexMenu::links($documents);
     * </code>
     * @static
     * @param array $documents The array of index links
     * @return array The rows of array links for the Index.php
     */
    
function links($documents) {
        
$indexmenuLinks = array();
        
$isRequest = false;
        if (
defined('TAB_SHOW') && TAB_SHOW & TAB_SHOW_URL) {
            
$isRequest = true;
        }
        
$params = '';
        
$tabSourceCode = TAB_INDEX;
        if (
$isRequest) {
            
$params = Params::get(array(REQUEST_INDEX=>''));
            
$indexmenuLinks[] = array('text'=>LINK_TEXT_OVERVIEW,'href'=>$params,'aux'=>LINK_LAYOUT_LI,'class'=>'','title'=>LINK_TITLE_OVERVIEW,);
        } else {
            
$indexmenuLinks[] = array('text'=>LINK_TEXT_OVERVIEW,'href'=>$GLOBALS[LINK_NAME_HREF ][LINK_SOURCE_CODE].'/'.$tabSourceCode,'aux'=>LINK_LAYOUT_LI,'class'=>'','title'=>LINK_TITLE_OVERVIEW,);
        }
        foreach(
$documents as $document) {
            if (
$isRequest) {
                
$params = Params::get(array(REQUEST_INDEX=>$document));
                
$indexmenuLinks[] = array('text'=>$document,'href'=>$params,'aux'=>LINK_LAYOUT_LI);
            } else {
                
$indexmenuLinks[] = array('text'=>$document,'href'=>$GLOBALS[LINK_NAME_HREF ][LINK_SOURCE_CODE].'/'.$tabSourceCode.'/'.$document,'aux'=>LINK_LAYOUT_LI);
            }
        }
        return
$indexmenuLinks;
    }
    
    
/**
     * Builds the html for an Index menu, and return it
     * @return String The Index menu as html
     */
    
function getHtml() {
        
$html = '';
        
$documents = array('Message','MessageList','Redirect','Rowcolor','Singleton',);
        
$indexmenuLinks = IndexMenu::links($documents);
        foreach(
$indexmenuLinks as $no=>$links) {
            
$row = '';
            foreach(
$links as $key=>$value) {
                
$row .= "$key=>$value ";
            }
            
$html .= "$no) $row<br />\r\n";
        }
        return
$html;
    }
}
?>

HTML source code

Den fulde HTML kildekode for IndexMenu klassen

<?
0
) text=>Oversigt href=>/source-code/tab aux=>16 class=> title=>Klik her for at se oversigten ...  <br />
1) text=>Message href=>/source-code/tab/Message aux=>16 <br />
2) text=>MessageList href=>/source-code/tab/MessageList aux=>16 <br />
3) text=>Redirect href=>/source-code/tab/Redirect aux=>16 <br />
4) text=>Rowcolor href=>/source-code/tab/Rowcolor aux=>16 <br />
5) text=>Singleton href=>/source-code/tab/Singleton aux=>16 <br />

?>

Class methods

Her er 'klasse metoderne' for IndexMenu klassen:

  • indexmenu
  • file
  • links
  • gethtml

Object vars

Her er 'objekt variable' for IndexMenu klassen:


 
triangle.gif

danmark

Germany

England

France

Italy

Norge

Sverige

USA


 
blank.gif