Cenarium has uploaded a new change for review.
https://gerrit.wikimedia.org/r/189178
Change subject: Adding support for per category editnotices
......................................................................
Adding support for per category editnotices
For each category the page is in, the corresponding editnotice message (of the
form editnotice-category- ) is checked and added if existent.
This also includes a few variable name changes for consistency.
Bug: T85372
Change-Id: Id318d6184c3a6164bd1961666c73065668d8b34e
---
M includes/Title.php
1 file changed, 18 insertions(+), 8 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core
refs/changes/78/189178/1
diff --git a/includes/Title.php b/includes/Title.php
index 9a7cd04..e672486 100644
--- a/includes/Title.php
+++ b/includes/Title.php
@@ -4689,7 +4689,7 @@
public function getEditNotices( $oldid = 0 ) {
$notices = array();
- # Optional notices on a per-namespace and per-page basis
+ # Optional notices on a per-namespace basis
$editnotice_ns = 'editnotice-' . $this->getNamespace();
$editnotice_ns_message = wfMessage( $editnotice_ns );
if ( $editnotice_ns_message->exists() ) {
@@ -4697,6 +4697,7 @@
Sanitizer::escapeClass( "mw-$editnotice_ns" ) .
'">' .
$editnotice_ns_message->parseAsBlock() .
'</div>';
}
+ # Optional notices on a per-page basis
if ( MWNamespace::hasSubpages( $this->getNamespace() ) ) {
$parts = explode( '/', $this->getDBkey() );
$editnotice_base = $editnotice_ns;
@@ -4711,15 +4712,24 @@
}
} else {
# Even if there are no subpages in namespace, we still
don't want / in MW ns.
- $editnoticeText = $editnotice_ns . '-' . str_replace(
'/', '-', $this->getDBkey() );
- $editnoticeMsg = wfMessage( $editnoticeText );
- if ( $editnoticeMsg->exists() ) {
- $notices[$editnoticeText] = '<div
class="mw-editnotice mw-editnotice-page ' .
- Sanitizer::escapeClass(
"mw-$editnoticeText" ) . '">' .
- $editnoticeMsg->parseAsBlock() .
'</div>';
+ $editnotice_page = $editnotice_ns . '-' . str_replace(
'/', '-', $this->getDBkey() );
+ $editnotice_page_message = wfMessage( $editnotice_page
);
+ if ( $editnotice_page_message->exists() ) {
+ $notices[$editnotice_page] = '<div
class="mw-editnotice mw-editnotice-page ' .
+ Sanitizer::escapeClass(
"mw-$editnotice_page" ) . '">' .
+ $editnotice_page->parseAsBlock() .
'</div>';
}
}
-
+ # Optional notices on a per-category basis
+ foreach ($this->getParentCategories() as $cat) {
+ $editnotice_cat = 'editnotice-category-' . $cat;
+ $editnotice_cat_message = wfMessage ( $editnotice_cat );
+ if ( $editnotice_cat_message->exists() ) {
+ $notices[$editnotice_cat] = '<div
class="mw-editnotice mw-editnotice-category ' .
+ Sanitizer::escapeClass(
"mw-$editnotice_cat" ) . '">' .
+ $editnotice_cat_message->parseAsBlock()
. '</div>';
+ }
+ }
Hooks::run( 'TitleGetEditNotices', array( $this, $oldid,
&$notices ) );
return $notices;
}
--
To view, visit https://gerrit.wikimedia.org/r/189178
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Id318d6184c3a6164bd1961666c73065668d8b34e
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Cenarium <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits