function wfGetRecommendContent() { global $wgUser, $wgParser; $block = HuijiSkinTemplate::getIndexBlock('首页/Admin'); $pageTitle = Title::newFromText('首页/Admin'); $wgParserOptions = new ParserOptions($wgUser); $n = count($block); $recContent = array(); for ($i = 0; $i < $n; $i++) { $contentRes['title'] = $block[$i]->title; $contentRes['wikiname'] = $block[$i]->wikiname; $contentRes['desc'] = $wgParser->parse($block[$i]->desc, $pageTitle, $wgParserOptions)->getText(); $contentRes['wikiurl'] = $block[$i]->wikiurl; $contentRes['siteurl'] = $block[$i]->siteurl; $contentRes['backgroungimg'] = $block[$i]->backgroungimg; $recContent[] = $contentRes; } $randKey = array_rand($recContent, 7); $resRand = array(); foreach ($randKey as $value) { $resRand[] = $recContent[$value]; } $ret = array('success' => true, 'result' => $resRand); $out = json_encode($ret); return $out; }
/** * Update page's cache when someone edit the page(Admin,subnav,footer) */ public static function onNewRevisionFromEditComplete($article, Revision $rev, $baseID, User $user) { global $wgMemc, $wgParser, $wgHuijiPrefix; if (in_array($article->getTitle()->getFullText(), HuijiSkinTemplate::getPageParts())) { $option = new ParserOptions($user); $key = wfMemcKey('page', 'getPageRaw', 'all', $article->getTitle()->getFullText()); $output = $wgParser->preprocess($article->getContent()->getNativeData(), $article->getTitle(), $option); $wgMemc->set($key, $output); } elseif ($wgHuijiPrefix == 'www' && in_array($article->getTitle()->getFullText(), HuijiSkinTemplate::getSharedParts())) { $option = new ParserOptions($user); $key = wfForeignMemcKey('huiji', '', 'page', 'getPageRaw', 'shared', $article->getTitle()->getFullText()); $output = $wgParser->preprocess($article->getContent()->getNativeData(), $article->getTitle(), $option); $wgMemc->set($key, $output); } return true; }