From: Timo Tijhof Date: Thu, 12 Mar 2015 20:12:30 +0000 (+0100) Subject: Title: Clean up getEditNotices() X-Git-Tag: 1.31.0-rc.0~12046^2~2 X-Git-Url: https://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/banques/?a=commitdiff_plain;h=3bfe4eca3f5269ed50bebd1c1b1ff1f61bf776ec;p=lhc%2Fweb%2Fwiklou.git Title: Clean up getEditNotices() Change-Id: I4ad5e16dfe42494ee6d8c43cfc50ae57e2b9a2d4 --- diff --git a/includes/Title.php b/includes/Title.php index 36237ed5bf..b04bf0436c 100644 --- a/includes/Title.php +++ b/includes/Title.php @@ -4680,34 +4680,57 @@ class Title { public function getEditNotices( $oldid = 0 ) { $notices = array(); - # Optional notices on a per-namespace and per-page basis + // Optional notice for the entire namespace $editnotice_ns = 'editnotice-' . $this->getNamespace(); - $editnotice_ns_message = wfMessage( $editnotice_ns ); - if ( $editnotice_ns_message->exists() ) { - $notices[$editnotice_ns] = '
' . - $editnotice_ns_message->parseAsBlock() . '
'; + $msg = wfMessage( $editnotice_ns ); + if ( $msg->exists() ) { + $html = $msg->parseAsBlock(); + $notices[$editnotice_ns] = Html::rawElement( + 'div', + array( 'class' => array( + 'mw-editnotice', + 'mw-editnotice-namespace', + Sanitizer::escapeClass( "mw-$editnotice_ns" ) + ) ), + $html + ); } + if ( MWNamespace::hasSubpages( $this->getNamespace() ) ) { + // Optional notice for page itself and any parent page $parts = explode( '/', $this->getDBkey() ); $editnotice_base = $editnotice_ns; while ( count( $parts ) > 0 ) { $editnotice_base .= '-' . array_shift( $parts ); - $editnotice_base_msg = wfMessage( $editnotice_base ); - if ( $editnotice_base_msg->exists() ) { - $notices[$editnotice_base] = '
' . - $editnotice_base_msg->parseAsBlock() . '
'; + $msg = wfMessage( $editnotice_base ); + if ( $msg->exists() ) { + $html = $msg->parseAsBlock(); + $notices[$editnotice_base] = Html::rawElement( + 'div', + array( 'class' => array( + 'mw-editnotice', + 'mw-editnotice-base', + Sanitizer::escapeClass( "mw-$editnotice_base" ) + ) ), + $html + ); } } } else { - # Even if there are no subpages in namespace, we still don't want / in MW ns. + // Even if there are no subpages in namespace, we still don't want "/" in MediaWiki message keys $editnoticeText = $editnotice_ns . '-' . str_replace( '/', '-', $this->getDBkey() ); - $editnoticeMsg = wfMessage( $editnoticeText ); - if ( $editnoticeMsg->exists() ) { - $notices[$editnoticeText] = '
' . - $editnoticeMsg->parseAsBlock() . '
'; + $msg = wfMessage( $editnoticeText ); + if ( $msg->exists() ) { + $html = $msg->parseAsBlock(); + $notices[$editnoticeText] = Html::rawElement( + 'div', + array( 'class' => array( + 'mw-editnotice', + 'mw-editnotice-page', + Sanitizer::escapeClass( "mw-$editnoticeText" ) + ) ), + $html + ); } }