Date: 12/12/99
- Next message: ssilk: "[PHPLIB-DEV] cvs commit"
- Previous message: Massimiliano Masserelli: "[PHPLIB-DEV] ct_dbm question"
- Next in thread: ssilk: "[PHPLIB-DEV] cvs commit"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
From: padraic
Date: Sun Dec 12 17:30:24 1999
Modified files:
php-lib/CHANGES
php-lib/doc/sgml/05-menu.sgml
php-lib/php/menu.inc
Log message:
cleaned up, documented... the title feature
in the menu class.
Index: php-lib/CHANGES
diff -u php-lib/CHANGES:1.151 php-lib/CHANGES:1.152
--- php-lib/CHANGES:1.151 Fri Dec 10 09:51:56 1999
+++ php-lib/CHANGES Sun Dec 12 17:29:51 1999
@@ -1,4 +1,9 @@
-$Id: CHANGES,v 1.151 1999/12/10 08:51:56 mbravo Exp $
+$Id: CHANGES,v 1.152 1999/12/12 16:29:51 padraic Exp $
+
+12-Dec-1999 padraic
+ - cleaned up, documented... the title feature of in
+ the menu class. Added public method get_title() and
+ variables title, title_delim to support this feature.
10-Dec-1999 mbravo
- fixed permissions array handling and leftover references to 'uid' instead
Index: php-lib/doc/sgml/05-menu.sgml
diff -u php-lib/doc/sgml/05-menu.sgml:1.1 php-lib/doc/sgml/05-menu.sgml:1.2
--- php-lib/doc/sgml/05-menu.sgml:1.1 Fri Oct 29 00:13:15 1999
+++ php-lib/doc/sgml/05-menu.sgml Sun Dec 12 17:29:52 1999
@@ -1,4 +1,4 @@
-<!-- $Id: 05-menu.sgml,v 1.1 1999/10/28 22:13:15 kk Exp $ -->
+<!-- $Id: 05-menu.sgml,v 1.2 1999/12/12 16:29:52 padraic Exp $ -->
<sect1>Menu
<p>
Menu will generate a hierarchical menu of clickable items
@@ -28,8 +28,8 @@
<table>
<tabular ca="">
-$urlmap<colsep>Hash. Maps a relative URL as seen in
-PHP_SELF to a menustring.<rowsep>
+$urlmap<colsep>Hash. Maps a relative URL as seen
+in PHP_SELF to a menustring.<rowsep>
$map<colsep>Menustring. Current position in menu.<rowsep>
@@ -48,6 +48,10 @@
be shown. This menu item is always the menu root, adding an
extra level of indentation.<rowsep>
+$title<colsep>String. After calling <tt/get_title()/, this variable contains the title of the page based on it's location in the menu hierarchy.<rowsep>
+
+$title_delim<colsep>String. Used to delimit (i.e., separate) components in the page title built by <tt/get_title()/. Default is <tt>" : "</tt><rowsep>
+
</tabular>
<caption>Accessible instance variables.</caption>
</table>
@@ -112,6 +116,15 @@
menu item, which should be rendered in way to stand out from the
rest of the menu items.
+<tag>get_title()</tag>
+<p>
+
+This function will calculate the title of the current page based
+on the position of the current page in the menu hierarchy. This
+function uses <tt/$this->title_delim/ to separate the components
+of the title. This function sets <tt/$this>title/ to the calculated
+title and returns the title as a string.
+
<tag>setup()</tag>
<p>
This function initializes the internal arrays of Menu and should
@@ -217,14 +230,14 @@
$m = new Example_Menu;
?><html>
<head>
- <title>Page with a menu</title>
+ <title><?php $m->get_menu() ?></title>
</head>
<body bgcolor="#ffffff">
<table border=1 bgcolor="#eeeeee" cellspacing=0 cellpadding=4>
<tr>
<td colspan=2 valign=top align=center>
- <h1>Page with a menu</h1>
+ <h1><?php print $m->title ?></h1>
</td>
</tr>
<tr>
Index: php-lib/php/menu.inc
diff -u php-lib/php/menu.inc:1.7 php-lib/php/menu.inc:1.8
--- php-lib/php/menu.inc:1.7 Sat Nov 13 22:48:05 1999
+++ php-lib/php/menu.inc Sun Dec 12 17:29:53 1999
@@ -5,7 +5,7 @@
* Copyright (c) 1999 NetUSE GmbH
* Kristian Koehntopp
*
- * $Id: menu.inc,v 1.7 1999/11/13 21:48:05 padraic Exp $
+ * $Id: menu.inc,v 1.8 1999/12/12 16:29:53 padraic Exp $
*
*/
class Menu {
@@ -32,6 +32,9 @@
# Set true if you do not want to see the main menu
var $nomain = false;
+ # Delimiter to separate components of the page title
+ var $title_delim = " : ";
+
/***************************************************************************/
/* public: constructor
*/
@@ -55,14 +58,6 @@
# Determine menu levels up from current position
$r = $this->split_path($this->map);
- unset($this->title);
- while(list($a, $b) = each($r)) {
- if ($this->title) {
- $this->title .= " -> ";
- }
- $this->title .= $this->item["$b"]["title"];
- }
-
# set up the visible menu items
$this->find_visible($r);
@@ -107,7 +102,28 @@
return $str;
}
-
+
+ /* public: build the title of the page based on
+ its location in the menu hierarchy. */
+ function get_title() {
+ global $PHP_SELF;
+ unset($this->title);
+
+ # Determine normalized current position in tree
+ $this->map = $this->normalize_pos($PHP_SELF);
+
+ # Determine menu levels up from current position
+ $r = $this->split_path($this->map);
+
+ while(list($a, $b) = each($r)) {
+ if ($this->title)
+ $this->title .= $this->title_delim;
+ $this->title .= $this->item[$b]["title"];
+ }
+
+ return $this->title;
+ }
+
function shift_in($oldlevel, $level) { ; }
function shift_out($oldlevel, $level) { ; }
-
PHPLIB Developers Mailing List. Send messages to <phplib-dev <email protected>>.
To unsubscribe, send "unsubscribe" to <phplib-dev-request <email protected>> in
the body, not the subject, of your message.
- Next message: ssilk: "[PHPLIB-DEV] cvs commit"
- Previous message: Massimiliano Masserelli: "[PHPLIB-DEV] ct_dbm question"
- Next in thread: ssilk: "[PHPLIB-DEV] cvs commit"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]

