(bug 13606) Added archivename to iiprop
authorBryan Tong Minh <btongminh@users.mediawiki.org>
Fri, 4 Apr 2008 11:49:20 +0000 (11:49 +0000)
committerBryan Tong Minh <btongminh@users.mediawiki.org>
Fri, 4 Apr 2008 11:49:20 +0000 (11:49 +0000)
RELEASE-NOTES
includes/api/ApiQueryExtLinksUsage.php
includes/api/ApiQueryImageInfo.php

index 7aae02e..beedfaa 100644 (file)
@@ -189,6 +189,7 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN
 * (bug 13603) Added siprop=usergroups to meta=siteinfo
 * Cleaned up redirect resolution
 * Added possibility to obtain all external links through list=exturlusage
+* (bug 13606) Added archivename to iiprop
 
 === Languages updated in 1.13 ===
 
index 2919adb..08e09cb 100644 (file)
@@ -54,31 +54,30 @@ class ApiQueryExtLinksUsage extends ApiQueryGeneratorBase {
                
                // Find the right prefix
                global $wgUrlProtocols;
-               if(!is_null($protocol) && $protocol != '' && !in_array($protocol, $wgUrlProtocols))
-               {
-                       foreach ($wgUrlProtocols as $p) {
-                               if( substr( $p, 0, strlen( $protocol ) ) === $protocol ) {
-                                       $protocol = $p;
-                                       break;
-                               }
+               foreach ($wgUrlProtocols as $p) {
+                       if( substr( $p, 0, strlen( $protocol ) ) === $protocol ) {
+                               $protocol = $p;
+                               break;
                        }
                }
                
-               $db = $this->getDb();
-               $this->addTables(array('page','externallinks'));        // must be in this order for 'USE INDEX' 
-               $this->addOption('USE INDEX', 'el_index');
-               $this->addWhere('page_id=el_from');
-               $this->addWhereFld('page_namespace', $params['namespace']);
-
-               if(!is_null($query) || $query != '')
-               {
+               $likeQuery = false;
+               if (!is_null($query)) {
                        $likeQuery = LinkFilter::makeLike($query , $protocol);
                        if (!$likeQuery)
                                $this->dieUsage('Invalid query', 'bad_query');
                        $likeQuery = substr($likeQuery, 0, strpos($likeQuery,'%')+1);
-                       $this->addWhere('el_index LIKE ' . $db->addQuotes( $likeQuery ));
                }
 
+               $this->addTables(array('page','externallinks'));        // must be in this order for 'USE INDEX' 
+               $this->addOption('USE INDEX', 'el_index');
+
+               $db = $this->getDB();
+               $this->addWhere('page_id=el_from');
+               if ($likeQuery)
+                       $this->addWhere('el_index LIKE ' . $db->addQuotes( $likeQuery ));
+               $this->addWhereFld('page_namespace', $params['namespace']);
+
                $prop = array_flip($params['prop']);
                $fld_ids = isset($prop['ids']);
                $fld_title = isset($prop['title']);
@@ -181,7 +180,7 @@ class ApiQueryExtLinksUsage extends ApiQueryGeneratorBase {
                        'prop' => 'What pieces of information to include',
                        'offset' => 'Used for paging. Use the value returned for "continue"',
                        'protocol' => 'Protocol of the url',
-                       'query' => 'Search string without protocol. See [[Special:LinkSearch]]. Leave empty to list all external links (euprotocol will be ignored)',
+                       'query' => 'Search string without protocol. See [[Special:LinkSearch]]',
                        'namespace' => 'The page namespace(s) to enumerate.',
                        'limit' => 'How many entries to return.'
                );
index fb11c12..69cc3a9 100644 (file)
@@ -50,6 +50,7 @@ class ApiQueryImageInfo extends ApiQueryBase {
                $this->fld_size = isset($prop['size']);
                $this->fld_sha1 = isset($prop['sha1']);
                $this->fld_metadata = isset($prop['metadata']);
+               $this->fld_archivename = isset($prop['archivename']);
                
                if($params['urlheight'] != -1 && $params['urlwidth'] == -1)
                        $this->dieUsage("iiurlheight cannot be used without iiurlwidth", 'iiurlwidth');
@@ -144,6 +145,9 @@ class ApiQueryImageInfo extends ApiQueryBase {
                        $vals['metadata'] = $metadata ? $metadata : null;
                        $this->getResult()->setIndexedTagName_recursive($vals['metadata'], 'meta');
                }
+               if($this->fld_archivename && $f->isOld())
+                       $vals['archivename'] = $f->getArchiveName();
+               
                return $vals;
        }
 
@@ -159,7 +163,8 @@ class ApiQueryImageInfo extends ApiQueryBase {
                                        'url',
                                        'size',
                                        'sha1',
-                                       'metadata'
+                                       'metadata',
+                                       'archivename'
                                )
                        ),
                        'limit' => array(