Ticket #2386 (closed Bug: fixed)

Opened 6 years ago

Last modified 5 years 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 6 years ago.
2386_2.patch (1.1 KB) - added by arczi 6 years ago.
2386_3.patch (3.7 KB) - added by arczi 6 years ago.
2386_4.patch (3.7 KB) - added by wwalc 5 years ago.
Rerolled patch against head

Change History

comment:1 Changed 6 years 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);

}

}


comment:2 Changed 6 years ago by alfonsoml

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

Changed 6 years ago by arczi

comment:3 Changed 6 years ago by arczi

  • Keywords Review? added

comment:4 Changed 6 years 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 6 years ago by arczi

comment:5 Changed 6 years ago by arczi

  • Keywords Review? added; Review- removed

comment:6 Changed 6 years 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)

comment:7 Changed 6 years ago by wwalc

  • Keywords Review- added; Review? removed

Changed 6 years ago by arczi

comment:8 Changed 6 years ago by arczi

  • Keywords Review? added; Review- removed

Changed 5 years ago by wwalc

Rerolled patch against head

comment:9 Changed 5 years ago by wwalc

  • Keywords Review+ added; Review? removed
  • Status changed from new to closed
  • Resolution set to fixed

The old patch did't work with the current trunk so I have manually applied all changes. It seems that it works (tested on 1.13.5 and 1.14.0).

Committed with [3185].

Note: See TracTickets for help on using tickets.
© 2003 – 2012 CKSource – Frederico Knabben. All rights reserved. | Terms of use | Privacy policy