Ticket #2386 (new Bug)

Opened 5 months ago

Last modified 3 months ago

Patch for function wfSajaxSearchArticleFCKeditor

Reported by: tmanthey Owned by:
Priority: Normal Milestone:
Component: Project : MediaWiki+FCKeditor Version: FCKeditor 2.6.2
Keywords: HasPatch Review? Cc:

Description

The function searches by default only the NS_MAIN namespace. It does not extract the namespace from search term and thus does not find articles that are not located in NS_MAIN.

The below code adds this functionality:


function wfSajaxSearchArticleFCKeditor( $term ) {

global $wgContLang, $wgOut,$wgExtraNamespaces;

$limit = 10;

$ns = NS_MAIN;

$term = $wgContLang->checkTitleEncoding( $wgContLang->recodeInput( js_unescape( $term ) ) );

if (strpos($term, "Category:") === 0) {

$ns = NS_CATEGORY; $term = substr($term, 9); $prefix = "Category:";

} else if (strpos($term, ":Category:") === 0) {

$ns = NS_CATEGORY; $term = substr($term, 10); $prefix = ":Category:";

} else if (strpos($term,":")) {

$pos = strpos($term,":"); $find_ns = array_search(substr($term,0,$pos),$wgExtraNamespaces); if ($find_ns) {

$ns = $find_ns; $prefix = substr($term,0,$pos+1); $term = substr($term,$pos+1);

}

}


Attachments

2386.patch (1.1 KB) - added by arczi 3 months ago.
2386_2.patch (1.1 KB) - added by arczi 3 months ago.
2386_3.patch (3.7 KB) - added by arczi 3 months ago.

Change History

Changed 5 months ago by tmanthey

The function searches by default only the NS_MAIN namespace. It does not extract the namespace from search term and thus does not find articles that are not located in NS_MAIN. Addititionally the functionality to add Media: and :Image: links was added.

The below code adds this functionality:


function wfSajaxSearchArticleFCKeditor( $term ) {

global $wgContLang, $wgOut,$wgExtraNamespaces; $limit = 10; $ns = NS_MAIN;

$term = $wgContLang->checkTitleEncoding( $wgContLang->recodeInput( js_unescape( $term ) ) );

if (strpos($term, "Category:") === 0) {

$ns = NS_CATEGORY; $term = substr($term, 9); $prefix = "Category:";

} else if (strpos($term, ":Category:") === 0) {

$ns = NS_CATEGORY; $term = substr($term, 10); $prefix = ":Category:";

} else if (strpos($term, "Media:") === 0) {

$ns = NS_IMAGE; $term = substr($term, 6); $prefix = "Media:";

} else if (strpos($term, ":Image:") === 0) {

$ns = NS_IMAGE; $term = substr($term, 7); $prefix = ":Image:";

} else if (strpos($term,":")) {

$pos = strpos($term,":"); $find_ns = array_search(substr($term,0,$pos),$wgExtraNamespaces); if ($find_ns) {

$ns = $find_ns; $prefix = substr($term,0,$pos+1); $term = substr($term,$pos+1);

}

}


Changed 4 months ago by alfonsoml

  • keywords HasPatch added; patch wfSajaxSearchArticleFCKeditor removed
  • component changed from General to Project : MediaWiki+FCKeditor

Changed 3 months ago by arczi

Changed 3 months ago by arczi

  • keywords Review? added

Changed 3 months ago by wwalc

  • keywords Review- added; Review? removed

There is an error when there is no extra namespace defined in $wgExtraNamespaces.

Additional check must be performed when this condition returns true:

else if (strpos($term,":")) {

I mean something like

is_array($wgExtraNamespaces)

Changed 3 months ago by arczi

Changed 3 months ago by arczi

  • keywords Review? added; Review- removed

Changed 3 months ago by wwalc

When I search for:

:Image:Monz

I get valid results, so it generally works, but when I select one of the links to images, I get:

[[:Image:Monza_3.gif|rtecolonImage:Monza_3.gif]]

("rtecolon" is added)

Changed 3 months ago by wwalc

  • keywords Review- added; Review? removed

Changed 3 months ago by arczi

Changed 3 months ago by arczi

  • keywords Review? added; Review- removed
Note: See TracTickets for help on using tickets.