diff options
| author | Greg Roach <fisharebest@gmail.com> | 2014-11-19 19:04:35 +0000 |
|---|---|---|
| committer | Greg Roach <fisharebest@gmail.com> | 2014-11-19 19:04:35 +0000 |
| commit | ca3a1b2267d8ad8d52ff359998c791d54ff2a35a (patch) | |
| tree | da0fade6efd26e771eba6858b34c5bfb8d42ba55 /library/WT/Menu.php | |
| parent | ee5f36e9b58fc3fef678cec00f72ba5eb6a8f310 (diff) | |
| download | webtrees-ca3a1b2267d8ad8d52ff359998c791d54ff2a35a.tar.gz webtrees-ca3a1b2267d8ad8d52ff359998c791d54ff2a35a.tar.bz2 webtrees-ca3a1b2267d8ad8d52ff359998c791d54ff2a35a.zip | |
Unit tests for the menu class
Diffstat (limited to 'library/WT/Menu.php')
| -rw-r--r-- | library/WT/Menu.php | 48 |
1 files changed, 24 insertions, 24 deletions
diff --git a/library/WT/Menu.php b/library/WT/Menu.php index 1f2b38d957..f64dece286 100644 --- a/library/WT/Menu.php +++ b/library/WT/Menu.php @@ -59,7 +59,7 @@ class WT_Menu { * @param string $onclick A javascript onclick handler * @param WT_Menu[] $submenus Any submenus */ - function __construct($label = ' ', $link = '#', $id = '', $onclick = '', $submenus = array()) { + function __construct($label, $link = '#', $id = '', $onclick = '', $submenus = array()) { $this ->setLabel($label) ->setLink($link) @@ -232,7 +232,7 @@ class WT_Menu { if ($c >= 0) { $link .= "timeout_submenu('menu{$id}_subs');"; } - if ($this->onclick !== null) { + if ($this->onclick) { $link .= "\" onclick=\"{$this->onclick}"; } $link .= "\">"; @@ -261,41 +261,41 @@ class WT_Menu { } /** - * Render this menu as an HTML list - for accessible interfaces, search engines and CSS menus + * Render this menu as an HTML list * * @return string */ function getMenuAsList() { - $link = ''; + if ($this->iconclass) { + $class = ' class="' . $this->iconclass . '"'; + } else { + $class = ''; + } + if ($this->onclick) { + $onclick = ' onclick="' . $this->onclick . '"'; + } else { + $onclick = ''; + } if ($this->link) { - if ($this->link == '#') { - if ($this->onclick !== null) { - $link .= ' onclick="' . $this->onclick . '"'; - } - $html = '<a class="' . $this->iconclass . '" href="' . $this->link . '"' . $link . '>' . $this->label . '</a>'; - } else { - $html = '<a class="' . $this->iconclass . '" href="' . $this->link . '"' . $link . '>' . $this->label . '</a>'; - } + $link = ' href="' . $this->link . '"'; } else { - $html = $this->label; + $link = ''; } + if ($this->id) { + $id = ' id="' . $this->id . '"'; + } else { + $id = ''; + } + $html = '<a' . $link . $class . $onclick . '>' . $this->label . '</a>'; if ($this->submenus) { $html .= '<ul>'; foreach ($this->submenus as $submenu) { - if ($submenu) { - if ($submenu->submenus) { - $submenu->iconclass .= ' icon_arrow'; - } - $html .= $submenu->getMenuAsList(); - } + $html .= $submenu->getMenuAsList(); } $html .= '</ul>'; } - if ($this->id) { - return '<li id="' . $this->id . '">' . $html . '</li>'; - } else { - return '<li>' . $html . '</li>'; - } + + return '<li' . $id . '>' . $html . '</li>'; } /** |
