Index: trunk/extensions/SemanticForms/specials/SF_RunQuery.php |
— | — | @@ -20,13 +20,8 @@ |
21 | 21 | function execute($query) { |
22 | 22 | global $wgRequest; |
23 | 23 | $this->setHeaders(); |
24 | | - $form_name = $wgRequest->getVal('form'); |
| 24 | + $form_name = $this->including() ? $query : $wgRequest->getVal('form', $query); |
25 | 25 | |
26 | | - // if query string did not contain this variable, try the URL |
27 | | - if (! $form_name) { |
28 | | - $form_name = $query; |
29 | | - } |
30 | | - |
31 | 26 | self::printQueryForm($form_name, $this->including()); |
32 | 27 | } |
33 | 28 | |
— | — | @@ -50,12 +45,21 @@ |
51 | 46 | $form_article = new Article($form_title); |
52 | 47 | $form_definition = $form_article->getContent(); |
53 | 48 | $submit_url = $form_title->getLocalURL('action=submit'); |
54 | | - $run_query = $wgRequest->getCheck('wpRunQuery'); |
55 | | - $content = $wgRequest->getVal('wpTextbox1'); |
| 49 | + if ( $embedded ) { |
| 50 | + $run_query = false; |
| 51 | + $content = NULL; |
| 52 | + $raw = false; |
| 53 | + } else { |
| 54 | + $run_query = $wgRequest->getCheck('wpRunQuery'); |
| 55 | + $content = $wgRequest->getVal('wpTextbox1'); |
| 56 | + $raw = $wgRequest->getBool('raw', false); |
| 57 | + } |
56 | 58 | $form_submitted = ($run_query); |
| 59 | + if ( $raw ) |
| 60 | + $wgOut->setArticleBodyOnly( true ); |
57 | 61 | // if user already made some action, ignore the edited |
58 | 62 | // page and just get data from the query string |
59 | | - if ($wgRequest->getVal('query') == 'true') { |
| 63 | + if (!$embedded && $wgRequest->getVal('query') == 'true') { |
60 | 64 | $edit_content = null; |
61 | 65 | $is_text_source = false; |
62 | 66 | } elseif ($content != null) { |
— | — | @@ -79,15 +83,18 @@ |
80 | 84 | $wgParser->mOptions->initialiseFromUser($wgUser); |
81 | 85 | $text = $wgParser->parse($data_text, $wgTitle, $wgParser->mOptions)->getText(); |
82 | 86 | $additional_query = wfMsg('sf_runquery_additionalquery'); |
83 | | - $text .= "\n<h2>$additional_query</h2>\n"; |
| 87 | + if ( !$raw ) |
| 88 | + $text .= "\n<h2>$additional_query</h2>\n"; |
84 | 89 | } |
85 | | - $action = htmlspecialchars(SpecialPage::getTitleFor("RunQuery", $form_name)->getLocalURL()); |
86 | | - $text .=<<<END |
| 90 | + if ( !$raw ) { |
| 91 | + $action = htmlspecialchars(SpecialPage::getTitleFor("RunQuery", $form_name)->getLocalURL()); |
| 92 | + $text .=<<<END |
87 | 93 | <form name="createbox" onsubmit="return validate_all()" action="$action" method="post" class="createbox"> |
88 | 94 | <input type="hidden" name="query" value="true" /> |
89 | 95 | |
90 | 96 | END; |
91 | | - $text .= $form_text; |
| 97 | + $text .= $form_text; |
| 98 | + } |
92 | 99 | } |
93 | 100 | SFUtils::addJavascriptAndCSS(); |
94 | 101 | $wgOut->addScript(' <script type="text/javascript">' . "\n" . $javascript_text . '</script>' . "\n"); |