Class Gadget_Tree_Serializer_Menu

Description

Gadget_Tree_Serializer_Menu

HTML tree menu serializer

  • since: 1.0

Located in /Gadget/Tree/Serializer/Menu.php (line 31)

Gadget_Object
   |
   --Gadget_Tree_Serializer
      |
      --Gadget_Tree_Serializer_Menu
Variable Summary
Method Summary
bool cookieExpandsNode (string $id)
string hiddenElements (bool $hidden)
string onChildsEnter (mixed &$node)
string onChildsExit ()
string onEnd ()
string onNodeEnter (mixed &$node)
string onNodeExit ()
string onStart ()
Variables
string $columnClassCol1 = 'Gadget_Tree_Col1' (line 73)

Column Class for Column 1

string $columnClassCol2 = 'Gadget_Tree_Col2' (line 80)

Column Class for Column 2

string $cookiePath = '/' (line 143)

Cookie Path

string $displayStyle = 'block' (line 94)

Display Style of shown/unhidden nodes/elements

mixed $expandedImageSuffix = '-expanded' (line 129)

Expandend Image Suffix

array $hideElements = array() (line 87)

Element IDs to hide while initializing the tree node state

string $imagePath = '/images' (line 136)

URL Path to Images

string $javascript = '
<script type="text/javascript"><!--
function GTM_changeState(node, postfix, changeExpImage)
{
var expanded;

{%hideElements%}

if (node.tagName == "IMG") {
expanded = GTM_changeImg(node, postfix, changeExpImage);
}

while (node && node.tagName != "{%nodeTag%}") {
node = node.parentNode;
}

if (node && node.tagName == "{%nodeTag%}") {
var child = node.firstChild;
while (child && child.tagName != "{%menuTag%}") {
child = child.nextSibling;
}
if (child && child.tagName == "{%menuTag%}") {
child.style.display = (child.style.display == "none") ?
"{%displayStyle%}" : "none";
}
}

if ({%useCookies%}) {
GTM_rememberState(node, expanded);
}

{%unhideElements%}
}

function GTM_changeImg(node, postfix, changeExpImage)
{
var exp_key = "{%expandedImageSuffix%}";
var off_img = "minus"+ postfix +".gif";
var on_img = "plus"+ postfix +".gif";
var path = node.src.substr(0, node.src.lastIndexOf("/"));
var expanded;

if (node.src == path +"/"+ on_img) {
node.src = path +"/"+ off_img;
expanded = true;
} else {
node.src = path +"/"+ on_img;
expanded = false;
}

if (changeExpImage && node.nextSibling && node.nextSibling.tagName == "IMG") {
if (expanded) {
node.nextSibling.src = node.nextSibling.src.substr(0, node.nextSibling.src.length-4) + exp_key + node.nextSibling.src.substr(node.nextSibling.src.length-4);
} else {
node.nextSibling.src = node.nextSibling.src.replace(exp_key, "");
}
}

return expanded;
}

function GTM_rememberState(node, expanded)
{
var key = "Gadget_Tree_Menu_{%menuId%}=";
var nds = GTM_fetchStateCookie();
var add = node.getAttribute("ID");

if (expanded) {
if (!GTM_lookupCookieState(add)) {
nds += add +",";
}
} else {
if (GTM_lookupCookieState(add)) {
nds = nds.replace(add, "").replace(/,{2,}/, ",");
}
}

document.cookie = key + nds + "; path={%cookiePath%}";
}

function GTM_fetchStateCookie()
{
var key = "Gadget_Tree_Menu_{%menuId%}=";
var pos = document.cookie.indexOf(key);
var len = document.cookie.length;

if (pos == -1) {
return "";
}
pos += key.length;

return document.cookie.substring(pos, len).replace(/;.*/,"");
}

function GTM_lookupCookieState(nodeId)
{
return -1 != GTM_fetchStateCookie().indexOf(nodeId +",");
}

