Source for file Wikilink.php
Documentation is available at Wikilink.php
class Text_Wiki_Render_Xhtml_Wikilink extends Text_Wiki_Render {
'pages' => array (), // set to null or false to turn off page checks
'view_url' => 'http://example.com/index.php?page=%s',
'new_url' => 'http://example.com/new.php?page=%s',
'new_text_pos' => 'after', // 'before', 'after', or null/false
'exists_callback' => null // call_user_func() callback
* Renders a token into XHTML.
* @param array $options The "options" portion of the token (second
* @return string The text rendered from the token options.
// make nice variable names (page, anchor, text)
// is there a "page existence" callback?
// we need to access it directly instead of through
// getConf() because we'll need a reference (for
// object instance method callbacks).
if (isset ($this->conf['exists_callback'])) {
$callback = & $this->conf['exists_callback'];
// use the callback function
// no callback, go to the naive page array.
$list = & $this->getConf ('pages');
// yes, check against the page list
// convert *after* checking against page names so as not to mess
// up what the user typed and what we're checking.
// link to the page view, but we have to build
// the HREF. we support both the old form where
// the page always comes at the end, and the new
// form that uses %s for sprintf()
$href = $this->getConf ('view_url');
if (strpos($href, '%s') === false ) {
// use the old form (page-at-end)
$href = $href . $page . $anchor;
// 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');
$output = " <a$css href=\"$href\">$text</a>";
// link to a create-page url, but only if new_url is set
$href = $this->getConf ('new_url', null );
if (! $href || trim($href) == '') {
// no useful href, return the text as it is
// yes, link to the new-page href, but we have to build
// it. we support both the old form where
// the page always comes at the end, and the new
// form that uses sprintf()
if (strpos($href, '%s') === false ) {
// get the appropriate CSS class and new-link text
$css = $this->formatConf (' class="%s"', 'css_new');
$new = $this->getConf ('new_text');
// what kind of linking are we doing?
$pos = $this->getConf ('new_text_pos');
// no position (or no new_text), use css only on the page name
$output = " <a$css href=\"$href\">$page</a>";
} elseif ($pos == 'before') {
// use the new_text BEFORE the page name
$output = " <a$css href=\"$href\">$new</a>$text";
// default, use the new_text link AFTER the page name
$output = " $text<a$css href=\"$href\">$new</a>";
Documentation generated on Mon, 11 Mar 2019 14:22:35 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.
|