GIT.Harvie.CZ
/
mirrors
/
DokuWiki-Plugin-SVGEdit.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
9b4c1b7
)
started moving svg embeding to function
author
Harvie
<tomas@mudrunka.cz>
Sun, 20 Jun 2010 02:43:10 +0000
(
04:43
+0200)
committer
Harvie
<tomas@mudrunka.cz>
Sun, 20 Jun 2010 02:43:10 +0000
(
04:43
+0200)
syntax.php
patch
|
blob
|
blame
|
history
diff --git
a/syntax.php
b/syntax.php
index c5bd599e4b683486f9c54fca5c703c96beca054f..17224c66d18444f94afaee935b32fe74807db8ea 100755
(executable)
--- a/
syntax.php
+++ b/
syntax.php
@@
-48,12
+48,9
@@
class syntax_plugin_svgedit extends DokuWiki_Syntax_Plugin {
return array($type, $match);
}
return array($type, $match);
}
- function render($format, &$renderer, $data) {
- if ($format!='xhtml') return;
+ function format_svg_embed($svglink, $alt) {
global $ID;
global $ID;
- $svg_wiki_page = trim(substr($data[1], 6, -2)); //name of wiki page containing SVG image
-
//detect image size for stupid browsers (like firefox) - ugly (fails if svg does not contain information about it's size)
$svg_dimensions = '';
preg_match('/width="[0-9]+" height="[0-9]+"/', $data[1].rawWiki($svg_wiki_page), $_);
//detect image size for stupid browsers (like firefox) - ugly (fails if svg does not contain information about it's size)
$svg_dimensions = '';
preg_match('/width="[0-9]+" height="[0-9]+"/', $data[1].rawWiki($svg_wiki_page), $_);
@@
-62,25
+59,38
@@
class syntax_plugin_svgedit extends DokuWiki_Syntax_Plugin {
//use object tag for stupid browsers (like firefox) - ugly (relies on browser identification)
$is_webkit= preg_match('/webkit/', strtolower($_SERVER['HTTP_USER_AGENT']));
if ($is_webkit)
//use object tag for stupid browsers (like firefox) - ugly (relies on browser identification)
$is_webkit= preg_match('/webkit/', strtolower($_SERVER['HTTP_USER_AGENT']));
if ($is_webkit)
- $svgtag='
<img src="
';
+ $svgtag='
img src
';
else
else
- $svgtag='<object '.$svg_dimensions.' data="';
+ $svgtag='object '.$svg_dimensions.' data';
+
+ return '<a href="'.$svglink.'" type="image/svg+xml" /><'.$svgtag.'="'.$svglink.'" alt="'.$alt.'" type="image/svg+xml" /></a>'."<br />";
+ }
+
+ function render($format, &$renderer, $data) {
+ if ($format!='xhtml') return;
+ global $ID;
+
+ $svg_wiki_page = trim(substr($data[1], 6, -2)); //name of wiki page containing SVG image
+
+
if($data[0]==='<svg') {
if($data[0]==='<svg') {
- $svg
enc
= 'data:image/svg+xml;base64,'.base64_encode($data[1]).'" type="image/svg+xml';
- $renderer->doc .=
'<a href="'.$svgenc.'" type="image/svg+xml" />'.$svgtag.$svgenc.'" alt="svg-image@'.$ID.'" /></a>'."<br />"
;
+ $svg
link
= 'data:image/svg+xml;base64,'.base64_encode($data[1]).'" type="image/svg+xml';
+ $renderer->doc .=
$this->format_svg_embed($svglink, 'svg-image@'.$ID)
;
return true;
}
if($data[0]==='{{sv') {
return true;
}
if($data[0]==='{{sv') {
- $svgenc = exportlink($svg_wiki_page,'svg');
- $renderer->doc .= '<a href="'.$svgenc.'" type="image/svg+xml" />'.$svgtag.$svgenc.'" alt="image:'.htmlspecialchars($svg_wiki_page).'" type="image/svg+xml"/></a><br />';
+ $svglink = exportlink($svg_wiki_page,'svg');
+ $renderer->doc .= $this->format_svg_embed($svglink, 'image:'.htmlspecialchars($svg_wiki_page));
+ //$renderer->doc .= '<a href="'.$svglink.'" type="image/svg+xml" />'.$svgtag.$svglink.'" alt="image:'.htmlspecialchars($svg_wiki_page).'" type="image/svg+xml"/></a><br />';
$renderer->doc .= html_wikilink($svg_wiki_page,'svg@'.$svg_wiki_page);
return true;
}
if($data[0]==='{{SV') {
$renderer->doc .= html_wikilink($svg_wiki_page,'svg@'.$svg_wiki_page);
return true;
}
if($data[0]==='{{SV') {
- $svgenc = 'data:image/svg+xml;base64,'.base64_encode(rawWiki($svg_wiki_page)).'" type="image/svg+xml';
- $renderer->doc .= '<a href="'.$svgenc.'" type="image/svg+xml" />'.$svgtag.$svgenc.'" alt="image:'.htmlspecialchars($svg_wiki_page).'" /></a><br />';
+ $svglink = 'data:image/svg+xml;base64,'.base64_encode(rawWiki($svg_wiki_page)).'" type="image/svg+xml';
+ $renderer->doc .= $this->format_svg_embed($svglink, 'image:'.htmlspecialchars($svg_wiki_page));
+ //$renderer->doc .= '<a href="'.$svglink.'" type="image/svg+xml" />'.$svgtag.$svglink.'" alt="image:'.htmlspecialchars($svg_wiki_page).'" /></a><br />';
$renderer->doc .= html_wikilink($svg_wiki_page,'SVG@'.$svg_wiki_page);
return true;
}
$renderer->doc .= html_wikilink($svg_wiki_page,'SVG@'.$svg_wiki_page);
return true;
}
This page took
0.138075 seconds
and
4
git commands to generate.