| Index: trunk/phase3/includes/SpecialIpblocklist.php |
| — | — | @@ -126,51 +126,118 @@ |
| 127 | 127 | if ( "" != $msg ) { |
| 128 | 128 | $wgOut->setSubtitle( $msg ); |
| 129 | 129 | } |
| | 130 | + global $wgRequest; |
| | 131 | + list( $this->limit, $this->offset ) = $wgRequest->getLimitOffset(); |
| | 132 | + $this->counter = 0; |
| | 133 | + |
| | 134 | + $paging = '<p>' . wfViewPrevNext( $this->offset, $this->limit, |
| | 135 | + Title::makeTitle( NS_SPECIAL, 'Ipblocklist' ), |
| | 136 | + 'ip=' . urlencode( $this->ip ) ) . "</p>\n"; |
| | 137 | + $wgOut->addHTML( $paging ); |
| | 138 | + |
| | 139 | + $search = $this->searchForm(); |
| | 140 | + $wgOut->addHTML( $search ); |
| | 141 | + |
| 130 | 142 | $wgOut->addHTML( "<ul>" ); |
| 131 | | - // FIXME hack to solve #bug 1487 |
| 132 | | - if(!Block::enumBlocks( "wfAddRow", 0 )) |
| 133 | | - $wgOut->addHTML( '<li>'.wfMsg( 'ipblocklistempty' ).'</li>' ); |
| | 143 | + if( !Block::enumBlocks( array( &$this, "addRow" ), 0 ) ) { |
| | 144 | + // FIXME hack to solve #bug 1487 |
| | 145 | + $wgOut->addHTML( '<li>'.wfMsgHtml( 'ipblocklistempty' ).'</li>' ); |
| | 146 | + } |
| 134 | 147 | $wgOut->addHTML( "</ul>\n" ); |
| | 148 | + $wgOut->addHTML( $paging ); |
| 135 | 149 | } |
| 136 | | -} |
| 137 | | - |
| 138 | | -/** |
| 139 | | - * Callback function to output a block |
| 140 | | - */ |
| 141 | | -function wfAddRow( $block, $tag ) { |
| 142 | | - global $wgOut, $wgUser, $wgLang, $wgContLang; |
| 143 | | - |
| 144 | | - $sk = $wgUser->getSkin(); |
| 145 | | - |
| 146 | | - # Hide addresses blocked by User::spreadBlocks, for privacy |
| 147 | | - $addr = $block->mAuto ? "#{$block->mId}" : $block->mAddress; |
| 148 | | - |
| 149 | | - $name = $block->getByName(); |
| 150 | | - $ulink = $sk->makeKnownLinkObj( Title::makeTitle( NS_USER, $name ), $name ); |
| 151 | | - $formattedTime = $wgLang->timeanddate( $block->mTimestamp, true ); |
| 152 | 150 | |
| 153 | | - if ( $block->mExpiry === "" ) { |
| 154 | | - $formattedExpiry = wfMsgHtml('infiniteblock'); |
| 155 | | - } else { |
| 156 | | - $formattedExpiry = wfMsgHtml('expiringblock', $wgLang->timeanddate( $block->mExpiry, true ) ); |
| | 151 | + function searchForm() { |
| | 152 | + global $wgTitle; |
| | 153 | + return |
| | 154 | + wfElement( 'form', array( |
| | 155 | + 'action' => $wgTitle->getLocalUrl() ), |
| | 156 | + null ) . |
| | 157 | + wfElement( 'input', array( |
| | 158 | + 'type' => 'hidden', |
| | 159 | + 'name' => 'action', |
| | 160 | + 'value' => 'search' ) ). |
| | 161 | + wfElement( 'input', array( |
| | 162 | + 'type' => 'hidden', |
| | 163 | + 'name' => 'limit', |
| | 164 | + 'value' => $this->limit ) ). |
| | 165 | + wfElement( 'input', array( |
| | 166 | + 'name' => 'ip', |
| | 167 | + 'value' => $this->ip ) ) . |
| | 168 | + wfElement( 'input', array( |
| | 169 | + 'type' => 'submit', |
| | 170 | + 'value' => wfMsg( 'search' ) ) ) . |
| | 171 | + '</form>'; |
| 157 | 172 | } |
| | 173 | + |
| | 174 | + /** |
| | 175 | + * Callback function to output a block |
| | 176 | + */ |
| | 177 | + function addRow( $block, $tag ) { |
| | 178 | + global $wgOut, $wgUser, $wgLang, $wgContLang; |
| | 179 | + |
| | 180 | + if( $this->ip != '' ) { |
| | 181 | + if( stristr( $block->mAddress, $this->ip ) == false ) { |
| | 182 | + return; |
| | 183 | + } |
| | 184 | + } |
| | 185 | + |
| | 186 | + // Loading blocks is fast; displaying them is slow. |
| | 187 | + // Quick hack for paging. |
| | 188 | + $this->counter++; |
| | 189 | + if( $this->counter <= $this->offset ) { |
| | 190 | + return; |
| | 191 | + } |
| | 192 | + if( $this->counter - $this->offset > $this->limit ) { |
| | 193 | + return; |
| | 194 | + } |
| | 195 | + |
| | 196 | + $fname = 'IPUnblockForm-addRow'; |
| | 197 | + wfProfileIn( $fname ); |
| | 198 | + |
| | 199 | + static $sk=null, $msg=null; |
| | 200 | + |
| | 201 | + if( is_null( $sk ) ) |
| | 202 | + $sk = $wgUser->getSkin(); |
| | 203 | + if( is_null( $msg ) ) { |
| | 204 | + $msg = array(); |
| | 205 | + foreach( array( 'infiniteblock', 'expiringblock', 'contribslink', 'unblocklink' ) as $key ) { |
| | 206 | + $msg[$key] = wfMsgHtml( $key ); |
| | 207 | + } |
| | 208 | + $msg['blocklistline'] = wfMsg( 'blocklistline' ); |
| | 209 | + } |
| 158 | 210 | |
| 159 | | - $line = wfMsg( "blocklistline", $formattedTime, $ulink, $addr, $formattedExpiry ); |
| | 211 | + # Hide addresses blocked by User::spreadBlocks, for privacy |
| | 212 | + $addr = $block->mAuto ? "#{$block->mId}" : $block->mAddress; |
| 160 | 213 | |
| 161 | | - $wgOut->addHTML( "<li>{$line}" ); |
| 162 | | - |
| 163 | | - if ( !$block->mAuto ) { |
| 164 | | - $titleObj = Title::makeTitle( NS_SPECIAL, "Contributions" ); |
| 165 | | - $wgOut->addHTML( ' (' . $sk->makeKnownLinkObj($titleObj, wfMsgHtml( 'contribslink' ), "target={$block->mAddress}") . ')' ); |
| | 214 | + $name = $block->getByName(); |
| | 215 | + $ulink = $sk->makeKnownLinkObj( Title::makeTitle( NS_USER, $name ), $name ); |
| | 216 | + $formattedTime = $wgLang->timeanddate( $block->mTimestamp, true ); |
| | 217 | + |
| | 218 | + if ( $block->mExpiry === "" ) { |
| | 219 | + $formattedExpiry = $msg['infiniteblock']; |
| | 220 | + } else { |
| | 221 | + $formattedExpiry = wfMsgReplaceArgs( $msg['expiringblock'], |
| | 222 | + array( $wgLang->timeanddate( $block->mExpiry, true ) ) ); |
| | 223 | + } |
| | 224 | + |
| | 225 | + $line = wfMsgReplaceArgs( $msg['blocklistline'], array( $formattedTime, $ulink, $addr, $formattedExpiry ) ); |
| | 226 | + |
| | 227 | + $wgOut->addHTML( "<li>{$line}" ); |
| | 228 | + |
| | 229 | + if ( !$block->mAuto ) { |
| | 230 | + $titleObj = Title::makeTitle( NS_SPECIAL, "Contributions" ); |
| | 231 | + $wgOut->addHTML( ' (' . $sk->makeKnownLinkObj($titleObj, $msg['contribslink'], "target={$block->mAddress}") . ')' ); |
| | 232 | + } |
| | 233 | + |
| | 234 | + if ( $wgUser->isAllowed('block') ) { |
| | 235 | + $titleObj = Title::makeTitle( NS_SPECIAL, "Ipblocklist" ); |
| | 236 | + $wgOut->addHTML( ' (' . $sk->makeKnownLinkObj($titleObj, $msg['unblocklink'], 'action=unblock&ip=' . urlencode( $addr ) ) . ')' ); |
| | 237 | + } |
| | 238 | + $wgOut->addHTML( $sk->commentBlock( $block->mReason ) ); |
| | 239 | + $wgOut->addHTML( "</li>\n" ); |
| | 240 | + wfProfileOut( $fname ); |
| 166 | 241 | } |
| 167 | | - |
| 168 | | - if ( $wgUser->isAllowed('block') ) { |
| 169 | | - $titleObj = Title::makeTitle( NS_SPECIAL, "Ipblocklist" ); |
| 170 | | - $wgOut->addHTML( ' (' . $sk->makeKnownLinkObj($titleObj, wfMsgHtml( 'unblocklink' ), 'action=unblock&ip=' . urlencode( $addr ) ) . ')' ); |
| 171 | | - } |
| 172 | | - $wgOut->addHTML( $sk->commentBlock( $block->mReason ) ); |
| 173 | | - $wgOut->addHTML( "</li>\n" ); |
| 174 | 242 | } |
| 175 | 243 | |
| 176 | | - |
| 177 | 244 | ?> |
| Index: trunk/phase3/includes/Block.php |
| — | — | @@ -219,10 +219,10 @@ |
| 220 | 220 | |
| 221 | 221 | if ( !( $flags & EB_KEEP_EXPIRED ) ) { |
| 222 | 222 | if ( !$block->deleteIfExpired() ) { |
| 223 | | - $callback( $block, $tag ); |
| | 223 | + call_user_func( $callback, $block, $tag ); |
| 224 | 224 | } |
| 225 | 225 | } else { |
| 226 | | - $callback( $block, $tag ); |
| | 226 | + call_user_func( $callback, $block, $tag ); |
| 227 | 227 | } |
| 228 | 228 | } |
| 229 | 229 | wfFreeResult( $res ); |
| Index: trunk/phase3/RELEASE-NOTES |
| — | — | @@ -65,6 +65,7 @@ |
| 66 | 66 | * Finally dropped MySQL 3.23.x support |
| 67 | 67 | * Experimental feature to allow translation of block expiry times |
| 68 | 68 | Implementation only for Finnish currently |
| | 69 | +* (bug 3284) Ipblocklist paging, substring search |
| 69 | 70 | |
| 70 | 71 | |
| 71 | 72 | === Caveats === |