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); } }
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; }
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; }
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; }
/** * @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')); } }