6
6
* @author Gina Häußge, Michael Klier <dokuwiki@chimeric.de>
7
7
* @author Michael Hamann <michael@content-space.de>
8
8
*/
9
+ use dokuwiki \plugin \include \GenericResolver ;
10
+ use dokuwiki \File \PageResolver ;
9
11
10
12
/**
11
13
* Helper functions for the include plugin and other plugins that want to include pages.
@@ -302,7 +304,6 @@ function _convert_instructions(&$ins, $lvl, $page, $sect, $flags, $root_id, $inc
302
304
$ this ->_get_firstsec ($ ins , $ page , $ flags ); // only first section
303
305
}
304
306
305
- $ ns = getNS ($ page );
306
307
$ num = count ($ ins );
307
308
308
309
$ conv_idx = array (); // conversion index
@@ -544,13 +545,12 @@ function _permalink(&$ins, $page, $sect, $flags) {
544
545
*/
545
546
private function adapt_links (&$ ins , $ page , $ included_pages = null ) {
546
547
$ num = count ($ ins );
547
- $ ns = getNS ($ page );
548
548
549
549
for ($ i =0 ; $ i <$ num ; $ i ++) {
550
550
// adjust links with image titles
551
551
if (strpos ($ ins [$ i ][0 ], 'link ' ) !== false && isset ($ ins [$ i ][1 ][1 ]) && is_array ($ ins [$ i ][1 ][1 ]) && $ ins [$ i ][1 ][1 ]['type ' ] == 'internalmedia ' ) {
552
552
// resolve relative ids, but without cleaning in order to preserve the name
553
- $ media_id = resolve_id ( $ ns , $ ins [$ i ][1 ][1 ]['src ' ]);
553
+ $ media_id = ( new GenericResolver ( $ page ))-> resolveId ( $ ins [$ i ][1 ][1 ]['src ' ]);
554
554
// make sure that after resolving the link again it will be the same link
555
555
if ($ media_id [0 ] != ': ' ) $ media_id = ': ' .$ media_id ;
556
556
$ ins [$ i ][1 ][1 ]['src ' ] = $ media_id ;
@@ -567,7 +567,7 @@ private function adapt_links(&$ins, $page, $included_pages = null) {
567
567
$ link_params = $ link_parts [1 ];
568
568
}
569
569
// resolve the id without cleaning it
570
- $ link_id = resolve_id ( $ ns , $ link_id, false );
570
+ $ link_id = ( new GenericResolver ( $ page ))-> resolveId ( $ link_id );
571
571
// this id is internal (i.e. absolute) now, add ':' to make resolve_id work again
572
572
if ($ link_id [0 ] != ': ' ) $ link_id = ': ' .$ link_id ;
573
573
// restore parameters
@@ -579,8 +579,7 @@ private function adapt_links(&$ins, $page, $included_pages = null) {
579
579
$ link_id = $ ins [$ i ][1 ][0 ];
580
580
$ link_parts = explode ('? ' , $ link_id , 2 );
581
581
if (count ($ link_parts ) === 1 ) {
582
- $ exists = false ;
583
- resolve_pageid ($ ns , $ link_id , $ exists );
582
+ $ link_id = (new PageResolver ($ page ))->resolveId ($ link_id );
584
583
585
584
$ link_parts = explode ('# ' , $ link_id , 2 );
586
585
$ hash = '' ;
@@ -725,7 +724,8 @@ function _get_included_pages($mode, $page, $sect, $parent_id, $flags) {
725
724
break ;
726
725
default :
727
726
$ page = $ this ->_apply_macro ($ page , $ parent_id );
728
- resolve_pageid (getNS ($ parent_id ), $ page , $ exists ); // resolve shortcuts and clean ID
727
+ // resolve shortcuts and clean ID
728
+ $ page = (new PageResolver ($ parent_id ))->resolveId ($ page );
729
729
if (auth_quickaclcheck ($ page ) >= AUTH_READ )
730
730
$ pages [] = $ page ;
731
731
}
@@ -843,8 +843,8 @@ function _get_language_of_wiki($id, $parent_id) {
843
843
arsort ($ langs );
844
844
foreach ($ langs as $ lang => $ langq ){
845
845
$ testpage = $ this ->_apply_macro (str_replace ('@BROWSER_LANG@ ' , $ lang , $ id ), $ parent_id );
846
- resolve_pageid ( getNS ($ parent_id ), $ testpage, $ exists );
847
- if ( $ exists ) {
846
+ $ testpage = ( new PageResolver ($ parent_id ))-> resolveId ( $ testpage );
847
+ if ( page_exists ( $ testpage )) {
848
848
$ result = $ lang ;
849
849
break ;
850
850
}
0 commit comments