aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorAndreas Gohr <andi@splitbrain.org>2016-11-13 11:45:11 +0100
committerGitHub <noreply@github.com>2016-11-13 11:45:11 +0100
commit1f0bb9cd65aee190f6267a051fae58890de4893f (patch)
tree3706de89c11a1842c09f5784359d916c6da5da4b
parentd88476abf90eea37f4760428dfbe2af4e6c47e67 (diff)
parent6efc45a25e0ef5d61585c38faaeebb6cf265281f (diff)
downloaddokuwiki-1f0bb9cd65aee190f6267a051fae58890de4893f.tar.gz
dokuwiki-1f0bb9cd65aee190f6267a051fae58890de4893f.zip
Merge pull request #1737 from dmak/issue-1614
Implemented interwiki substitution for external images (issue #1614).
-rw-r--r--inc/common.php11
-rw-r--r--inc/parser/handler.php6
-rw-r--r--inc/parser/xhtml.php5
3 files changed, 19 insertions, 3 deletions
diff --git a/inc/common.php b/inc/common.php
index 7f71696cd..ff32fe17a 100644
--- a/inc/common.php
+++ b/inc/common.php
@@ -835,6 +835,17 @@ function clientismobile() {
}
/**
+ * 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
*
* If $conf['dnslookups'] is disabled it simply returns the input string
diff --git a/inc/parser/handler.php b/inc/parser/handler.php
index f477d36f8..a5e7f39cd 100644
--- a/inc/parser/handler.php
+++ b/inc/parser/handler.php
@@ -446,7 +446,7 @@ class Doku_Handler {
//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 = explode('>',$link[0],2);
$this->_addCall(
@@ -693,8 +693,8 @@ function Doku_Handler_Parse_Media($match) {
$cache = 'cache';
}
- // Check whether this is a local or remote image
- if ( media_isexternal($src) ) {
+ // Check whether this is a local or remote image or interwiki
+ if (media_isexternal($src) || link_isinterwiki($src)){
$call = 'externalmedia';
} else {
$call = 'internalmedia';
diff --git a/inc/parser/xhtml.php b/inc/parser/xhtml.php
index 2efb1d831..724981820 100644
--- a/inc/parser/xhtml.php
+++ b/inc/parser/xhtml.php
@@ -1186,6 +1186,11 @@ class Doku_Renderer_xhtml extends Doku_Renderer {
*/
function externalmedia($src, $title = null, $align = null, $width = null,
$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);
$noLink = false;
$render = ($linking == 'linkonly') ? false : true;