API: (bug 16126) Added siprop=magicwords to meta=siteinfo
authorRoan Kattouw <catrope@users.mediawiki.org>
Sun, 26 Oct 2008 13:57:19 +0000 (13:57 +0000)
committerRoan Kattouw <catrope@users.mediawiki.org>
Sun, 26 Oct 2008 13:57:19 +0000 (13:57 +0000)
RELEASE-NOTES
includes/api/ApiQuerySiteinfo.php

index c431f84..8f938c4 100644 (file)
@@ -369,6 +369,7 @@ The following extensions are migrated into MediaWiki 1.14:
 * (bug 16074) rvprop=content combined with a generator with a high limit causes
   an error
 * (bug 16105) Image metadata attributes containing spaces result in invalid XML
+* (bug 16126) Added siprop=magicwords to meta=siteinfo
 
 === Languages updated in 1.14 ===
 
index b2d6da1..e0d045f 100644 (file)
@@ -57,6 +57,9 @@ class ApiQuerySiteinfo extends ApiQueryBase {
                                case 'specialpagealiases':
                                        $this->appendSpecialPageAliases( $p );
                                        break;
+                               case 'magicwords':
+                                       $this->appendMagicWords( $p );
+                                       break;
                                case 'interwikimap':
                                        $filteriw = isset( $params['filteriw'] ) ? $params['filteriw'] : false;
                                        $this->appendInterwikiMap( $p, $filteriw );
@@ -164,6 +167,23 @@ class ApiQuerySiteinfo extends ApiQueryBase {
                $this->getResult()->setIndexedTagName( $data, 'specialpage' );
                $this->getResult()->addValue( 'query', $property, $data );
        }
+       
+       protected function appendMagicWords( $property ) {
+               global $wgContLang;
+               $data = array();
+               foreach($wgContLang->getMagicWords() as $magicword => $aliases)
+               {
+                       $caseSensitive = array_shift($aliases);
+                       $arr = array('name' => $magicword, 'aliases' => $aliases);
+                       if($caseSensitive)
+                               $arr['case-sensitive'] = '';
+                       $this->getResult()->setIndexedTagName($arr['aliases'], 'alias');
+                       $data[] = $arr;
+               }
+               $this->getResult()->setIndexedTagName($data, 'magicword');
+               $this->getResult()->addValue('query', $property, $data);
+       }
+                       
 
        protected function appendInterwikiMap( $property, $filter ) {
                $this->resetQueryParams();
@@ -268,6 +288,7 @@ class ApiQuerySiteinfo extends ApiQueryBase {
                                        'namespaces',
                                        'namespacealiases',
                                        'specialpagealiases',
+                                       'magicwords',
                                        'interwikimap',
                                        'dbrepllag',
                                        'statistics',
@@ -292,6 +313,7 @@ class ApiQuerySiteinfo extends ApiQueryBase {
                                ' "namespaces"   - List of registered namespaces (localized)',
                                ' "namespacealiases" - List of registered namespace aliases',
                                ' "specialpagealiases" - List of special page aliases',
+                               ' "magicwords"   - List of magic words and their aliases',
                                ' "statistics"   - Returns site statistics',
                                ' "interwikimap" - Returns interwiki map (optionally filtered)',
                                ' "dbrepllag"    - Returns database server with the highest replication lag',