r59239 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r59238‎ | r59239 | r59240 >
Date:10:34, 19 November 2009
Author:dantman
Status:deferred
Tags:
Comment:
Modify Special:RunQuery so that it can be embedded into an article. Also, remove that unnecessary use of the redirect form (that's for edit pages, this doesn't need that). As a side effect removing that makes RunQuery work with JS off.
Modified paths:
  • /trunk/extensions/SemanticForms/includes/SF_FormInputs.inc (modified) (history)
  • /trunk/extensions/SemanticForms/specials/SF_RunQuery.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticForms/specials/SF_RunQuery.php
@@ -7,13 +7,13 @@
88
99 if (!defined('MEDIAWIKI')) die();
1010
11 -class SFRunQuery extends SpecialPage {
 11+class SFRunQuery extends IncludableSpecialPage {
1212
1313 /**
1414 * Constructor
1515 */
1616 function SFRunQuery() {
17 - SpecialPage::SpecialPage('RunQuery');
 17+ parent::__construct('RunQuery');
1818 wfLoadExtensionMessages('SemanticForms');
1919 }
2020
@@ -27,10 +27,10 @@
2828 $form_name = $query;
2929 }
3030
31 - self::printQueryForm($form_name);
 31+ self::printQueryForm($form_name, $this->including());
3232 }
3333
34 - static function printQueryForm($form_name) {
 34+ static function printQueryForm($form_name, $embedded = false) {
3535 global $wgOut, $wgRequest, $wgScriptPath, $sfgScriptPath, $sfgFormPrinter, $sfgYUIBase;
3636
3737 wfLoadExtensionMessages('SemanticForms');
@@ -67,36 +67,32 @@
6868 }
6969 list ($form_text, $javascript_text, $data_text, $form_page_title) =
7070 $sfgFormPrinter->formHTML($form_definition, $form_submitted, $is_text_source, $edit_content, null, null, true);
 71+ $text = "";
 72+ // override the default title for this page if
 73+ // a title was specified in the form
 74+ if ($form_page_title != NULL) {
 75+ $wgOut->setPageTitle($form_page_title);
 76+ }
7177 if ($form_submitted) {
72 - $wgOut->setArticleBodyOnly( true );
73 - global $wgTitle;
74 - $new_url = $wgTitle->getLocalURL() . "/$form_name";
75 - $text = SFUtils::printRedirectForm($new_url, $data_text, $wgRequest->getVal('wpSummary'), false, false, false, $wgRequest->getCheck('wpMinoredit'), $wgRequest->getCheck('wpWatchthis'), $wgRequest->getVal('wpStarttime'), $wgRequest->getVal('wpEdittime'));
76 - } else {
77 - $text = "";
78 - // override the default title for this page if
79 - // a title was specified in the form
80 - if ($form_page_title != NULL) {
81 - $wgOut->setPageTitle($form_page_title);
82 - }
83 - if ($wgRequest->getCheck('wpTextbox1')) {
84 - global $wgParser, $wgUser, $wgTitle;
85 - $wgParser->mOptions = new ParserOptions();
86 - $wgParser->mOptions->initialiseFromUser($wgUser);
87 - $text = $wgParser->parse($content, $wgTitle, $wgParser->mOptions)->getText();
88 - $additional_query = wfMsg('sf_runquery_additionalquery');
89 - $text .= "\n<h2>$additional_query</h2>\n";
90 - }
91 - $text .=<<<END
92 - <form name="createbox" onsubmit="return validate_all()" action="" method="post" class="createbox">
 78+ global $wgParser, $wgUser, $wgTitle;
 79+ $wgParser->mOptions = new ParserOptions();
 80+ $wgParser->mOptions->initialiseFromUser($wgUser);
 81+ $text = $wgParser->parse($data_text, $wgTitle, $wgParser->mOptions)->getText();
 82+ $additional_query = wfMsg('sf_runquery_additionalquery');
 83+ $text .= "\n<h2>$additional_query</h2>\n";
 84+ }
 85+ $action = htmlspecialchars(SpecialPage::getTitleFor("RunQuery", $form_name)->getLocalURL());
 86+ $text .=<<<END
 87+ <form name="createbox" onsubmit="return validate_all()" action="$action" method="post" class="createbox">
9388 <input type="hidden" name="query" value="true" />
9489
9590 END;
96 - $text .= $form_text;
97 - }
 91+ $text .= $form_text;
9892 }
9993 SFUtils::addJavascriptAndCSS();
10094 $wgOut->addScript(' <script type="text/javascript">' . "\n" . $javascript_text . '</script>' . "\n");
 95+ if ( $embedded )
 96+ $text = "<div class='runQueryEmbedded'>$text</div>";
10197 $wgOut->addHTML($text);
10298 }
10399 }
Index: trunk/extensions/SemanticForms/includes/SF_FormInputs.inc
@@ -99,8 +99,7 @@
100100 $cur_value = htmlspecialchars($cur_value);
101101
102102 $text =<<<END
103 - <input id="$input_id" tabindex="$sfgTabIndex" class="$className" name="$input_name" type="text"
104 - value="$cur_value" size="$size"
 103+ <input id="$input_id" tabindex="$sfgTabIndex" class="$className" name="$input_name" type="text" value="$cur_value" size="$size"
105104 END;
106105 if ($is_disabled)
107106 $text .= " disabled";

Status & tagging log