diff options
author | Renato Botelho <renato@netgate.com> | 2017-01-11 10:00:57 -0200 |
---|---|---|
committer | Renato Botelho <renato@netgate.com> | 2017-01-11 10:00:57 -0200 |
commit | 7cdb1ff98361bd352134d78732fb519957803728 (patch) | |
tree | bcb876642d722031b522c81653b686a7d4aa2db8 /src/usr/local/www/guiconfig.inc | |
parent | 9bec85af54284943d9f2293718e69865e1ecbf68 (diff) | |
parent | edcd75357f0e93b124159314d3306197d5312e6c (diff) | |
download | pfsense-7cdb1ff98361bd352134d78732fb519957803728.zip pfsense-7cdb1ff98361bd352134d78732fb519957803728.tar.gz |
Merge pull request #3369 from phil-davis/breadcrumbs_detail
Diffstat (limited to 'src/usr/local/www/guiconfig.inc')
-rw-r--r-- | src/usr/local/www/guiconfig.inc | 32 |
1 files changed, 28 insertions, 4 deletions
diff --git a/src/usr/local/www/guiconfig.inc b/src/usr/local/www/guiconfig.inc index 2d22114..3b3c1c4 100644 --- a/src/usr/local/www/guiconfig.inc +++ b/src/usr/local/www/guiconfig.inc @@ -525,15 +525,39 @@ function gentitle($title) { } } -function genhtmltitle($title) { +function genhtmltitle($title, $links=true) { + + $num_crumbs = count($title); // If the array contains only one element, there are no breadcrumbs, so don't // add anything else - if (count($title) > 1) { + if ($num_crumbs > 1) { $bc = '<ol class="breadcrumb">'; - foreach ($title as $el) { - $bc .= '<li>'.$el.'</li>'; + if (!is_array($links)) { + $gen_default = ($links === true); + $links = array_fill(0, $num_crumbs, ''); + // If no links passed, then default to a link to self on the last entry. + if ($gen_default) { + $links[$num_crumbs-1] = '@self'; + } + } + + foreach ($title as $idx => $el) { + $href = $links[$idx]; + if (strlen($href) > 0) { + // For convenience, if the caller specifies '@self' then make a link + // to the current page, including any query string. + if ($href == '@self') { + $href = $_SERVER['REQUEST_URI']; + } + if (substr($href, 0, 1) != '/') { + $href = '/' . $href; + } + $bc .= '<li><a href="' . htmlentities($href) . '">' . $el . '</a></li>'; + } else { + $bc .= '<li>' . $el . '</li>'; + } } $bc .= '</ol>'; |