X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fapi%2FApiQueryLinks.php;h=7b675b0eede0b551cd91c0f07dc55ed1abc016cf;hb=4f5d2386f35384cea26db6f1ea6d7b5e425b8435;hp=3e55400f2d5dbc47ee806dcbd059b24b37eba6d6;hpb=53000baecf8374f00b2d1d65b70cbb084d07ba95;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/api/ApiQueryLinks.php b/includes/api/ApiQueryLinks.php index 3e55400f2d..7b675b0eed 100644 --- a/includes/api/ApiQueryLinks.php +++ b/includes/api/ApiQueryLinks.php @@ -4,7 +4,7 @@ * * Created on May 12, 2007 * - * Copyright © 2006 Yuri Astrakhan @gmail.com + * Copyright © 2006 Yuri Astrakhan "@gmail.com" * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -99,7 +99,7 @@ class ApiQueryLinks extends ApiQueryGeneratorBase { foreach ( $params[$this->titlesParam] as $t ) { $title = Title::newFromText( $t ); if ( !$title ) { - $this->setWarning( "``$t'' is not a valid title" ); + $this->setWarning( "\"$t\" is not a valid title" ); } else { $lb->addObj( $title ); } @@ -116,19 +116,20 @@ class ApiQueryLinks extends ApiQueryGeneratorBase { $this->dieUsage( 'Invalid continue param. You should pass the ' . 'original value returned by the previous query', '_badcontinue' ); } + $op = $params['dir'] == 'descending' ? '<' : '>'; $plfrom = intval( $cont[0] ); $plns = intval( $cont[1] ); - $pltitle = $this->getDB()->strencode( $this->titleToKey( $cont[2] ) ); + $pltitle = $this->getDB()->addQuotes( $this->titleToKey( $cont[2] ) ); $this->addWhere( - "{$this->prefix}_from > $plfrom OR " . + "{$this->prefix}_from $op $plfrom OR " . "({$this->prefix}_from = $plfrom AND " . - "({$this->prefix}_namespace > $plns OR " . + "({$this->prefix}_namespace $op $plns OR " . "({$this->prefix}_namespace = $plns AND " . - "{$this->prefix}_title >= '$pltitle')))" + "{$this->prefix}_title $op= $pltitle)))" ); } - $dir = ( $params['dir'] == 'descending' ? ' DESC' : '' ); + $sort = ( $params['dir'] == 'descending' ? ' DESC' : '' ); // Here's some MySQL craziness going on: if you use WHERE foo='bar' // and later ORDER BY foo MySQL doesn't notice the ORDER BY is pointless // but instead goes and filesorts, because the index for foo was used @@ -136,13 +137,13 @@ class ApiQueryLinks extends ApiQueryGeneratorBase { // clause from the ORDER BY clause $order = array(); if ( count( $this->getPageSet()->getGoodTitles() ) != 1 ) { - $order[] = $this->prefix . '_from' . $dir; + $order[] = $this->prefix . '_from' . $sort; } if ( count( $params['namespace'] ) != 1 ) { - $order[] = $this->prefix . '_namespace' . $dir; + $order[] = $this->prefix . '_namespace' . $sort; } - $order[] = $this->prefix . "_title" . $dir; + $order[] = $this->prefix . '_title' . $sort; $this->addOption( 'ORDER BY', $order ); $this->addOption( 'USE INDEX', $this->prefix . '_from' ); $this->addOption( 'LIMIT', $params['limit'] + 1 ); @@ -226,18 +227,26 @@ class ApiQueryLinks extends ApiQueryGeneratorBase { ); } + public function getResultProperties() { + return array( + '' => array( + 'ns' => 'namespace', + 'title' => 'string' + ) + ); + } + public function getDescription() { return "Returns all {$this->description}s from the given page(s)"; } public function getExamples() { + $desc = $this->description; + $name = $this->getModuleName(); return array( - "Get {$this->description}s from the [[Main Page]]:", - " api.php?action=query&prop={$this->getModuleName()}&titles=Main%20Page", - "Get information about the {$this->description} pages in the [[Main Page]]:", - " api.php?action=query&generator={$this->getModuleName()}&titles=Main%20Page&prop=info", - "Get {$this->description}s from the Main Page in the User and Template namespaces:", - " api.php?action=query&prop={$this->getModuleName()}&titles=Main%20Page&{$this->prefix}namespace=2|10" + "api.php?action=query&prop={$name}&titles=Main%20Page" => "Get {$desc}s from the [[Main Page]]:", + "api.php?action=query&generator={$name}&titles=Main%20Page&prop=info" => "Get information about the {$desc} pages in the [[Main Page]]:", + "api.php?action=query&prop={$name}&titles=Main%20Page&{$this->prefix}namespace=2|10" => "Get {$desc}s from the Main Page in the User and Template namespaces:", ); }