Skip to content
Snippets Groups Projects
Commit 6efc45a2 authored by Dmitry Katsubo's avatar Dmitry Katsubo
Browse files

Implemented interwiki substitution for external images (issue #1614).

parent 12762111
No related branches found
No related tags found
No related merge requests found
...@@ -834,6 +834,17 @@ function clientismobile() { ...@@ -834,6 +834,17 @@ function clientismobile() {
return false; return false;
} }
/**
* check if a given link is interwiki link
*
* @param string $link the link, e.g. "wiki>page"
* @return bool
*/
function link_isinterwiki($link){
if (preg_match('/^[a-zA-Z0-9\.]+>/u',$link)) return true;
return false;
}
/** /**
* Convert one or more comma separated IPs to hostnames * Convert one or more comma separated IPs to hostnames
* *
......
...@@ -446,7 +446,7 @@ class Doku_Handler { ...@@ -446,7 +446,7 @@ class Doku_Handler {
//decide which kind of link it is //decide which kind of link it is
if ( preg_match('/^[a-zA-Z0-9\.]+>{1}.*$/u',$link[0]) ) { if ( link_isinterwiki($link[0]) ) {
// Interwiki // Interwiki
$interwiki = explode('>',$link[0],2); $interwiki = explode('>',$link[0],2);
$this->_addCall( $this->_addCall(
...@@ -693,8 +693,8 @@ function Doku_Handler_Parse_Media($match) { ...@@ -693,8 +693,8 @@ function Doku_Handler_Parse_Media($match) {
$cache = 'cache'; $cache = 'cache';
} }
// Check whether this is a local or remote image // Check whether this is a local or remote image or interwiki
if ( media_isexternal($src) ) { if (media_isexternal($src) || link_isinterwiki($src)){
$call = 'externalmedia'; $call = 'externalmedia';
} else { } else {
$call = 'internalmedia'; $call = 'internalmedia';
......
...@@ -1186,6 +1186,11 @@ class Doku_Renderer_xhtml extends Doku_Renderer { ...@@ -1186,6 +1186,11 @@ class Doku_Renderer_xhtml extends Doku_Renderer {
*/ */
function externalmedia($src, $title = null, $align = null, $width = null, function externalmedia($src, $title = null, $align = null, $width = null,
$height = null, $cache = null, $linking = null, $return = false) { $height = null, $cache = null, $linking = null, $return = false) {
if(link_isinterwiki($src)){
list($shortcut, $reference) = explode('>', $src, 2);
$exists = null;
$src = $this->_resolveInterWiki($shortcut, $reference, $exists);
}
list($src, $hash) = explode('#', $src, 2); list($src, $hash) = explode('#', $src, 2);
$noLink = false; $noLink = false;
$render = ($linking == 'linkonly') ? false : true; $render = ($linking == 'linkonly') ? false : true;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment