Revisión | d82def10cf5f997425492b8484b43622ca33df8e (tree) |
---|---|
Tiempo | 2019-03-29 10:30:39 |
Autor | umorigu <umorigu@gmai...> |
Commiter | umorigu |
BugTrack/2487 READONLY - Link only existing pages in topicpath title
@@ -303,7 +303,8 @@ EOS; | ||
303 | 303 | } |
304 | 304 | // Topicpath title |
305 | 305 | $topicpath_data = ''; |
306 | - if ($topicpath_title && exist_plugin('topicpath')) { | |
306 | + if ($topicpath_title && exist_plugin('topicpath') && | |
307 | + function_exists('plugin_topicpath_parent_links')) { | |
307 | 308 | $parents = plugin_topicpath_parent_links($page); |
308 | 309 | $h_topicpath = htmlsc_json($parents); |
309 | 310 | $topicpath_data = <<<EOS |
@@ -32,6 +32,26 @@ function plugin_topicpath_convert() | ||
32 | 32 | |
33 | 33 | function plugin_topicpath_parent_links($page) |
34 | 34 | { |
35 | + $links = plugin_topicpath_parent_all_links($page); | |
36 | + if (PKWK_READONLY) { | |
37 | + $active_links = array(); | |
38 | + foreach ($links as $link) { | |
39 | + if (is_page($link['page'])) { | |
40 | + $active_links[] = $link; | |
41 | + } else { | |
42 | + $active_links[] = array( | |
43 | + 'page' => $link['page'], | |
44 | + 'leaf' => $link['leaf'], | |
45 | + ); | |
46 | + } | |
47 | + } | |
48 | + return $active_links; | |
49 | + } | |
50 | + return $links; | |
51 | +} | |
52 | + | |
53 | +function plugin_topicpath_parent_all_links($page) | |
54 | +{ | |
35 | 55 | $parts = explode('/', $page); |
36 | 56 | $parents = array(); |
37 | 57 | for ($i = 0, $pos = 0; $pos = strpos($page, '/', $i); $i = $pos + 1) { |
@@ -50,7 +70,7 @@ function plugin_topicpath_inline() | ||
50 | 70 | global $vars, $defaultpage; |
51 | 71 | $page = isset($vars['page']) ? $vars['page'] : ''; |
52 | 72 | if ($page == '' || $page == $defaultpage) return ''; |
53 | - $parents = plugin_topicpath_parent_links($page); | |
73 | + $parents = plugin_topicpath_parent_all_links($page); | |
54 | 74 | $topic_path = array(); |
55 | 75 | foreach ($parents as $p) { |
56 | 76 | if (PKWK_READONLY && !is_page($p['page'])) { |
@@ -583,11 +583,17 @@ window.addEventListener && window.addEventListener('DOMContentLoaded', function( | ||
583 | 583 | var fragment = document.createDocumentFragment(); |
584 | 584 | for (var i = 0, n = topicpathLinks.length; i < n; i++) { |
585 | 585 | var path = topicpathLinks[i]; |
586 | - var a1 = document.createElement('a'); | |
587 | - a1.setAttribute('href', path.uri); | |
588 | - a1.setAttribute('title', path.page); | |
589 | - a1.textContent = path.leaf; | |
590 | - fragment.appendChild(a1); | |
586 | + if (path.uri) { | |
587 | + var a1 = document.createElement('a'); | |
588 | + a1.setAttribute('href', path.uri); | |
589 | + a1.setAttribute('title', path.page); | |
590 | + a1.textContent = path.leaf; | |
591 | + fragment.appendChild(a1); | |
592 | + } else { | |
593 | + var s1 = document.createElement('span'); | |
594 | + s1.textContent = path.leaf; | |
595 | + fragment.appendChild(s1); | |
596 | + } | |
591 | 597 | var span = document.createElement('span'); |
592 | 598 | span.className = 'topicpath-slash'; |
593 | 599 | span.textContent = '/'; |