summaryrefslogtreecommitdiff
path: root/inc/parser
diff options
context:
space:
mode:
authorChristopher Smith <chris@jalakai.co.uk>2013-08-03 00:40:34 +0200
committerChristopher Smith <chris@jalakai.co.uk>2013-08-03 00:40:34 +0200
commitb8b64ed77285e4d753d35d4ceab0516be597a2f1 (patch)
tree7cc1a82a5887a9efeb3f9160f98613e65e404ba0 /inc/parser
parentaf07997c5ff7cc096965159d90158e3710d2d019 (diff)
parent586da9c1028b1013e8dc47911ba430671a389b5b (diff)
downloadrpg-b8b64ed77285e4d753d35d4ceab0516be597a2f1.tar.gz
rpg-b8b64ed77285e4d753d35d4ceab0516be597a2f1.tar.bz2
Merge branch 'master' into configmgr_improvements
Diffstat (limited to 'inc/parser')
-rw-r--r--inc/parser/metadata.php30
-rw-r--r--inc/parser/parser.php8
2 files changed, 29 insertions, 9 deletions
diff --git a/inc/parser/metadata.php b/inc/parser/metadata.php
index e17b82f8b..d64fe4d77 100644
--- a/inc/parser/metadata.php
+++ b/inc/parser/metadata.php
@@ -282,8 +282,10 @@ class Doku_Renderer_metadata extends Doku_Renderer {
function internallink($id, $name = NULL){
global $ID;
- if(is_array($name))
+ if(is_array($name)) {
$this->_firstimage($name['src']);
+ if ($name['type'] == 'internalmedia') $this->_recordMediaUsage($name['src']);
+ }
$default = $this->_simpleTitle($id);
@@ -304,8 +306,10 @@ class Doku_Renderer_metadata extends Doku_Renderer {
}
function externallink($url, $name = NULL){
- if(is_array($name))
+ if(is_array($name)) {
$this->_firstimage($name['src']);
+ if ($name['type'] == 'internalmedia') $this->_recordMediaUsage($name['src']);
+ }
if ($this->capture){
$this->doc .= $this->_getLinkTitle($name, '<' . $url . '>');
@@ -313,8 +317,10 @@ class Doku_Renderer_metadata extends Doku_Renderer {
}
function interwikilink($match, $name = NULL, $wikiName, $wikiUri){
- if(is_array($name))
+ if(is_array($name)) {
$this->_firstimage($name['src']);
+ if ($name['type'] == 'internalmedia') $this->_recordMediaUsage($name['src']);
+ }
if ($this->capture){
list($wikiUri, $hash) = explode('#', $wikiUri, 2);
@@ -324,8 +330,10 @@ class Doku_Renderer_metadata extends Doku_Renderer {
}
function windowssharelink($url, $name = NULL){
- if(is_array($name))
+ if(is_array($name)) {
$this->_firstimage($name['src']);
+ if ($name['type'] == 'internalmedia') $this->_recordMediaUsage($name['src']);
+ }
if ($this->capture){
if ($name) $this->doc .= $name;
@@ -334,8 +342,10 @@ class Doku_Renderer_metadata extends Doku_Renderer {
}
function emaillink($address, $name = NULL){
- if(is_array($name))
+ if(is_array($name)) {
$this->_firstimage($name['src']);
+ if ($name['type'] == 'internalmedia') $this->_recordMediaUsage($name['src']);
+ }
if ($this->capture){
if ($name) $this->doc .= $name;
@@ -347,6 +357,7 @@ class Doku_Renderer_metadata extends Doku_Renderer {
$height=NULL, $cache=NULL, $linking=NULL){
if ($this->capture && $title) $this->doc .= '['.$title.']';
$this->_firstimage($src);
+ $this->_recordMediaUsage($src);
}
function externalmedia($src, $title=NULL, $align=NULL, $width=NULL,
@@ -439,6 +450,15 @@ class Doku_Renderer_metadata extends Doku_Renderer {
$this->firstimage = $src;
}
}
+
+ function _recordMediaUsage($src) {
+ global $ID;
+
+ list ($src, $hash) = explode('#', $src, 2);
+ if (media_isexternal($src)) return;
+ resolve_mediaid(getNS($ID), $src, $exists);
+ $this->meta['relation']['media'][$src] = $exists;
+ }
}
//Setup VIM: ex: et ts=4 :
diff --git a/inc/parser/parser.php b/inc/parser/parser.php
index 915899f53..4af1cd333 100644
--- a/inc/parser/parser.php
+++ b/inc/parser/parser.php
@@ -454,8 +454,8 @@ class Doku_Parser_Mode_table extends Doku_Parser_Mode {
}
function connectTo($mode) {
- $this->Lexer->addEntryPattern('\n\^',$mode,'table');
- $this->Lexer->addEntryPattern('\n\|',$mode,'table');
+ $this->Lexer->addEntryPattern('\s*\n\^',$mode,'table');
+ $this->Lexer->addEntryPattern('\s*\n\|',$mode,'table');
}
function postConnect() {
@@ -555,7 +555,7 @@ class Doku_Parser_Mode_preformatted extends Doku_Parser_Mode {
class Doku_Parser_Mode_code extends Doku_Parser_Mode {
function connectTo($mode) {
- $this->Lexer->addEntryPattern('<code(?=.*</code>)',$mode,'code');
+ $this->Lexer->addEntryPattern('<code\b(?=.*</code>)',$mode,'code');
}
function postConnect() {
@@ -571,7 +571,7 @@ class Doku_Parser_Mode_code extends Doku_Parser_Mode {
class Doku_Parser_Mode_file extends Doku_Parser_Mode {
function connectTo($mode) {
- $this->Lexer->addEntryPattern('<file(?=.*</file>)',$mode,'file');
+ $this->Lexer->addEntryPattern('<file\b(?=.*</file>)',$mode,'file');
}
function postConnect() {