本文整理汇总了PHP中RequestContext::getMain方法的典型用法代码示例。如果您正苦于以下问题:PHP RequestContext::getMain方法的具体用法?PHP RequestContext::getMain怎么用?PHP RequestContext::getMain使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RequestContext
的用法示例。
在下文中一共展示了RequestContext::getMain方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: isVisible
/**
* This should be part of the controller, not the model
*/
public function isVisible()
{
if (!isset($this->visible)) {
$this->visible = in_array(strtolower(RequestContext::getMain()->getSkin()->getSkinName()), array('oasis')) && $this->ownerUser && !$this->ownerUser->isAnon() && AchAwardingService::canEarnBadges($this->ownerUser) && !$this->ownerUser->getGlobalPreference('hidepersonalachievements');
}
return $this->visible;
}
示例2: testForm
/**
* @dataProvider provideValidate
*/
public function testForm($text, $value)
{
$form = HTMLForm::factory('ooui', ['restrictions' => ['class' => HTMLRestrictionsField::class]]);
$request = new FauxRequest(['wprestrictions' => $text], true);
$context = new DerivativeContext(RequestContext::getMain());
$context->setRequest($request);
$form->setContext($context);
$form->setTitle(Title::newFromText('Main Page'))->setSubmitCallback(function () {
return true;
})->prepareForm();
$status = $form->trySubmit();
if ($status instanceof StatusValue) {
$this->assertEquals($value !== false, $status->isGood());
} elseif ($value === false) {
$this->assertNotSame(true, $status);
} else {
$this->assertSame(true, $status);
}
if ($value !== false) {
$restrictions = $form->mFieldData['restrictions'];
$this->assertInstanceOf(MWRestrictions::class, $restrictions);
$this->assertEquals($value, $restrictions->toArray()['IPAddresses']);
}
// sanity
$form->getHTML($status);
}
示例3: execute
function execute($par)
{
/**
* Some satellite ISPs use broken precaching schemes that log people out straight after
* they're logged in (bug 17790). Luckily, there's a way to detect such requests.
*/
if (isset($_SERVER['REQUEST_URI']) && strpos($_SERVER['REQUEST_URI'], '&') !== false) {
wfDebug("Special:Userlogout request {$_SERVER['REQUEST_URI']} looks suspicious, denying.\n");
throw new HttpError(400, $this->msg('suspicious-userlogout'), $this->msg('loginerror'));
}
$this->setHeaders();
$this->outputHeader();
// Make sure it's possible to log out
$session = MediaWiki\Session\SessionManager::getGlobalSession();
if (!$session->canSetUser()) {
throw new ErrorPageError('cannotlogoutnow-title', 'cannotlogoutnow-text', [$session->getProvider()->describe(RequestContext::getMain()->getLanguage())]);
}
$user = $this->getUser();
$oldName = $user->getName();
$user->logout();
$loginURL = SpecialPage::getTitleFor('Userlogin')->getFullURL($this->getRequest()->getValues('returnto', 'returntoquery'));
$out = $this->getOutput();
$out->addWikiMsg('logouttext', $loginURL);
// Hook.
$injected_html = '';
Hooks::run('UserLogoutComplete', [&$user, &$injected_html, $oldName]);
$out->addHTML($injected_html);
$out->returnToMain();
}
示例4: singleton
/**
* @return EventRelayerGroup
*/
public static function singleton()
{
if (!self::$instance) {
self::$instance = new self(RequestContext::getMain()->getConfig());
}
return self::$instance;
}
示例5: execute
public function execute($params = false)
{
$sEditLinkText = wfMessage('bs-widget-edit')->text();
$oTitle = Title::makeTitle(NS_USER, RequestContext::getMain()->getUser()->getName() . '/Widgetbar');
$sEditLink = Linker::link($oTitle, Html::rawElement('span', array(), $sEditLinkText), array('id' => 'bs-widgetbar-edit', 'class' => 'icon-pencil clearfix'), array('action' => 'edit', 'preload' => ''));
$aOut = array();
$aOut[] = '<div id="bs-widget-container" >';
$aOut[] = ' <div class="icon-plus" id="bs-widget-tab" title="' . wfMessage('bs-widget-container-tooltip')->text() . '" tabindex="100">[+/-]</div>';
$aOut[] = ' <div id="bs-flyout">';
$aOut[] = ' <h4 id="bs-flyout-heading">' . wfMessage('bs-widget-flyout-heading')->text() . '</h4>';
$aOut[] = ' <div id="bs-flyout-content">';
$aOut[] = ' <div id="bs-flyout-content-widgets">';
$aOut[] = ' <h4 id="bs-flyout-content-widgets-header">' . wfMessage("bs-widget-flyout-heading")->plain() . $sEditLink . '</h4>';
foreach ($this->_mWidgets as $oWidgetView) {
if ($oWidgetView instanceof ViewWidget) {
$aOut[] = $oWidgetView->execute();
} else {
wfDebug(__METHOD__ . ': Invalid widget.');
}
}
$aOut[] = ' </div>';
$aOut[] = ' </div>';
$aOut[] = ' </div>';
$aOut[] = '</div>';
return implode("\n", $aOut);
}
示例6: wfTalkHereAjaxEditor
function wfTalkHereAjaxEditor( $page, $section, $returnto ) {
global $wgRequest, $wgTitle, $wgOut;
$title = Title::newFromText( $page );
if ( !$title ) {
return false;
}
//fake editor environment
$args = array(
'wpTalkHere' => '1',
'wpReturnTo' => $returnto,
'action' => 'edit',
'section' => $section
);
$wgRequest = new FauxRequest( $args );
$wgTitle = $title;
$article = Article::newFromTitle( $title, RequestContext::getMain() );
$editor = new TalkHereEditPage( $article );
//generate form
$editor->importFormData( $wgRequest );
$editor->showEditForm();
$response = new AjaxResponse();
$response->addText( $wgOut->getHTML() );
$response->setCacheDuration( false ); //don't cache, because of tokens etc
return $response;
}
示例7: index
public function index()
{
$title = Title::newFromText('Version', NS_SPECIAL);
$popts = ParserOptions::newFromContext(RequestContext::getMain());
$this->wg->Title = $title;
$this->specialPage->setHeaders();
$softwareListPrepped = array();
foreach ($this->version->getSoftwareList() as $key => $val) {
$softwareListPrepped[$this->wg->Parser->parse($key, $title, $popts)->getText()] = $this->wg->Parser->parse($val, $title, $popts)->getText();
}
$this->setVal('copyRightAndAuthorList', $this->wg->Parser->parse($this->version->getCopyrightAndAuthorList(), $title, $popts)->getText());
$this->setVal('softwareInformation', $this->wg->Parser->parse($this->version->softwareInformation(), $title, $popts)->getText());
$this->setVal('extensionCredit', $this->wg->Parser->parse($this->version->getExtensionCredits(), $title, $popts)->getText());
$this->setVal('ip', str_replace('--', ' - ', htmlspecialchars($this->getContext()->getRequest()->getIP())));
$this->setVal('wikiaCodeMessage', wfMessage('wikia-version-code')->escaped());
$this->setVal('wikiaCodeVersion', $this->version->getWikiaCodeVersion());
$this->setVal('wikiaConfigMessage', wfMessage('wikia-version-config')->escaped());
$this->setVal('wikiaConfigVersion', $this->version->getWikiaConfigVersion());
$this->setVal('versionLicenseMessage', wfMessage('version-license')->escaped());
$this->setVal('versionLicenseInfoMessage', wfMessage('version-license-info')->parse());
$this->setVal('versionSoftwareMessage', wfMessage('version-software')->escaped());
$this->setVal('versionSoftwareProductMessage', wfMessage('version-software-product')->escaped());
$this->setVal('versionSoftwareVersionMessage', wfMessage('version-software-version')->escaped());
$this->setVal('versionSoftwareList', $softwareListPrepped);
}
示例8: purgeMainPage
public static function purgeMainPage($args)
{
if ($args['name'] === 'wgEnableNjordExt') {
Article::newFromTitle(Title::newFromText(self::MAINPAGE_PAGE), RequestContext::getMain())->doPurge();
}
return true;
}
示例9: __construct
function __construct()
{
//Some internal methods called from this controller need the skin to be wikiamobile
//It makes sense to set it explicitly here as other skins shouldn't use it anyway
RequestContext::getMain()->setSkin(Skin::newFromKey('wikiamobile'));
parent::__construct();
}
示例10: wfInstallerMain
function wfInstallerMain()
{
global $wgRequest, $wgLang, $wgMetaNamespace, $wgCanonicalNamespaceNames;
$installer = InstallerOverrides::getWebInstaller($wgRequest);
if (!$installer->startSession()) {
if ($installer->request->getVal("css")) {
// Do not display errors on css pages
$installer->outputCss();
exit;
}
$errors = $installer->getPhpErrors();
$installer->showError('config-session-error', $errors[0]);
$installer->finish();
exit;
}
$fingerprint = $installer->getFingerprint();
if (isset($_SESSION['installData'][$fingerprint])) {
$session = $_SESSION['installData'][$fingerprint];
} else {
$session = [];
}
if (!is_null($wgRequest->getVal('uselang'))) {
$langCode = $wgRequest->getVal('uselang');
} elseif (isset($session['settings']['_UserLang'])) {
$langCode = $session['settings']['_UserLang'];
} else {
$langCode = 'en';
}
$wgLang = Language::factory($langCode);
RequestContext::getMain()->setLanguage($wgLang);
$installer->setParserLanguage($wgLang);
$wgMetaNamespace = $wgCanonicalNamespaceNames[NS_PROJECT];
$session = $installer->execute($session);
$_SESSION['installData'][$fingerprint] = $session;
}
示例11: execute
/**
* Produces the actual output.
* @param array $params List of parameters for the rendering of output.
* @return string The rendered HTML of the extension list
*/
public function execute($params = false)
{
global $wgBlueSpiceExtInfo, $wgVersion;
$aExtensionInfo = array();
foreach ($this->mExtensions as $aExtension) {
if (!isset($aExtension[EXTINFO::NAME])) {
continue;
}
$aExtensionInfoArray = array('name' => array($aExtension[EXTINFO::NAME], $this->getHelpdeskUrl($aExtension)), 'version' => $aExtension[EXTINFO::VERSION] === 'default' ? $wgBlueSpiceExtInfo['version'] : $aExtension[EXTINFO::VERSION], 'package' => !isset($aExtension[EXTINFO::PACKAGE]) || $aExtension[EXTINFO::PACKAGE] === 'default' ? $wgBlueSpiceExtInfo['package'] : $aExtension[EXTINFO::PACKAGE], 'description' => wfMessage($aExtension[EXTINFO::DESCRIPTION])->escaped(), 'status' => $aExtension[EXTINFO::STATUS] === 'default' ? $wgBlueSpiceExtInfo['status'] : $aExtension[EXTINFO::STATUS]);
$aExtensionInfo[] = $aExtensionInfoArray;
}
RequestContext::getMain()->getOutput()->addJsConfigVars('aExtensionInfo', $aExtensionInfo);
$sCreditsLink = ' (<a href="' . SpecialPage::getTitleFor('SpecialCredits')->getFullURL() . '">Credits</a>)';
$sVersion = $wgBlueSpiceExtInfo['version'] . ($wgBlueSpiceExtInfo['status'] !== 'stable' ? ' ' . $wgBlueSpiceExtInfo['status'] : '');
$aOut = array();
$aOut[] = '<table class="bs-softwaretable">';
$aOut[] = '<tr>';
$aOut[] = '<th>' . wfMessage('bs-extensioninfo-software')->plain() . '</th>';
$aOut[] = '<th>' . wfMessage('bs-extensioninfo-version')->plain() . '</th>';
$aOut[] = '</tr>';
$aOut[] = '<tr>';
$aOut[] = '<td><a title="' . $wgBlueSpiceExtInfo['url'] . '" href="' . $wgBlueSpiceExtInfo['url'] . '">' . $wgBlueSpiceExtInfo['name'] . '</a>' . $sCreditsLink . '</td>';
$aOut[] = '<td>' . $sVersion . '</td>';
$aOut[] = '</tr>';
$aOut[] = '<tr>';
$aOut[] = '<td><a title="MediaWiki" href="http://www.mediawiki.org/"> MediaWiki </a></td>';
$oTitle = SpecialPage::getTitleFor("Version");
$aOut[] = '<td><a title="' . $oTitle->getFullText() . '" href="' . $oTitle->getFullURL() . '">' . $wgVersion . '</a></td>';
$aOut[] = '</tr>';
$aOut[] = '</table>';
$aOut[] = '<div id="bs-extensioninfo-grid"></div>';
return implode("\n", $aOut);
}
示例12: testLessFileCompilation
public function testLessFileCompilation()
{
$thisString = $this->toString();
$this->assertTrue(is_string($this->file) && is_file($this->file) && is_readable($this->file), "{$thisString} must refer to a readable file");
$compiler = ResourceLoader::getLessCompiler(RequestContext::getMain()->getConfig());
$this->assertNotNull($compiler->compileFile($this->file));
}
示例13: index
public function index()
{
$bodyContent = $this->request->getVal('bodyText', '');
$categoryLinks = $this->request->getVal('categoryLinks', '');
$afterBodyHtml = '';
$afterContentHookText = null;
// this hook allows adding extra HTML just after <body> opening tag
// append your content to $html variable instead of echoing
// (taken from Monaco skin)
$this->wf->RunHooks('GetHTMLAfterBody', array(RequestContext::getMain()->getSkin(), &$afterBodyHtml));
// this hook is needed for SMW's factbox
if (!$this->wf->RunHooks('SkinAfterContent', array(&$afterContentHookText))) {
$afterContentHookText = '';
}
/* Dont show header if user profile page */
if ($this->wg->Title->getNamespace() !== NS_USER) {
$this->response->setVal('pageHeaderContent', $this->app->renderView('WikiaMobilePageHeaderService', 'index'));
} else {
$this->response->setVal('pageHeaderContent', '');
}
$this->response->setVal('bodyContent', $bodyContent);
$this->response->setVal('relatedPages', !empty($this->wg->EnableRelatedPagesExt) && empty($this->wg->MakeWikiWebsite) && empty($this->wg->EnableAnswers) ? $this->app->renderView('RelatedPagesController', 'index') : null);
$this->response->setVal('categoryLinks', $this->app->renderView('WikiaMobileCategoryService', 'index', array('categoryLinks' => $categoryLinks)));
$this->response->setVal('navMenu', $this->app->renderView('WikiaMobileNavigationService', 'navMenu'));
$this->response->setVal('afterBodyContent', $afterBodyHtml);
$this->response->setVal('afterContentHookText', $afterContentHookText);
}
示例14: getPage
/**
* @brief Api entry point to get a page and globals and messages that are relevant to the page
*
* @example wikia.php?controller=CuratedContent&method=getPage&page={Title}
*/
public function getPage()
{
global $wgTitle;
// This will always return json
$this->response->setFormat('json');
$this->cacheResponseFor(7, self::DAYS);
// set mobile skin as this is based on it
RequestContext::getMain()->setSkin(Skin::newFromKey('wikiamobile'));
$titleName = $this->getVal('page');
$title = Title::newFromText($titleName);
if ($title instanceof Title) {
RequestContext::getMain()->setTitle($title);
$wgTitle = $title;
$revId = $title->getLatestRevID();
$articleId = $title->getArticleID();
if ($revId > 0) {
try {
$relatedPages = $this->app->sendRequest('RelatedPagesApi', 'getList', ['ids' => [$articleId]])->getVal('items')[$articleId];
if (!empty($relatedPages)) {
$this->response->setVal('relatedPages', $relatedPages);
}
} catch (NotFoundApiException $error) {
// If RelatedPagesApi is not available don't throw it to app
}
$this->response->setVal('html', $this->sendSelfRequest('renderPage', array('page' => $titleName))->toString());
$this->response->setVal('revisionid', $revId);
} else {
throw new NotFoundApiException('Revision ID = 0');
}
} else {
throw new NotFoundApiException('Title not found');
}
}
示例15: getDetails
protected function getDetails()
{
$article = \Article::newFromTitle($this->commentTitle, \RequestContext::getMain());
$service = new \ArticleService($article);
$snippet = $service->getTextSnippet();
return $snippet;
}