r51068 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r51067‎ | r51068 | r51069 >
Date:15:47, 27 May 2009
Author:yaron
Status:deferred
Tags:
Comment:
Added handling for RunQuery page and 'includeonly free text' option
Modified paths:
  • /trunk/extensions/SemanticForms/includes/SF_FormPrinter.inc (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticForms/includes/SF_FormPrinter.inc
@@ -6,6 +6,7 @@
77 * @author Nils Oppermann
88 * @author Jeffrey Stuckman
99 * @author Harold Solbrig
 10+ * @author Daniel Hansch
1011 */
1112
1213 class SFFormPrinter {
@@ -116,7 +117,7 @@
117118 }
118119
119120
120 - function formHTML($form_def, $form_submitted, $source_is_page, $existing_page_content = null, $page_title = null, $page_name_formula = null) {
 121+ function formHTML($form_def, $form_submitted, $source_is_page, $existing_page_content = null, $page_title = null, $page_name_formula = null, $is_query = false) {
121122 global $wgRequest, $wgUser, $wgParser;
122123 global $sfgTabIndex; // used to represent the current tab index in the form
123124 global $sfgFieldNum; // used for setting various HTML IDs
@@ -135,6 +136,8 @@
136137 // the parsing, so we have to assume that it will become a possibility
137138 $form_is_partial = false;
138139 $new_text = "";
 140+ // flag for placing "<includeonly>" and "<noinclude>" tags in form output
 141+ $includeonly_free_text;
139142
140143 // if we have existing content and we're not in an active replacement
141144 // situation, preserve the original content. We do this because we want
@@ -167,7 +170,7 @@
168171 // show previous set of deletions for this page, if it's been deleted before
169172 if (! $form_submitted && ! $this->mPageTitle->exists())
170173 $this->showDeletionLog($wgOut);
171 - if ($wgUser->isAllowed('edit') && $this->mPageTitle->userCan( 'edit', true ) ) {
 174+ if ($wgUser->isAllowed('edit') && $this->mPageTitle->userCan('edit')) {
172175 $form_is_disabled = false;
173176 $form_text = "";
174177 // show "Your IP address will be recorded" warning if user is
@@ -632,7 +635,7 @@
633636 $data_text .= "<free_text>\n";
634637 }
635638
636 - if ($template_name == '') {
 639+ if ($template_name == '' || $field_name == '<freetext>') {
637640 $section = substr_replace($section, $new_text, $brackets_loc, $brackets_end_loc + 3 - $brackets_loc);
638641 } else {
639642 if (is_array($cur_value)) {
@@ -896,6 +899,12 @@
897900 // standard input processing
898901 // =====================================================
899902 } elseif ($tag_title == 'standard input') {
 903+ // if it's a query, ignore all standard inputs
 904+ if ($is_query) {
 905+ $new_text = "";
 906+ $section = substr_replace($section, $new_text, $brackets_loc, $brackets_end_loc + 3 - $brackets_loc);
 907+ continue;
 908+ }
900909 // set a flag so that the standard 'form bottom' won't get displayed
901910 $this->standardInputsIncluded = true;
902911 // handle all the possible values
@@ -963,8 +972,11 @@
964973 $form_is_partial = true;
965974 // replacement pages may have minimal matches...
966975 $source_page_matches_this_form = true;
967 - }
 976+ }
 977+ elseif($tag == 'includeonly free text') {
 978+ $includeonly_free_text = true;
968979 }
 980+ }
969981 $section = substr_replace($section, '', $brackets_loc, $brackets_end_loc + 3 - $brackets_loc);
970982 // =====================================================
971983 // default outer level processing
@@ -1091,6 +1103,17 @@
10921104 } else {
10931105 $free_text = null;
10941106 }
 1107+ // modify free text and data text to insert <noinclude> and <includeonly>
 1108+ // tags, if necessary
 1109+ if ($includeonly_free_text) {
 1110+ $free_text = str_replace("<noinclude>",'', $free_text);
 1111+ $free_text = str_replace("</noinclude>",'', $free_text);
 1112+ $free_text = str_replace("<includeonly>",'', $free_text);
 1113+ $free_text = str_replace("</includeonly>",'', $free_text);
 1114+ $free_text = trim($free_text);
 1115+ $data_text = str_replace('<free_text>','</noinclude><includeonly><free_text></includeonly><noinclude>', $data_text);
 1116+ $data_text = "<noinclude>".$data_text."</noinclude>";
 1117+ }
10951118 // if the FCKeditor extension is installed, use that for the free text input
10961119 global $wgFCKEditorDir;
10971120 if ($wgFCKEditorDir) {
@@ -1192,7 +1215,9 @@
11931216 $form_text = str_replace('{{{choosers}}}', $chooser_text, $form_text);
11941217
11951218 // add form bottom, if no custom "standard inputs" have been defined
1196 - if (! $this->standardInputsIncluded)
 1219+ if ($is_query)
 1220+ $form_text .= SFFormUtils::queryFormBottom($form_is_disabled);
 1221+ elseif (! $this->standardInputsIncluded)
11971222 $form_text .= SFFormUtils::formBottom($form_is_disabled);
11981223 $starttime = wfTimestampNow();
11991224 $page_article = new Article($this->mPageTitle);

Status & tagging log