-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* Add a new gerneric resolver to resolve ids without cleaning * Replace deprecated calls * Remove some unused variables
- Loading branch information
Showing
2 changed files
with
20 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?php | ||
namespace dokuwiki\plugin\include; | ||
use dokuwiki\File\Resolver; | ||
|
||
/** | ||
* Resolves ids without cleaning them. | ||
* | ||
* @package dokuwiki\plugin\include | ||
*/ | ||
class GenericResolver extends Resolver { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,8 @@ | |
* @author Gina Häußge, Michael Klier <[email protected]> | ||
* @author Michael Hamann <[email protected]> | ||
*/ | ||
use dokuwiki\plugin\include\GenericResolver; | ||
use dokuwiki\File\PageResolver; | ||
|
||
/** | ||
* 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 | |
$this->_get_firstsec($ins, $page, $flags); // only first section | ||
} | ||
|
||
$ns = getNS($page); | ||
$num = count($ins); | ||
|
||
$conv_idx = array(); // conversion index | ||
|
@@ -544,13 +545,12 @@ function _permalink(&$ins, $page, $sect, $flags) { | |
*/ | ||
private function adapt_links(&$ins, $page, $included_pages = null) { | ||
$num = count($ins); | ||
$ns = getNS($page); | ||
|
||
for($i=0; $i<$num; $i++) { | ||
// adjust links with image titles | ||
if (strpos($ins[$i][0], 'link') !== false && isset($ins[$i][1][1]) && is_array($ins[$i][1][1]) && $ins[$i][1][1]['type'] == 'internalmedia') { | ||
// resolve relative ids, but without cleaning in order to preserve the name | ||
$media_id = resolve_id($ns, $ins[$i][1][1]['src']); | ||
$media_id = (new GenericResolver($page))->resolveId($ins[$i][1][1]['src']); | ||
// make sure that after resolving the link again it will be the same link | ||
if ($media_id[0] != ':') $media_id = ':'.$media_id; | ||
$ins[$i][1][1]['src'] = $media_id; | ||
|
@@ -567,7 +567,7 @@ private function adapt_links(&$ins, $page, $included_pages = null) { | |
$link_params = $link_parts[1]; | ||
} | ||
// resolve the id without cleaning it | ||
$link_id = resolve_id($ns, $link_id, false); | ||
$link_id = (new GenericResolver($page))->resolveId($link_id); | ||
// this id is internal (i.e. absolute) now, add ':' to make resolve_id work again | ||
if ($link_id[0] != ':') $link_id = ':'.$link_id; | ||
// restore parameters | ||
|
@@ -579,8 +579,7 @@ private function adapt_links(&$ins, $page, $included_pages = null) { | |
$link_id = $ins[$i][1][0]; | ||
$link_parts = explode('?', $link_id, 2); | ||
if (count($link_parts) === 1) { | ||
$exists = false; | ||
resolve_pageid($ns, $link_id, $exists); | ||
$link_id = (new PageResolver($page))->resolveId($link_id); | ||
|
||
$link_parts = explode('#', $link_id, 2); | ||
$hash = ''; | ||
|
@@ -725,7 +724,8 @@ function _get_included_pages($mode, $page, $sect, $parent_id, $flags) { | |
break; | ||
default: | ||
$page = $this->_apply_macro($page, $parent_id); | ||
resolve_pageid(getNS($parent_id), $page, $exists); // resolve shortcuts and clean ID | ||
// resolve shortcuts and clean ID | ||
$page = (new PageResolver($parent_id))->resolveId($page); | ||
if (auth_quickaclcheck($page) >= AUTH_READ) | ||
$pages[] = $page; | ||
} | ||
|
@@ -843,8 +843,8 @@ function _get_language_of_wiki($id, $parent_id) { | |
arsort($langs); | ||
foreach($langs as $lang => $langq){ | ||
$testpage = $this->_apply_macro(str_replace('@BROWSER_LANG@', $lang, $id), $parent_id); | ||
resolve_pageid(getNS($parent_id), $testpage, $exists); | ||
if($exists){ | ||
$testpage = (new PageResolver($parent_id))->resolveId($testpage); | ||
if (page_exists($testpage)) { | ||
$result = $lang; | ||
break; | ||
} | ||
|