function internallink($match, $state, $pos)
{
// Strip the opening and closing markup
$link = preg_replace(array('/^\\[\\[/', '/\\]\\]$/u'), '', $match);
// Split title from URL
$link = explode('|', $link, 2);
if (!isset($link[1])) {
$link[1] = null;
} else {
if (preg_match('/^\\{\\{[^\\}]+\\}\\}$/', $link[1])) {
// If the title is an image, convert it to an array containing the image details
$link[1] = Doku_Handler_Parse_Media($link[1]);
}
}
$link[0] = trim($link[0]);
//decide which kind of link it is
if (link_isinterwiki($link[0])) {
// Interwiki
$interwiki = explode('>', $link[0], 2);
$this->_addCall('interwikilink', array($link[0], $link[1], strtolower($interwiki[0]), $interwiki[1]), $pos);
} elseif (preg_match('/^\\\\\\\\[^\\\\]+?\\\\/u', $link[0])) {
// Windows Share
$this->_addCall('windowssharelink', array($link[0], $link[1]), $pos);
} elseif (preg_match('#^([a-z0-9\\-\\.+]+?)://#i', $link[0])) {
// external link (accepts all protocols)
$this->_addCall('externallink', array($link[0], $link[1]), $pos);
} elseif (preg_match('<' . PREG_PATTERN_VALID_EMAIL . '>', $link[0])) {
// E-Mail (pattern above is defined in inc/mail.php)
$this->_addCall('emaillink', array($link[0], $link[1]), $pos);
} elseif (preg_match('!^#.+!', $link[0])) {
// local link
$this->_addCall('locallink', array(substr($link[0], 1), $link[1]), $pos);
} else {
// internal link
$this->_addCall('internallink', array($link[0], $link[1]), $pos);
}
return true;
}