From: This, that and the other Date: Mon, 21 Jul 2014 01:36:20 +0000 (+1000) Subject: Hide edit toolbar Signature button in non-discussion namespaces X-Git-Tag: 1.31.0-rc.0~10522^2 X-Git-Url: http://git.cyclocoop.org/%7B%24admin_url%7Dcompta/comptes/journal.php?a=commitdiff_plain;h=b3f897e971a90c82f5a9a15433bd03e5ac839e63;p=lhc%2Fweb%2Fwiklou.git Hide edit toolbar Signature button in non-discussion namespaces Most wikis only use user signatures on pages set aside from discussion, (Talk namespaces and sometimes project/main namespaces depending on the wiki), so having the button available everywhere is confusing. The few wikis that need the button (especially non-content, internal/corporate/planning wikis), can add relevant namespaces to the $wgExtraSignatureNamespaces array in LocalSettings. This would make it possible to solve bugs like T59727 or T53154. Since this is a change to default behavior, a release note is added. Bug: T7645 Change-Id: I7ccf1093b888c7b33721234349ca0ac054c3cd3f --- diff --git a/RELEASE-NOTES-1.26 b/RELEASE-NOTES-1.26 index 11da802d18..bbd63b5c4c 100644 --- a/RELEASE-NOTES-1.26 +++ b/RELEASE-NOTES-1.26 @@ -16,6 +16,10 @@ production. use the 'rawcontinue' parameter to receive raw query-continue data, but the new style is encouraged as it's harder to implement incorrectly. * Deprecated API formats dump and wddx have been completely removed. +* (T7645) The "Signature" button on the edit toolbar is now hidden by default + in non-talk namespaces. A new configuration variable, + $wgExtraSignatureNamespaces, controls in which subject (non-talk) namespaces + the "Signature" button on the edit toolbar will be displayed. * $wgResourceLoaderUseESI was deprecated and removed. This was an experimental feature that was never enabled by default. diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php index 4d1b3299cd..53137a68fe 100644 --- a/includes/DefaultSettings.php +++ b/includes/DefaultSettings.php @@ -3962,6 +3962,15 @@ $wgTrackingCategories = array(); */ $wgContentNamespaces = array( NS_MAIN ); +/** + * Array of namespaces, in addition to the talk namespaces, where signatures + * (~~~~) are likely to be used. This determines whether to display the + * Signature button on the edit toolbar, and may also be used by extensions. + * For example, "traditional" style wikis, where content and discussion are + * intermixed, could place NS_MAIN and NS_PROJECT namespaces in this array. + */ +$wgExtraSignatureNamespaces = array(); + /** * Max number of redirects to follow when resolving redirects. * 1 means only the first redirect is followed (default behavior). diff --git a/includes/EditPage.php b/includes/EditPage.php index 0233b11d74..0ca2f80f49 100644 --- a/includes/EditPage.php +++ b/includes/EditPage.php @@ -2545,7 +2545,7 @@ class EditPage { $wgOut->addHTML( $this->editFormTextBeforeContent ); if ( !$this->isCssJsSubpage && $showToolbar && $wgUser->getOption( 'showtoolbar' ) ) { - $wgOut->addHTML( EditPage::getEditToolbar() ); + $wgOut->addHTML( EditPage::getEditToolbar( $this->mTitle ) ); } if ( $this->blankArticle ) { @@ -3686,13 +3686,18 @@ HTML * Shows a bulletin board style toolbar for common editing functions. * It can be disabled in the user preferences. * + * @param $title Title object for the page being edited (optional) * @return string */ - static function getEditToolbar() { + static function getEditToolbar( $title = null ) { global $wgContLang, $wgOut; global $wgEnableUploads, $wgForeignFileRepos; $imagesAvailable = $wgEnableUploads || count( $wgForeignFileRepos ); + $showSignature = true; + if ( $title ) { + $showSignature = MWNamespace::wantSignatures( $title->getNamespace() ); + } /** * $toolarray is an array of arrays each of which includes the @@ -3760,13 +3765,13 @@ HTML 'sample' => wfMessage( 'nowiki_sample' )->text(), 'tip' => wfMessage( 'nowiki_tip' )->text(), ), - array( + $showSignature ? array( 'id' => 'mw-editbutton-signature', 'open' => '--~~~~', 'close' => '', 'sample' => '', 'tip' => wfMessage( 'sig_tip' )->text(), - ), + ) : false, array( 'id' => 'mw-editbutton-hr', 'open' => "\n----\n", diff --git a/includes/MWNamespace.php b/includes/MWNamespace.php index bd68551453..731b62e036 100644 --- a/includes/MWNamespace.php +++ b/includes/MWNamespace.php @@ -296,6 +296,18 @@ class MWNamespace { return $index == NS_MAIN || in_array( $index, $wgContentNamespaces ); } + /** + * Might pages in this namespace require the use of the Signature button on + * the edit toolbar? + * + * @param int $index Index to check + * @return bool + */ + public static function wantSignatures( $index ) { + global $wgExtraSignatureNamespaces; + return self::isTalk( $index ) || in_array( $index, $wgExtraSignatureNamespaces ); + } + /** * Can pages in a namespace be watched? * diff --git a/includes/resourceloader/ResourceLoaderStartUpModule.php b/includes/resourceloader/ResourceLoaderStartUpModule.php index 16424a0031..2936d765fb 100644 --- a/includes/resourceloader/ResourceLoaderStartUpModule.php +++ b/includes/resourceloader/ResourceLoaderStartUpModule.php @@ -88,6 +88,7 @@ class ResourceLoaderStartUpModule extends ResourceLoaderModule { 'wgContentNamespaces' => MWNamespace::getContentNamespaces(), 'wgSiteName' => $conf->get( 'Sitename' ), 'wgDBname' => $conf->get( 'DBname' ), + 'wgExtraSignatureNamespaces' => $conf->get( 'ExtraSignatureNamespaces' ), 'wgAvailableSkins' => Skin::getSkinNames(), 'wgExtensionAssetsPath' => $conf->get( 'ExtensionAssetsPath' ), // MediaWiki sets cookies to have this prefix by default