Merge "Revert "Adding sanity check to Title::isRedirect().""
[lhc/web/wiklou.git] / includes / api / ApiQueryLangBacklinks.php
index 19d7472..efc2e81 100644 (file)
  * @file
  */
 
-if ( !defined( 'MEDIAWIKI' ) ) {
-       // Eclipse helper - will be ignored in production
-       require_once( "ApiQueryBase.php" );
-}
-
 /**
  * This gives links pointing to the given interwiki
  * @ingroup API
@@ -66,27 +61,28 @@ class ApiQueryLangBacklinks extends ApiQueryGeneratorBase {
                                        'original value returned by the previous query', '_badcontinue' );
                        }
 
-                       $prefix = $this->getDB()->strencode( $cont[0] );
-                       $title = $this->getDB()->strencode( $this->titleToKey( $cont[1] ) );
+                       $db = $this->getDB();
+                       $prefix = $db->addQuotes( $cont[0] );
+                       $title = $db->addQuotes( $this->titleToKey( $cont[1] ) );
                        $from = intval( $cont[2] );
                        $this->addWhere(
-                               "ll_lang > '$prefix' OR " .
-                               "(ll_lang = '$prefix' AND " .
-                               "(ll_title > '$title' OR " .
-                               "(ll_title = '$title' AND " .
+                               "ll_lang > $prefix OR " .
+                               "(ll_lang = $prefix AND " .
+                               "(ll_title > $title OR " .
+                               "(ll_title = $title AND " .
                                "ll_from >= $from)))"
                        );
                }
 
                $prop = array_flip( $params['prop'] );
-               $lllang = isset( $prop['llang'] );
+               $lllang = isset( $prop['lllang'] );
                $lltitle = isset( $prop['lltitle'] );
 
                $this->addTables( array( 'langlinks', 'page' ) );
                $this->addWhere( 'll_from = page_id' );
 
                $this->addFields( array( 'page_id', 'page_title', 'page_namespace', 'page_is_redirect',
-                       'll_from', 'iwl_lang', 'll_title' ) );
+                       'll_from', 'll_lang', 'll_title' ) );
 
                if ( isset( $params['lang'] ) ) {
                        $this->addWhereFld( 'll_lang', $params['lang'] );
@@ -94,10 +90,17 @@ class ApiQueryLangBacklinks extends ApiQueryGeneratorBase {
                                $this->addWhereFld( 'll_title', $params['title'] );
                                $this->addOption( 'ORDER BY', 'll_from' );
                        } else {
-                               $this->addOption( 'ORDER BY', 'll_title, ll_from' );
+                               $this->addOption( 'ORDER BY', array(
+                                       'll_title',
+                                       'll_from'
+                               ));
                        }
                } else {
-                       $this->addOption( 'ORDER BY', 'll_lang, ll_title, ll_from' );
+                       $this->addOption( 'ORDER BY', array(
+                               'll_lang',
+                               'll_title',
+                               'll_from'
+                       ));
                }
 
                $this->addOption( 'LIMIT', $params['limit'] + 1 );
@@ -129,11 +132,11 @@ class ApiQueryLangBacklinks extends ApiQueryGeneratorBase {
                                }
 
                                if ( $lllang ) {
-                                       $entry['iwprefix'] = $row->ll_lang;
+                                       $entry['lllang'] = $row->ll_lang;
                                }
 
                                if ( $lltitle ) {
-                                       $entry['iwtitle'] = $row->ll_title;
+                                       $entry['lltitle'] = $row->ll_title;
                                }
 
                                $fit = $result->addValue( array( 'query', $this->getModuleName() ), null, $entry );
@@ -157,7 +160,7 @@ class ApiQueryLangBacklinks extends ApiQueryGeneratorBase {
 
        public function getAllowedParams() {
                return array(
-                       'prefix' => null,
+                       'lang' => null,
                        'title' => null,
                        'continue' => null,
                        'limit' => array(
@@ -181,7 +184,7 @@ class ApiQueryLangBacklinks extends ApiQueryGeneratorBase {
        public function getParamDescription() {
                return array(
                        'lang' => 'Language for the language link',
-                       'title' => "Language link to search for. Must be used with {$this->getModulePrefix()}prefix",
+                       'title' => "Language link to search for. Must be used with {$this->getModulePrefix()}lang",
                        'continue' => 'When more results are available, use this to continue',
                        'prop' => array(
                                'Which properties to get',
@@ -207,10 +210,10 @@ class ApiQueryLangBacklinks extends ApiQueryGeneratorBase {
                ) );
        }
 
-       protected function getExamples() {
+       public function getExamples() {
                return array(
-                       'api.php?action=query&list=llbacklinks&lbltitle=Test&lbllang=fr',
-                       'api.php?action=query&generator=llbacklinks&glbltitle=Test&lbllang=fr&prop=info'
+                       'api.php?action=query&list=langbacklinks&lbltitle=Test&lbllang=fr',
+                       'api.php?action=query&generator=langbacklinks&glbltitle=Test&glbllang=fr&prop=info'
                );
        }