mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/DiscussionTools
synced 2024-11-23 16:06:53 +00:00
Merge "Clean up subscribe links/buttons"
This commit is contained in:
commit
083900821e
|
@ -151,7 +151,7 @@ class CommentFormatter {
|
||||||
);
|
);
|
||||||
|
|
||||||
self::addSubscribeLink(
|
self::addSubscribeLink(
|
||||||
$headingItem, $doc, $headingElement, $wrapperNode, $latestReplyItem, $bar
|
$headingItem, $doc, $wrapperNode, $latestReplyItem, $bar
|
||||||
);
|
);
|
||||||
|
|
||||||
if ( $latestReplyItem ) {
|
if ( $latestReplyItem ) {
|
||||||
|
@ -171,11 +171,11 @@ class CommentFormatter {
|
||||||
* of comments, and number of editors in the discussion.
|
* of comments, and number of editors in the discussion.
|
||||||
*/
|
*/
|
||||||
protected static function addTopicContainer(
|
protected static function addTopicContainer(
|
||||||
Element &$wrapperNode,
|
Element $wrapperNode,
|
||||||
?ContentCommentItem $latestReplyItem,
|
?ContentCommentItem $latestReplyItem,
|
||||||
Document &$doc,
|
Document $doc,
|
||||||
ContentHeadingItem &$headingItem,
|
ContentHeadingItem $headingItem,
|
||||||
?Element &$bar,
|
?Element $bar,
|
||||||
array &$tocInfo
|
array &$tocInfo
|
||||||
) {
|
) {
|
||||||
if ( !DOMCompat::getClassList( $wrapperNode )->contains( 'mw-heading' ) ) {
|
if ( !DOMCompat::getClassList( $wrapperNode )->contains( 'mw-heading' ) ) {
|
||||||
|
@ -223,10 +223,9 @@ class CommentFormatter {
|
||||||
protected static function addSubscribeLink(
|
protected static function addSubscribeLink(
|
||||||
ContentHeadingItem $headingItem,
|
ContentHeadingItem $headingItem,
|
||||||
Document $doc,
|
Document $doc,
|
||||||
Element $headingElement,
|
Element $wrapperNode,
|
||||||
Element &$wrapperNode,
|
|
||||||
?ContentCommentItem $latestReplyItem,
|
?ContentCommentItem $latestReplyItem,
|
||||||
?Element &$bar
|
?Element $bar
|
||||||
) {
|
) {
|
||||||
$headingJSONEscaped = htmlspecialchars(
|
$headingJSONEscaped = htmlspecialchars(
|
||||||
json_encode( static::getJsonForHeadingMarker( $headingItem ) )
|
json_encode( static::getJsonForHeadingMarker( $headingItem ) )
|
||||||
|
@ -234,9 +233,6 @@ class CommentFormatter {
|
||||||
|
|
||||||
// Replaced in ::postprocessTopicSubscription() as the text depends on user state
|
// Replaced in ::postprocessTopicSubscription() as the text depends on user state
|
||||||
if ( $headingItem->isSubscribable() ) {
|
if ( $headingItem->isSubscribable() ) {
|
||||||
$subscribeLink = $doc->createComment( '__DTSUBSCRIBELINK__' . $headingJSONEscaped );
|
|
||||||
$headingElement->insertBefore( $subscribeLink, $headingElement->firstChild );
|
|
||||||
|
|
||||||
$subscribeButton = $doc->createComment( '__DTSUBSCRIBEBUTTONDESKTOP__' . $headingJSONEscaped );
|
$subscribeButton = $doc->createComment( '__DTSUBSCRIBEBUTTONDESKTOP__' . $headingJSONEscaped );
|
||||||
$wrapperNode->insertBefore( $subscribeButton, $wrapperNode->firstChild );
|
$wrapperNode->insertBefore( $subscribeButton, $wrapperNode->firstChild );
|
||||||
}
|
}
|
||||||
|
@ -459,6 +455,7 @@ class CommentFormatter {
|
||||||
] );
|
] );
|
||||||
|
|
||||||
$text = preg_replace( '/<!--__DTELLIPSISBUTTON__(.*?)-->/', '', $text );
|
$text = preg_replace( '/<!--__DTELLIPSISBUTTON__(.*?)-->/', '', $text );
|
||||||
|
// No longer used, this can be removed once parser cache expires:
|
||||||
$text = preg_replace( '/<!--__DTSUBSCRIBELINK__(.*?)-->/', '', $text );
|
$text = preg_replace( '/<!--__DTSUBSCRIBELINK__(.*?)-->/', '', $text );
|
||||||
$text = preg_replace( '/<!--__DTSUBSCRIBEBUTTON(DESKTOP|MOBILE)__(.*?)-->/', '', $text );
|
$text = preg_replace( '/<!--__DTSUBSCRIBEBUTTON(DESKTOP|MOBILE)__(.*?)-->/', '', $text );
|
||||||
|
|
||||||
|
@ -474,6 +471,7 @@ class CommentFormatter {
|
||||||
): string {
|
): string {
|
||||||
$doc = DOMCompat::newDocument( true );
|
$doc = DOMCompat::newDocument( true );
|
||||||
|
|
||||||
|
// No longer used, this can be removed once parser cache expires:
|
||||||
$text = preg_replace( '/<!--__DTSUBSCRIBELINK__(.*?)-->/', '', $text );
|
$text = preg_replace( '/<!--__DTSUBSCRIBELINK__(.*?)-->/', '', $text );
|
||||||
|
|
||||||
$matches = [];
|
$matches = [];
|
||||||
|
|
Loading…
Reference in a new issue