66 * @author Gina Häußge, Michael Klier <[email protected] > 77 * @author Michael Hamann <[email protected] > 88 */
9+ use dokuwiki \plugin \include \GenericResolver ;
10+ use dokuwiki \File \PageResolver ;
911
1012/**
1113 * 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
302304 $ this ->_get_firstsec ($ ins , $ page , $ flags ); // only first section
303305 }
304306
305- $ ns = getNS ($ page );
306307 $ num = count ($ ins );
307308
308309 $ conv_idx = array (); // conversion index
@@ -544,13 +545,12 @@ function _permalink(&$ins, $page, $sect, $flags) {
544545 */
545546 private function adapt_links (&$ ins , $ page , $ included_pages = null ) {
546547 $ num = count ($ ins );
547- $ ns = getNS ($ page );
548548
549549 for ($ i =0 ; $ i <$ num ; $ i ++) {
550550 // adjust links with image titles
551551 if (strpos ($ ins [$ i ][0 ], 'link ' ) !== false && isset ($ ins [$ i ][1 ][1 ]) && is_array ($ ins [$ i ][1 ][1 ]) && $ ins [$ i ][1 ][1 ]['type ' ] == 'internalmedia ' ) {
552552 // 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 ' ]);
554554 // make sure that after resolving the link again it will be the same link
555555 if ($ media_id [0 ] != ': ' ) $ media_id = ': ' .$ media_id ;
556556 $ ins [$ i ][1 ][1 ]['src ' ] = $ media_id ;
@@ -567,7 +567,7 @@ private function adapt_links(&$ins, $page, $included_pages = null) {
567567 $ link_params = $ link_parts [1 ];
568568 }
569569 // resolve the id without cleaning it
570- $ link_id = resolve_id ( $ ns , $ link_id, false );
570+ $ link_id = ( new GenericResolver ( $ page ))-> resolveId ( $ link_id );
571571 // this id is internal (i.e. absolute) now, add ':' to make resolve_id work again
572572 if ($ link_id [0 ] != ': ' ) $ link_id = ': ' .$ link_id ;
573573 // restore parameters
@@ -579,8 +579,7 @@ private function adapt_links(&$ins, $page, $included_pages = null) {
579579 $ link_id = $ ins [$ i ][1 ][0 ];
580580 $ link_parts = explode ('? ' , $ link_id , 2 );
581581 if (count ($ link_parts ) === 1 ) {
582- $ exists = false ;
583- resolve_pageid ($ ns , $ link_id , $ exists );
582+ $ link_id = (new PageResolver ($ page ))->resolveId ($ link_id );
584583
585584 $ link_parts = explode ('# ' , $ link_id , 2 );
586585 $ hash = '' ;
@@ -725,7 +724,8 @@ function _get_included_pages($mode, $page, $sect, $parent_id, $flags) {
725724 break ;
726725 default :
727726 $ 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 );
729729 if (auth_quickaclcheck ($ page ) >= AUTH_READ )
730730 $ pages [] = $ page ;
731731 }
@@ -843,8 +843,8 @@ function _get_language_of_wiki($id, $parent_id) {
843843 arsort ($ langs );
844844 foreach ($ langs as $ lang => $ langq ){
845845 $ 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 )) {
848848 $ result = $ lang ;
849849 break ;
850850 }
0 commit comments