X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;ds=sidebyside;f=include%2FText%2FWiki%2FRender%2FLatex%2FWikilink.php;fp=include%2FText%2FWiki%2FRender%2FLatex%2FWikilink.php;h=3cf33a6ebb6bc15d74670033604f49fba2eb21fb;hb=6855525e48fad5de270500a5445c4f4ff85d8bda;hp=0000000000000000000000000000000000000000;hpb=e69709aa8ee6108a1197e46b45367ba8dab55a52;p=diogenes.git diff --git a/include/Text/Wiki/Render/Latex/Wikilink.php b/include/Text/Wiki/Render/Latex/Wikilink.php new file mode 100644 index 0000000..3cf33a6 --- /dev/null +++ b/include/Text/Wiki/Render/Latex/Wikilink.php @@ -0,0 +1,60 @@ + array(), + 'view_url' => 'http://example.com/index.php?page=%s', + 'new_url' => 'http://example.com/new.php?page=%s', + 'new_text' => '?' + ); + + /** + * + * Renders a token into XHTML. + * + * @access public + * + * @param array $options The "options" portion of the token (second + * element). + * + * @return string The text rendered from the token options. + * + */ + + function token($options) + { + // make nice variable names (page, anchor, text) + extract($options); + + // are we checking page existence? + $list =& $this->getConf('pages'); + if (is_array($list)) { + // yes, check against the page list + $exists = in_array($page, $list); + } else { + // no, assume it exists + $exists = true; + } + + // convert *after* checking against page names so as not to mess + // up what the user typed and what we're checking. + $page = htmlspecialchars($page); + $anchor = htmlspecialchars($anchor); + $text = htmlspecialchars($text); + + $href = $this->getConf('view_url'); + + if (strpos($href, '%s') === false) { + // use the old form (page-at-end) + $href = $href . $page . $anchor; + } else { + // use the new form (sprintf format string) + $href = sprintf($href, $page . $anchor); + } + + // get the CSS class and generate output + $css = $this->formatConf(' class="%s"', 'css'); + return "$text\\footnote\{$href}"; + } +} +?> \ No newline at end of file