http://www.mediawiki.org/wiki/Special:Code/MediaWiki/89319
Revision: 89319
Author: yaron
Date: 2011-06-02 04:26:58 +0000 (Thu, 02 Jun 2011)
Log Message:
-----------
Moved formatting of API data for remote autocompletion to happen right before
display of data, to not interfere with sorting of pages
Modified Paths:
--------------
trunk/extensions/SemanticForms/includes/SF_AutocompleteAPI.php
trunk/extensions/SemanticForms/includes/SF_Utils.php
Modified: trunk/extensions/SemanticForms/includes/SF_AutocompleteAPI.php
===================================================================
--- trunk/extensions/SemanticForms/includes/SF_AutocompleteAPI.php
2011-06-02 02:44:33 UTC (rev 89318)
+++ trunk/extensions/SemanticForms/includes/SF_AutocompleteAPI.php
2011-06-02 04:26:58 UTC (rev 89319)
@@ -61,10 +61,16 @@
}
*/
+ // Format data as the API requires it.
+ $formattedData = array();
+ foreach ( $data as $value ) {
+ $formattedData[] = array( 'title' => $value );
+ }
+
// Set top-level elements.
$result = $this->getResult();
- $result->setIndexedTagName( $data, 'p' );
- $result->addValue( null, $this->getModuleName(), $data );
+ $result->setIndexedTagName( $formattedData, 'p' );
+ $result->addValue( null, $this->getModuleName(), $formattedData
);
}
protected function getAllowedParams() {
@@ -147,7 +153,7 @@
while ( $row = $db->fetchRow( $res ) ) {
if ( $substring != null ) {
- $values[] = array( 'title' => str_replace( '_',
' ', $row[0] ) );
+ $values[] = str_replace( '_', ' ', $row[0] );
} else {
$cur_value = str_replace( "'", "\'", $row[0] );
$values[] = str_replace( '_', ' ', $cur_value );
Modified: trunk/extensions/SemanticForms/includes/SF_Utils.php
===================================================================
--- trunk/extensions/SemanticForms/includes/SF_Utils.php 2011-06-02
02:44:33 UTC (rev 89318)
+++ trunk/extensions/SemanticForms/includes/SF_Utils.php 2011-06-02
04:26:58 UTC (rev 89319)
@@ -480,10 +480,7 @@
$cur_title =
Title::makeTitleSafe( $row['page_namespace'], $row['page_title'] );
$cur_value =
self::titleString( $cur_title );
if ( !
in_array( $cur_value, $pages ) ) {
- if (
$substring == null )
-
$pages[] = $cur_value;
- else
-
$pages[] = array( 'title' => $cur_value );
+
$pages[] = $cur_value;
}
// return if
we've reached the maximum number of allowed values
if ( count(
$pages ) > $sfgMaxAutocompleteValues ) {
@@ -520,6 +517,7 @@
$store = smwfGetStore();
$concept = Title::makeTitleSafe( SMW_NS_CONCEPT, $concept_name
);
+
if ( !is_null( $substring ) ) {
$substring = strtolower( $substring );
}
@@ -552,7 +550,7 @@
$lowercasePageName = strtolower( $pageName );
if ( strpos( $lowercasePageName, $substring )
=== 0 ||
strpos( $lowercasePageName, ' ' .
$substring ) > 0 ) {
- $pages[] = array( 'title' =>
$pageName );
+ $pages[] = $pageName;
}
}
}
@@ -582,12 +580,7 @@
$conditions, __METHOD__,
array( 'ORDER BY' => 'page_title' ) );
while ( $row = $db->fetchRow( $res ) ) {
- $cur_value = str_replace( '_', ' ',
$row[0] );
- if ( $substring == null ) {
- $pages[] = $cur_value;
- } else {
- $pages[] = array( 'title' =>
$cur_value );
- }
+ $pages[] = str_replace( '_', ' ',
$row[0] );
}
$db->freeResult( $res );
}
_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs