Opened 16 years ago

Closed 15 years ago

#2386 closed Bug (fixed)

Patch for function wfSajaxSearchArticleFCKeditor

Reported by: Tobias Manthey 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 (4)

2386.patch (1.1 KB) - added by Artur Formella 16 years ago.
2386_2.patch (1.1 KB) - added by Artur Formella 16 years ago.
2386_3.patch (3.7 KB) - added by Artur Formella 16 years ago.
2386_4.patch (3.7 KB) - added by Wiktor Walc 15 years ago.
Rerolled patch against head

Download all attachments as: .zip

Change History (13)

comment:1 Changed 16 years ago by Tobias Manthey

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 16 years ago by Alfonso Martínez de Lizarrondo

Component: GeneralProject : MediaWiki+FCKeditor
Keywords: HasPatch added; patch wfSajaxSearchArticleFCKeditor removed

Changed 16 years ago by Artur Formella

Attachment: 2386.patch added

comment:3 Changed 16 years ago by Artur Formella

Keywords: Review? added

comment:4 Changed 16 years ago by Wiktor Walc

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 16 years ago by Artur Formella

Attachment: 2386_2.patch added

comment:5 Changed 16 years ago by Artur Formella

Keywords: Review? added; Review- removed

comment:6 Changed 16 years ago by Wiktor Walc

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 16 years ago by Wiktor Walc

Keywords: Review- added; Review? removed

Changed 16 years ago by Artur Formella

Attachment: 2386_3.patch added

comment:8 Changed 16 years ago by Artur Formella

Keywords: Review? added; Review- removed

Changed 15 years ago by Wiktor Walc

Attachment: 2386_4.patch added

Rerolled patch against head

comment:9 Changed 15 years ago by Wiktor Walc

Keywords: Review+ added; Review? removed
Resolution: fixed
Status: newclosed

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 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy