r94213 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r94212‎ | r94213 | r94214 >
Date:23:57, 10 August 2011
Author:jeroendedauw
Status:deferred
Tags:
Comment:
Modified paths:
  • /trunk/extensions/SemanticMediaWiki/specials/AskSpecial/SMW_SpecialAsk.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticMediaWiki/specials/AskSpecial/SMW_SpecialAsk.php
@@ -361,7 +361,7 @@
362362 $result_mime = false; // output in MW Special page as usual
363363
364364 // build parameter strings for URLs, based on current settings
365 - $urltail = '&q=' . urlencode( $this->m_querystring );
 365+ $urlArgs['q'] = $this->m_querystring;
366366
367367 $tmp_parray = array();
368368 foreach ( $this->m_params as $key => $value ) {
@@ -370,16 +370,16 @@
371371 }
372372 }
373373
374 - $urltail .= '&p=' . urlencode( SMWInfolink::encodeParameters( $tmp_parray ) );
 374+ $urlArgs['p'] = SMWInfolink::encodeParameters( $tmp_parray );
375375 $printoutstring = '';
376376
377377 foreach ( $this->m_printouts as $printout ) {
378378 $printoutstring .= $printout->getSerialisation() . "\n";
379379 }
380380
381 - if ( $printoutstring != '' ) $urltail .= '&po=' . urlencode( $printoutstring );
382 - if ( array_key_exists( 'sort', $this->m_params ) ) $urltail .= '&sort=' . $this->m_params['sort'];
383 - if ( array_key_exists( 'order', $this->m_params ) ) $urltail .= '&order=' . $this->m_params['order'];
 381+ if ( $printoutstring != '' ) $urlArgs['po'] = $printoutstring;
 382+ if ( array_key_exists( 'sort', $this->m_params ) ) $urlArgs['sort'] = $this->m_params['sort'];
 383+ if ( array_key_exists( 'order', $this->m_params ) ) $urlArgs['order'] = $this->m_params['order'];
384384
385385 if ( $this->m_querystring != '' ) {
386386 $queryobj = SMWQueryProcessor::createQuery( $this->m_querystring, $this->m_params, SMWQueryProcessor::SPECIAL_PAGE , $this->m_params['format'], $this->m_printouts );
@@ -425,10 +425,14 @@
426426
427427 if ( $result_mime == false ) {
428428 if ( $res->getCount() > 0 ) {
429 - if ( $this->m_editquery ) $urltail .= '&eq=yes';
430 - if ( $hidequery ) $urltail .= '&eq=no';
 429+ if ( $this->m_editquery ) {
 430+ $urlArgs['eq'] = 'yes';
 431+ }
 432+ else if ( $hidequery ) {
 433+ $urlArgs['eq'] = 'no';
 434+ }
431435
432 - $navigation = $this->getNavigationBar( $res, $urltail );
 436+ $navigation = $this->getNavigationBar( $res, $urlArgs );
433437 $result .= '<div style="text-align: center;">' . "\n" . $navigation . "\n</div>\n";
434438 $query_result = $printer->getResult( $res, $this->m_params, SMW_OUTPUT_HTML );
435439
@@ -440,7 +444,7 @@
441445
442446 $result .= '<div style="text-align: center;">' . "\n" . $navigation . "\n</div>\n";
443447 } else {
444 - $result = '<div style="text-align: center;">' . wfMsg( 'smw_result_noresults' ) . '</div>';
 448+ $result = '<div style="text-align: center;">' . wfMsgHtml( 'smw_result_noresults' ) . '</div>';
445449 }
446450 } else { // make a stand-alone file
447451 $result = $printer->getResult( $res, $this->m_params, SMW_OUTPUT_FILE );
@@ -455,7 +459,13 @@
456460 $wgOut->setHTMLtitle( wfMsg( 'ask' ) );
457461 }
458462
459 - $result = $this->getInputForm( $printoutstring, 'offset=' . $this->m_params['offset'] . '&limit=' . $this->m_params['limit'] . $urltail ) . $result;
 463+ $result = $this->getInputForm(
 464+ $printoutstring,
 465+ 'offset=' . $this->m_params['offset']
 466+ . '&limit=' . $this->m_params['limit']
 467+ . wfArrayToCGI( $urlArgs )
 468+ ) . $result;
 469+
460470 $wgOut->addHTML( $result );
461471 } else {
462472 $wgOut->disable();
@@ -560,7 +570,7 @@
561571 $result .= '<fieldset><legend>' . wfMsg( 'smw_ask_otheroptions' ) . "</legend>\n";
562572 $result .= "<div id=\"other_options\">" . $this->showFormatOptions( $this->m_params['format'], $this->m_params ) . "</div>";
563573 $result .= "</fieldset>\n";
564 - $urltail = str_replace( '&eq=yes', '', $urltail ) . '&eq=no';
 574+ $urltail = str_replace( '&eq=yes', '', $urltail ) . '&eq=no'; // FIXME: doing it wrong, srysly
565575
566576 $result .= '<br /><input type="submit" value="' . wfMsg( 'smw_ask_submit' ) . '"/>' .
567577 '<input type="hidden" name="eq" value="yes"/>' .
@@ -629,11 +639,11 @@
630640 * Build the navigation for some given query result, reuse url-tail parameters.
631641 *
632642 * @param SMWQueryResult $res
633 - * @param string $urltail
 643+ * @param array $urlArgs
634644 *
635645 * @return string
636646 */
637 - protected function getNavigationBar( SMWQueryResult $res, $urltail ) {
 647+ protected function getNavigationBar( SMWQueryResult $res, array $urlArgs ) {
638648 global $smwgQMaxInlineLimit;
639649
640650 $offset = $this->m_params['offset'];
@@ -646,8 +656,8 @@
647657 array(
648658 'href' => SpecialPage::getSafeTitleFor( 'Ask' )->getLocalURL( array(
649659 'offset' => max( 0, $offset - $limit ),
650 - 'limit' => $limit . $urltail
651 - ) ),
 660+ 'limit' => $limit
 661+ ) + $urlArgs ),
652662 'rel' => 'nofollow'
653663 ),
654664 wfMsg( 'smw_result_prev' )
@@ -670,8 +680,8 @@
671681 array(
672682 'href' => SpecialPage::getSafeTitleFor( 'Ask' )->getLocalURL( array(
673683 'offset' => ( $offset + $limit ),
674 - 'limit' => $limit . $urltail
675 - ) ),
 684+ 'limit' => $limit
 685+ ) + $urlArgs ),
676686 'rel' => 'nofollow'
677687 ),
678688 wfMsg( 'smw_result_next' )
@@ -698,8 +708,8 @@
699709 array(
700710 'href' => SpecialPage::getSafeTitleFor( 'Ask' )->getLocalURL( array(
701711 'offset' => $offset,
702 - 'limit' => $l . $urltail
703 - ) ),
 712+ 'limit' => $l
 713+ ) + $urlArgs ),
704714 'rel' => 'nofollow'
705715 ),
706716 $l