Index: trunk/extensions/SemanticForms/includes/SF_FormEditPage.php |
— | — | @@ -1,7 +1,7 @@ |
2 | 2 | <?php |
3 | 3 | /** |
4 | 4 | * Contains Form Edit Page inheriting from EditPage |
5 | | - * |
| 5 | + * |
6 | 6 | * @author Daniel Friesen |
7 | 7 | * @author Yaron Koren |
8 | 8 | * @file |
— | — | @@ -25,7 +25,7 @@ |
26 | 26 | $this->form = Title::makeTitleSafe( SF_NS_FORM, $form_name ); |
27 | 27 | $this->form_name = $form_name; |
28 | 28 | } |
29 | | - |
| 29 | + |
30 | 30 | protected function isSectionEditSupported() { |
31 | 31 | return false; // sections and forms don't mix |
32 | 32 | } |
— | — | @@ -43,11 +43,11 @@ |
44 | 44 | if ( $this->textbox1 != null ) |
45 | 45 | parent::displayPreviewArea( $previewOutput ); |
46 | 46 | } |
47 | | - |
| 47 | + |
48 | 48 | protected function importContentFormData( &$request ) { |
49 | 49 | // @todo This is where $request to save&preview page text should go |
50 | 50 | } |
51 | | - |
| 51 | + |
52 | 52 | protected function showContentForm() { |
53 | 53 | $target_title = $this->mArticle->getTitle(); |
54 | 54 | $target_name = SFUtils::titleString( $target_title ); |
Index: trunk/extensions/SemanticForms/includes/SF_FormPrinter.php |
— | — | @@ -208,7 +208,7 @@ |
209 | 209 | * - this might make sense in the SFUtils class, if it's useful in |
210 | 210 | * other places. |
211 | 211 | */ |
212 | | - function strReplaceFirst( $search, $replace, $subject) { |
| 212 | + function strReplaceFirst( $search, $replace, $subject ) { |
213 | 213 | $firstChar = strpos( $subject, $search ); |
214 | 214 | if ( $firstChar !== false ) { |
215 | 215 | $beforeStr = substr( $subject, 0, $firstChar ); |
— | — | @@ -254,7 +254,7 @@ |
255 | 255 | |
256 | 256 | $removeButton = Xml::element( 'input', $attributes ); |
257 | 257 | |
258 | | - $text =<<<END |
| 258 | + $text = <<<END |
259 | 259 | <table> |
260 | 260 | <tr> |
261 | 261 | <td>$mainText</td> |
— | — | @@ -292,7 +292,7 @@ |
293 | 293 | $this->multipleTemplateInstanceTableHTML( $form_is_disabled, $section ) |
294 | 294 | ) . "\n"; |
295 | 295 | |
296 | | - } else { //if ( $all_instances_printed ) { |
| 296 | + } else { // if ( $all_instances_printed ) { |
297 | 297 | // This is the last instance of this |
298 | 298 | // template - print all the sections |
299 | 299 | // necessary for adding additional |
— | — | @@ -304,7 +304,7 @@ |
305 | 305 | ), |
306 | 306 | $this->multipleTemplateInstanceTableHTML( $form_is_disabled, $section ) |
307 | 307 | ) . "\n"; |
308 | | - |
| 308 | + |
309 | 309 | $attributes = array( |
310 | 310 | 'type' => 'button', |
311 | 311 | 'value' => Sanitizer::decodeCharReferences( $add_button_text ), |
— | — | @@ -338,7 +338,7 @@ |
339 | 339 | global $sfgFieldNum; // used for setting various HTML IDs |
340 | 340 | |
341 | 341 | wfProfileIn( __METHOD__ ); |
342 | | - |
| 342 | + |
343 | 343 | // initialize some variables |
344 | 344 | $sfgTabIndex = 1; |
345 | 345 | $sfgFieldNum = 1; |
— | — | @@ -354,7 +354,7 @@ |
355 | 355 | $new_text = ""; |
356 | 356 | // flag for placing "<onlyinclude>" tags in form output |
357 | 357 | $onlyinclude_free_text = false; |
358 | | - |
| 358 | + |
359 | 359 | // If we have existing content and we're not in an active replacement |
360 | 360 | // situation, preserve the original content. We do this because we want |
361 | 361 | // to pass the original content on IF this is a partial form. |
— | — | @@ -403,7 +403,7 @@ |
404 | 404 | // permission errors from the start, and use those to determine whether |
405 | 405 | // the page is editable. |
406 | 406 | if ( !$is_query ) { |
407 | | - //$userCanEditPage = ( $wgUser->isAllowed( 'edit' ) && $this->mPageTitle->userCan( 'edit' ) ); |
| 407 | + // $userCanEditPage = ( $wgUser->isAllowed( 'edit' ) && $this->mPageTitle->userCan( 'edit' ) ); |
408 | 408 | $permissionErrors = $this->mPageTitle->getUserPermissionsErrors( 'edit', $wgUser ); |
409 | 409 | $userCanEditPage = count( $permissionErrors ) == 0; |
410 | 410 | wfRunHooks( 'sfUserCanEditPage', array( $this->mPageTitle, &$userCanEditPage ) ); |
— | — | @@ -431,9 +431,9 @@ |
432 | 432 | $wgParser->Options( ParserOptions::newFromUser( $wgUser ) ); |
433 | 433 | $wgParser->Title( $this->mPageTitle ); |
434 | 434 | $wgParser->clearState(); |
435 | | - |
| 435 | + |
436 | 436 | $form_def = SFFormUtils::getFormDefinition( $wgParser, $form_def, $form_id ); |
437 | | - |
| 437 | + |
438 | 438 | // Turn form definition file into an array of sections, one for each |
439 | 439 | // template definition (plus the first section) |
440 | 440 | $form_def_sections = array(); |
— | — | @@ -477,14 +477,14 @@ |
478 | 478 | $instance_num = 0; |
479 | 479 | $all_instances_printed = false; |
480 | 480 | $strict_parsing = false; |
481 | | - |
| 481 | + |
482 | 482 | // Placeholder name in the form |
483 | 483 | $curPlaceholder = null; |
484 | | - // Used to store the HTML code of the multiple template, to reinsert it into the right spot |
485 | | - $multipleTemplateString = ""; |
| 484 | + // Used to store the HTML code of the multiple template, to reinsert it into the right spot |
| 485 | + $multipleTemplateString = ""; |
486 | 486 | // This array will keep track of all the replaced @<name>@ strings |
487 | | - $placeholderFields = array(); |
488 | | - |
| 487 | + $placeholderFields = array(); |
| 488 | + |
489 | 489 | for ( $section_num = 0; $section_num < count( $form_def_sections ); $section_num++ ) { |
490 | 490 | $start_position = 0; |
491 | 491 | $template_text = ""; |
— | — | @@ -492,9 +492,9 @@ |
493 | 493 | // array doesn't get modified; is it necessary? |
494 | 494 | $section = " " . $form_def_sections[$section_num]; |
495 | 495 | |
496 | | - |
497 | | - $multipleTemplateString=""; |
498 | | - |
| 496 | + |
| 497 | + $multipleTemplateString = ""; |
| 498 | + |
499 | 499 | while ( $brackets_loc = strpos( $section, '{{{', $start_position ) ) { |
500 | 500 | $brackets_end_loc = strpos( $section, "}}}", $brackets_loc ); |
501 | 501 | $bracketed_string = substr( $section, $brackets_loc + 3, $brackets_end_loc - ( $brackets_loc + 3 ) ); |
— | — | @@ -525,14 +525,14 @@ |
526 | 526 | $template_label = $sub_components[1]; |
527 | 527 | } elseif ( $sub_components[0] == 'add button text' ) { |
528 | 528 | $add_button_text = $sub_components[1]; |
529 | | - } elseif ($sub_components[0] == 'embed in field') { |
| 529 | + } elseif ( $sub_components[0] == 'embed in field' ) { |
530 | 530 | // Placeholder on form template level. Assume that the template form def |
531 | 531 | // will have a multiple+placeholder parameters, and get the placeholder value. |
532 | 532 | // We expect something like TemplateName[fieldName], and convert it to the |
533 | 533 | // TemplateName___fieldName form used internally. |
534 | 534 | preg_match( '/\s*(.*)\[(.*)\]\s*/', $sub_components[1], $matches ); |
535 | 535 | $curPlaceholder = ( count( $matches ) > 2 ) ? self::placeholderFormat( $matches[1], $matches[2] ) : null; |
536 | | - unset ($matches); |
| 536 | + unset ( $matches ); |
537 | 537 | } |
538 | 538 | } |
539 | 539 | } |
— | — | @@ -549,13 +549,13 @@ |
550 | 550 | // If $curPlaceholder is set, it means we want to insert a |
551 | 551 | // multiple template form's HTML into the main form's HTML. |
552 | 552 | // So, the HTML will be stored in $multipleTemplateString. |
553 | | - if ($allow_multiple) { |
| 553 | + if ( $allow_multiple ) { |
554 | 554 | $multipleTemplateString .= "\t" . '<div class="multipleTemplateWrapper">' . "\n"; |
555 | 555 | $multipleTemplateString .= "\t" . '<div class="multipleTemplateList">' . "\n"; |
556 | 556 | } |
557 | 557 | } |
558 | 558 | if ( $curPlaceholder == null ) { |
559 | | - $form_text .= $multipleTemplateString; |
| 559 | + $form_text .= $multipleTemplateString; |
560 | 560 | } |
561 | 561 | $template_text .= "{{" . $template_name; |
562 | 562 | $all_fields = $tif->getAllFields(); |
— | — | @@ -597,7 +597,7 @@ |
598 | 598 | $matches = array(); |
599 | 599 | $search_pattern = '/{{' . $preg_match_template_str . '\s*[\|}]/i'; |
600 | 600 | $content_str = str_replace( '_', ' ', $existing_page_content ); |
601 | | - preg_match($search_pattern, $content_str, $matches, PREG_OFFSET_CAPTURE); |
| 601 | + preg_match( $search_pattern, $content_str, $matches, PREG_OFFSET_CAPTURE ); |
602 | 602 | // is this check necessary? |
603 | 603 | if ( array_key_exists( 0, $matches ) && array_key_exists( 1, $matches[0] ) ) { |
604 | 604 | $start_char = $matches[0][1]; |
— | — | @@ -607,7 +607,7 @@ |
608 | 608 | $fields_start_char++; |
609 | 609 | } |
610 | 610 | // If the next character is a pipe, skip that too. |
611 | | - if( $existing_page_content[$fields_start_char] == '|' ) { |
| 611 | + if ( $existing_page_content[$fields_start_char] == '|' ) { |
612 | 612 | $fields_start_char++; |
613 | 613 | } |
614 | 614 | $template_contents = array( '0' => '' ); |
— | — | @@ -754,11 +754,11 @@ |
755 | 755 | $semantic_property = null; |
756 | 756 | $preload_page = null; |
757 | 757 | $holds_template = false; |
758 | | - |
| 758 | + |
759 | 759 | for ( $i = 2; $i < count( $tag_components ); $i++ ) { |
760 | | - |
| 760 | + |
761 | 761 | $component = trim( $tag_components[$i] ); |
762 | | - |
| 762 | + |
763 | 763 | if ( $component == 'mandatory' ) { |
764 | 764 | $is_mandatory = true; |
765 | 765 | } elseif ( $component == 'hidden' ) { |
— | — | @@ -769,10 +769,10 @@ |
770 | 770 | $is_list = true; |
771 | 771 | } elseif ( $component == 'edittools' ) { // free text only |
772 | 772 | $free_text_components[] = 'edittools'; |
773 | | - } |
774 | | - |
| 773 | + } |
| 774 | + |
775 | 775 | $sub_components = array_map( 'trim', explode( '=', $component, 2 ) ); |
776 | | - |
| 776 | + |
777 | 777 | if ( count( $sub_components ) == 1 ) { |
778 | 778 | // add handling for single-value params, for custom input types |
779 | 779 | $field_args[$sub_components[0]] = true; |
— | — | @@ -812,7 +812,7 @@ |
813 | 813 | if ( array_key_exists( $div_id, $show_on_select ) ) |
814 | 814 | $show_on_select[$div_id][] = $option; |
815 | 815 | else |
816 | | - $show_on_select[$div_id] = array($option); |
| 816 | + $show_on_select[$div_id] = array( $option ); |
817 | 817 | } else { |
818 | 818 | $show_on_select[$val] = array(); |
819 | 819 | } |
— | — | @@ -1207,20 +1207,20 @@ |
1208 | 1208 | |
1209 | 1209 | // Generate a hidden field with a placeholder value that will be replaced |
1210 | 1210 | // by the multiple-instances template output at form submission. |
1211 | | - ////<input type="hidden" value="@replace_Town___mayors@" name="Town[town_mayors]" /> |
| 1211 | + //// <input type="hidden" value="@replace_Town___mayors@" name="Town[town_mayors]" /> |
1212 | 1212 | if ( $holds_template ) { |
1213 | | - $cur_value = self::makePlaceholderInWikiText( self::placeholderFormat($template_name,$field_name) ); |
| 1213 | + $cur_value = self::makePlaceholderInWikiText( self::placeholderFormat( $template_name, $field_name ) ); |
1214 | 1214 | } |
1215 | | - |
| 1215 | + |
1216 | 1216 | $new_text = $this->formFieldHTML( $form_field, $cur_value ); |
1217 | 1217 | |
1218 | | - // Add a field just after the hidden field, within the HTML, to locate |
| 1218 | + // Add a field just after the hidden field, within the HTML, to locate |
1219 | 1219 | // where the multiple-templates HTML, stored in $multipleTemplateString, |
1220 | 1220 | // should be inserted. |
1221 | 1221 | if ( $holds_template ) { |
1222 | 1222 | $new_text .= self::makePlaceholderInFormHTML( self::placeholderFormat( $template_name, $field_name ) ); |
1223 | 1223 | } |
1224 | | - |
| 1224 | + |
1225 | 1225 | // If this field is disabled, add a hidden field holding |
1226 | 1226 | // the value of this field, because disabled inputs for some |
1227 | 1227 | // reason don't submit their value. |
— | — | @@ -1255,7 +1255,7 @@ |
1256 | 1256 | $input_name = $tag_components[1]; |
1257 | 1257 | $input_label = null; |
1258 | 1258 | $attr = array(); |
1259 | | - |
| 1259 | + |
1260 | 1260 | // if it's a query, ignore all standard inputs except run query |
1261 | 1261 | if ( ( $is_query && $input_name != 'run query' ) || ( !$is_query && $input_name == 'run query' ) ) { |
1262 | 1262 | $new_text = ""; |
— | — | @@ -1389,7 +1389,7 @@ |
1390 | 1390 | // Note: this cleanup step could also be done with a regexp, instead of |
1391 | 1391 | // keeping a track array (e.g., /@replace_(.*)@/) |
1392 | 1392 | $reptmp = self::makePlaceholderInWikiText( $curPlaceholder ); |
1393 | | - if ( $curPlaceholder != null && $data_text && strpos( $data_text, $reptmp, 0 ) !== false) { |
| 1393 | + if ( $curPlaceholder != null && $data_text && strpos( $data_text, $reptmp, 0 ) !== false ) { |
1394 | 1394 | $data_text = preg_replace( '/' . $reptmp . '/', $template_text . $reptmp, $data_text ); |
1395 | 1395 | } else { |
1396 | 1396 | $data_text .= $template_text . "\n"; |
— | — | @@ -1441,7 +1441,7 @@ |
1442 | 1442 | // re-parsed on the next go. |
1443 | 1443 | $section_num--; |
1444 | 1444 | } |
1445 | | - } else { //if ( $allow_multiple ) { |
| 1445 | + } else { // if ( $allow_multiple ) { |
1446 | 1446 | $form_text .= $section; |
1447 | 1447 | } |
1448 | 1448 | $curPlaceholder = null; |
— | — | @@ -1451,13 +1451,13 @@ |
1452 | 1452 | // Remove all the remaining placeholder |
1453 | 1453 | // tags in the HTML and wiki-text. |
1454 | 1454 | foreach ( $placeholderFields as $stringToReplace ) { |
1455 | | - //remove the @<replacename>@ tags from the data that is submitted |
1456 | | - $data_text = preg_replace('/'.self::makePlaceholderInWikiText( $stringToReplace ).'/', '',$data_text); |
1457 | | - |
1458 | | - //remove the @<insertHTML>@ tags from the generated HTML form |
1459 | | - $form_text = preg_replace( '/' . self::makePlaceholderInFormHTML( $stringToReplace ) . '/', '', $form_text ); |
| 1455 | + // remove the @<replacename>@ tags from the data that is submitted |
| 1456 | + $data_text = preg_replace( '/' . self::makePlaceholderInWikiText( $stringToReplace ) . '/', '', $data_text ); |
| 1457 | + |
| 1458 | + // remove the @<insertHTML>@ tags from the generated HTML form |
| 1459 | + $form_text = preg_replace( '/' . self::makePlaceholderInFormHTML( $stringToReplace ) . '/', '', $form_text ); |
1460 | 1460 | } |
1461 | | - |
| 1461 | + |
1462 | 1462 | // if it wasn't included in the form definition, add the |
1463 | 1463 | // 'free text' input as a hidden field at the bottom |
1464 | 1464 | if ( ! $free_text_was_included ) { |
— | — | @@ -1475,8 +1475,8 @@ |
1476 | 1476 | $form_text .= SFFormUtils::hiddenFieldHTML( 'partial', 1 ); |
1477 | 1477 | } else { |
1478 | 1478 | $free_text = null; |
1479 | | - $existing_page_content = preg_replace( array( '/�\{/m','/\}�/m' ), |
1480 | | - array( '{{','}}' ), |
| 1479 | + $existing_page_content = preg_replace( array( '/�\{/m', '/\}�/m' ), |
| 1480 | + array( '{{', '}}' ), |
1481 | 1481 | $existing_page_content ); |
1482 | 1482 | $existing_page_content = preg_replace( '/\{\{\{insertionpoint\}\}\}/', '', $existing_page_content ); |
1483 | 1483 | } |
Index: trunk/extensions/SemanticForms/includes/SF_AutoeditAPI.php |
— | — | @@ -2,7 +2,7 @@ |
3 | 3 | |
4 | 4 | /** |
5 | 5 | * File holding the SFAutoEditAPI class |
6 | | - * |
| 6 | + * |
7 | 7 | * @author Stephan Gambke |
8 | 8 | * @file |
9 | 9 | * @ingroup SemanticForms |
— | — | @@ -59,12 +59,12 @@ |
60 | 60 | if ( $result === true ) { |
61 | 61 | |
62 | 62 | $options = $handler->getOptions(); |
63 | | - $result = wfMsgReplaceArgs( $oktext, array($options['target'], $options['form']) ); |
| 63 | + $result = wfMsgReplaceArgs( $oktext, array( $options['target'], $options['form'] ) ); |
64 | 64 | |
65 | 65 | } else { |
66 | 66 | |
67 | | - $result->setResponseCode('400 Bad Request'); |
68 | | - $result = wfMsgReplaceArgs( $errortext, array($result) ); |
| 67 | + $result->setResponseCode( '400 Bad Request' ); |
| 68 | + $result = wfMsgReplaceArgs( $errortext, array( $result ) ); |
69 | 69 | } |
70 | 70 | |
71 | 71 | // initialize parser |
— | — | @@ -78,23 +78,23 @@ |
79 | 79 | |
80 | 80 | if ( $parseroptions == null ) { |
81 | 81 | $parseroptions = new ParserOptions(); |
82 | | - $wgParser->Options($parseroptions); |
| 82 | + $wgParser->Options( $parseroptions ); |
83 | 83 | } |
84 | 84 | |
85 | 85 | $parseroptions->enableLimitReport( false ); |
86 | 86 | |
87 | 87 | |
88 | | - $result = new AjaxResponse($wgParser->parse( $result, $title, $parseroptions )->getText()); |
89 | | - $result->setContentType('text/html'); |
90 | | - |
| 88 | + $result = new AjaxResponse( $wgParser->parse( $result, $title, $parseroptions )->getText() ); |
| 89 | + $result->setContentType( 'text/html' ); |
| 90 | + |
91 | 91 | return $result; |
92 | 92 | } |
93 | 93 | |
94 | 94 | /** |
95 | 95 | * Getter/setter for the ApiQuery flag. |
96 | | - * |
| 96 | + * |
97 | 97 | * If this is set, we are in an API query, else we are in an Ajax query. |
98 | | - * |
| 98 | + * |
99 | 99 | * @param bool $isApiQuery Optional. The new value |
100 | 100 | * @return The old value |
101 | 101 | */ |
— | — | @@ -111,7 +111,7 @@ |
112 | 112 | |
113 | 113 | /** |
114 | 114 | * Converts an options string into an options array and stores it |
115 | | - * |
| 115 | + * |
116 | 116 | * @param string $options |
117 | 117 | * @return the options array |
118 | 118 | */ |
— | — | @@ -221,13 +221,13 @@ |
222 | 222 | |
223 | 223 | /** |
224 | 224 | * This method will try to store the data in mOptions. |
225 | | - * |
| 225 | + * |
226 | 226 | * It will return true on success or an error message on failure. |
227 | 227 | * The used form and target page will be available in mOptions after |
228 | 228 | * execution of the method. |
229 | 229 | * |
230 | 230 | * This method also sets HTTP response headers according to the result. |
231 | | - * |
| 231 | + * |
232 | 232 | * @param bool $prefillFromExisting If this is set, existing values in the page will be used to prefill the form. |
233 | 233 | * @return true or an error message |
234 | 234 | */ |
— | — | @@ -309,7 +309,7 @@ |
310 | 310 | return $this->reportError( wfMsg( 'sf_autoedit_nosemanticform', |
311 | 311 | array( |
312 | 312 | $this->mOptions['target'], |
313 | | - $this->mOptions['form']) ) |
| 313 | + $this->mOptions['form'] ) ) |
314 | 314 | ); |
315 | 315 | } |
316 | 316 | } else { |
— | — | @@ -320,7 +320,7 @@ |
321 | 321 | |
322 | 322 | //////////////////////////////////////////////////////////////////////// |
323 | 323 | // Store the modified form |
324 | | - //$wgOut->clearHTML(); |
| 324 | + // $wgOut->clearHTML(); |
325 | 325 | $wgRequest = new FauxRequest( $data, true ); |
326 | 326 | |
327 | 327 | // get the MW form |
— | — | @@ -395,12 +395,12 @@ |
396 | 396 | $this->addToArray( $data, $name, $input->getAttribute( 'value' ) ); |
397 | 397 | break; |
398 | 398 | |
399 | | - //case 'button': |
| 399 | + // case 'button': |
400 | 400 | case 'hidden': |
401 | 401 | case 'image': |
402 | 402 | case 'password': |
403 | | - //case 'reset': |
404 | | - //case 'submit': |
| 403 | + // case 'reset': |
| 404 | + // case 'submit': |
405 | 405 | case 'text': |
406 | 406 | $this->addToArray( $data, $name, $input->getAttribute( 'value' ) ); |
407 | 407 | break; |
— | — | @@ -425,7 +425,7 @@ |
426 | 426 | $values = array(); |
427 | 427 | $options = $select->getElementsByTagName( 'option' ); |
428 | 428 | |
429 | | - if ( count( $options ) && (!$select->hasAttribute( "multiple" ) || $options->item( 0 )->hasAttribute( 'selected' ) ) ) { |
| 429 | + if ( count( $options ) && ( !$select->hasAttribute( "multiple" ) || $options->item( 0 )->hasAttribute( 'selected' ) ) ) { |
430 | 430 | $this->addToArray( $data, $name, $options->item( 0 )->getAttribute( 'value' ) ); |
431 | 431 | } |
432 | 432 | |
— | — | @@ -486,7 +486,7 @@ |
487 | 487 | // $toplevel: if this is a toplevel value. |
488 | 488 | private function addToArray( &$array, $key, $value, $toplevel = true ) { |
489 | 489 | $matches = array(); |
490 | | - |
| 490 | + |
491 | 491 | if ( preg_match( '/^([^\[\]]*)\[([^\[\]]*)\](.*)/', $key, $matches ) ) { |
492 | 492 | |
493 | 493 | // for some reason toplevel keys get their spaces encoded by MW. |
— | — | @@ -553,7 +553,7 @@ |
554 | 554 | private function reportError( $msg ) { |
555 | 555 | if ( $this->isApiQuery() ) { |
556 | 556 | header( 'HTTP/Status: 400 Bad Request' ); |
557 | | - $this->getResult()->addValue( null, 'result', array('code' => '400', '*' => $msg) ); |
| 557 | + $this->getResult()->addValue( null, 'result', array( 'code' => '400', '*' => $msg ) ); |
558 | 558 | } |
559 | 559 | return $msg; |
560 | 560 | } |
Index: trunk/extensions/SemanticForms/includes/SF_FormLinker.php |
— | — | @@ -38,7 +38,7 @@ |
39 | 39 | } |
40 | 40 | $properties = $store->getInProperties( $value ); |
41 | 41 | $propertyNames = array(); |
42 | | - foreach( $properties as $property ) { |
| 42 | + foreach ( $properties as $property ) { |
43 | 43 | // SMW 1.6+ |
44 | 44 | if ( $property instanceof SMWDIProperty ) { |
45 | 45 | $property_name = $property->getKey(); |
— | — | @@ -133,11 +133,11 @@ |
134 | 134 | } |
135 | 135 | |
136 | 136 | global $sfgContLang; |
137 | | - |
| 137 | + |
138 | 138 | $store = smwfGetStore(); |
139 | 139 | $subject = Title::makeTitleSafe( $page_namespace, $page_name ); |
140 | 140 | $form_names = SFUtils::getSMWPropertyValues( $store, $subject, $prop_smw_id ); |
141 | | - |
| 141 | + |
142 | 142 | // If we're using a non-English language, check for the English |
143 | 143 | // string as well. |
144 | 144 | if ( ! class_exists( 'SF_LanguageEn' ) || ! $sfgContLang instanceof SF_LanguageEn ) { |
— | — | @@ -205,7 +205,7 @@ |
206 | 206 | } |
207 | 207 | |
208 | 208 | $fe = SFUtils::getSpecialPage( 'FormEdit' ); |
209 | | - |
| 209 | + |
210 | 210 | $fe_url = $fe->getTitle()->getLocalURL(); |
211 | 211 | if ( count( $default_forms ) > 0 ) { |
212 | 212 | $form_edit_url = $fe_url . "/" . $default_forms[0] . "/" . SFUtils::titleURLString( $target_page_title ); |
— | — | @@ -333,7 +333,7 @@ |
334 | 334 | if ( $title->isSubpage() ) { |
335 | 335 | return array(); |
336 | 336 | } |
337 | | - |
| 337 | + |
338 | 338 | // If we're still here, just return the default form for the |
339 | 339 | // namespace, which may well be null. |
340 | 340 | if ( NS_MAIN === $namespace ) { |
Index: trunk/extensions/SemanticForms/includes/SF_PageSchemas.php |
— | — | @@ -145,10 +145,10 @@ |
146 | 146 | $param_value = explode( "=", $value, 2 ); |
147 | 147 | if ( count( $param_value ) == 2 && $param_value[1] != null ) { |
148 | 148 | // Handles <Parameter name="size">20</Parameter> |
149 | | - $xml .= '<Parameter name="'.$param_value[0].'">'.$param_value[1].'</Parameter>'; |
| 149 | + $xml .= '<Parameter name="' . $param_value[0] . '">' . $param_value[1] . '</Parameter>'; |
150 | 150 | } else { |
151 | 151 | // Handles <Parameter name="mandatory" /> |
152 | | - $xml .= '<Parameter name="'.$param_value[0].'"/>'; |
| 152 | + $xml .= '<Parameter name="' . $param_value[0] . '"/>'; |
153 | 153 | } |
154 | 154 | } |
155 | 155 | } |
— | — | @@ -171,7 +171,7 @@ |
172 | 172 | $form_array = array(); |
173 | 173 | $hasExistingValues = false; |
174 | 174 | if ( !is_null( $pageSchemaObj ) ) { |
175 | | - $form_array = $pageSchemaObj->getObject('semanticforms_Form'); |
| 175 | + $form_array = $pageSchemaObj->getObject( 'semanticforms_Form' ); |
176 | 176 | if ( !is_null( $form_array ) ) { |
177 | 177 | $hasExistingValues = true; |
178 | 178 | } |
— | — | @@ -254,7 +254,7 @@ |
255 | 255 | $hasExistingValues = false; |
256 | 256 | $inputType = null; |
257 | 257 | if ( !is_null( $psField ) ) { |
258 | | - $fieldValues = $psField->getObject('semanticforms_FormInput'); |
| 258 | + $fieldValues = $psField->getObject( 'semanticforms_FormInput' ); |
259 | 259 | if ( !is_null( $fieldValues ) ) { |
260 | 260 | $hasExistingValues = true; |
261 | 261 | $inputType = PageSchemas::getValueFromObject( $fieldValues, 'InputType' ); |
— | — | @@ -303,7 +303,7 @@ |
304 | 304 | } |
305 | 305 | |
306 | 306 | public static function getMainFormInfo( $pageSchemaObj ) { |
307 | | - //return $pageSchemaObj->getObject( 'semanticforms_Form' ); |
| 307 | + // return $pageSchemaObj->getObject( 'semanticforms_Form' ); |
308 | 308 | // We don't just call getObject() here, because sometimes, for |
309 | 309 | // some reason, this gets called before SF registers itself |
310 | 310 | // with Page Schemas, which means that getObject() would return |
— | — | @@ -332,7 +332,7 @@ |
333 | 333 | $fieldFormArray = $psField->getObject( 'semanticforms_FormInput' ); |
334 | 334 | if ( !is_null( $fieldFormArray ) ) { |
335 | 335 | $formField = SFFormField::create( $i, $template_fields[$i] ); |
336 | | - foreach ($fieldFormArray as $var => $val ) { |
| 336 | + foreach ( $fieldFormArray as $var => $val ) { |
337 | 337 | if ( $var == 'InputType' ) { |
338 | 338 | $formField->setInputType( $val ); |
339 | 339 | } elseif ( $var == 'mandatory' ) { |
— | — | @@ -379,8 +379,8 @@ |
380 | 380 | public static function getFieldsFromTemplateSchema( $psTemplate ) { |
381 | 381 | $psFields = $psTemplate->getFields(); |
382 | 382 | $templateFields = array(); |
383 | | - foreach( $psFields as $psField ) { |
384 | | - $prop_array = $psField->getObject('semanticmediawiki_Property'); |
| 383 | + foreach ( $psFields as $psField ) { |
| 384 | + $prop_array = $psField->getObject( 'semanticmediawiki_Property' ); |
385 | 385 | $propertyName = PageSchemas::getValueFromObject( $prop_array, 'name' ); |
386 | 386 | if ( $psField->getLabel() === '' ) { |
387 | 387 | $fieldLabel = $psField->getName(); |
Index: trunk/extensions/SemanticForms/includes/SF_FormUtils.php |
— | — | @@ -32,7 +32,7 @@ |
33 | 33 | $vars['sfgBadNumberErrorStr'] = wfMsg( 'sf_bad_number_error' ); |
34 | 34 | // This error message isn't currently used, but it might be |
35 | 35 | // in the future, if SMW begins to support integers again. |
36 | | - //$vars['sfgBadIntegerErrorStr'] = wfMsg( 'sf_bad_integer_error' ); |
| 36 | + // $vars['sfgBadIntegerErrorStr'] = wfMsg( 'sf_bad_integer_error' ); |
37 | 37 | $vars['sfgBadDateErrorStr'] = wfMsg( 'sf_bad_date_error' ); |
38 | 38 | $vars['sfgAnonEditWarning'] = wfMsg( 'sf_autoedit_anoneditwarning' ); |
39 | 39 | $vars['sfgSaveAndContinueSummary'] = wfMsg( 'sf_formedit_saveandcontinue_summary', wfMsg( 'sf_formedit_saveandcontinueediting' ) ); |
— | — | @@ -425,7 +425,7 @@ |
426 | 426 | global $wgHooks, $wgExtensionFunctions; |
427 | 427 | |
428 | 428 | $numRows = isset( $fieldArgs['rows'] ) && $fieldArgs['rows'] > 0 ? $fieldArgs['rows'] : 5; |
429 | | - $FCKEditorHeight = ($wgFCKEditorHeight < 300) ? 300 : $wgFCKEditorHeight; |
| 429 | + $FCKEditorHeight = ( $wgFCKEditorHeight < 300 ) ? 300 : $wgFCKEditorHeight; |
430 | 430 | |
431 | 431 | $newWinMsg = wfMsg( 'rich_editor_new_window' ); |
432 | 432 | $javascript_text = ' |
— | — | @@ -840,11 +840,11 @@ |
841 | 841 | public static function getFormDefinition( &$parser, &$form_def = null, &$form_id = null ) { |
842 | 842 | |
843 | 843 | $cachedDef = self::getFormDefinitionFromCache( $form_id, $parser ); |
844 | | - |
| 844 | + |
845 | 845 | if ( $cachedDef ) { |
846 | 846 | return $cachedDef; |
847 | 847 | } |
848 | | - |
| 848 | + |
849 | 849 | if ( $form_id !== null ) { |
850 | 850 | |
851 | 851 | $form_article = Article::newFromID( $form_id ); |
— | — | @@ -867,7 +867,7 @@ |
868 | 868 | // us with what we need |
869 | 869 | $form_def = "__NOEDITSECTION__" . strtr( $form_def, array( '{{{' => '<nowiki>{{{', '}}}' => '}}}</nowiki>' ) ); |
870 | 870 | |
871 | | - $title = is_object( $parser->getTitle() )?$parser->getTitle():new Title(); |
| 871 | + $title = is_object( $parser->getTitle() ) ? $parser->getTitle():new Title(); |
872 | 872 | |
873 | 873 | // parse wiki-text |
874 | 874 | $output = $parser->parse( $form_def, $title, $parser->getOptions() ); |
— | — | @@ -882,7 +882,7 @@ |
883 | 883 | * Get a form definition from cache |
884 | 884 | */ |
885 | 885 | protected static function getFormDefinitionFromCache ( &$form_id, &$parser ) { |
886 | | - |
| 886 | + |
887 | 887 | global $sfgCacheFormDefinitions; |
888 | 888 | |
889 | 889 | // use cache if allowed |
— | — | @@ -900,20 +900,20 @@ |
901 | 901 | |
902 | 902 | wfDebug( "Cache hit: Got form definition $cachekey from cache\n" ); |
903 | 903 | return $cached_def; |
904 | | - |
| 904 | + |
905 | 905 | } else { |
906 | 906 | wfDebug( "Cache miss: Form definition $cachekey not found in cache\n" ); |
907 | 907 | } |
908 | 908 | } |
909 | | - |
| 909 | + |
910 | 910 | return null; |
911 | 911 | } |
912 | | - |
| 912 | + |
913 | 913 | /** |
914 | 914 | * Store a form definition in cache |
915 | 915 | */ |
916 | 916 | protected static function cacheFormDefinition ( &$form_id, &$parser, &$output ) { |
917 | | - |
| 917 | + |
918 | 918 | global $sfgCacheFormDefinitions; |
919 | 919 | |
920 | 920 | // store in cache if allowed |
— | — | @@ -923,19 +923,19 @@ |
924 | 924 | $cachekey = self::getCacheKey( $form_id, $parser ); |
925 | 925 | |
926 | 926 | if ( $output->getCacheTime() == -1 ) { |
927 | | - |
| 927 | + |
928 | 928 | $form_article = Article::newFromID( $form_id ); |
929 | 929 | self::purgeCache( $form_article ); |
930 | 930 | wfDebug( "Caching disabled for form definition $cachekey\n" ); |
931 | | - |
| 931 | + |
932 | 932 | } else { |
933 | 933 | |
934 | 934 | $cachekeyForForm = self::getCacheKey( $form_id ); |
935 | | - |
| 935 | + |
936 | 936 | // update list of form definitions |
937 | 937 | $arrayOfStoredDatasets = $cache->get( $cachekeyForForm ); |
938 | 938 | $arrayOfStoredDatasets[ $cachekey ] = $cachekey; // just need the key defined, don't care for the value |
939 | | - |
| 939 | + |
940 | 940 | // We cache indefinitely ignoring $wgParserCacheExpireTime. |
941 | 941 | // The reasoning is that there really is not point in expiring |
942 | 942 | // rarely changed forms automatically (after one day per |
— | — | @@ -943,10 +943,10 @@ |
944 | 944 | // form definition. |
945 | 945 | // A side effect of this is, that there is no need to |
946 | 946 | // distinguish between MW <1.17 and >=1.17. |
947 | | - |
| 947 | + |
948 | 948 | // store form definition with current user options |
949 | 949 | $cache->set( $cachekey, $output->getText() ); |
950 | | - |
| 950 | + |
951 | 951 | // store updated list of form definitions |
952 | 952 | $cache->set( $cachekeyForForm, $arrayOfStoredDatasets ); |
953 | 953 | |
— | — | @@ -954,10 +954,10 @@ |
955 | 955 | } |
956 | 956 | |
957 | 957 | } |
958 | | - |
| 958 | + |
959 | 959 | return null; |
960 | 960 | } |
961 | | - |
| 961 | + |
962 | 962 | /** |
963 | 963 | * Deletes the form definition associated with the given wiki page |
964 | 964 | * from the main cache. |
— | — | @@ -975,21 +975,21 @@ |
976 | 976 | |
977 | 977 | // get references to stored datasets |
978 | 978 | $arrayOfStoredDatasets = $cache->get( $cachekeyForForm ); |
979 | | - |
| 979 | + |
980 | 980 | if ( $arrayOfStoredDatasets !== false ) { |
981 | | - |
| 981 | + |
982 | 982 | // delete stored datasets |
983 | 983 | foreach ( $arrayOfStoredDatasets as $key ) { |
984 | 984 | $cache->delete( $key ); |
985 | 985 | wfDebug( "Deleted cached form definition $key.\n" ); |
986 | 986 | } |
987 | | - |
| 987 | + |
988 | 988 | // delete references to datasets |
989 | 989 | $cache->delete( $cachekeyForForm ); |
990 | 990 | wfDebug( "Deleted cached form definition references $cachekeyForForm.\n" ); |
991 | 991 | } |
992 | 992 | |
993 | | - |
| 993 | + |
994 | 994 | } |
995 | 995 | |
996 | 996 | return true; |
Index: trunk/extensions/SemanticForms/includes/SF_ParserFunctions.php |
— | — | @@ -137,7 +137,7 @@ |
138 | 138 | if ( is_callable( array( $wgOut, 'includeJQuery' ) ) ) { |
139 | 139 | $wgOut->includeJQuery(); |
140 | 140 | } |
141 | | - |
| 141 | + |
142 | 142 | return true; |
143 | 143 | } |
144 | 144 | |
— | — | @@ -168,19 +168,19 @@ |
169 | 169 | // - support unlabelled params, for backwards compatibility |
170 | 170 | // - parse and sanitize all parameter values |
171 | 171 | foreach ( $params as $i => $param ) { |
172 | | - |
| 172 | + |
173 | 173 | $elements = explode( '=', $param, 2 ); |
174 | 174 | |
175 | 175 | // set param_name and value |
176 | 176 | if ( count( $elements ) > 1 ) { |
177 | | - |
| 177 | + |
178 | 178 | $param_name = trim( $elements[0] ); |
179 | | - |
| 179 | + |
180 | 180 | // parse (and sanitize) parameter values |
181 | 181 | $value = trim( $parser->recursiveTagParse( $elements[1] ) ); |
182 | | - |
| 182 | + |
183 | 183 | } else { |
184 | | - |
| 184 | + |
185 | 185 | $param_name = null; |
186 | 186 | |
187 | 187 | // parse (and sanitize) parameter values |
— | — | @@ -200,7 +200,7 @@ |
201 | 201 | } elseif ( $param_name == 'target' ) { |
202 | 202 | $inTargetName = $value; |
203 | 203 | } elseif ( $param_name == null && $value == 'popup' |
204 | | - && version_compare( $wgVersion, '1.16', '>=' )) { |
| 204 | + && version_compare( $wgVersion, '1.16', '>=' ) ) { |
205 | 205 | self::loadScriptsForPopupForm( $parser ); |
206 | 206 | $classStr = 'popupformlink'; |
207 | 207 | } |
— | — | @@ -251,14 +251,14 @@ |
252 | 252 | } |
253 | 253 | if ( $inLinkType == 'button' ) { |
254 | 254 | $str = |
255 | | - Xml::tags( 'form', array('action' => $link_url, 'method' => 'get', 'class' => $classStr), |
256 | | - Xml::tags( 'button', array('type' => 'submit', 'value' => $inLinkStr), $inLinkStr ) . |
| 255 | + Xml::tags( 'form', array( 'action' => $link_url, 'method' => 'get', 'class' => $classStr ), |
| 256 | + Xml::tags( 'button', array( 'type' => 'submit', 'value' => $inLinkStr ), $inLinkStr ) . |
257 | 257 | $hidden_inputs |
258 | 258 | ); |
259 | 259 | } elseif ( $inLinkType == 'post button' ) { |
260 | 260 | $str = |
261 | | - Xml::tags( 'form', array('action' => $link_url, 'method' => 'post', 'class' => $classStr), |
262 | | - Xml::tags( 'button', array('type' => 'submit', 'value' => $inLinkStr), $inLinkStr ) . |
| 261 | + Xml::tags( 'form', array( 'action' => $link_url, 'method' => 'post', 'class' => $classStr ), |
| 262 | + Xml::tags( 'button', array( 'type' => 'submit', 'value' => $inLinkStr ), $inLinkStr ) . |
263 | 263 | $hidden_inputs |
264 | 264 | ); |
265 | 265 | } else { |
— | — | @@ -266,7 +266,7 @@ |
267 | 267 | // exist, make it a red link. |
268 | 268 | if ( ! empty( $inTargetName ) ) { |
269 | 269 | $targetTitle = Title::newFromText( $inTargetName ); |
270 | | - if ( is_null( $targetTitle) || !$targetTitle->exists() ) { |
| 270 | + if ( is_null( $targetTitle ) || !$targetTitle->exists() ) { |
271 | 271 | $classStr .= " new"; |
272 | 272 | } |
273 | 273 | } |
— | — | @@ -279,7 +279,7 @@ |
280 | 280 | |
281 | 281 | static function renderFormInput ( &$parser ) { |
282 | 282 | global $wgVersion; |
283 | | - |
| 283 | + |
284 | 284 | $params = func_get_args(); |
285 | 285 | array_shift( $params ); // don't need the parser |
286 | 286 | // set defaults |
— | — | @@ -316,7 +316,7 @@ |
317 | 317 | } elseif ( $param_name == 'remote autocompletion' ) { |
318 | 318 | $inRemoteAutocompletion = true; |
319 | 319 | } elseif ( $param_name == null && $value == 'popup' |
320 | | - && version_compare( $wgVersion, '1.16', '>=' )) { |
| 320 | + && version_compare( $wgVersion, '1.16', '>=' ) ) { |
321 | 321 | self::loadScriptsForPopupForm( $parser ); |
322 | 322 | $classStr = 'popupforminput'; |
323 | 323 | } |
— | — | @@ -333,7 +333,7 @@ |
334 | 334 | } |
335 | 335 | |
336 | 336 | $fs = SFUtils::getSpecialPage( 'FormStart' ); |
337 | | - |
| 337 | + |
338 | 338 | $fs_url = $fs->getTitle()->getLocalURL(); |
339 | 339 | $str = <<<END |
340 | 340 | <form name="createbox" action="$fs_url" method="get" class="$classStr"> |
— | — | @@ -404,7 +404,7 @@ |
405 | 405 | $subcomponents = explode( '=', $component, 2 ); |
406 | 406 | $key = ( isset( $subcomponents[0] ) ) ? $subcomponents[0] : ''; |
407 | 407 | $val = ( isset( $subcomponents[1] ) ) ? $subcomponents[1] : ''; |
408 | | - if ( ! empty( $key ) ){ |
| 408 | + if ( ! empty( $key ) ) { |
409 | 409 | $str .= ' ' . |
410 | 410 | Xml::element( 'input', |
411 | 411 | array( |
— | — | @@ -485,7 +485,7 @@ |
486 | 486 | # let '\n' represent newlines |
487 | 487 | $delimiter = str_replace( '\n', "\n", $delimiter ); |
488 | 488 | $new_delimiter = str_replace( '\n', "\n", $new_delimiter ); |
489 | | - |
| 489 | + |
490 | 490 | if ( $delimiter == '' ) { |
491 | 491 | $values_array = preg_split( '/(.)/u', $value, -1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE ); |
492 | 492 | } else { |
— | — | @@ -525,7 +525,7 @@ |
526 | 526 | |
527 | 527 | $results = array(); |
528 | 528 | $template = trim( $template ); |
529 | | - |
| 529 | + |
530 | 530 | foreach ( $values_array as $cur_value ) { |
531 | 531 | $cur_value = trim( $cur_value ); |
532 | 532 | // ignore a value if it's null |
— | — | @@ -534,7 +534,7 @@ |
535 | 535 | $results[] = '{{' . $template . '|' . $cur_value . '}}'; |
536 | 536 | } |
537 | 537 | } |
538 | | - |
| 538 | + |
539 | 539 | return array( implode( $new_delimiter, $results ), 'noparse' => false, 'isHTML' => false ); |
540 | 540 | } |
541 | 541 | |
— | — | @@ -568,7 +568,7 @@ |
569 | 569 | $template, '1=' . $old_value ); |
570 | 570 | // special handling if preprocessor class is set to |
571 | 571 | // 'Preprocessor_Hash' |
572 | | - if ($bracketed_value instanceof PPNode_Hash_Array) { |
| 572 | + if ( $bracketed_value instanceof PPNode_Hash_Array ) { |
573 | 573 | $bracketed_value = $bracketed_value->value; |
574 | 574 | } |
575 | 575 | $results_array[] = $parser->replaceVariables( |
— | — | @@ -579,7 +579,7 @@ |
580 | 580 | |
581 | 581 | |
582 | 582 | static function renderAutoEdit ( &$parser ) { |
583 | | - |
| 583 | + |
584 | 584 | global $wgTitle; |
585 | 585 | |
586 | 586 | // set defaults |
— | — | @@ -636,11 +636,11 @@ |
637 | 637 | } |
638 | 638 | |
639 | 639 | if ( $summary == null ) { |
640 | | - $summary = wfMsg('sf_autoedit_summary', "[[$wgTitle]]" ); |
| 640 | + $summary = wfMsg( 'sf_autoedit_summary', "[[$wgTitle]]" ); |
641 | 641 | } |
642 | | - |
| 642 | + |
643 | 643 | $formcontent .= |
644 | | - Xml::input( 'wpSummary', false, $summary, array('type' => 'hidden') ); |
| 644 | + Xml::input( 'wpSummary', false, $summary, array( 'type' => 'hidden' ) ); |
645 | 645 | |
646 | 646 | $form = Xml::tags( 'form', array( 'class' => 'autoedit-data' ), $formcontent ); |
647 | 647 | |
— | — | @@ -698,7 +698,7 @@ |
699 | 699 | |
700 | 700 | return true; |
701 | 701 | } |
702 | | - |
| 702 | + |
703 | 703 | // load scripts and style files for AutoEdit |
704 | 704 | private static function loadScriptsForAutoEdit ( &$parser ) { |
705 | 705 | |
— | — | @@ -716,14 +716,14 @@ |
717 | 717 | // load extensions JavaScript |
718 | 718 | $parser->getOutput()->addHeadItem( |
719 | 719 | '<script type="text/javascript" src="' . $sfgScriptPath |
720 | | - . '/libs/SF_autoedit.js"></script> ' ."\n", |
| 720 | + . '/libs/SF_autoedit.js"></script> ' . "\n", |
721 | 721 | 'sf_autoedit_script' |
722 | 722 | ); |
723 | 723 | |
724 | 724 | // load extensions style sheet |
725 | 725 | $parser->getOutput()->addHeadItem( |
726 | 726 | '<link rel="stylesheet" href="' . $sfgScriptPath |
727 | | - . '/skins/SF_autoedit.css"/> ' ."\n", |
| 727 | + . '/skins/SF_autoedit.css"/> ' . "\n", |
728 | 728 | 'sf_autoedit_style' |
729 | 729 | ); |
730 | 730 | |
Index: trunk/extensions/SemanticForms/includes/SF_TemplateInForm.php |
— | — | @@ -48,7 +48,7 @@ |
49 | 49 | // Ignore 'noinclude' sections and 'includeonly' tags. |
50 | 50 | $templateText = StringUtils::delimiterReplace( '<noinclude>', '</noinclude>', '', $templateText ); |
51 | 51 | $templateText = strtr( $templateText, array( '<includeonly>' => '', '</includeonly>' => '' ) ); |
52 | | - |
| 52 | + |
53 | 53 | // First, look for "arraymap" parser function calls |
54 | 54 | // that map a property onto a list. |
55 | 55 | if ( $ret = preg_match_all( '/{{#arraymap:{{{([^|}]*:?[^|}]*)[^\[]*\[\[([^:]*:?[^:]*)::/mis', $templateText, $matches ) ) { |
— | — | @@ -66,7 +66,7 @@ |
67 | 67 | print 'Semantic Forms error: backtrace limit exceeded during parsing! Please increase the value of <a href="http://www.php.net/manual/en/pcre.configuration.php#ini.pcre.backtrack-limit">pcre.backtrack-limit</a> in the PHP settings.'; |
68 | 68 | } |
69 | 69 | } |
70 | | - |
| 70 | + |
71 | 71 | // Second, look for normal property calls. |
72 | 72 | if ( preg_match_all( '/\[\[([^:|\[\]]*:*?[^:|\[\]]*)::{{{([^\]\|}]*).*?\]\]/mis', $templateText, $matches ) ) { |
73 | 73 | foreach ( $matches[1] as $i => $propertyName ) { |
— | — | @@ -100,9 +100,9 @@ |
101 | 101 | if ( preg_match_all( '/#declare:(.*?)}}/mis', $templateText, $matches ) ) { |
102 | 102 | foreach ( $matches[1] as $i => $match ) { |
103 | 103 | $setValues = explode( '|', $match ); |
104 | | - foreach( $setValues as $valuePair ) { |
| 104 | + foreach ( $setValues as $valuePair ) { |
105 | 105 | $keyAndVal = explode( '=', $valuePair ); |
106 | | - if ( count( $keyAndVal ) == 2) { |
| 106 | + if ( count( $keyAndVal ) == 2 ) { |
107 | 107 | $propertyName = trim( $keyAndVal[0] ); |
108 | 108 | $fieldName = trim( $keyAndVal[1] ); |
109 | 109 | if ( ! in_array( $fieldName, $fieldNamesArray ) ) { |
— | — | @@ -113,7 +113,7 @@ |
114 | 114 | } |
115 | 115 | } |
116 | 116 | } |
117 | | - |
| 117 | + |
118 | 118 | // Finally, get any non-semantic fields defined. |
119 | 119 | if ( preg_match_all( '/{{{([^|}]*)/mis', $templateText, $matches ) ) { |
120 | 120 | foreach ( $matches[1] as $i => $fieldName ) { |
Index: trunk/extensions/SemanticForms/includes/forminputs/SF_TextInput.php |
— | — | @@ -41,25 +41,25 @@ |
42 | 42 | public static function getOtherPropTypeListsHandled() { |
43 | 43 | return array( '_wpg' ); |
44 | 44 | } |
45 | | - |
| 45 | + |
46 | 46 | /** |
47 | 47 | * Gets the HTML for the preview image or null if there is none. |
48 | | - * |
| 48 | + * |
49 | 49 | * @since 2.3.3 |
50 | | - * |
| 50 | + * |
51 | 51 | * @param string $imageName |
52 | | - * |
| 52 | + * |
53 | 53 | * @return string|null |
54 | 54 | */ |
55 | 55 | protected static function getPreviewImage( $imageName ) { |
56 | 56 | $previewImage = null; |
57 | | - |
| 57 | + |
58 | 58 | $imageTitle = Title::newFromText( $imageName, NS_FILE ); |
59 | | - |
| 59 | + |
60 | 60 | if ( !is_object( $imageTitle ) ) { |
61 | 61 | return $previewImage; |
62 | 62 | } |
63 | | - |
| 63 | + |
64 | 64 | $api = new ApiMain( new FauxRequest( array( |
65 | 65 | 'action' => 'query', |
66 | 66 | 'format' => 'json', |
— | — | @@ -68,12 +68,12 @@ |
69 | 69 | 'titles' => $imageTitle->getFullText(), |
70 | 70 | 'iiurlwidth' => 200 |
71 | 71 | ), true ), true ); |
72 | | - |
| 72 | + |
73 | 73 | $api->execute(); |
74 | 74 | $result = $api->getResultData(); |
75 | 75 | |
76 | 76 | $url = false; |
77 | | - |
| 77 | + |
78 | 78 | if ( array_key_exists( 'query', $result ) && array_key_exists( 'pages', $result['query'] ) ) { |
79 | 79 | foreach ( $result['query']['pages'] as $page ) { |
80 | 80 | foreach ( $page['imageinfo'] as $imageInfo ) { |
— | — | @@ -82,14 +82,14 @@ |
83 | 83 | } |
84 | 84 | } |
85 | 85 | } |
86 | | - |
| 86 | + |
87 | 87 | if ( $url !== false ) { |
88 | 88 | $previewImage = Html::element( |
89 | 89 | 'img', |
90 | 90 | array( 'src' => $url ) |
91 | 91 | ); |
92 | 92 | } |
93 | | - |
| 93 | + |
94 | 94 | return $previewImage; |
95 | 95 | } |
96 | 96 | |
— | — | @@ -112,13 +112,13 @@ |
113 | 113 | } |
114 | 114 | |
115 | 115 | $cssClasses = array( 'sfFancyBox', 'sfUploadable' ); |
116 | | - |
| 116 | + |
117 | 117 | $showPreview = array_key_exists( 'image preview', $other_args ); |
118 | | - |
| 118 | + |
119 | 119 | if ( $showPreview ) { |
120 | 120 | $cssClasses[] = 'sfImagePreview'; |
121 | 121 | } |
122 | | - |
| 122 | + |
123 | 123 | $linkAttrs = array( |
124 | 124 | 'href' => $upload_window_url, |
125 | 125 | 'class' => implode( ' ', $cssClasses ), |
— | — | @@ -126,9 +126,9 @@ |
127 | 127 | 'rev' => $style, |
128 | 128 | 'data-input-id' => $input_id |
129 | 129 | ); |
130 | | - |
| 130 | + |
131 | 131 | $text = "\t" . Xml::element( 'a', $linkAttrs, $upload_label ) . "\n"; |
132 | | - |
| 132 | + |
133 | 133 | if ( $showPreview ) { |
134 | 134 | $text .= Html::rawElement( |
135 | 135 | 'div', |
— | — | @@ -136,7 +136,7 @@ |
137 | 137 | self::getPreviewImage( $cur_value ) |
138 | 138 | ); |
139 | 139 | } |
140 | | - |
| 140 | + |
141 | 141 | return $text; |
142 | 142 | } |
143 | 143 | |
— | — | @@ -216,7 +216,7 @@ |
217 | 217 | } else { |
218 | 218 | $default_filename = ''; |
219 | 219 | } |
220 | | - |
| 220 | + |
221 | 221 | $text .= self::uploadableHTML( $input_id, $delimiter, $default_filename, $cur_value, $other_args ); |
222 | 222 | } |
223 | 223 | $spanClass = 'inputSpan'; |
Index: trunk/extensions/SemanticForms/includes/forminputs/SF_TextAreaWithAutocompleteInput.php |
— | — | @@ -50,10 +50,10 @@ |
51 | 51 | |
52 | 52 | if ( array_key_exists( 'editor', $other_args ) && |
53 | 53 | $other_args['editor'] == 'wikieditor' && |
54 | | - |
| 54 | + |
55 | 55 | method_exists( $wgOut, 'getResourceLoader' ) && |
56 | 56 | in_array( 'jquery.wikiEditor', $wgOut->getResourceLoader()->getModuleNames() ) && |
57 | | - |
| 57 | + |
58 | 58 | class_exists( 'WikiEditorHooks' ) ) { |
59 | 59 | |
60 | 60 | // load modules for all enabled features |
Index: trunk/extensions/SemanticForms/includes/forminputs/SF_FormInput.php |
— | — | @@ -273,9 +273,9 @@ |
274 | 274 | /** |
275 | 275 | * Method to make new style input types compatible with old-style call from |
276 | 276 | * the SF parser. |
277 | | - * |
| 277 | + * |
278 | 278 | * @deprecated Do not use/override this in new input type classes |
279 | | - * |
| 279 | + * |
280 | 280 | * TODO: remove/refactor once SF uses forminput objects properly |
281 | 281 | */ |
282 | 282 | public static function getHTML( $cur_value, $input_name, $is_mandatory, $is_disabled, $other_args ) { |
Index: trunk/extensions/SemanticForms/includes/forminputs/SF_TextAreaInput.php |
— | — | @@ -19,15 +19,15 @@ |
20 | 20 | } |
21 | 21 | |
22 | 22 | public static function getDefaultPropTypes() { |
23 | | - return array('_txt' => array(), '_cod' => array()); |
| 23 | + return array( '_txt' => array(), '_cod' => array() ); |
24 | 24 | } |
25 | 25 | |
26 | 26 | public static function getOtherPropTypesHandled() { |
27 | | - return array('_wpg', '_str'); |
| 27 | + return array( '_wpg', '_str' ); |
28 | 28 | } |
29 | 29 | |
30 | 30 | public static function getOtherPropTypeListsHandled() { |
31 | | - return array('_wpg', '_str'); |
| 31 | + return array( '_wpg', '_str' ); |
32 | 32 | } |
33 | 33 | |
34 | 34 | public static function getHTML( $cur_value, $input_name, $is_mandatory, $is_disabled, $other_args ) { |
— | — | @@ -40,10 +40,10 @@ |
41 | 41 | |
42 | 42 | if ( array_key_exists( 'editor', $other_args ) && |
43 | 43 | $other_args['editor'] == 'wikieditor' && |
44 | | - |
| 44 | + |
45 | 45 | method_exists( $wgOut, 'getResourceLoader' ) && |
46 | 46 | in_array( 'jquery.wikiEditor', $wgOut->getResourceLoader()->getModuleNames() ) && |
47 | | - |
| 47 | + |
48 | 48 | class_exists( 'WikiEditorHooks' ) ) { |
49 | 49 | |
50 | 50 | // load modules for all enabled features |
— | — | @@ -132,7 +132,7 @@ |
133 | 133 | if ( $is_mandatory ) { |
134 | 134 | $spanClass .= ' mandatoryFieldSpan'; |
135 | 135 | } |
136 | | - $text = Xml::tags( 'span', array('class' => $spanClass), $text ); |
| 136 | + $text = Xml::tags( 'span', array( 'class' => $spanClass ), $text ); |
137 | 137 | |
138 | 138 | return $text; |
139 | 139 | } |
Index: trunk/extensions/SemanticForms/includes/SF_AutocompleteAPI.php |
— | — | @@ -32,7 +32,7 @@ |
33 | 33 | if ( strlen( $substr ) == 0 ) { |
34 | 34 | $this->dieUsage( 'The substring must be specified', 'param_substr' ); |
35 | 35 | } |
36 | | - |
| 36 | + |
37 | 37 | if ( !is_null( $attribute ) ) { |
38 | 38 | $data = self::getAllValuesForProperty( false, $attribute, $substr ); |
39 | 39 | } elseif ( !is_null( $relation ) ) { |
— | — | @@ -48,7 +48,7 @@ |
49 | 49 | } else { |
50 | 50 | $data = array(); |
51 | 51 | } |
52 | | - |
| 52 | + |
53 | 53 | // to prevent JS parsing problems, display should be the same |
54 | 54 | // even if there are no results |
55 | 55 | /* |
— | — | @@ -124,7 +124,7 @@ |
125 | 125 | $db = wfGetDB( DB_SLAVE ); |
126 | 126 | $sql_options = array(); |
127 | 127 | $sql_options['LIMIT'] = $sfgMaxAutocompleteValues; |
128 | | - |
| 128 | + |
129 | 129 | if ( $is_relation ) { |
130 | 130 | $value_field = 'o_ids.smw_title'; |
131 | 131 | $from_clause = $db->tableName( 'smw_rels2' ) . " r JOIN " . $db->tableName( 'smw_ids' ) . " p_ids ON r.p_id = p_ids.smw_id JOIN " . $db->tableName( 'smw_ids' ) . " o_ids ON r.o_id = o_ids.smw_id"; |
— | — | @@ -132,21 +132,21 @@ |
133 | 133 | $value_field = 'a.value_xsd'; |
134 | 134 | $from_clause = $db->tableName( 'smw_atts2' ) . " a JOIN " . $db->tableName( 'smw_ids' ) . " p_ids ON a.p_id = p_ids.smw_id"; |
135 | 135 | } |
136 | | - |
| 136 | + |
137 | 137 | $property_name = str_replace( ' ', '_', $property_name ); |
138 | 138 | $conditions = "p_ids.smw_title = '$property_name'"; |
139 | | - |
| 139 | + |
140 | 140 | if ( $substring != null ) { |
141 | 141 | $substring = str_replace( "'", "\'", strtolower( $substring ) ); |
142 | 142 | // utf8 conversion is needed in case MediaWiki is using |
143 | 143 | // binary data storage |
144 | 144 | $conditions .= " AND (REPLACE(LOWER(CONVERT($value_field USING utf8)),'_',' ') LIKE '" . $substring . "%' OR REPLACE(LOWER(CONVERT($value_field USING utf8)),'_',' ') LIKE '% " . $substring . "%')"; |
145 | 145 | } |
146 | | - |
| 146 | + |
147 | 147 | $sql_options['ORDER BY'] = $value_field; |
148 | 148 | $res = $db->select( $from_clause, "DISTINCT $value_field", |
149 | 149 | $conditions, __METHOD__, $sql_options ); |
150 | | - |
| 150 | + |
151 | 151 | while ( $row = $db->fetchRow( $res ) ) { |
152 | 152 | if ( $substring != null ) { |
153 | 153 | $values[] = str_replace( '_', ' ', $row[0] ); |
— | — | @@ -156,8 +156,8 @@ |
157 | 157 | } |
158 | 158 | } |
159 | 159 | $db->freeResult( $res ); |
160 | | - |
| 160 | + |
161 | 161 | return $values; |
162 | 162 | } |
163 | | - |
| 163 | + |
164 | 164 | } |
Index: trunk/extensions/SemanticForms/includes/SF_Utils.php |
— | — | @@ -209,7 +209,7 @@ |
210 | 210 | if ( is_null( $text ) ) { |
211 | 211 | $text = $title->getText(); |
212 | 212 | } |
213 | | - $l = class_exists('DummyLinker') ? new DummyLinker : new Linker; |
| 213 | + $l = class_exists( 'DummyLinker' ) ? new DummyLinker : new Linker; |
214 | 214 | return $l->makeLinkObj( $title, htmlspecialchars( $text ) ); |
215 | 215 | } |
216 | 216 | |
— | — | @@ -645,11 +645,11 @@ |
646 | 646 | * type, for use by both Javascript autocompletion and comboboxes. |
647 | 647 | */ |
648 | 648 | public static function getAutocompleteValues( $source_name, $source_type ) { |
649 | | - |
| 649 | + |
650 | 650 | if ( $source_name == null ) { |
651 | 651 | return null; |
652 | 652 | } |
653 | | - |
| 653 | + |
654 | 654 | $names_array = array(); |
655 | 655 | // The query depends on whether this is a property, category, |
656 | 656 | // concept or namespace. |
— | — | @@ -713,10 +713,10 @@ |
714 | 714 | // unused character (here, "\1"), then do the explode, then |
715 | 715 | // convert them back. |
716 | 716 | $pattern = '/({{.*)\|(.*}})/'; |
717 | | - while ( preg_match($pattern, $str, $matches) ) { |
718 | | - $str = preg_replace($pattern, "$1" . "\1" . "$2", $str); |
| 717 | + while ( preg_match( $pattern, $str, $matches ) ) { |
| 718 | + $str = preg_replace( $pattern, "$1" . "\1" . "$2", $str ); |
719 | 719 | } |
720 | | - return array_map( array('SFUtils', 'convertBackToPipes'), explode('|', $str) ); |
| 720 | + return array_map( array( 'SFUtils', 'convertBackToPipes' ), explode( '|', $str ) ); |
721 | 721 | } |
722 | 722 | |
723 | 723 | /** |
— | — | @@ -836,21 +836,21 @@ |
837 | 837 | |
838 | 838 | return true; |
839 | 839 | } |
840 | | - |
| 840 | + |
841 | 841 | /** |
842 | 842 | * Compatibility helper function. |
843 | 843 | * Since 1.17 SpecialPageFactory::getPage should be used. |
844 | 844 | * SpecialPage::getPage is deprecated in 1.18. |
845 | | - * |
| 845 | + * |
846 | 846 | * @since 2.3.3 |
847 | | - * |
| 847 | + * |
848 | 848 | * @param string $pageName |
849 | | - * |
| 849 | + * |
850 | 850 | * @return SpecialPage|null |
851 | 851 | */ |
852 | 852 | public static function getSpecialPage( $pageName ) { |
853 | 853 | $hasFactory = class_exists( 'SpecialPageFactory' ) && method_exists( 'SpecialPageFactory', 'getPage' ); |
854 | 854 | return $hasFactory ? SpecialPageFactory::getPage( $pageName ) : SpecialPage::getPage( $pageName ); |
855 | 855 | } |
856 | | - |
| 856 | + |
857 | 857 | } |