From a719d5ff1ca446d3f9b209a9dda70d5c5fb8ddf6 Mon Sep 17 00:00:00 2001 From: Jason Richey Date: Wed, 15 Oct 2008 19:32:59 +0000 Subject: [PATCH] Added 2 hooks. One in Parser to allow custom handling of namespace links, and one in EditPage, to allow custom output/handling when a user has no edit rights --- RELEASE-NOTES | 7 ++++++- docs/hooks.txt | 13 +++++++++++++ includes/EditPage.php | 1 + includes/parser/Parser.php | 4 ++++ 4 files changed, 24 insertions(+), 1 deletion(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index bac626d4a8..56342169f0 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -163,7 +163,12 @@ The following extensions are migrated into MediaWiki 1.14: several uses of the same image. * (bug 1250) Users can still use "show preview" and "show changes" even if the wiki is set to read-only mode. - +* Added 'ParserLinkNSCheck' hook in the parser, allowing extensions to catch and handle + links based on namespace (for instance, to add code to handle [[Tag: Foo]] similarly + to how [[Category: Foo]] is handled. +* Added 'EditPageNoPermission' hook to allow special handling/output when a non-editor + views an edit page. + === Bug fixes in 1.14 === * (bug 14907) DatabasePostgres::fieldType now defined. diff --git a/docs/hooks.txt b/docs/hooks.txt index 7cab7561b2..5209796f73 100644 --- a/docs/hooks.txt +++ b/docs/hooks.txt @@ -492,6 +492,15 @@ rendered inline in wiki pages or galleries in category pages. &$skip: skip this template and link it? &$id: the id of the revision being parsed +'ParserLinkNSCheck': after Image and Category links are handled, before general link processing +Allows an extension to catch arbitrary namespaces and hande their links differently +&$parser: the parser instance +&$title: The title instance +&$s: The current value of s, as used in replaceInternalLinks2 +&$text: The text of the link +&$prefix:The bit of text just before the link begins, depending on language settings +&$trail: The bit of text after the link ends, depending on language settings + 'BeforeParserMakeImageLinkObj': before an image is rendered by Parser &$parser: Parser object &$nt: the image title @@ -587,6 +596,10 @@ $text: content of the edit box $error: error message to return $summary: Edit summary for page +'EditPageNoPermission': allows modification of permission Errors before the readonly page is loaded +&$editpage: The editpage instance +&$permErrors: the permission Errors from editpage->getEditPermissionErrors() + 'EditFormPreloadText': Allows population of the edit form when creating new pages &$text: Text to preload with &$title: Title object representing the page being created diff --git a/includes/EditPage.php b/includes/EditPage.php index be4dee1b19..963969741f 100644 --- a/includes/EditPage.php +++ b/includes/EditPage.php @@ -385,6 +385,7 @@ class EditPage { $permErrors = $this->getEditPermissionErrors(); if ( $permErrors ) { wfDebug( __METHOD__.": User can't edit\n" ); + wfRunHooks( 'EditPageNoPermission', array( &$this, &$permErrors ) ); $this->readOnlyPage( $this->getContent(), true, $permErrors, 'edit' ); wfProfileOut( __METHOD__ ); return; diff --git a/includes/parser/Parser.php b/includes/parser/Parser.php index 0021e98416..7070be609d 100644 --- a/includes/parser/Parser.php +++ b/includes/parser/Parser.php @@ -1801,6 +1801,10 @@ class Parser wfProfileOut( __METHOD__."-category" ); continue; } + # Give extensions a chance to catch other namespace links + if ( !wfRunHooks( 'ParserLinkNSCheck', array( &$this, &$nt, &$s, &$text, &$prefix, &$trail ) ) ) { + continue; + } } # Self-link checking -- 2.20.1