HTML_Menu
[ class tree: HTML_Menu ] [ index: HTML_Menu ] [ all elements ]

Class: HTML_MenuBrowser

Source Location: /HTML_Menu-2.1.3/MenuBrowser.php

Class Overview


Simple filesystem browser that can be used to generated menu (3) hashes based on the directory structure.


Author(s):

Version:

  • $Revision: 1.4 $

Variables

Methods


Inherited Variables

Inherited Methods


Class Details

[line 51]
Simple filesystem browser that can be used to generated menu (3) hashes based on the directory structure.

Together with menu (3) and the (userland) cache you can use this browser to generate simple fusebox like applications / content systems.

Let the menubrowser scan your document root and generate a menu (3) structure hash which maps the directory structure, pass it to menu's setMethod() and optionally wrap the cache around all this to save script runs. If you do so, it looks like this:

// document root directory define('DOC_ROOT', '/home/server/www.example.com/');

// instantiate the menubrowser $browser = new menubrowser(DOC_ROOT);

// instantiate menu (3) $menu = new menu($browser->getMenu());

// output the sitemap $menu->show('sitemap');

Now, use e.g. simple XML files to store your content and additional menu informations (title!). Subclass exploreFile() depending on your file format.



[ Top ]


Class Variables

$dir =  ''

[line 91]

Directory to scan.

Type:   string


[ Top ]

$file_suffix =  'xml'

[line 59]

Filesuffix of your XML files.

Type:   string


[ Top ]

$file_suffix_length =  3

[line 67]

Number of characters of the file suffix.

Type:   int


[ Top ]

$id_prefix =  ''

[line 103]

Prefix for every menu hash entry.

Set the ID prefix if you want to merge the browser menu hash with another (static) menu hash so that there're no name clashes with the ids.


Type:   string


[ Top ]

$index =  'index'

[line 75]

Filename (without suffix) of your index / start pages.

Type:   string


[ Top ]

$index_file =  ''

[line 83]

Full filename of your index / start pages.

Type:   string


[ Top ]

$menu = array()

[line 110]

Menu (3)'s setMenu() hash.

Type:   array


[ Top ]



Method Detail

HTML_MenuBrowser (Constructor)   [line 120]

HTML_MenuBrowser HTML_MenuBrowser( [string $dir = ''], [string $index = ''], [string $file_suffix = ''])

Creates the object and optionally sets the directory to scan.

Parameters:

string   $dir   —  Directory to scan
string   $index   —  Filename of index pages
string   $file_suffix   —  Suffix for files containing the additional data

[ Top ]

addFileInfo   [line 234]

array addFileInfo( array $menu)

Adds further informations to the menu hash gathered from the files in it
  • Return: Modified menu hash with the new informations

Parameters:

array   $menu   —  Menu hash to examine

[ Top ]

browse   [line 195]

array browse( string $dir, [integer $id = 0], [boolean $noindex = false])

Recursive function that does the scan and builds the menu (3) hash.

Parameters:

string   $dir   —  directory to scan
integer   $id   —  entry id - used only for recursion
boolean   $noindex   —  ??? - used only for recursion

[ Top ]

exploreFile   [line 258]

void exploreFile( string $file)

Returns additional menu informations decoded in the file that appears in the menu.

You should subclass this method to make it work with your own file formats. I used a simple XML format to store the content.


Parameters:

string   $file   —  filename

[ Top ]

getMenu   [line 168]

void getMenu( [string $dir = ''], [string $prefix = ''])

Returns a hash to be used with menu(3)'s setMenu().
  • Access: public

Parameters:

string   $dir   —  directory to scan
string   $prefix   —  id prefix

[ Top ]

setDirectory   [line 143]

void setDirectory( string $dir)

Sets the directory to scan.
  • Access: public

Parameters:

string   $dir   —  directory to scan

[ Top ]

setIDPrefix   [line 155]

void setIDPrefix( string $prefix)

Sets the prefix for every id in the menu hash.
  • Access: public

Parameters:

string   $prefix   — 

[ Top ]


Documentation generated on Mon, 11 Mar 2019 14:46:21 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.