
dantman at svn
Nov 19, 2009, 9:31 PM
Post #1 of 1
(80 views)
Permalink
|
|
SVN: [59277] trunk/extensions/SemanticForms/specials/SF_RunQuery.php
|
|
http://www.mediawiki.org/wiki/Special:Code/MediaWiki/59277 Revision: 59277 Author: dantman Date: 2009-11-20 05:31:09 +0000 (Fri, 20 Nov 2009) Log Message: ----------- SemanticForms: Add a raw=true mode for use via ajax and fix up the use of $wgRequest so it does not have side effects while on a page the special page was embedded into. Modified Paths: -------------- trunk/extensions/SemanticForms/specials/SF_RunQuery.php Modified: trunk/extensions/SemanticForms/specials/SF_RunQuery.php =================================================================== --- trunk/extensions/SemanticForms/specials/SF_RunQuery.php 2009-11-20 02:24:28 UTC (rev 59276) +++ trunk/extensions/SemanticForms/specials/SF_RunQuery.php 2009-11-20 05:31:09 UTC (rev 59277) @@ -20,13 +20,8 @@ function execute($query) { global $wgRequest; $this->setHeaders(); - $form_name = $wgRequest->getVal('form'); + $form_name = $this->including() ? $query : $wgRequest->getVal('form', $query); - // if query string did not contain this variable, try the URL - if (! $form_name) { - $form_name = $query; - } - self::printQueryForm($form_name, $this->including()); } @@ -50,12 +45,21 @@ $form_article = new Article($form_title); $form_definition = $form_article->getContent(); $submit_url = $form_title->getLocalURL('action=submit'); - $run_query = $wgRequest->getCheck('wpRunQuery'); - $content = $wgRequest->getVal('wpTextbox1'); + if ( $embedded ) { + $run_query = false; + $content = NULL; + $raw = false; + } else { + $run_query = $wgRequest->getCheck('wpRunQuery'); + $content = $wgRequest->getVal('wpTextbox1'); + $raw = $wgRequest->getBool('raw', false); + } $form_submitted = ($run_query); + if ( $raw ) + $wgOut->setArticleBodyOnly( true ); // if user already made some action, ignore the edited // page and just get data from the query string - if ($wgRequest->getVal('query') == 'true') { + if (!$embedded && $wgRequest->getVal('query') == 'true') { $edit_content = null; $is_text_source = false; } elseif ($content != null) { @@ -79,15 +83,18 @@ $wgParser->mOptions->initialiseFromUser($wgUser); $text = $wgParser->parse($data_text, $wgTitle, $wgParser->mOptions)->getText(); $additional_query = wfMsg('sf_runquery_additionalquery'); - $text .= "\n<h2>$additional_query</h2>\n"; + if ( !$raw ) + $text .= "\n<h2>$additional_query</h2>\n"; } - $action = htmlspecialchars(SpecialPage::getTitleFor("RunQuery", $form_name)->getLocalURL()); - $text .=<<<END + if ( !$raw ) { + $action = htmlspecialchars(SpecialPage::getTitleFor("RunQuery", $form_name)->getLocalURL()); + $text .=<<<END <form name="createbox" onsubmit="return validate_all()" action="$action" method="post" class="createbox"> <input type="hidden" name="query" value="true" /> END; - $text .= $form_text; + $text .= $form_text; + } } SFUtils::addJavascriptAndCSS(); $wgOut->addScript(' <script type="text/javascript">' . "\n" . $javascript_text . '</script>' . "\n"); _______________________________________________ MediaWiki-CVS mailing list MediaWiki-CVS [at] lists https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs
|