r62218 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r62217‎ | r62218 | r62219 >
Date:01:59, 10 February 2010
Author:yaron
Status:deferred
Tags:
Comment:
Fixed problems with #forminput added in last version: setting of size/width, and placement of the button on the same line
Modified paths:
  • /trunk/extensions/SemanticForms/includes/SF_ParserFunctions.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticForms/includes/SF_ParserFunctions.php
@@ -155,7 +155,7 @@
156156 elseif ($i == 0)
157157 $inFormName = $value;
158158 elseif ($i == 1)
159 - $inFormSize = $value;
 159+ $inSize = $value;
160160 elseif ($i == 2)
161161 $inLinkStr = $value;
162162 elseif ($i == 3)
@@ -219,7 +219,7 @@
220220 if ($param_name == 'form')
221221 $inFormName = $value;
222222 elseif ($param_name == 'size')
223 - $inFormSize = $value;
 223+ $inSize = $value;
224224 elseif ($param_name == 'default value')
225225 $inValue = $value;
226226 elseif ($param_name == 'button text')
@@ -236,7 +236,7 @@
237237 elseif ($i == 0)
238238 $inFormName = $value;
239239 elseif ($i == 1)
240 - $inFormSize = $value;
 240+ $inSize = $value;
241241 elseif ($i == 2)
242242 $inValue = $value;
243243 elseif ($i == 3)
@@ -282,10 +282,16 @@
283283
284284 END;
285285 } else {
 286+ // if there's autocompletion, we need to place it in
 287+ // a table so that the autocompletion <div> won't lead
 288+ // to the button being on a separate line (this can
 289+ // probably be done just with CSS instead, but I don't
 290+ // know how)
286291 $str = <<<END
287292 <form name="createbox" action="$ap_url" method="get">
288 - <p><input type="text" name="page_name" id="input_$input_num" size="$inSize" value="$inValue" class="autocompleteInput createboxInput" />
289 - <div class="page_name_auto_complete" id="div_$input_num"></div>
 293+ <table><tr><td><input type="text" name="page_name" id="input_$input_num" size="$inSize" value="$inValue" class="autocompleteInput createboxInput" />
 294+ <div class="page_name_auto_complete" id="div_$input_num"></div>
 295+ </td>
290296
291297 END;
292298 }
@@ -299,6 +305,7 @@
300306 $str .= SFUtils::formDropdownHTML();
301307 } else {
302308 $str .= ' <input type="hidden" name="form" value="' . $inFormName . '">' . "\n";
 309+ $str .= ' <input type="hidden" name="form2" value="' . $inFormName . '">' . "\n";
303310 }
304311 // recreate the passed-in query string as a set of hidden variables
305312 $query_components = explode('&', $inQueryStr);
@@ -306,16 +313,25 @@
307314 $subcomponents = explode('=', $component, 2);
308315 $key = (isset($subcomponents[0])) ? $subcomponents[0] : '';
309316 $val = (isset($subcomponents[1])) ? $subcomponents[1] : '';
310 - $str .= ' <input type="hidden" name="' . $key . '" value="' . $val . '">' . "\n";
 317+ if (! empty($key))
 318+ $str .= ' <input type="hidden" name="' . $key . '" value="' . $val . '">' . "\n";
311319 }
312320 wfLoadExtensionMessages('SemanticForms');
313321 $button_str = ($inButtonStr != '') ? $inButtonStr : wfMsg('addoreditdata');
314 - $str .= <<<END
 322+ if (empty($inAutocompletionSource)) {
 323+ $str .= <<<END
315324 <input type="submit" value="$button_str"></p>
316325 </form>
317326
318327 END;
 328+ } else {
 329+ $str .= <<<END
 330+ <td><input type="submit" value="$button_str"></td></tr></table>
 331+ </form>
319332
 333+END;
 334+ }
 335+
320336 // hack to remove newline from beginning of output, thanks to
321337 // http://jimbojw.com/wiki/index.php?title=Raw_HTML_Output_from_a_MediaWiki_Parser_Function
322338 return $parser->insertStripItem($str, $parser->mStripState);

Status & tagging log