$uselang = $this->getUser()->getOption( 'language' );
$uselang = RequestContext::sanitizeLangCode( $uselang );
wfRunHooks( 'UserGetLanguageObject', array( $this->getUser(), &$uselang, $this ) );
+ } elseif ( $uselang === 'content' ) {
+ global $wgContLang;
+ $uselang = $wgContLang->getCode();
}
$code = RequestContext::sanitizeLangCode( $uselang );
$this->getContext()->setLanguage( $code );
if ( !$this->mInternalMode ) {
global $wgLang;
- $wgLang = RequestContext::getMain()->getLanguage();
+ $wgLang = $this->getContext()->getLanguage();
+ RequestContext::getMain()->setLanguage( $wgLang );
}
$config = $this->getConfig();
// then there's an appropriate Vary header set by whatever set
// their non-default language.
wfDebug( __METHOD__ . ": downgrading cache mode 'public' to " .
- "'anon-public-user-private' due to uselang=user\n" );
+ "'anon-public-user-private' due to uselang=user\n" );
$mode = 'anon-public-user-private';
}
* @return array
*/
public function getAllowedParams() {
- global $wgContLang;
-
return array(
'action' => array(
ApiBase::PARAM_DFLT => 'help',
'curtimestamp' => false,
'origin' => null,
'uselang' => array(
- ApiBase::PARAM_DFLT => $wgContLang->getCode(),
+ ApiBase::PARAM_DFLT => 'user',
),
);
}
/** @see ApiBase::getExamplesMessages() */
- public function getExamplesMessages() {
+ protected function getExamplesMessages() {
return array(
'action=help'
=> 'apihelp-help-example-main',
return $this->mModuleMgr;
}
+ /**
+ * Fetches the user agent used for this request
+ *
+ * The value will be the combination of the 'Api-User-Agent' header (if
+ * any) and the standard User-Agent header (if any).
+ *
+ * @return string
+ */
+ public function getUserAgent() {
+ return trim(
+ $this->getRequest()->getHeader( 'Api-user-agent' ) . ' ' .
+ $this->getRequest()->getHeader( 'User-agent' )
+ );
+ }
+
/************************************************************************//**
* @name Deprecated
* @{