Skip to content

Commit 24c531d

Browse files
committed
add spaces also to non linked tag in breadcrumbs
1 parent e4c4099 commit 24c531d

File tree

1 file changed

+27
-30
lines changed

1 file changed

+27
-30
lines changed

src/class/wacko.php

Lines changed: 27 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -4478,8 +4478,9 @@ function group_link($group_name, $linking = true, $add_icon = true)
44784478
* Add spaces to WikiWords (if config parameter show_spaces = 1) and replace
44794479
* relative path (/ !/ ../) to icons RootLinkIcon, SubLinkIcon, UpLinkIcon
44804480
*
4481-
* @param string $text Text with WikiWords
4482-
* @return string Text with Wiki Words
4481+
* @param string $text Text with WikiWords
4482+
*
4483+
* @return string Text with Wiki Words
44834484
*/
44844485
function add_spaces($text): ?string
44854486
{
@@ -6693,8 +6694,8 @@ function get_menu_default()
66936694
return (!isset($this->sess->menu_default)) || $this->sess->menu_default;
66946695
}
66956696

6696-
// TODO: do not add
6697-
// - comments, system pages, methodes,
6697+
// TODO:
6698+
// - comments, system pages, methods (?)
66986699
// - url arguments ?profile= ['page_id', 'arguments']
66996700
// - add parameter for trail size in user settings ?
67006701
// parse only once, without included pages (avoid call in run function!)
@@ -6709,23 +6710,25 @@ function set_user_trail($size = 5): void
67096710
{
67106711
$count = count($this->sess->user_trail);
67116712

6712-
if (isset($this->sess->user_trail[$count - 1][0])
6713-
&& $this->sess->user_trail[$count - 1][0] == $page_id)
6714-
{
6715-
// nothing
6716-
}
6717-
else
6713+
if (!(isset($this->sess->user_trail[$count - 1][0])
6714+
&& $this->sess->user_trail[$count - 1][0] == $page_id))
67186715
{
6719-
if (count($this->sess->user_trail) > $size)
6716+
// this is about navigation, remove double entries
6717+
foreach ($this->sess->user_trail as $link)
67206718
{
6721-
$this->sess->user_trail = array_slice($this->sess->user_trail, -$size);
6719+
if ($page_id != $link[0])
6720+
{
6721+
$trail[] = $link;
6722+
}
67226723
}
67236724

6724-
$_user_trail[-1] = [$page_id, $this->page['tag'], $this->page['title']];
6725-
$user_trail = $this->sess->user_trail + $_user_trail;
6726-
$user_trail = array_values($user_trail);
6725+
if (count($trail) > $size)
6726+
{
6727+
$trail = array_slice($trail, -$size);
6728+
}
67276729

6728-
$this->sess->user_trail = $user_trail;
6730+
$trail[-1] = [$page_id, $this->page['tag'], $this->page['title']];
6731+
$this->sess->user_trail = $trail;
67296732
}
67306733
}
67316734
else
@@ -6738,24 +6741,23 @@ function set_user_trail($size = 5): void
67386741
// user trail navigation
67396742
// call this function in your theme header or footer
67406743
// $separator = > »
6741-
function get_user_trail($titles = false, $separator = ' > ', $linking = true, $size = null): string
6744+
function get_user_trail($title = false, $separator = ' > ', $linking = true, $size = null): string
67426745
{
67436746
// don't call this inside the run function, it will also writes all included pages
67446747
// in the user trail because the engine parses them before it includes them
67456748
$this->set_user_trail($size);
67466749

67476750
if (isset($this->sess->user_trail))
67486751
{
6749-
$links = $this->sess->user_trail;
67506752
$result = '';
67516753
$size = (int) $size;
67526754
$i = 0;
67536755

6754-
foreach ($links as $link)
6756+
foreach ($this->sess->user_trail as $link)
67556757
{
67566758
if ($i < $size && $this->page['page_id'] != $link[0])
67576759
{
6758-
if (!$titles)
6760+
if (!$title)
67596761
{
67606762
$result .= $this->link($link[1], '', $link[1]) . $separator;
67616763
}
@@ -6772,14 +6774,7 @@ function get_user_trail($titles = false, $separator = ' &gt; ', $linking = true,
67726774
$i++;
67736775
}
67746776

6775-
if (!$titles)
6776-
{
6777-
$result .= $this->page['tag'];
6778-
}
6779-
else
6780-
{
6781-
$result .= $this->page['title'];
6782-
}
6777+
$result .= $title ? $this->page['title'] : $this->page['tag'];
67836778

67846779
return $result;
67856780
}
@@ -7350,13 +7345,15 @@ function get_page_path($tag = '', $titles = false, $separator = '/', $linking =
73507345
continue;
73517346
}
73527347

7348+
$item = $titles? $this->get_page_title($link) : $step;
7349+
73537350
if ($linking && $link != $this->tag)
73547351
{
7355-
$item = $this->link($link, '', ($titles? $this->get_page_title($link) : $step));
7352+
$item = $this->link($link, '', $item);
73567353
}
73577354
else
73587355
{
7359-
$item = $titles? $this->get_page_title($link) : $step;
7356+
$item = $this->add_spaces($item);
73607357
}
73617358

73627359
$result[] = '<bdi>' . $item . '</bdi>';

0 commit comments

Comments
 (0)