X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fapi%2FApiMain.php;h=004bfae94cb2702a5c17aaf910aa2e59f66972c0;hb=239b0c772a3cf4dc2160e2c36c2813cd705adb50;hp=bf26eeec0c44e61ad61fd72ebc0e94a6933f2d34;hpb=d1870da545e6b6e5420944c49787a4bf822c2f3b;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/api/ApiMain.php b/includes/api/ApiMain.php index bf26eeec0c..004bfae94c 100644 --- a/includes/api/ApiMain.php +++ b/includes/api/ApiMain.php @@ -192,6 +192,9 @@ class ApiMain extends ApiBase { $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 ); @@ -310,7 +313,7 @@ class ApiMain extends ApiBase { // 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'; } @@ -1121,8 +1124,6 @@ class ApiMain extends ApiBase { * @return array */ public function getAllowedParams() { - global $wgContLang; - return array( 'action' => array( ApiBase::PARAM_DFLT => 'help', @@ -1151,13 +1152,13 @@ class ApiMain extends ApiBase { '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', @@ -1241,6 +1242,21 @@ class ApiMain extends ApiBase { 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 * @{