Index: trunk/phase3/includes/api/ApiQueryIWLinks.php |
— | — | @@ -54,6 +54,14 @@ |
55 | 55 | |
56 | 56 | $this->addTables( 'iwlinks' ); |
57 | 57 | $this->addWhereFld( 'iwl_from', array_keys( $this->getPageSet()->getGoodTitles() ) ); |
| 58 | + |
| 59 | + $url = !is_null( $params['url'] ); |
| 60 | + if ( $url ) { |
| 61 | + $this->addTables( 'interwiki' ); |
| 62 | + $this->addJoinConds( array( 'interwiki' => array( 'INNER JOIN', 'iw_prefix=iwl_prefix' ) ) ); |
| 63 | + $this->addFields( 'iw_url' ); |
| 64 | + } |
| 65 | + |
58 | 66 | if ( !is_null( $params['continue'] ) ) { |
59 | 67 | $cont = explode( '|', $params['continue'] ); |
60 | 68 | if ( count( $cont ) != 3 ) { |
— | — | @@ -91,6 +99,12 @@ |
92 | 100 | break; |
93 | 101 | } |
94 | 102 | $entry = array( 'prefix' => $row->iwl_prefix ); |
| 103 | + |
| 104 | + if ( $url ) { |
| 105 | + $rowUrl = str_replace( '$1', $row->iwl_title, $row->iw_url ); |
| 106 | + $entry = array_merge( $entry, array( 'url' => $rowUrl ) ); |
| 107 | + } |
| 108 | + |
95 | 109 | ApiResult::setContent( $entry, $row->iwl_title ); |
96 | 110 | $fit = $this->addPageSubItem( $row->iwl_from, $entry ); |
97 | 111 | if ( !$fit ) { |
— | — | @@ -103,6 +117,7 @@ |
104 | 118 | |
105 | 119 | public function getAllowedParams() { |
106 | 120 | return array( |
| 121 | + 'url' => null, |
107 | 122 | 'limit' => array( |
108 | 123 | ApiBase::PARAM_DFLT => 10, |
109 | 124 | ApiBase::PARAM_TYPE => 'limit', |
— | — | @@ -116,6 +131,7 @@ |
117 | 132 | |
118 | 133 | public function getParamDescription() { |
119 | 134 | return array( |
| 135 | + 'url' => 'Whether to get the full URL', |
120 | 136 | 'limit' => 'How many interwiki links to return', |
121 | 137 | 'continue' => 'When more results are available, use this to continue', |
122 | 138 | ); |