'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();
+ $op = $params['dir'] == 'descending' ? '<' : '>';
+ $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_from >= $from)))"
+ "ll_lang $op $prefix OR " .
+ "(ll_lang = $prefix AND " .
+ "(ll_title $op $title OR " .
+ "(ll_title = $title AND " .
+ "ll_from $op= $from)))"
);
}
$this->addFields( array( 'page_id', 'page_title', 'page_namespace', 'page_is_redirect',
'll_from', 'll_lang', 'll_title' ) );
+ $sort = ( $params['dir'] == 'descending' ? ' DESC' : '' );
if ( isset( $params['lang'] ) ) {
$this->addWhereFld( 'll_lang', $params['lang'] );
if ( isset( $params['title'] ) ) {
$this->addWhereFld( 'll_title', $params['title'] );
- $this->addOption( 'ORDER BY', 'll_from' );
+ $this->addOption( 'ORDER BY', 'll_from' . $sort );
} else {
- $this->addOption( 'ORDER BY', 'll_title, ll_from' );
+ $this->addOption( 'ORDER BY', array(
+ 'll_title' . $sort,
+ 'll_from' . $sort
+ ));
}
} else {
- $this->addOption( 'ORDER BY', 'll_lang, ll_title, ll_from' );
+ $this->addOption( 'ORDER BY', array(
+ 'll_lang' . $sort,
+ 'll_title' . $sort,
+ 'll_from' . $sort
+ ));
}
$this->addOption( 'LIMIT', $params['limit'] + 1 );
'lltitle',
),
),
+ 'dir' => array(
+ ApiBase::PARAM_DFLT => 'ascending',
+ ApiBase::PARAM_TYPE => array(
+ 'ascending',
+ 'descending'
+ )
+ ),
);
}
' lltitle - Adds the title of the language ink',
),
'limit' => 'How many total pages to return',
+ 'dir' => 'The direction in which to list',
+ );
+ }
+
+ public function getResultProperties() {
+ return array(
+ '' => array(
+ 'pageid' => 'integer',
+ 'ns' => 'namespace',
+ 'title' => 'string',
+ 'redirect' => 'boolean'
+ ),
+ 'lllang' => array(
+ 'lllang' => 'string'
+ ),
+ 'lltitle' => array(
+ 'lltitle' => 'string'
+ )
);
}