Sitellite Application Framework
Class Tree         Index         All Elements

Class: Menu

Source Location: Program_Root/GUI/Menu.php

Class Overview


Menu is a class that is used to generate navigation systems on the fly on web sites, based on a self-referencial database table structure.


Author(s)

Version

  • 2.6, 2003-06-18, $Id: Menu.php,v 1.7 2007/01/17 15:37:09 lux Exp $

Copyright

  • Copyright (C) 2001-2003, Simian Systems Inc.

Variables

Methods


Inherited Variables

Inherited Methods


Class Details

[line 80]
Menu is a class that is used to generate navigation systems on the fly on web sites, based on a self-referencial database table structure.

New in 1.2:

  • Fixed a PHP4.2+ compatibility issue where it was calling $GLOBALS['PHP_SELF'], now it calls $_SERVER['PHP_SELF'], and calls global $_SERVER so that versions of PHP prior to 4.1 can rely on a $_SERVER reference to $HTTP_SERVER_VARS.
New in 2.0:
  • Rewritten so that Menu is no longer so strongly tied to EasyText. The PHP API is much improved. New features include loading of the site tree in a single database call (in the getTree() method), and storing the resulting tree in memory or in a file as PHP code (created using the buildConfig() method) which can be retrived using the loadConfig() method. Trees can also be built manually using the addItem() method, which takes care off all the messy stuff for you.
  • Moved from saf.EasyText.Menu to saf.GUI.Menu.
New in 2.2:
  • Changed addItem() so that it returns a reference to the new item object.
New in 2.4:
  • Changed sorting order to be by $showcol instead of $idcol.
New in 2.6:
  • Removed the EasyText() and EasyTextInit() methods.
  • Added the countChildren() and getChildren() methods.
New in 2.8:
  • Added sort_weight field.

1 <?php
2
3 $menu = new Menu ('sitellite_page', 'id', 'title', 'below_page');
4
5 $menu->getTree ();
6
7 echo $menu->trail ('contact', '<a href="/index/##id##">##title##</a>');
8
9 ? >




Tags:

access:  public
version:  2.6, 2003-06-18, $Id: Menu.php,v 1.7 2007/01/17 15:37:09 lux Exp $
license:  http://www.sitellite.org/index/license
copyright:  Copyright (C) 2001-2003, Simian Systems Inc.
author:  John Luxford <mailto:lux@simian.ca>


[ Top ]


Class Variables

$cache =  false

[line 162]


Type:   mixed


[ Top ]

$cacheLocation =  'cache/.menu'

[line 163]


Type:   mixed


[ Top ]

$closedPic =

[line 181]

The path to the image to use for the'"closed' graphic in the collapsible display mode. Defaults to '/pix/false.gif'.



Tags:

access:  public

Type:   mixed


[ Top ]

$colours =

[line 227]

A list of background colours to use to differentiate between levels in the collapsible display mode. Starts at #ffffff (white) and goes down to #999999 (medium grey) and back.



Tags:

access:  public

Type:   mixed


[ Top ]

$error =

[line 172]

Contains the most recent error message if an error has occurred, false otherwise.



Tags:

access:  public

Type:   mixed


[ Top ]

$hideValue =

[line 217]

The value that the database column in $listcolumn is supposed to contain when a field is not to be shown. Defaults to 'no'.



Tags:

access:  public

Type:   mixed


[ Top ]

$idcolumn =

[line 105]

The name of the column in the database table that contains the primary key values.



Tags:

access:  public

Type:   mixed


[ Top ]

$includedJs =

[line 245]

Remembers whether or not the JavaScript for the collapsible display mode has been included yet or not.



Tags:

access:  public

Type:   mixed


[ Top ]

$initFunc =

[line 256]

The name of the JavaScript init() function for this menu.

Different menus on the same page need separate init() functions. The default is 'saf_xbinit_' plus the name of the database table linked to this menu.




Tags:

access:  public

Type:   mixed


[ Top ]

$jsDir =

[line 236]

The directory to find the JavaScript for the collapsible view in. Default is '/js'.



Tags:

access:  public

Type:   mixed


[ Top ]

$listcolumn =

[line 132]

The name of the column in the database table that says whether or not to display each record as an item.



Tags:

access:  public

Type:   mixed


[ Top ]

$openedPic =

[line 190]

The path to the image to use for the'"opened' graphic in the collapsible display mode. Defaults to '/pix/true.gif'.



Tags:

access:  public

Type:   mixed


[ Top ]

$refcolumn =

[line 123]

The name of the column in the database table that makes a self-reference to the primary key, or id, column.



Tags:

access:  public

Type:   mixed


[ Top ]

$showcolumn =

[line 114]

The name of the column in the database table that is to be displayed.



Tags:

access:  public

Type:   mixed


[ Top ]

$sitelliteAllowed =

[line 160]

Specifies whether or not to use the global $sitellite object (from the Sitellite CMS-only package saf.App.Conf.Sitellite) to add automatic permission limits on the database query. For more information, see saf.App.Conf.Sitellite in DocReader.



Tags:

access:  public

Type:   mixed


[ Top ]

$sortcolumn =

[line 141]

The field to sort by, in case of a sort field. A sort field outweighs the default sorting alphabetically.



