本文整理汇总了PHP中WikiFactory::UrlToID方法的典型用法代码示例。如果您正苦于以下问题:PHP WikiFactory::UrlToID方法的具体用法?PHP WikiFactory::UrlToID怎么用?PHP WikiFactory::UrlToID使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WikiFactory
的用法示例。
在下文中一共展示了WikiFactory::UrlToID方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: tryUpdateWiki
function tryUpdateWiki(DatabaseBase $db, $wikiId, $user)
{
if (is_string($wikiId)) {
$w = WikiFactory::UrlToID($wikiId);
if ($w == null) {
throw new Exception("Can't resolve " . $wikiId);
}
$wikiId = $w;
}
$userId = tryInsertUser($db, $user);
$res = $db->update("webmaster_sitemaps", array("user_id" => $userId, "upload_date" => "1970-01-01"), array("wiki_id" => $wikiId));
if (!$res) {
throw new Exception("Failed to update " . $userId . " " . $wikiId);
}
}
示例2: explodeURL
public static function explodeURL($url)
{
global $wgDevelEnvironment;
$urlParts = parse_url($url);
if ($wgDevelEnvironment) {
$explodedServer = explode('.', $url);
$url = $explodedServer[0] . '.wikia.com';
}
$wikiId = WikiFactory::UrlToID($url);
if (isset($urlParts['query'])) {
parse_str($urlParts['query'], $queryParts);
}
if (isset($queryParts['title'])) {
$articleName = $queryParts['title'];
} else {
$destinationWgArticlePath = self::getWgArticlePath($wikiId);
$articleName = self::stripArticlePath($urlParts['path'], $destinationWgArticlePath);
}
$result = array('wikiId' => $wikiId, 'articleName' => $articleName);
return $result;
}
示例3: explodeURL
public static function explodeURL($url)
{
$app = F::app();
$urlParts = parse_url($url);
if (isset($urlParts['query'])) {
parse_str($urlParts['query'], $queryParts);
}
if (isset($queryParts['title'])) {
$articleName = $queryParts['title'];
} else {
$articleName = preg_replace('!^/wiki/!i', '', $urlParts['path']);
}
if ($app->wg->develEnvironment) {
$explodedServer = explode('.', $url);
$url = $explodedServer[0] . '.wikia.com';
}
$wikiId = WikiFactory::UrlToID($url);
$result = array('wikiId' => $wikiId, 'articleName' => $articleName);
return $result;
}
示例4: parseMsg
public static function parseMsg($msg, $isFavicon = false)
{
global $wgMemc, $wgArticlePath;
$mcKey = wfMemcKey("hp_msg_parser", strtolower($msg));
$out = $wgMemc->get($mcKey);
if (is_array($out)) {
return $out;
}
wfProfileIn(__METHOD__);
$message = wfMsgForContent($msg);
$lines = explode("\n", $message);
$out = array();
foreach ($lines as $v) {
if (preg_match("/^([\\*]+)([^|]+)\\|(((.*)\\|(.*))|(.*))\$/", trim($v), $matches)) {
$param = "";
if (!empty($matches[5])) {
$param = $matches[6];
$title = trim($matches[5]);
} else {
$title = trim($matches[3]);
}
if (strlen($matches[1]) == 1) {
$matches[2] = trim($matches[2]);
if (preg_match('/^(?:' . wfUrlProtocols() . ')/', $matches[2])) {
$href = $matches[2];
} else {
$href = str_replace('$1', $matches[2], $wgArticlePath);
}
$out[] = array("title" => $title, 'href' => $href, 'sub' => array());
}
if (strlen($matches[1]) == 2) {
if (count($out) > 0) {
if ($isFavicon) {
$id = (int) WikiFactory::UrlToID(trim($matches[2]));
$favicon = "";
if ($id > 0) {
$favicon = WikiFactory::getVarValueByName("wgFavicon", $id);
}
}
$out[count($out) - 1]['sub'][] = array("param" => $param, "favicon" => $favicon, "title" => $title, 'href' => trim($matches[2]));
}
}
}
}
if (count($out) > 0) {
$out[0]['isfirst'] = true;
$out[count($out) - 1]['islast'] = true;
}
$wgMemc->set($mcKey, $out, 60 * 60 * 12);
wfProfileOut(__METHOD__);
return $out;
}
示例5: parseWikiData
/**
* @desc Parses wiki data validate and returns an array
*
* @param String $data line from the media wiki message
*
* @throws Exception
*
* @author Andrzej 'nAndy' Łukaszewski
*/
private function parseWikiData($data)
{
$data = explode(self::$dataSeparator, $data);
if (count($data) >= 3) {
$wikiName = trim(str_replace(self::$wikiIndicator, '', $data[0]));
$wikiUrl = trim($data[1]);
$wikiDesc = !empty($data[3]) ? trim($data[3]) : '';
$wikiImgName = trim($data[2]);
$wikiImg = wfFindFile($wikiImgName);
$wikiId = WikiFactory::UrlToID(trim($wikiUrl));
if (!$wikiId) {
$wikiId = 0;
}
return array('wikiid' => $wikiId, 'wikiname' => $wikiName, 'wikiurl' => $wikiUrl, 'wikidesc' => $wikiDesc, 'image' => $wikiImgName, 'wikipromoted' => false, 'wikiblocked' => false);
} else {
throw new Exception(wfMsg('wikia-home-parse-wiki-too-few-parameters'));
}
}