function data_alias($pData, $pParams, $pCommonObject) { $page = ''; require_once WIKI_PKG_PATH . "BitPage.php"; foreach ($pParams as $key => $value) { if (!empty($value)) { switch ($key) { case 'page': $page = $value; break; default: break; } } } return tra("This page is an alias for:") . ' ' . BitPage::getPageLink($page, LibertyContent::pageExists($page)); }
/** * convert wiki links to html links * * @param string $pData * @param array $pParamHash * @param object $pObject * @access public * @return TRUE on success, FALSE on failure - mErrors will contain reason for failure */ function parseLinks($pData, $pParamHash, $pObject) { global $gBitSystem; // if wiki isn't active, there isn't much we can do here if (!$gBitSystem->isPackageActive('wiki')) { return $pData; } // fetch BitPage in case it hasn't been loaded yet require_once WIKI_PKG_PATH . 'BitPage.php'; // We need to remove ))WikiWords(( before links get made. // users just need to be strict about not inserting spaces between // words and brackets preg_match_all("!\\){2}(" . WIKI_WORDS_REGEX . ")\\({2}!", $pData, $protected); // this array is used to fill the text with temporary placeholders that get replaced back in further down $replacements = array(); if (!empty($protected)) { foreach ($protected[0] as $i => $prot) { $key = md5(mt_rand()); $replacements[$key] = $protected[1][$i]; $pData = str_replace($prot, $key, $pData); } } // Process ((Wiki Page|Wiki Page Description)) type links first. Here // we don't handle plurals and the like since the user should know what // he's linking to when using these links preg_match_all("/\\({2}({$this->mWikiWordRegex})\\|(.+?)\\){2}/", $pData, $pages); for ($i = 0; $i < count($pages[1]); $i++) { $page = str_replace($pages[5][$i], "", $pages[1][$i]); $exists = $this->pageExists($page, $pObject, $pParamHash['content_id']); // anchor if (!empty($pages[5][$i])) { $repl = preg_replace('!href="([^"]*)"!', "href=\"\$1{$pages[5][$i]}\"", BitPage::getPageLink($page, $exists)); } else { $repl = BitPage::getPageLink($page, $exists); } // alternate title if (strlen(trim($pages[6][$i])) > 0) { $repl = str_replace($page . "</a>", "{$pages[6][$i]}</a>", $repl); } $key = md5(mt_rand()); $replacements[$key] = $repl; $pData = str_replace($pages[0][$i], $key, $pData); } // Process the simpler ((Wiki Page)) type links without the description preg_match_all("/\\({2}({$this->mWikiWordRegex})\\){2}/", $pData, $pages); foreach (array_unique($pages[1]) as $i => $page) { $page = str_replace($pages[5][$i], "", $pages[1][$i]); $exists = $this->pageExists($page, $pObject, $pParamHash['content_id']); if (!empty($pages[5][$i])) { $repl = preg_replace('!href="([^"]*)"!', "href=\"\$1{$pages[5][$i]}\"", BitPage::getPageLink($page, $exists)); } else { $repl = BitPage::getPageLink($page, $exists); } $key = md5(mt_rand()); $replacements[$key] = $repl; $pData = str_replace("(({$pages[1][$i]}))", $key, $pData); } // Finally we deal with WikiWord links if ($gBitSystem->isFeatureActive('wiki_words')) { $pages = $this->extractWikiWords($pData); foreach ($pages as $page) { if ($exists = $this->pageExists($page, $pObject, $pParamHash['content_id'])) { $repl = BitPage::getPageLink($page, $exists); } elseif ($gBitSystem->isFeatureActive('wiki_plurals') && $this->getLocale() == 'en_US') { // Link plural topic names to singular topic names if the plural // doesn't exist, and the language is english $plural_tmp = $page; // Plurals like policy / policies $plural_tmp = preg_replace("/ies\$/", "y", $plural_tmp); // Plurals like address / addresses $plural_tmp = preg_replace("/sses\$/", "ss", $plural_tmp); // Plurals like box / boxes $plural_tmp = preg_replace("/([Xx])es\$/", "\$1", $plural_tmp); // Others, excluding ending ss like address(es) $plural_tmp = preg_replace("/([A-Za-rt-z])s\$/", "\$1", $plural_tmp); // prevent redundant pageExists calls if plurals are on, and plural is same as original word if ($page != $plural_tmp) { $exists = $this->pageExists($plural_tmp, $pObject, $pParamHash['content_id']); } $repl = BitPage::getPageLink($plural_tmp, $exists); } else { $repl = BitPage::getPageLink($page, $exists); } // old code //$slashed = preg_replace( "/([\/\[\]\(\)])/", "\\\\$1", $page_parse ); //$data = preg_replace( "#([\s\,\;])\b$slashed\b([\s\,\;\.])#", "$1 ".$repl."$2", $data); // new code // i never understood why the simple stuff never worked but it // seems to work now - xing - Sunday Jul 22, 2007 17:37:17 CEST $pData = preg_replace("/\\b" . preg_quote($page, "/") . "\\b/", $repl, $pData); } } // replace protection keys with original words foreach ($replacements as $key => $replace) { $pData = str_replace($key, $replace, $pData); } return $pData; }
/** * Generates a link to a wiki page within lists of pages * @return the link to display the page. */ function getListLink($pParamHash) { return BitPage::getPageLink($pParamHash['title'], NULL); }