Index: trunk/extensions/SemanticForms/includes/SF_Utils.php |
— | — | @@ -495,19 +495,18 @@ |
496 | 496 | static function getAllPagesForConcept( $concept_name, $substring = null ) { |
497 | 497 | global $sfgMaxAutocompleteValues; |
498 | 498 | |
499 | | - // TODO - substring isn't being handled. Is there a way to |
500 | | - // include it through the API? |
501 | 499 | $store = smwfGetStore(); |
502 | | -/* |
503 | | - $requestoptions = new SMWRequestOptions(); |
504 | | - if ($substring != null) { |
505 | | - $requestoptions->addStringCondition($substring, SMWStringCondition::STRCOND_PRE); |
| 500 | + |
| 501 | + $concept = Title::makeTitleSafe( SMW_NS_CONCEPT, $concept_name ); |
| 502 | + if ( !is_null( $substring ) ) { |
| 503 | + $substring = strtolower( $substring ); |
506 | 504 | } |
507 | | -*/ |
508 | | - $concept = Title::makeTitleSafe( SMW_NS_CONCEPT, $concept_name ); |
509 | | - // escape if there's a problem |
510 | | - if ( $concept == null ) |
| 505 | + |
| 506 | + // Escape if there's a problem. |
| 507 | + if ( $concept == null ) { |
511 | 508 | return array(); |
| 509 | + } |
| 510 | + |
512 | 511 | $desc = new SMWConceptDescription( $concept ); |
513 | 512 | $printout = new SMWPrintRequest( SMWPrintRequest::PRINT_THIS, "" ); |
514 | 513 | $desc->addPrintRequest( $printout ); |
— | — | @@ -516,7 +515,20 @@ |
517 | 516 | $query_result = $store->getQueryResult( $query ); |
518 | 517 | $pages = array(); |
519 | 518 | while ( $res = $query_result->getNext() ) { |
520 | | - $pages[] = $res[0]->getNextText( SMW_OUTPUT_WIKI ); |
| 519 | + $pageName = $res[0]->getNextText( SMW_OUTPUT_WIKI ); |
| 520 | + if ( is_null( $substring ) ) { |
| 521 | + $pages[] = $pageName; |
| 522 | + } else { |
| 523 | + // Filter on the substring manually. It would |
| 524 | + // be better to do this filtering in the |
| 525 | + // original SMW query, but that doesn't seem |
| 526 | + // possible yet. |
| 527 | + $lowercasePageName = strtolower( $pageName ); |
| 528 | + if ( strpos( $lowercasePageName, $substring ) === 0 || |
| 529 | + strpos( $lowercasePageName, ' ' . $substring ) > 0 ) { |
| 530 | + $pages[] = array( 'title' => $pageName ); |
| 531 | + } |
| 532 | + } |
521 | 533 | } |
522 | 534 | sort( $pages ); |
523 | 535 | return $pages; |