r60606 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r60605‎ | r60606 | r60607 >
Date:18:18, 4 January 2010
Author:yaron
Status:deferred
Tags:
Comment:
Got edit query/hide query links to work again, and improved handling of export formats like CSV and JSON (only the link is now shown by default), both thanks to the new 'eq=no' query string option
Modified paths:
  • /trunk/extensions/SemanticMediaWiki/specials/AskSpecial/SMW_SpecialAsk.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticMediaWiki/specials/AskSpecial/SMW_SpecialAsk.php
@@ -157,8 +157,7 @@
158158 }
159159 $this->m_params['limit'] = min($this->m_params['limit'], $smwgQMaxInlineLimit);
160160
161 - $this->m_editquery = ( $wgRequest->getVal( 'eq' ) != '' ) || ('' == $this->m_querystring );
162 -$this->m_editquery = true;
 161+ $this->m_editquery = ( $wgRequest->getVal( 'eq' ) == 'yes' ) || ('' == $this->m_querystring );
163162 }
164163
165164 protected function makeHTMLResult() {
@@ -289,8 +288,20 @@
290289 }
291290 $printer = SMWQueryProcessor::getResultPrinter($this->m_params['format'], SMWQueryProcessor::SPECIAL_PAGE);
292291 $result_mime = $printer->getMimeType($res);
 292+ global $wgRequest;
 293+ $hidequery = $wgRequest->getVal( 'eq' ) == 'no';
 294+ // if it's an export format (like CSV, JSON, etc.),
 295+ // don't actually export the data if 'eq' is set to
 296+ // either 'yes' or 'no' in the query string - just
 297+ // show the link instead
 298+ if ($this->m_editquery || $hidequery)
 299+ $result_mime = false;
293300 if ($result_mime == false) {
294301 if ( $res->getCount() > 0 ) {
 302+ if ($this->m_editquery)
 303+ $urltail .= '&eq=yes';
 304+ if ($hidequery)
 305+ $urltail .= '&eq=no';
295306 $navigation = $this->getNavigationBar($res, $urltail);
296307 $result .= '<div style="text-align: center;">' . "\n" . $navigation . "\n</div>\n";
297308 $query_result = $printer->getResult($res, $this->m_params,SMW_OUTPUT_HTML);
@@ -399,16 +410,18 @@
400411 $result .= '<fieldset><legend>' . wfMsg('smw_ask_otheroptions') . "</legend>\n";
401412 $result .= "<div id=\"other_options\">" . self::showFormatOptions($this->m_params['format'], $this->m_params) . "</div>";
402413 $result .= "</fieldset>\n";
 414+ $urltail = str_replace('&eq=yes', '', $urltail) . '&eq=no';
403415
404416 $result .= '<br /><input type="submit" value="' . wfMsg('smw_ask_submit') . '"/>' .
405417 '<input type="hidden" name="eq" value="yes"/>' .
406 - ' <a href="' . htmlspecialchars($skin->makeSpecialUrl('Ask',$urltail)) . '" rel="nofollow">' . wfMsg('smw_ask_hidequery') . '</a> ' .
 418+ ' <a href="' . htmlspecialchars($skin->makeSpecialUrl('Ask', $urltail)) . '" rel="nofollow">' . wfMsg('smw_ask_hidequery') . '</a> ' .
407419 SMWAskPage::$pipeseparator .' '.SMWAskPage::getEmbedToggle() .
408420 SMWAskPage::$pipeseparator .
409421 ' <a href="' . htmlspecialchars(wfMsg('smw_ask_doculink')) . '">' . wfMsg('smw_ask_help') . '</a>' .
410422 "\n</form>";
411423 } else { // if $this->m_editquery == false
412 - $result .= '<p><a href="' . htmlspecialchars($skin->makeSpecialUrl('Ask',$urltail . '&eq=yes')) . '" rel="nofollow">' . wfMsg('smw_ask_editquery') . '</a> '.
 424+ $urltail = str_replace('&eq=no', '', $urltail) . '&eq=yes';
 425+ $result .= '<p><a href="' . htmlspecialchars($skin->makeSpecialUrl('Ask', $urltail)) . '" rel="nofollow">' . wfMsg('smw_ask_editquery') . '</a> '.
413426 SMWAskPage::$pipeseparator.' '.SMWAskPage::getEmbedToggle().'</p>';
414427 '<input type="hidden" name="eq" value="yes"/>' .
415428 ' <a href="' . htmlspecialchars($skin->makeSpecialUrl('Ask',$urltail)) . '" rel="nofollow">' . wfMsg('smw_ask_hidequery') . '</a> ' .

Status & tagging log