本文整理汇总了PHP中Wikia::setVar方法的典型用法代码示例。如果您正苦于以下问题:PHP Wikia::setVar方法的具体用法?PHP Wikia::setVar怎么用?PHP Wikia::setVar使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Wikia
的用法示例。
在下文中一共展示了Wikia::setVar方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testAutosummaryType
function testAutosummaryType()
{
Wikia::setVar('AutoSummaryType', 'autosumm-replace');
$edit = array();
$out = array('autosummaryType' => 'autosumm-replace');
$this->assertEquals($out, $this->doEdit($edit));
// cleanup
Wikia::unsetVar('AutoSummaryType');
}
示例2: execute
public function execute()
{
wfProfileIn(__METHOD__);
// check rights
if (!ThemeDesignerHelper::checkAccess()) {
$this->displayRestrictionError();
wfProfileOut(__METHOD__);
return;
}
Wikia::setVar('OasisEntryControllerName', 'ThemeDesigner');
wfProfileOut(__METHOD__);
}
示例3: execute
public function execute()
{
wfProfileIn(__METHOD__);
global $wgUser;
// check rights
// @FIXME when we're out of beta editinterface needs to be removed and themedesgner set to true for sysops
if (!$wgUser->isAllowed('themedesigner')) {
$this->displayRestrictionError();
wfProfileOut(__METHOD__);
return;
}
Wikia::setVar('OasisEntryControllerName', 'ThemeDesigner');
wfProfileOut(__METHOD__);
}
示例4: execute
public function execute()
{
wfProfileIn(__METHOD__);
global $wgUser, $wgOut, $wgCityId;
// check if logged in
if ($wgUser->isLoggedIn()) {
if (Chat::canChat($wgUser)) {
Wikia::setVar('OasisEntryControllerName', 'Chat');
Chat::logChatWindowOpenedEvent();
} else {
$wgOut->showErrorPage('chat-you-are-banned', 'chat-you-are-banned-text');
}
} else {
// TODO: FIXME: Make a link on this page which lets the user login.
// TODO: FIXME: Make a link on this page which lets the user login.
// $wgOut->permissionRequired( 'chat' ); // this is a really useless message, don't use it.
$wgOut->showErrorPage('chat-no-login', 'chat-no-login-text');
}
wfProfileOut(__METHOD__);
}
示例5: setupEditPage
/**
* Change the module used as an entry-point for Oasis skin and use custom class for rendering edit page
*
* Keep global and user nav only.
*
* @author macbre
*/
function setupEditPage(Article $editedArticle, $fullScreen = true, $class = false)
{
global $wgHooks;
wfProfileIn(__METHOD__);
$user = $this->app->wg->User;
// don't render edit area when we're in read only mode
if (wfReadOnly()) {
// set correct page title
$this->out->setPageTitle(wfMessage('editing', $this->app->getGlobal('wgTitle')->getPrefixedText())->escaped());
wfProfileOut(__METHOD__);
return false;
}
// use "reskined" edit page layout
$this->fullScreen = $fullScreen;
if ($fullScreen) {
// set Oasis entry-point
Wikia::setVar('OasisEntryControllerName', 'EditPageLayout');
}
// Disable custom JS while loading the edit page on MediaWiki JS pages and user subpages (BugID: 41449)
$editedArticleTitle = $editedArticle->getTitle();
$editedArticleTitleNS = $editedArticleTitle->getNamespace();
$editedArticleTitleText = $editedArticleTitle->getText();
if ($editedArticleTitleNS === NS_MEDIAWIKI && substr($editedArticleTitleText, -3) === '.js' || $editedArticleTitleNS === NS_USER && preg_match('/^' . preg_quote($user->getName(), '/') . '\\/.*\\.js$/', $editedArticleTitleText)) {
$this->out->disallowUserJs();
}
// Add variables for pages to edit code (css, js, lua)
if ($this->isCodeSyntaxHighlightingEnabled($editedArticleTitle)) {
$this->prepareVarsForCodePage($editedArticleTitle);
}
// initialize custom edit page
$this->editPage = new EditPageLayout($editedArticle);
$editedTitle = $this->editPage->getEditedTitle();
$formCustomHandler = $this->editPage->getCustomFormHandler();
$this->addJsVariable('wgIsEditPage', true);
$this->addJsVariable('wgEditedTitle', $editedTitle->getPrefixedText());
$this->addJsVariable('wgEditPageClass', $class ? $class : 'SpecialCustomEditPage');
$this->addJsVariable('wgEditPageHandler', !is_null($formCustomHandler) ? $formCustomHandler->getLocalUrl('wpTitle=$1') : $this->app->getGlobal('wgScript') . '?action=ajax&rs=EditPageLayoutAjax&title=$1');
$this->addJsVariable('wgEditPagePopularTemplates', TemplateService::getPromotedTemplates());
$this->addJsVariable('wgEditPageIsWidePage', $this->isWidePage());
$this->addJsVariable('wgIsDarkTheme', SassUtil::isThemeDark());
if ($user->isLoggedIn()) {
global $wgRTEDisablePreferencesChange;
$wgRTEDisablePreferencesChange = true;
$this->addJsVariable('wgEditPageWideSourceMode', (bool) $user->getGlobalPreference('editwidth'));
unset($wgRTEDisablePreferencesChange);
}
$this->addJsVariableRef('wgEditPageFormType', $this->editPage->formtype);
$this->addJsVariableRef('wgEditPageIsConflict', $this->editPage->isConflict);
$this->addJsVariable('wgEditPageIsReadOnly', $this->editPage->isReadOnlyPage());
$this->addJsVariableRef('wgEditPageHasEditPermissionError', $this->editPage->mHasPermissionError);
$this->addJsVariableRef('wgEditPageSection', $this->editPage->section);
// data for license module (BugId:6967)
$titleLicensing = GlobalTitle::newFromText('Community_Central:Licensing', null, 177);
$this->addJsVariable('wgEditPageLicensingUrl', $titleLicensing->getFullUrl());
$this->addJsVariable('wgRightsText', $this->app->wg->RightsText);
// copyright warning for notifications (BugId:7951)
$this->addJsVariable('wgCopywarn', $this->editPage->getCopyrightNotice());
// extra hooks for edit page
$wgHooks['MakeGlobalVariablesScript'][] = 'EditPageLayoutHooks::onMakeGlobalVariablesScript';
$wgHooks['SkinGetPageClasses'][] = 'EditPageLayoutHooks::onSkinGetPageClasses';
$this->helper = self::getInstance();
wfProfileOut(__METHOD__);
return $this->editPage;
}
示例6: insertImage
//.........这里部分代码省略.........
// Test if this violates the size requirements we've been given
if ($msg = $this->invalidSize($file)) {
header('X-screen-type: error');
return $msg;
}
$ns_img = $wgContLang->getFormattedNsText(NS_IMAGE);
if (-2 == $gallery && !$ck) {
// this went in from the single placeholder...
$name = $title->getText();
$size = $wgRequest->getVal('size');
$width = $wgRequest->getVal('width');
$layout = $wgRequest->getVal('layout');
// clear the old caption for upload
$caption = $wgRequest->getVal('caption');
$slider = $wgRequest->getVal('slider');
$title_obj = Title::newFromText($title_main, $ns);
$article_obj = new Article($title_obj);
$text = $article_obj->getContent();
wfRunHooks('WikiaMiniUpload::fetchTextForImagePlaceholder', array(&$title_obj, &$text));
$box = $wgRequest->getVal('box', '');
$placeholder = MediaPlaceholderMatch($text, $box);
$success = false;
if ($placeholder) {
$our_gallery = $placeholder[0];
$gallery_split = explode(':', $our_gallery);
$thumb = false;
$tag = $gallery_split[0] . ":" . $name;
if ($size != 'full') {
$tag .= '|thumb';
$thumb = true;
}
if (isset($width)) {
$tag .= '|' . $width;
}
$tag .= '|' . $layout;
if ($link != '') {
$tag .= '|link=' . $link;
}
if ($caption != '') {
$tag .= '|' . $caption;
}
$tag .= "]]";
$text = substr_replace($text, $tag, $placeholder[1], strlen($our_gallery));
// return the proper embed code with all fancies around it
$embed_code = $this->generateImage($file, $name, $title_obj, $thumb, (int) str_replace('px', '', $width), $layout, $caption);
$message = wfMsg('wmu-success');
Wikia::setVar('EditFromViewMode', true);
$summary = wfMsg('wmu-added-from-plc');
$success = $article_obj->doEdit($text, $summary);
}
if ($success) {
header('X-screen-type: summary');
} else {
// failure signal opens js alert (BugId:4935)
header('X-screen-type: error');
return;
}
} else {
header('X-screen-type: summary');
$size = $wgRequest->getVal('size');
$width = $wgRequest->getVal('width');
$layout = $wgRequest->getVal('layout');
$caption = $wgRequest->getVal('caption');
$slider = $wgRequest->getVal('slider');
$tag = '[[' . $ns_img . ':' . $title->getDBkey();
if ($size != 'full' && ($file->getMediaType() == 'BITMAP' || $file->getMediaType() == 'DRAWING')) {
$tag .= '|thumb';
if ($layout != 'right') {
$tag .= '|' . $layout;
}
if ($slider == 'true') {
$tag .= '|' . $width;
}
}
if ($link != '' && $size == 'full') {
$tag .= '|link=' . $link;
}
if ($caption != '') {
if ($size == 'full') {
$tag .= '|frame';
if ($layout != 'right') {
$tag .= '|' . $layout;
}
}
$tag .= '|' . $caption . ']]';
} else {
if ($size == 'full') {
$tag .= '|' . $layout;
}
$tag .= ']]';
}
}
$message = wfMsg('wmu-success');
if ($wgRequest->getVal('update_caption') == 'on') {
Wikia::setProps($title->getArticleID(), array('default_caption' => $caption));
}
$tmpl = new EasyTemplate(dirname(__FILE__) . '/templates/');
$tmpl->set_vars(array('tag' => $tag, 'filename' => $ns_img . ':' . $title->getDBkey(), 'message' => $message, 'code' => isset($embed_code) ? $embed_code : ''));
return $tmpl->render('summary');
}
示例7: save
/**
* Save categories sent via AJAX into article
*/
public function save()
{
wfProfileIn(__METHOD__);
$articleId = $this->request->getVal('articleId', 0);
$categories = $this->request->getVal('categories', array());
$response = array();
$title = Title::newFromID($articleId);
if (wfReadOnly()) {
$response['error'] = wfMessage('categoryselect-error-db-locked')->text();
} else {
if (is_null($title)) {
$response['error'] = wfMessage('categoryselect-error-article-doesnt-exist', $articleId)->text();
} else {
if (!$title->userCan('edit') || $this->wg->User->isBlocked()) {
$response['error'] = wfMessage('categoryselect-error-user-rights')->text();
} else {
if (!empty($categories) && is_array($categories)) {
Wikia::setVar('EditFromViewMode', 'CategorySelect');
$article = new Article($title);
$wikitext = $article->fetchContent();
// Pull in categories from templates inside of the article (BugId:100980)
$options = new ParserOptions();
$preprocessedWikitext = ParserPool::preprocess($wikitext, $title, $options);
$preprocessedData = CategoryHelper::extractCategoriesFromWikitext($preprocessedWikitext, true);
// Compare the new categories with those already in the article to weed out duplicates
$newCategories = CategoryHelper::getDiffCategories($preprocessedData['categories'], $categories);
// Append the new categories to the end of the article wikitext
$wikitext .= CategoryHelper::changeFormat($newCategories, 'array', 'wikitext');
// Update the array of categories for the front-end
$categories = array_merge($preprocessedData['categories'], $newCategories);
$dbw = wfGetDB(DB_MASTER);
$dbw->begin();
$editPage = new EditPage($article);
$editPage->edittime = $article->getTimestamp();
$editPage->recreate = true;
$editPage->textbox1 = $wikitext;
$editPage->summary = wfMessage('categoryselect-edit-summary')->inContentLanguage()->text();
$editPage->watchthis = $editPage->mTitle->userIsWatching();
$bot = $this->wg->User->isAllowed('bot');
$status = $editPage->internalAttemptSave($result, $bot)->value;
$response['status'] = $status;
switch ($status) {
case EditPage::AS_SUCCESS_UPDATE:
case EditPage::AS_SUCCESS_NEW_ARTICLE:
$dbw->commit();
$title->invalidateCache();
Article::onArticleEdit($title);
$response['html'] = $this->app->renderView('CategorySelectController', 'categories', array('categories' => $categories));
wfRunHooks('CategorySelectSave', array($title, $newCategories));
break;
case EditPage::AS_SPAM_ERROR:
$dbw->rollback();
$response['error'] = wfMessage('spamprotectiontext')->text() . '<p>( Case #8 )</p>';
break;
default:
$dbw->rollback();
$response['error'] = wfMessage('categoryselect-error-edit-abort')->text();
}
}
}
}
}
$this->response->setData($response);
wfProfileOut(__METHOD__);
}
示例8: CategorySelectAjaxSaveCategories
/**
* Save categories sent via AJAX into article
*
* @author Maciej Błaszkowski <marooned at wikia-inc.com>
*/
function CategorySelectAjaxSaveCategories($articleId, $categories)
{
global $wgUser;
if (wfReadOnly()) {
$result['error'] = wfMsg('categoryselect-error-db-locked');
return json_encode($result);
}
wfProfileIn(__METHOD__);
Wikia::setVar('EditFromViewMode', 'CategorySelect');
$categories = CategorySelectChangeFormat($categories, 'json', 'wiki');
if ($categories == '') {
$result['info'] = 'Nothing to add.';
} else {
$title = Title::newFromID($articleId);
if (is_null($title)) {
$result['error'] = wfMsg('categoryselect-error-not-exist', $articleId);
} else {
if ($title->userCan('edit') && !$wgUser->isBlocked()) {
$result = null;
$article = new Article($title);
$article_text = $article->fetchContent();
$article_text .= $categories;
$dbw = wfGetDB(DB_MASTER);
$dbw->begin();
$editPage = new EditPage($article);
$editPage->edittime = $article->getTimestamp();
$editPage->recreate = true;
$editPage->textbox1 = $article_text;
$editPage->summary = wfMsgForContent('categoryselect-edit-summary');
$editPage->watchthis = $editPage->mTitle->userIsWatching();
$bot = $wgUser->isAllowed('bot');
$status = $editPage->internalAttemptSave($result, $bot);
$retval = $status->value;
Wikia::log(__METHOD__, "editpage", "Returned value {$retval}");
switch ($retval) {
case EditPage::AS_SUCCESS_UPDATE:
case EditPage::AS_SUCCESS_NEW_ARTICLE:
$dbw->commit();
$title->invalidateCache();
Article::onArticleEdit($title);
$skin = RequestContext::getMain()->getSkin();
// return HTML with new categories
// OutputPage::tryParserCache become deprecated in MW1.17 and removed in MW1.18 (BugId:30443)
$parserOutput = ParserCache::singleton()->get($article, $article->getParserOptions());
if ($parserOutput !== false) {
$skin->getOutput()->addParserOutput($parserOutput);
}
$cats = $skin->getCategoryLinks();
$result['info'] = 'ok';
$result['html'] = $cats;
break;
case EditPage::AS_SPAM_ERROR:
$dbw->rollback();
$result['error'] = wfMsg('spamprotectiontext') . '<p>( Case #8 )</p>';
break;
default:
$dbw->rollback();
$result['error'] = wfMsg('categoryselect-edit-abort');
}
} else {
$result['error'] = wfMsg('categoryselect-error-user-rights');
}
}
}
wfProfileOut(__METHOD__);
return json_encode($result);
}
示例9: setupEditPage
/**
* Change the module used as an entry-point for Oasis skin and use custom class for rendering edit page
*
* Keep global and user nav only.
*
* @author macbre
*/
function setupEditPage(Article $editedArticle, $fullScreen = true, $class = false)
{
wfProfileIn(__METHOD__);
$user = $this->app->wg->User;
// don't render edit area when we're in read only mode
if ($this->app->runFunction('wfReadOnly')) {
// set correct page title
$this->out->setPageTitle($this->app->runFunction('wfMsg', 'editing', $this->app->getGlobal('wgTitle')->getPrefixedText()));
return false;
}
// use "reskined" edit page layout
$this->fullScreen = $fullScreen;
if ($fullScreen) {
// set Oasis entry-point
Wikia::setVar('OasisEntryControllerName', 'EditPageLayout');
}
// macbre: load YUI on edit page (it's always loaded using $.loadYUI)
// PLB has problems with $.loadYUI not working correctly in Firefox (callback is fired to early)
/*
$srcs = F::build('AssetsManager',array(),'getInstance')->getGroupCommonURL('yui');
$wgJsMimeType = $this->app->wg->JsMimeType;
foreach($srcs as $src) {
$this->out->addScript("<script type=\"{$wgJsMimeType}\" src=\"{$src}\"></script>");
}
*/
$this->out->addModules('wikia.yui');
// Disable custom JS while loading the edit page on MediaWiki JS pages and user subpages (BugID: 41449)
if ($editedArticle->getTitle()->getNamespace() === NS_MEDIAWIKI && substr($editedArticle->getTitle()->getText(), -3) === '.js' || $editedArticle->getTitle()->getNamespace() === NS_USER && preg_match('/^' . preg_quote($user->getName(), '/') . '\\/.*\\.js$/', $editedArticle->getTitle()->getText())) {
$this->out->disallowUserJs();
}
// initialize custom edit page
$this->editPage = new EditPageLayout($editedArticle);
$editedTitle = $this->editPage->getEditedTitle();
$formCustomHandler = $this->editPage->getCustomFormHandler();
$this->addJsVariable('wgIsEditPage', true);
$this->addJsVariable('wgEditedTitle', $editedTitle->getPrefixedText());
$this->addJsVariable('wgEditPageClass', $class ? $class : 'SpecialCustomEditPage');
$this->addJsVariable('wgEditPageHandler', !is_null($formCustomHandler) ? $formCustomHandler->getLocalUrl('wpTitle=$1') : $this->app->getGlobal('wgScript') . '?action=ajax&rs=EditPageLayoutAjax&title=$1');
$this->addJsVariable('wgEditPagePopularTemplates', TemplateService::getPromotedTemplates());
$this->addJsVariable('wgEditPageIsWidePage', $this->isWidePage());
if ($user->isLoggedIn()) {
global $wgRTEDisablePreferencesChange;
$wgRTEDisablePreferencesChange = true;
$this->addJsVariable('wgEditPageWideSourceMode', (bool) $user->getOption('editwidth'));
unset($wgRTEDisablePreferencesChange);
}
$this->addJsVariableRef('wgEditPageFormType', $this->editPage->formtype);
$this->addJsVariableRef('wgEditPageIsConflict', $this->editPage->isConflict);
$this->addJsVariable('wgEditPageIsReadOnly', $this->editPage->isReadOnlyPage());
$this->addJsVariableRef('wgEditPageHasEditPermissionError', $this->editPage->mHasPermissionError);
$this->addJsVariableRef('wgEditPageSection', $this->editPage->section);
// data for license module (BugId:6967)
$titleLicensing = GlobalTitle::newFromText('Community_Central:Licensing', null, 177);
$this->addJsVariable('wgEditPageLicensingUrl', $titleLicensing->getFullUrl());
$this->addJsVariable('wgRightsText', $this->app->wg->RightsText);
// copyright warning for notifications (BugId:7951)
$this->addJsVariable('wgCopywarn', $this->editPage->getCopyrightNotice());
// extra hooks for edit page
$this->app->registerHook('MakeGlobalVariablesScript', 'EditPageLayoutHelper', 'onMakeGlobalVariablesScript', array(), false, $this);
$this->app->registerHook('SkinGetPageClasses', 'EditPageLayoutHelper', 'onSkinGetPageClasses', array(), false, $this);
WF::setInstance('EditPageLayoutHelper', $this);
$this->editPage->setHelper($this);
wfProfileOut(__METHOD__);
return $this->editPage;
}
示例10: insertFinalVideo
function insertFinalVideo()
{
global $wgRequest, $wgContLang;
$id = $wgRequest->getVal('id');
$provider = $wgRequest->getVal('provider');
$name = urldecode($wgRequest->getVal('name'));
$embed_code = '';
if ($provider == 'FILE') {
// no need to upload, local reference
$title = $oTitle = Title::newFromText($name, NS_FILE);
if (empty($oTitle)) {
header('X-screen-type: error');
return wfMessage('vet-name-incorrect')->plain();
}
wfRunHooks('AddPremiumVideo', array($title));
} else {
// needs to upload
// sanitize name and init title objects
$name = VideoFileUploader::sanitizeTitle($name);
if ($name == '') {
header('X-screen-type: error');
return wfMessage('vet-warn3')->plain();
}
$nameFile = VideoFileUploader::sanitizeTitle($name);
$titleFile = VideoFileUploader::getUniqueTitle($nameFile);
if (empty($titleFile)) {
header('X-screen-type: error');
return wfMessage('vet-name-incorrect')->plain();
}
// by definition, WikiaFileHelper::useVideoHandlersExtForEmbed() == true
$nameSanitized = $titleFile->getBaseText();
$title = $titleFile;
$extra = 0;
$metadata = array();
while ('' != $wgRequest->getVal('metadata' . $extra)) {
$metadata[] = $wgRequest->getVal('metadata' . $extra);
$extra++;
}
$parts = explode('/', $provider);
$provider = $parts[1];
$oTitle = null;
$status = $this->uploadVideoAsFile($provider, $id, $nameSanitized, $oTitle);
if (!$status->ok) {
header('X-screen-type: error');
return wfMessage('wva-thumbnail-upload-failed')->plain();
}
}
$description = trim(urldecode($wgRequest->getVal('description')));
// Set the video descriptions
$vHelper = new VideoHandlerHelper();
$vHelper->setVideoDescription($oTitle, $description);
$message = wfMessage('vet-single-success')->plain();
$ns_file = $wgContLang->getFormattedNsText($title->getNamespace());
$caption = $wgRequest->getVal('caption');
$width = $wgRequest->getVal('width');
$width = empty($width) ? 335 : $width;
$layout = $wgRequest->getVal('layout');
header('X-screen-type: summary');
$tag = $ns_file . ":" . $oTitle->getText();
// all videos added via VET will be shown as thumbnails / "framed"
$tag .= "|thumb";
if (!empty($layout)) {
$tag .= "|{$layout}";
}
if ($width != '') {
$tag .= "|{$width} px";
}
if ($caption != '') {
$tag .= "|" . $caption;
}
$tag = "[[{$tag}]]";
$button_message = wfMessage('vet-return')->plain();
// Adding a video from article view page
$editFromViewMode = $wgRequest->getVal('placeholder');
if ($editFromViewMode) {
Wikia::setVar('EditFromViewMode', true);
$article_title = $wgRequest->getVal('article');
$ns = $wgRequest->getVal('ns');
$box = $wgRequest->getVal('box');
$article_title_obj = Title::newFromText($article_title, $ns);
$article_obj = new Article($article_title_obj);
$text = $article_obj->getContent();
// match [[File:Placeholder|video]]
$placeholder = MediaPlaceholderMatch($text, $box, true);
$success = false;
if ($placeholder) {
$placeholder_tag = $placeholder[0];
$file = wfFindFile($title);
$embed_code = $file->transform(array('width' => $width))->toHtml();
$params = array('alt' => $title->getText(), 'title' => $title->getText(), 'img-class' => 'thumbimage', 'align' => $layout, 'outerWidth' => $width, 'file' => $file, 'url' => $file->getUrl(), 'html' => $embed_code);
$embed_code = F::app()->renderView('ThumbnailController', 'articleBlock', $params);
// Make output match what's in a saved article
if ($layout == 'center') {
$embed_code = '<div class="center">' . $embed_code . '</div>';
}
$summary = wfMessage('vet-added-from-placeholder')->plain();
$text = substr_replace($text, $tag, $placeholder[1], strlen($placeholder_tag));
$button_message = wfMessage('vet-placeholder-return')->plain();
$success = $article_obj->doEdit($text, $summary);
}
//.........这里部分代码省略.........
示例11: execute
public function execute()
{
Wikia::setVar('OasisEntryControllerName', 'FounderEmails');
}
示例12: storeAdditionalRcData
/**
* Given an associative array of data to store, adds this to additional data and updates
* the row in recentchanges corresponding to the provided RecentChange (or, if rc is not
* provided, then the RecentChange that is stored in Wikia::getVar('rc') will be used);
*/
public static function storeAdditionalRcData($additionalData, &$rc = null)
{
wfProfileIn(__METHOD__);
$rc_data = Wikia::getVar('rc_data');
$rc_data = $rc_data ? $rc_data : array();
// rc_data might not have been set
$rc_data = array_merge($rc_data, $additionalData);
// additionalData overwrites existing keys in rc_data if there are collisions.
if (!is_object($rc)) {
$rc = Wikia::getVar('rc');
}
if ($rc instanceof RecentChange) {
/* @var $rc RecentChange */
$rc_id = $rc->getAttribute('rc_id');
$rc_log_type = $rc->getAttribute('rc_log_type');
if (!in_array($rc_log_type, self::$additionalRcDataBlacklist)) {
$dbw = wfGetDB(DB_MASTER);
$dbw->update('recentchanges', array('rc_params' => MyHome::packData($rc_data)), array('rc_id' => $rc_id), __METHOD__);
}
}
Wikia::setVar('rc_data', $rc_data);
wfProfileOut(__METHOD__);
}
示例13: doIncrementalUpdate
protected function doIncrementalUpdate()
{
// Wikia change - start (BAC-597)
if ($this->mId === 0) {
Wikia::logBacktrace(__CLASS__ . '::mIdIsZero - update skipped');
return;
}
// Wikia change - end
wfProfileIn(__METHOD__);
# Page links
$existing = $this->getExistingLinks();
$this->incrTableUpdate('pagelinks', 'pl', $this->getLinkDeletions($existing), $this->getLinkInsertions($existing));
# Image links
$existing = $this->getExistingImages();
$imageDeletes = $this->getImageDeletions($existing);
/* Wikia change begin - @author: mech */
$imageInserts = $this->getImageInsertions($existing);
Wikia::setVar('imageDeletes', $imageDeletes);
// images are in array keys!
Wikia::setVar('imageInserts', $imageInserts);
$this->incrTableUpdate('imagelinks', 'il', $imageDeletes, $imageInserts);
/* Wikia change end */
# Invalidate all image description pages which had links added or removed
$imageUpdates = $imageDeletes + array_diff_key($this->mImages, $existing);
/* Wikia change CE-677 @author Kamil Koterba kamil@wikia-inc.com */
$this->queueImageDescriptionsInvalidation($imageUpdates);
/* Wikia change end */
# External links
$existing = $this->getExistingExternals();
$this->incrTableUpdate('externallinks', 'el', $this->getExternalDeletions($existing), $this->getExternalInsertions($existing));
# Language links
$existing = $this->getExistingInterlangs();
$this->incrTableUpdate('langlinks', 'll', $this->getInterlangDeletions($existing), $this->getInterlangInsertions($existing));
# Inline interwiki links
$existing = $this->getExistingInterwikis();
$this->incrTableUpdate('iwlinks', 'iwl', $this->getInterwikiDeletions($existing), $this->getInterwikiInsertions($existing));
# Template links
$existing = $this->getExistingTemplates();
$this->incrTableUpdate('templatelinks', 'tl', $this->getTemplateDeletions($existing), $this->getTemplateInsertions($existing));
# Category links
$existing = $this->getExistingCategories();
$categoryDeletes = $this->getCategoryDeletions($existing);
$this->incrTableUpdate('categorylinks', 'cl', $categoryDeletes, $this->getCategoryInsertions($existing));
# Invalidate all categories which were added, deleted or changed (set symmetric difference)
$categoryInserts = array_diff_assoc($this->mCategories, $existing);
$categoryUpdates = $categoryInserts + $categoryDeletes;
/* Wikia change CE-677 @author Kamil Koterba kamil@wikia-inc.com */
$this->queueCategoriesInvalidation($categoryUpdates);
# do the actual invalidation in all pages queued so far
$this->invalidatePages();
/* Wikia change end */
$this->updateCategoryCounts($categoryInserts, $categoryDeletes);
wfRunHooks('AfterCategoriesUpdate', array($categoryInserts, $categoryDeletes, $this->mTitle));
Wikia::setVar('categoryInserts', $categoryInserts);
# Page properties
$existing = $this->getExistingProperties();
$propertiesDeletes = $this->getPropertyDeletions($existing);
$this->incrTableUpdate('page_props', 'pp', $propertiesDeletes, $this->getPropertyInsertions($existing));
# Invalidate the necessary pages
$changed = $propertiesDeletes + array_diff_assoc($this->mProperties, $existing);
$this->invalidateProperties($changed);
# Refresh links of all pages including this page
# This will be in a separate transaction
if ($this->mRecursive) {
$this->queueRecursiveJobs();
}
wfProfileOut(__METHOD__);
}
示例14: getAutosummary
/**
* Return an applicable autosummary if one exists for the given edit.
* @param $oldtext String: the previous text of the page.
* @param $newtext String: The submitted text of the page.
* @param $flags Int bitmask: a bitmask of flags submitted for the edit.
* @return string An appropriate autosummary, or an empty string.
*/
public static function getAutosummary($oldtext, $newtext, $flags)
{
global $wgContLang;
# Decide what kind of autosummary is needed.
# Redirect autosummaries
$ot = Title::newFromRedirect($oldtext);
$rt = Title::newFromRedirect($newtext);
if (is_object($rt) && (!is_object($ot) || !$rt->equals($ot) || $ot->getFragment() != $rt->getFragment())) {
$truncatedtext = $wgContLang->truncate(str_replace("\n", ' ', $newtext), max(0, 250 - strlen(wfMsgForContent('autoredircomment')) - strlen($rt->getFullText())));
# wikia changes begin
Wikia::setVar('AutoSummaryType', 'autoredircomment');
# wikia changes end
return wfMsgForContent('autoredircomment', $rt->getFullText(), $truncatedtext);
}
# New page autosummaries
if ($flags & EDIT_NEW && strlen($newtext)) {
# If they're making a new article, give its text, truncated, in the summary.
$truncatedtext = $wgContLang->truncate(str_replace("\n", ' ', $newtext), max(0, 200 - strlen(wfMsgForContent('autosumm-new'))));
# wikia changes begin
Wikia::setVar('AutoSummaryType', 'autosumm-new');
# wikia changes end
return wfMsgForContent('autosumm-new', $truncatedtext);
}
# Blanking autosummaries
if ($oldtext != '' && $newtext == '') {
# wikia changes begin
Wikia::setVar('AutoSummaryType', 'autosumm-blank');
# wikia changes end
return wfMsgForContent('autosumm-blank');
} elseif (strlen($oldtext) > 10 * strlen($newtext) && strlen($newtext) < 500) {
# Removing more than 90% of the article
$truncatedtext = $wgContLang->truncate($newtext, max(0, 200 - strlen(wfMsgForContent('autosumm-replace'))));
# wikia changes begin
Wikia::setVar('AutoSummaryType', 'autosumm-replace');
# wikia changes end
return wfMsgForContent('autosumm-replace', $truncatedtext);
}
# If we reach this point, there's no applicable autosummary for our case, so our
# autosummary is empty.
return '';
}