function GTM_initState(nodeId, postfix, expimg, hasimg)
{
if (!{%useCookies%} || !GTM_lookupCookieState(nodeId)) {
if ({%useImages%}) {
var imgNodes = document.getElementById(nodeId).firstChild.getElementsByTagName("IMG");
var imgCount = hasimg + ({%useFolderImages%} ? 2 : 1);
GTM_changeState(imgNodes.item(imgNodes.length - imgCount), postfix, expimg);
} else {
GTM_changeState(document.getElementById(nodeId), postfix, expimg);
}
}
}
//--></script>
'
(line 150)

Javascript

string $menuClass = 'Gadget_Tree_Menu' (line 52)

Menu Class

string $menuId = 'TreeMenu' (line 38)

Menu ID

string $menuTag = 'ul' (line 45)

Menu Tag

string $nodeClass = '' (line 66)

Node Class

int $nodeCnt = 0 (line 171)

Node Count

array $nodeIds = array() (line 164)

Node IDs to hide initially (computed at run-time)

string $nodeTag = 'li' (line 59)

Node Tag

string $stylesheet = '
<style type="text/css">
{%menuTag%}#{%menuId%},
{%menuTag%}#{%menuId%} {%nodeTag%},
{%menuTag%}#{%menuId%} {%menuTag%} {
padding: 0;
margin: 0;
}
{%menuTag%}#{%menuId%} {%nodeTag%} {
list-style-type: none;
}
{%menuTag%}#{%menuId%} img {
vertical-align: middle;
}
{%menuTag%}#{%menuId%} table {
width: auto;
border-collapse: collapse;
}
{%menuTag%}#{%menuId%} table td.{%classCol1} {
white-space: pre;
}
</style>
'
(line 157)

Stylesheet

bool $useColumns = true (line 108)

Whether to use Table Columns (if the actual node name/data is longer)

bool $useCookies = true (line 101)

Whether to use Cookies for maintaining the State

bool $useFolderImages = true (line 122)

Whether Nodes that have Childs should be displayed with a Folder Image

bool $useImages = true (line 115)

Whether to use images

Methods
cookieExpandsNode (line 385)

Cookie expands Node

  • access: protected
bool cookieExpandsNode (string $id)
  • string $id
hiddenElements (line 400)

Hidden Elements

  • access: protected
string hiddenElements (bool $hidden)
  • bool $hidden
imagePostfix (line 367)

Image Postfix

  • access: protected
string imagePostfix (object Gadget_Tree_Menu_Node &$node)
onChildsEnter (line 344)

On Node Exit

  • access: protected
string onChildsEnter (mixed &$node)

Redefinition of:
Gadget_Tree_Serializer::onChildsEnter()
On Childs Enter
onChildsExit (line 355)

On Node Exit

  • access: protected
string onChildsExit ()

Redefinition of:
Gadget_Tree_Serializer::onChildsExit()
On Childs Exit
onEnd (line 218)

On End

  • access: protected
string onEnd ()

Redefinition of:
Gadget_Tree_Serializer::onEnd()
On End
onNodeEnter (line 235)

On Node Enter

  • access: protected
string onNodeEnter (mixed &$node)

Redefinition of:
Gadget_Tree_Serializer::onNodeEnter()
On Node Enter
onNodeExit (line 333)

On Node Exit

  • access: protected
string onNodeExit ()

Redefinition of:
Gadget_Tree_Serializer::onNodeExit()
On Node Exit
onStart (line 179)

On Start

  • access: protected
string onStart ()

Redefinition of:
Gadget_Tree_Serializer::onStart()
On Start

Inherited Methods

Inherited From Gadget_Tree_Serializer

Gadget_Tree_Serializer::onChildsEnter()
Gadget_Tree_Serializer::onChildsExit()
Gadget_Tree_Serializer::onEnd()
Gadget_Tree_Serializer::onNodeEnter()
Gadget_Tree_Serializer::onNodeExit()
Gadget_Tree_Serializer::onStart()
Gadget_Tree_Serializer::serialize()
Gadget_Tree_Serializer::serializeTree()

Inherited From Gadget_Object

Gadget_Object::Gadget_Object()
Gadget_Object::onAfterConstruct()
Gadget_Object::onBeforeConstruct()
Gadget_Object::setOptions()

Documentation generated on Sun, 03 Jul 2005 12:45:55 +0200 by phpDocumentor 1.3.0RC3