function link($link, $linktext = false) { list($moniker, $page) = split(":", $link, 2); if (!isset($this->_map[$moniker])) { return HTML::span(array('class' => 'bad-interwiki'), $linktext ? $linktext : $link); } $url = $this->_map[$moniker]; // Urlencode page only if it's a query arg. // FIXME: this is a somewhat broken heuristic. $page_enc = strstr($url, '?') ? rawurlencode($page) : $page; if (strstr($url, '%s')) { $url = sprintf($url, $page_enc); } else { $url .= $page_enc; } $link = HTML::a(array('href' => $url)); if (!$linktext) { $link->pushContent(PossiblyGlueIconToText('interwiki', "{$moniker}:"), HTML::span(array('class' => 'wikipage'), $page)); $link->setAttr('class', 'interwiki'); } else { $link->pushContent(PossiblyGlueIconToText('interwiki', $linktext)); $link->setAttr('class', 'named-interwiki'); } return $link; }
function _UserLink($PageName) { $link = HTML::a(array('href' => $PageName)); $link->pushContent(PossiblyGlueIconToText('wikiuser', $PageName)); $link->setAttr('class', 'wikiuser'); return $link; }
/** * Generates an HtmlElement object to store data for a link. * * @param string $url URL that the link will point to. * @param string $linktext Text to be displayed as link. * @return HtmlElement HtmlElement object that contains data to construct an html link. */ function LinkURL($url, $linktext = '') { // FIXME: Is this needed (or sufficient?) if (!IsSafeURL($url)) { $link = HTML::span(array('class' => 'error'), _("BAD URL -- remove all of <, >, \"")); return $link; } else { if (!$linktext) { $linktext = preg_replace("/mailto:/A", "", $url); } $args = array('href' => $url); if (defined('EXTERNAL_LINK_TARGET')) { // can also be set in the css $args['target'] = (is_string(EXTERNAL_LINK_TARGET) and EXTERNAL_LINK_TARGET != "") ? EXTERNAL_LINK_TARGET : "_blank"; } $link = HTML::a($args, PossiblyGlueIconToText($url, $linktext)); } $link->setAttr('class', $linktext ? 'namedurl' : 'rawurl'); return $link; }
function link($link, $linktext = false) { global $WikiTheme; list($moniker, $page) = explode(":", $link, 2); if (!isset($this->_map[$moniker])) { return HTML::span(array('class' => 'bad-interwiki'), $linktext ? $linktext : $link); } $url = $this->_map[$moniker]; // localize Upload:links for WIKIDUMP if (!empty($WikiTheme->DUMP_MODE) and $moniker == 'Upload') { global $request; include_once "lib/config.php"; $url = getUploadFilePath(); // calculate to a relative local path to /uploads for pdf images. $doc_root = $request->get("DOCUMENT_ROOT"); $ldir = NormalizeLocalFileName($url); $wikiroot = NormalizeLocalFileName(''); if (isWindows()) { $ldir = strtolower($ldir); $doc_root = strtolower($doc_root); $wikiroot = strtolower($wikiroot); } if (string_starts_with($ldir, $doc_root)) { $link_prefix = substr($url, strlen($doc_root)); } elseif (string_starts_with($ldir, $wikiroot)) { $link_prefix = NormalizeWebFileName(substr($url, strlen($wikiroot))); } } // Urlencode page only if it's a query arg. // FIXME: this is a somewhat broken heuristic. if ($moniker == 'Upload') { $page_enc = $page; $page = rawurldecode($page); } else { $page_enc = strstr($url, '?') ? rawurlencode($page) : $page; } if (strstr($url, '%s')) { $url = sprintf($url, $page_enc); } else { $url .= $page_enc; } $link = HTML::a(array('href' => $url)); if (!$linktext) { $link->pushContent(PossiblyGlueIconToText('interwiki', "{$moniker}:"), HTML::span(array('class' => 'wikipage'), $page)); $link->setAttr('class', 'interwiki'); } else { $link->pushContent(PossiblyGlueIconToText('interwiki', $linktext)); $link->setAttr('class', 'named-interwiki'); } return $link; }
function expand($basepage, &$markup) { $label = isset($this->_label) ? $this->_label : false; $anchor = isset($this->_anchor) ? (string) $this->_anchor : ''; $page = new WikiPageName($this->_page, $basepage, $anchor); $link = WikiLink($page, 'auto', $label); // $link = HTML::a(array('href' => $PageName)); $link->setContent(PossiblyGlueIconToText('wikiuser', $this->_page)); $link->setAttr('class', 'wikiuser'); return $link; }