Add mw-body-content to indicators
[lhc/web/wiklou.git] / includes / api / ApiQueryInfo.php
index ea1b94e..e789dd4 100644 (file)
@@ -23,6 +23,8 @@
  *
  * @file
  */
+use MediaWiki\MediaWikiServices;
+use MediaWiki\Linker\LinkTarget;
 
 /**
  * A query module to show basic page information.
@@ -90,7 +92,7 @@ class ApiQueryInfo extends ApiQueryBase {
         * The prototype for a token function is func($pageid, $title)
         * it should return a token or false (permission denied)
         * @deprecated since 1.24
-        * @return array Array(tokenname => function)
+        * @return array [ tokenname => function ]
         */
        protected function getTokenFunctions() {
                // Don't call the hooks twice
@@ -425,7 +427,7 @@ class ApiQueryInfo extends ApiQueryBase {
                        foreach ( $this->params['token'] as $t ) {
                                $val = call_user_func( $tokenFunctions[$t], $pageid, $title );
                                if ( $val === false ) {
-                                       $this->setWarning( "Action '$t' is not allowed for the current user" );
+                                       $this->addWarning( [ 'apiwarn-tokennotallowed', $t ] );
                                } else {
                                        $pageInfo[$t . 'token'] = $val;
                                }
@@ -533,7 +535,6 @@ class ApiQueryInfo extends ApiQueryBase {
         * Get information about protections and put it in $protections
         */
        private function getProtectionInfo() {
-               global $wgContLang;
                $this->protections = [];
                $db = $this->getDB();
 
@@ -552,7 +553,7 @@ class ApiQueryInfo extends ApiQueryBase {
                                $a = [
                                        'type' => $row->pr_type,
                                        'level' => $row->pr_level,
-                                       'expiry' => $wgContLang->formatExpiry( $row->pr_expiry, TS_ISO_8601 )
+                                       'expiry' => ApiResult::formatExpiry( $row->pr_expiry )
                                ];
                                if ( $row->pr_cascade ) {
                                        $a['cascade'] = true;
@@ -612,7 +613,7 @@ class ApiQueryInfo extends ApiQueryBase {
                                $this->protections[$row->pt_namespace][$row->pt_title][] = [
                                        'type' => 'create',
                                        'level' => $row->pt_create_perm,
-                                       'expiry' => $wgContLang->formatExpiry( $row->pt_expiry, TS_ISO_8601 )
+                                       'expiry' => ApiResult::formatExpiry( $row->pt_expiry )
                                ];
                        }
                }
@@ -650,7 +651,7 @@ class ApiQueryInfo extends ApiQueryBase {
                                $this->protections[$row->tl_namespace][$row->tl_title][] = [
                                        'type' => $row->pr_type,
                                        'level' => $row->pr_level,
-                                       'expiry' => $wgContLang->formatExpiry( $row->pr_expiry, TS_ISO_8601 ),
+                                       'expiry' => ApiResult::formatExpiry( $row->pr_expiry ),
                                        'source' => $source->getPrefixedText()
                                ];
                        }
@@ -673,7 +674,7 @@ class ApiQueryInfo extends ApiQueryBase {
                                $this->protections[NS_FILE][$row->il_to][] = [
                                        'type' => $row->pr_type,
                                        'level' => $row->pr_level,
-                                       'expiry' => $wgContLang->formatExpiry( $row->pr_expiry, TS_ISO_8601 ),
+                                       'expiry' => ApiResult::formatExpiry( $row->pr_expiry ),
                                        'source' => $source->getPrefixedText()
                                ];
                        }
@@ -759,7 +760,7 @@ class ApiQueryInfo extends ApiQueryBase {
                $this->watched = [];
                $this->notificationtimestamps = [];
 
-               $store = WatchedItemStore::getDefaultInstance();
+               $store = MediaWikiServices::getInstance()->getWatchedItemStore();
                $timestamps = $store->getNotificationTimestampsBatch( $user, $this->everything );
 
                if ( $this->fld_watched ) {
@@ -799,7 +800,7 @@ class ApiQueryInfo extends ApiQueryBase {
                        $countOptions['minimumWatchers'] = $unwatchedPageThreshold;
                }
 
-               $this->watchers = WatchedItemStore::getDefaultInstance()->countWatchersMultiple(
+               $this->watchers = MediaWikiServices::getInstance()->getWatchedItemStore()->countWatchersMultiple(
                        $this->everything,
                        $countOptions
                );
@@ -866,8 +867,8 @@ class ApiQueryInfo extends ApiQueryBase {
                                )
                        );
                }
-
-               $this->visitingwatchers = WatchedItemStore::getDefaultInstance()->countVisitingWatchersMultiple(
+               $store = MediaWikiServices::getInstance()->getWatchedItemStore();
+               $this->visitingwatchers = $store->countVisitingWatchersMultiple(
                        $titlesWithThresholds,
                        !$canUnwatchedpages ? $unwatchedPageThreshold : null
                );