|
|
|
File: C:/usr/local/lib/php/blueshoes-4.2/core/html/Bs_HtmlNavigation.class.php
BlueShoes Application Framework - html
Bs_HtmlNavigation
Bs_Object | +-- Bs_HtmlNavigation
**********************************************************************
|
private class Bs_HtmlNavigation extends Bs_Object
**********************************************************************
HtmlNavigation classuses styles, usually from xml definitions.dependencies: none
| Authors | |
| Version | 4.0.$id$ |
| Copyright | blueshoes.org |
|
| |
|
Methods inherited from Bs_Object |
| isex, isexception, tostring, persist, unpersist, bs_object, bbsetoutput, bbawake, bbisawake, bbxmsg, bbxfunctionstart, bbxfunctionend, bbxecho, bbxvar, bbxvardump, bbforcetrace, bbbufferstart, bbbufferget, bbbufferendflush, bbbufferendclean |
|
|
|
|
|
Private Field Summary |
| array |
$_dataspecial cases: hash keys 'id', 'active' and 'parent' will be added (partly). |
| array |
$_stylethe style information. |
| string |
$_requestUri |
|
Public Method Details |
Bs_HtmlNavigation |
|
public void Bs_HtmlNavigation( )
|
| |
Constructor
|
| Returns |
void |
|
setData |
|
public void setData( array $data )
|
| |
sets the navigation data.
example array structure of $data:$data = array(0 => array('caption' => 'Links','children' => array(0 => array('url' => 'http://www.blueshoes.org/','caption' => 'blueshoes homepage','target' => '_self'),1 => array('url' => 'http://www.php.net/','caption' => 'php','target' => '_blank'))));so it's a structured array with [some] of the keys'caption' => text to display. must have.can be html code like <img src="imageWithTextThatLooksBetterThanPlainText.gif">'url' => url to link to. not specifield = no link.'target' => where to link 'url' to. not specified = '_self'.'children' => array with children of that element.defaultActivedefaultActiveSelfdefaultActiveSiblingdefaultActiveChilddefaultActiveParentchildrenActivechildrenActiveSelfchildrenActiveSiblingchildrenActiveChildchildrenActiveParentthat example creates a nav like this:+ Links+ blueshoes homepage+ phpthis method also sets a unique id for each element.
|
| Parameter |
|
| array |
$data |
|
|
(vector, see above) |
|
| Returns |
void |
|
setCurrentPage |
|
public void setCurrentPage( string $requestUri )
|
| |
sets which page is currently active (been viewed by the user).
the requestUri is something like "/path/to/file.html".
|
| Parameter |
|
|
| Returns |
void |
|
setStyle |
|
public void setStyle( array $style )
|
| |
sets the styles
|
| Parameter |
|
|
| Returns |
void |
| See Also |
$_style |
|
parseLinkStyle |
|
public string parseLinkStyle( string $linkStyle, array $data, [ string $linkFormat, string $noLinkFormat ] )
|
| |
creates a navigation element with the given style and data.
used internally, feel free to use it from outside this class.example:parseLinkStyle("<b>__LINK__</b>", array('caption'=>'blueshoes', 'url'=>'http://www.blueshoes.org/'));will return <b><a href="" target="http://www.blueshoes.org/">blueshoes</a></b>the special strings may be used in the $linkStyle param:__LINK____URL____TARGET____CAPTION____CAPTION_URLENCODE__
|
| Parameter |
|
|
|
|
|
| string |
$linkFormat |
= >>NULL,<< |
|
|
|
|
| string |
$noLinkFormat |
= >>NULL<< |
|
|
|
| Returns |
string |
|
toHtml |
|
public string toHtml( )
|
| |
returns the navigation as html output
Warning: documentation is missing.
|
| Returns |
string (html, may be an empty string.) |
| See Also |
toString() |
|
|
Private Method Details |
_locateCurrentPage |
|
private void _locateCurrentPage( array &$arr )
|
| |
to know which is the active page, we have to find it in our navigation data array.
|
| Parameter |
|
|
| Returns |
void |
| See Also |
setCurrentPage() |
|
_walkTreeUp |
|
private void _walkTreeUp( &$arr )
|
| |
see _locateCurrentPage()
|
| Parameter |
|
|
&$arr |
|
|
Warning: documentation is missing. |
|
| Returns |
void |
|
_walkTreeDown |
|
private void _walkTreeDown( &$arr )
|
| |
see _locateCurrentPage()
|
| Parameter |
|
|
&$arr |
|
|
Warning: documentation is missing. |
|
| Returns |
void |
|
_walkSibling |
|
private void _walkSibling( &$arr )
|
| |
see _locateCurrentPage()
|
| Parameter |
|
|
&$arr |
|
|
Warning: documentation is missing. |
|
| Returns |
void |
|
_addUniqueId |
|
private void _addUniqueId( array &$data, [ string $idPrefix ] )
|
| |
helper function that calls itself recursively to add the
unique id number 'id'.
|
| Parameter |
|
|
|
| string |
$idPrefix |
= >>''<< |
|
(used internally only) |
|
| Returns |
void |
|
_addParent |
|
private void _addParent( array &$data, [ string $parent ] )
|
| |
helper function that calls itself recursively to add the
link back to the parent array element (as reference).
|
| Parameter |
|
|
|
| string |
$parent |
= >>NULL<< |
|
(passed by ref, used internally) |
|
| Returns |
void |
|
_setDefaultStyle |
|
private void _setDefaultStyle( )
|
| |
sets a stupid default style (if we don't have another one)
so at least the navigation gets displayed. ugly, of course.
|
| Returns |
void |
|
_getStyleForLevel |
|
private array _getStyleForLevel( int $level )
|
| |
returns the appropriate style for the given level.
|
| Parameter |
|
|
| Returns |
array |
| Throws |
bool FALSE |
|
_toHtmlHelper |
|
private string _toHtmlHelper( array $data, [ integer $level ] )
|
| |
helper function, loops itself recursively.
|
| Parameter |
|
|
|
| integer |
$level |
= >>1<< |
|
(used internally, don't fuck with it.) |
|
| Returns |
string (html code) |
|
parseHeadFootStyle |
|
private void parseHeadFootStyle( $style, $parentId )
|
| |
Warning: documentation is missing.
|
| Parameter |
|
|
$style |
|
|
Warning: documentation is missing. |
|
|
|
$parentId |
|
|
Warning: documentation is missing. |
|
| Returns |
void |
|
_localEval |
|
private void _localEval( $str )
|
| |
Warning: documentation is missing.
|
| Parameter |
|
|
$str |
|
|
Warning: documentation is missing. |
|
| Returns |
void |
|
|
Private Field Details |
$_data |
|
private array $_data
>><<
special cases: hash keys 'id', 'active' and 'parent' will be added (partly).
see code for details. used internally only anyway.
|
| See Also |
setData() |
|
$_style |
|
private array $_style
>><<
the style information.
it's a structured array (hash), like this:'head' => gets added on top of the navigation. example: "nav starts here"'foot' => gets added at the end of the navigation.'empty' => gets spitted out if there is no navigation data. then even 'head'and 'foot' are ignored. example: "no navigation data"'level' => container for the levels that follow now.'1' => container for level 1. it can be any number, eg '2' would belevel 2. '3+' means 'all levels starting at 3, and above'.'3-7' means all levels from 3 to 7 (including 3 and 7). noother special cases (there is no '-7' to say 'everything from 1 to 7).levels start at number 1, not 0.'head' => gets added on top of every navigation entry for that level.example: "nbsp;nbsp;nbsp;" (to indent 3 spaces).'foot' => gets added at the end of every navigation entry for that level.example: "<br>" (to add a line break).'linkFormat' => you can overwrite the default <a href ...> code.'link' => container for the link itself.'default' => navigation link. example: "<b>__LINK__</b>"the default is used ... todo finish that documentation.'children' => used if set and the element has children.'defaultActive' => same as default, plus this link is currently active.'childrenActive' => same as children, plus this link is currently active.__LINK__ is a placeholder for <a href="__URL__">__CAPTION__</a>__URL__ is a placeholder for your url, eg http://www.blueshoes.org/__TARGET__ is a placeholder for your url target, eg _blank, _self, _top, ...__CAPTION__ is a placeholder for your navigation caption, eg "blueshoes homepage"__CAPTION_URLENCODE__ is a __CAPTION__ with rawurlencode() appliednote: you can even use php code in your link definition strings! (woohoo :)the following vars are usable in that scope:$level => int, the level you're in$style => todo$data => todo$dataElement => todo$styleElement => todoexample:'default' => '<tr><td><? php for ($i=1; $i<$level; $i++) { echo " "; }? >__LINK__</td></tr>'note: replace the spaces in "<? php" and "? >". i had to add them so my editor does not freak out.also see _setDefaultStyle() for a simple example.
|
| See Also |
_setDefaultStyle() |
|
$_requestUri |
|
private string $_requestUri
>><<
|
| See Also |
setCurrentPage() |
|
|
|
|
|
| PHPDoc 1.0beta |