added unit tests for WikitextContent
[lhc/web/wiklou.git] / includes / api / ApiQueryExternalLinks.php
index d4497e7..a9fbc83 100644 (file)
  * @file
  */
 
-if ( !defined( 'MEDIAWIKI' ) ) {
-       // Eclipse helper - will be ignored in production
-       require_once( "ApiQueryBase.php" );
-}
-
 /**
  * A query module to list all external URLs found on a given set of pages.
  *
@@ -69,6 +64,11 @@ class ApiQueryExternalLinks extends ApiQueryBase {
                        $this->addOption( 'ORDER BY', 'el_from' );
                }
 
+               // If we're querying all protocols, use DISTINCT to avoid repeating protocol-relative links twice
+               if ( $protocol === null ) {
+                       $this->addOption( 'DISTINCT' );
+               }
+
                $this->addOption( 'LIMIT', $params['limit'] + 1 );
                $offset = isset( $params['offset'] ) ? $params['offset'] : 0;
                if ( $offset ) {
@@ -143,15 +143,14 @@ class ApiQueryExternalLinks extends ApiQueryBase {
                ) );
        }
 
-       protected function getExamples() {
+       public function getExamples() {
                return array(
-                       'Get a list of external links on the [[Main Page]]:',
-                       '  api.php?action=query&prop=extlinks&titles=Main%20Page',
+                       'api.php?action=query&prop=extlinks&titles=Main%20Page' => 'Get a list of external links on the [[Main Page]]',
                );
        }
 
        public function getHelpUrls() {
-               return 'http://www.mediawiki.org/wiki/API:Properties#extlinks_.2F_el';
+               return 'https://www.mediawiki.org/wiki/API:Properties#extlinks_.2F_el';
        }
 
        public function getVersion() {