Logo ZenEngine Logo SourceForge.net ZenEngine
the lightweight CMS framework


package : ZenFS
Author : Bruno Desthuilliers
Version : 0.0.5

public class ZenFSMenuMaker

Builds a menu from a filesystem hierarchy.
Files and directories whose extensions are listed in the conf file will be listed as menuItems. Directories that dont have extensions are listed as categories. Dotted files and directories are ignored. Files and dirs names format goes like this file : file_name-xxx.ext dir : dir_name-xxx The 'xxx' part is the key for the item, and should be something like'000', '001' etc... Note that this key is also used to sort the menu. The menu 'caption' is the part of the name that comes before the first dash, underscores being replaced by spaces.


public void ZenFSMenuMaker

Parse the config, and list existing potential templates

Parameters :
string $config_path : the path to the (specific) config file

Return : (void)

public array getMenu

Build and return the menu for the data_path item of the config file

Return : (array) the menu (an associative array [key => ZenMenuItem])

private void _makeMenu

Just calls _makeMenuEx with base paramaters. The real job is done by _makeMenuEx()

See also : function _makeMenuEx()
Parameters :
string $path : : the data directory

Return : (void)

private void _makeMenuEx

Recurse thru the data directory and create the menu.

Parameters :
string $current_path : of the directory to visit
integer $level : recursion level
string $parent_key : for the parent directory if we're in a sub directory

Return : (void)

private void _listExistingTemplates

Create a list of all php pages at the root level.
If the name of one of the php pages matches a subdirectory name,this page will be used as 'template' for the documents in this subdirectory

Return : (void)

private void _findTemplateFor

Return the php page that should be used as template for the documents

See also : function _listExistingTemplates()
Parameters :
string $wanted : name of the template we're looking for
string $default : default template if we dont have what we 'wanted'

Return : (void)

private string _makeKey

Retrieve the key from the file or dir name

Parameters :
string $fname : current file or dir name
string $parent_key : parent key that must be prepended

Return : (string) the key for this entry

private string _makeCaption

Retrieve the caption from the file or dir name

Parameters :
string $fname : file or dir name
boolean $is_doc : this a document or a category ?

Return : (string)


private array $_menu

The menu itself (an associative array)

private array $_templates

A list of potential 'template' pages (in fact all the .php files in the root directory)

private array $_extensions

A list of knowns docTypes - with ZenFS, the file extension is used as docType