Index: trunk/extensions/SemanticForms/includes/SF_GlobalFunctions.php |
— | — | @@ -9,7 +9,7 @@ |
10 | 10 | |
11 | 11 | if ( !defined( 'MEDIAWIKI' ) ) die(); |
12 | 12 | |
13 | | -define('SF_VERSION','1.3.2'); |
| 13 | +define('SF_VERSION','1.3.3'); |
14 | 14 | |
15 | 15 | $wgExtensionCredits['specialpage'][]= array( |
16 | 16 | 'name' => 'Semantic Forms', |
— | — | @@ -253,7 +253,9 @@ |
254 | 254 | else // $is_diff |
255 | 255 | $action = "wpDiff"; |
256 | 256 | |
| 257 | + global $sfgScriptPath; |
257 | 258 | $text =<<<END |
| 259 | + <p style="position: absolute; left: 45%; top: 45%;"><img src="$sfgScriptPath/skins/loading.gif" /></p> |
258 | 260 | <form id="editform" name="editform" method="post" action="$new_url"> |
259 | 261 | <input type="hidden" name="wpTextbox1" id="wpTextbox1" value="$page_contents" /> |
260 | 262 | <input type="hidden" name="wpSummary" value="$edit_summary" /> |
— | — | @@ -370,9 +372,9 @@ |
371 | 373 | return null; |
372 | 374 | $ad = SpecialPage::getPage('AddData'); |
373 | 375 | if ($form_name) |
374 | | - $add_data_url = $ad->getTitle()->getFullURL() . "/" . $form_name . "/" . sffTitleURLString($target_page_title); |
| 376 | + $add_data_url = $ad->getTitle()->getLinkURL() . "/" . $form_name . "/" . sffTitleURLString($target_page_title); |
375 | 377 | else |
376 | | - $add_data_url = $ad->getTitle()->getFullURL() . "/" . sffTitleURLString($target_page_title); |
| 378 | + $add_data_url = $ad->getTitle()->getLinkURL() . "/" . sffTitleURLString($target_page_title); |
377 | 379 | foreach ($alt_forms as $i => $alt_form) { |
378 | 380 | $add_data_url .= ($i == 0) ? "?" : "&"; |
379 | 381 | $add_data_url .= "alt_form[$i]=$alt_form"; |
— | — | @@ -578,11 +580,11 @@ |
579 | 581 | ); |
580 | 582 | } |
581 | 583 | |
582 | | -function sffGetAllPagesForProperty_orig($is_relation, $property_name, $substring = null) { |
| 584 | +function sffGetAllValuesForProperty_orig($is_relation, $property_name, $substring = null) { |
583 | 585 | global $sfgMaxAutocompleteValues; |
584 | 586 | |
585 | | - $fname = "sffGetAllPagesForProperty_orig"; |
586 | | - $pages = array(); |
| 587 | + $fname = "sffGetAllValuesForProperty_orig"; |
| 588 | + $values = array(); |
587 | 589 | $db = wfGetDB( DB_SLAVE ); |
588 | 590 | $sql_options = array(); |
589 | 591 | $sql_options['LIMIT'] = $sfgMaxAutocompleteValues; |
— | — | @@ -602,17 +604,17 @@ |
603 | 605 | $conditions, $fname, $sql_options); |
604 | 606 | while ($row = $db->fetchRow($res)) { |
605 | 607 | if ($substring != null) { |
606 | | - $pages[] = array('title' => str_replace('_', ' ', $row[0])); |
| 608 | + $values[] = array('title' => str_replace('_', ' ', $row[0])); |
607 | 609 | } else { |
608 | 610 | $cur_value = str_replace("'", "\'", $row[0]); |
609 | | - $pages[] = str_replace('_', ' ', $cur_value); |
| 611 | + $values[] = str_replace('_', ' ', $cur_value); |
610 | 612 | } |
611 | 613 | } |
612 | 614 | $db->freeResult($res); |
613 | | - return $pages; |
| 615 | + return $values; |
614 | 616 | } |
615 | 617 | |
616 | | -function sffGetAllPagesForProperty_1_2($property_name, $substring = null) { |
| 618 | +function sffGetAllValuesForProperty_1_2($property_name, $substring = null) { |
617 | 619 | global $sfgMaxAutocompleteValues; |
618 | 620 | |
619 | 621 | $store = smwfGetStore(); |
— | — | @@ -623,18 +625,14 @@ |
624 | 626 | } |
625 | 627 | $property = Title::newFromText($property_name, SMW_NS_PROPERTY); |
626 | 628 | $data_values = $store->getPropertyValues(null, $property, $requestoptions); |
627 | | - $pages = array(); |
| 629 | + $values = array(); |
628 | 630 | foreach ($data_values as $dv) { |
629 | 631 | // getPropertyValues() gets many repeat values - we want |
630 | 632 | // only one of each value |
631 | 633 | $string_value = str_replace('_', ' ', $dv->getXSDValue()); |
632 | 634 | $string_value = str_replace("'", "\'", $string_value); |
633 | | - if (array_search($string_value, $pages) === false) |
634 | | - if ($substring != null) |
635 | | - $pages[] = array('title' => str_replace('_', ' ' |
636 | | -, $string_value)); |
637 | | - else |
638 | | - $pages[] = $string_value; |
| 635 | + if (array_search($string_value, $values) === false) |
| 636 | + $values[] = $string_value; |
639 | 637 | } |
640 | 638 | // if there was a substring specified, also find values that have |
641 | 639 | // it after a space, not just at the beginning of the value |
— | — | @@ -644,10 +642,23 @@ |
645 | 643 | $requestoptions2->addStringCondition(" $substring", SMWStringCondition::STRCOND_MID); |
646 | 644 | $data_values = $store->getPropertyValues(null, $property, $requestoptions2); |
647 | 645 | foreach ($data_values as $dv) { |
648 | | - $pages[] = array('title' => str_replace('_', ' ', $dv->getXSDValue())); |
| 646 | + $string_value = str_replace('_', ' ', $dv->getXSDValue()); |
| 647 | + if (array_search($string_value, $values) === false) |
| 648 | + $values[] = $string_value; |
649 | 649 | } |
650 | 650 | } |
651 | | - return $pages; |
| 651 | + if ($substring == null) |
| 652 | + return $values; |
| 653 | + else { |
| 654 | + $autocomplete_vals = array(); |
| 655 | + foreach ($values as $value) { |
| 656 | + // if these values are being returned for remote |
| 657 | + // autocompletion, undo the apostrophe-escaping |
| 658 | + $value = str_replace("\'", "'", $value); |
| 659 | + $autocomplete_vals[] = array('title' => $value); |
| 660 | + } |
| 661 | + return $autocomplete_vals; |
| 662 | + } |
652 | 663 | } |
653 | 664 | |
654 | 665 | /* |