Tags:

access:  public

Type:   mixed


[ Top ]

$sortorder =

[line 149]

The sort order, either 'ASC' (ascending) or 'DESC' (descending).



Tags:

access:  public

Type:   mixed


[ Top ]

$table =

[line 96]

The name of the database table (if any) that this menu is being pulled from.



Tags:

access:  public

Type:   mixed


[ Top ]

$tree =

[line 87]

Contains a multi-dimensional array of MenuItem objects.



Tags:

access:  public

Type:   mixed


[ Top ]

$xpos =

[line 199]

The distance from the left edge of the browser window to display the menu in collapsible display mode. Default is 0.



Tags:

access:  public

Type:   mixed


[ Top ]

$ypos =

[line 208]

The distance from the top edge of the browser window to display the menu in collapsible display mode. Default is 0.



Tags:

access:  public

Type:   mixed


[ Top ]



Class Methods


constructor Menu [line 269]

Menu Menu( [string $table = ''], [string $idcol = ''], [string $showcol = ''], [string $refcol = ''], [string $listcol = ''], [mixed $sectioncol = ''], [mixed $templatecol = ''])

Constructor method.



Tags:

access:  public


Parameters:

string   $table  
string   $idcol  
string   $showcol  
string   $refcol  
string   $listcol  

[ Top ]

method addItem [line 431]

object reference &addItem( string $id, string $title, [string $ref = ''], [mixed $sect = ''], [mixed $template = ''])

Adds an item to the tree. $ref is the id of the parent item.



Tags:

access:  public


Parameters:

string   $id  
string   $title  
string   $ref  

[ Top ]

method clear [line 753]

void clear( )

Clears the item tree.



Tags:

access:  public


[ Top ]

method countChildren [line 720]

integer countChildren( [string $id = false])

Returns the number of child items of the specified item.

If $id is not specified, returns the number of top-level items.




Tags:

access:  public


Parameters:

string   $id  

[ Top ]

method display [line 533]

string display( [string $mode = 'html'], [mixed $tplt = ''], [integer $recursive = 1])

Renders the menu. $mode can be 'html' or 'collapsible'.

$tplt can be a single template or an array of templates. If $recursive is set to 0 or false, it will only render a single level of the tree. Note: Do not set $recursive to true, rather set it to 1, so that it can be used to count the level of depth within the menu structure a given item is, and so it will use the proper template if $tplt is an array.




Tags:

access:  public


Parameters:

string   $mode  
mixed   $tplt  
integer   $recursive  

[ Top ]

method getChildren [line 738]

array getChildren( [string $id = false])

Returns the children of the specified item.

If $id is not specified, returns the top-level items.




Tags:

access:  public


Parameters:

string   $id  

[ Top ]

method getSections [line 768]

void getSections( [mixed $item = false])

Retrieves a list of all of the items denoted as section roots.



Tags:

access:  public


[ Top ]

method getTree [line 298]

boolean getTree( )

Builds the item tree from the database table specified.



Tags:

access:  public


[ Top ]

method homeLink [line 628]

string homeLink( string $tplt)

Returns a 'home' link. Called by the trail() method to add an optional 'home' link to breadcrumb trails. The home link id is always 'index', and the title is always 'Home', which can be changed or translated if a global $intl saf.I18n object is found.



Tags:

access:  public


Parameters:

string   $tplt  

[ Top ]

method includeJavaScript [line 610]

string includeJavaScript( )

Returns the HTML code to include the necessary JavaScript files for the collapsible display mode.



Tags:

access:  public


[ Top ]

method loadConfig [line 459]

void loadConfig( string $file)

Loads the item tree from an include file or string.



Tags:

access:  public


Parameters:

string   $file  

[ Top ]

method makeConfig [line 489]

string makeConfig( )

Creates the PHP code for a config file from the item tree.



Tags:

access:  public


[ Top ]

method section [line 661]

string section( [string $id = ''], [string $tplt = ''], [string $open = ''], [boolean $recursive = false], [string $skip = ''])

Returns a section of the item tree, rendered as an XHTML-compliant

unordered list. $open allows you to specify the id of a single item in the section which can be 'opened' to either one more level or entirely (if $recursive is set to true). This makes it possible to display a section such as a product list and while the visitor is viewing a specific product, to also show sub-links pertaining to that product. $skip specifies an optional item to ignore (ie. in a "related links" context, ignore the current item).




Tags:

access:  public


Parameters:

string   $id  
string   $tplt  
string   $open  
boolean   $recursive  
string   $skip  

[ Top ]

method trail [line 571]

array trail( string $id, [string $tplt = ''], [boolean $home = true], [mixed $separator = ' > '])

Generates a breadcrumb trail from the start of the tree to the specified item, returned as an array of template-rendered items. If $home is true, add a 'home' link by calling the homeLink() method.



Tags:

access:  public


Parameters:

string   $id  
string   $tplt  
boolean   $home  

[ Top ]


Copyright © 2007, SIMIAN systems Inc.
All rights reserved. Privacy policy
Documentation generated on Tue, 13 Feb 2007 17:18:09 -0600 by Sitellite AppDoc and phpDocumentor 1.2.2