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

Class: HTML_MenuBrowser

Source Location: /HTML_Menu-2.1.4/MenuBrowser.php

Class Overview


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


Author(s):

Version:

  • Release: 2.1.4

Variables

Methods


Inherited Variables

Inherited Methods


Class Details

[line 57]
Simple filesystem browser that can be used to generate 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:

  1.  // document root directory
  2.  define('DOC_ROOT''/home/server/www.example.com/');
  3.  
  4.  // instantiate the menubrowser
  5.  $browser = new HTML_MenuBrowser(DOC_ROOT);
  6.  
  7.  // instantiate menu (3)
  8.  $menu = new HTML_Menu($browser->getMenu());
  9.  
  10.  // output the sitemap
  11.  $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 97]

Directory to scan.

Type:   string


[ Top ]

$file_suffix =  'xml'

[line 65]

Filesuffix of your XML files.

Type:   string


[ Top ]

$file_suffix_length =  3

[line 73]

Number of characters of the file suffix.

Type:   int


[ Top ]

$id_prefix =  ''

[line 109]

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 81]

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

Type:   string


[ Top ]

$index_file =  ''

[line 89]

Full filename of your index / start pages.

Type:   string


[ Top ]

$menu = array()

[line 116]

Menu (3)'s setMenu() hash.

Type:   array


[ Top ]



Method Detail

HTML_MenuBrowser (Constructor)   [line 126]

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 240]

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 201]

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 264]

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 174]

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 149]

void setDirectory( string $dir)

Sets the directory to scan.
  • Access: public

Parameters:

string   $dir   —  directory to scan

[ Top ]

setIDPrefix   [line 161]

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 15:02:05 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.