Matthias Mullie has uploaded a new change for review.
https://gerrit.wikimedia.org/r/51173
Change subject: Discuss on talk page
......................................................................
Discuss on talk page
Change-Id: Ife2452d5343512c6093c6f68a498ef8d2ec22eb8
---
M ArticleFeedbackv5.i18n.php
M ArticleFeedbackv5.model.php
M ArticleFeedbackv5.render.php
M modules/jquery.articleFeedbackv5/jquery.articleFeedbackv5.special.js
4 files changed, 207 insertions(+), 8 deletions(-)
git pull
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/ArticleFeedbackv5
refs/changes/73/51173/1
diff --git a/ArticleFeedbackv5.i18n.php b/ArticleFeedbackv5.i18n.php
index b341440..29abfb1 100644
--- a/ArticleFeedbackv5.i18n.php
+++ b/ArticleFeedbackv5.i18n.php
@@ -191,6 +191,10 @@
'articlefeedbackv5-form-unrequest' => 'Unrequest oversight',
'articlefeedbackv5-form-decline' => 'Decline oversight',
'articlefeedbackv5-form-declined' => 'Oversight declined',
+ 'articlefeedbackv5-form-discuss-talk' => 'Discuss on talk page',
+ 'articlefeedbackv5-form-discuss-user' => 'Contact the user',
+ 'articlefeedbackv5-form-discuss-talk-exists' => 'See talk page
discussion',
+ 'articlefeedbackv5-form-discuss-user-exists' => 'See user discussion',
'articlefeedbackv5-form-tooltip-note' => 'Add a note explaining your
flag',
'articlefeedbackv5-form-tooltip-feature' => 'This can help improve the
article',
'articlefeedbackv5-form-tooltip-unfeature' => 'Undo usable flag',
@@ -208,6 +212,20 @@
'articlefeedbackv5-form-tooltip-request' => 'Offensive, private data
...',
'articlefeedbackv5-form-tooltip-unrequest' => 'Undo oversight request',
'articlefeedbackv5-form-tooltip-decline' => 'Decline oversight request',
+ 'articlefeedbackv5-form-tooltip-discuss-talk' => "Discuss feedback on
the article's talk page",
+ 'articlefeedbackv5-form-tooltip-discuss-user' => 'Discuss feedback with
the user who submitted it',
+ 'articlefeedbackv5-discuss-talk-section-title' => 'Reader feedback: $1',
+ 'articlefeedbackv5-discuss-user-section-title' => 'Reader feedback: $1',
+ 'articlefeedbackv5-discuss-talk-section-content' => '$1 posted
[[$2|this comment]] on $3 ([[$5|view all feedback]]).
+$6
+Any thoughts?
+
+~~~~',
+ 'articlefeedbackv5-discuss-user-section-content' => '$1 posted
[[$2|this comment]] on $3 ([[$5|view all feedback]]):
+$6
+Thank you for your feedback!
+
+~~~~',
'articlefeedbackv5-form1-header-found' => '{{GENDER:$1|$2 found what
they were looking for.}}',
'articlefeedbackv5-form1-header-not-found' => '{{GENDER:$1|$2 did not
find what they were looking for.}}',
'articlefeedbackv5-form1-header-left-comment' => '{{GENDER:$1|$2 posted
a comment.}}',
@@ -904,6 +922,8 @@
'articlefeedbackv5-form-unoversight' => 'Link text for undoing
oversight (= deletion) of a feedback entry',
'articlefeedbackv5-form-decline' => 'Link text for declining oversight',
'articlefeedbackv5-form-declined' => 'Link text when oversight has
already been declined',
+ 'articlefeedbackv5-form-discuss-talk' => "Link text to discuss feedback
in a section on the article's talk page",
+ 'articlefeedbackv5-form-discuss-user' => "Link text to discuss feedback
in a section on the submitting user's talk page",
'articlefeedbackv5-form-tooltip-note' => 'Link title-attribute to add a
comment for the action you just flagged (in the toolbox)',
'articlefeedbackv5-form-tooltip-feature' => 'Link title-attribute for
marking the post as useful (in the toolbox)',
'articlefeedbackv5-form-tooltip-unfeature' => 'Link title-attribute for
un-marking the post as useful (in the toolbox)',
@@ -921,6 +941,26 @@
'articlefeedbackv5-form-tooltip-request' => 'Link title-attribute for
requesting oversight',
'articlefeedbackv5-form-tooltip-unrequest' => 'Link title-attribute for
unrequesting oversight',
'articlefeedbackv5-form-tooltip-decline' => 'Link title-attribute for
declining oversight',
+ 'articlefeedbackv5-form-tooltip-discuss-talk' => "Link title-attribute
for discussing feedback on the article's talk page",
+ 'articlefeedbackv5-form-tooltip-discuss-user' => 'Link title-attribute
for discussing feedback with the user who submitted it',
+ 'articlefeedbackv5-discuss-talk-section-title' => "When feedback is to
be discussed on the article's talk page, this is what the section title will
be. Parameters:
+* $1 is the feedback comment",
+ 'articlefeedbackv5-discuss-user-section-title' => "When feedback is to
be discussed on the user's talk page, this is what the section title will be.
Parameters:
+* $1 is the feedback comment",
+ 'articlefeedbackv5-discuss-talk-section-content' => "When feedback is
to be discussed on the article's talk page, this is the content template that
will be provided. Parameters:
+* $1 is the user that submitted the feedback (either the IP for anonymous
user, or in the format [[User:Name|]] for registered users)
+* $2 is the permalink to the feedback that'll be discussed
+* $3 is the date the feedback was submitted
+* $4 is the time the feedback was submitted
+* $5 is the link to all feedback on this article
+* $6 is the full feedback comment (will be empty in the event that feedback
text is short and fits in the section title)",
+ 'articlefeedbackv5-discuss-user-section-content' => "When feedback is
to be discussed on the user's talk page, this is the content template that will
be provided. Parameters:
+* $1 is the user that submitted the feedback (either the IP for anonymous
user, or in the format [[User:Name|]] for registered users)
+* $2 is the permalink to the feedback that'll be discussed
+* $3 is the date the feedback was submitted
+* $4 is the time the feedback was submitted
+* $5 is the link to all feedback on this article
+* $6 is the full feedback comment (will be empty in the event that feedback
text is short and fits in the section title)",
'articlefeedbackv5-form1-header-found' => '{{doc-singularthey}}
Parameters
* $1 is a username.
diff --git a/ArticleFeedbackv5.model.php b/ArticleFeedbackv5.model.php
index 3af1bcb..a7739c5 100644
--- a/ArticleFeedbackv5.model.php
+++ b/ArticleFeedbackv5.model.php
@@ -358,13 +358,11 @@
global $wgArticleFeedbackv5MaxCommentLength;
- $page = Title::newFromID( $this->aft_page );
- if ( $page === null ) {
+ if ( $this->getArticle() === false ) {
throw new MWException( "Invalid page id
'$this->aft_page'." );
}
- $revision = Revision::newFromId( $this->aft_page_revision );
- if ( $revision === null ) {
+ if ( $this->getRevision() === false ) {
throw new MWException( "Invalid revision id
'$this->aft_page_revision'." );
}
@@ -548,16 +546,37 @@
}
/**
+ * Get article object for this entry
+ *
+ * @return Article|bool Article object or false if invalid page
+ */
+ public function getArticle() {
+ $page = Article::newFromID( $this->aft_page );
+ return $page ?: false;
+ }
+
+ /**
+ * Get revision object for this entry
+ *
+ * @return Revision|bool Revision object or false if invalid revision
+ */
+ public function getRevision() {
+ $revision = Revision::newFromId( $this->aft_page_revision );
+ return $revision ?: false;
+ }
+
+ /**
* Get user object for this entry
*
- * @return User
+ * @return User|bool User object or false if invalid user
*/
public function getUser() {
if ( $this->aft_user ) {
- return User::newFromId( $this->aft_user );
+ $user = User::newFromId( $this->aft_user );
+ } else {
+ $user = User::newFromName( $this->aft_user_text );
}
-
- return User::newFromName( $this->aft_user_text );
+ return $user ?: false;
}
/**
diff --git a/ArticleFeedbackv5.render.php b/ArticleFeedbackv5.render.php
index 33107f4..3212bcb 100644
--- a/ArticleFeedbackv5.render.php
+++ b/ArticleFeedbackv5.render.php
@@ -859,6 +859,97 @@
}
}
+ // build discussion tools
+ $discussType = '';
+ $discussPage = false;
+ if ( $record->isFeatured() ) {
+ // discuss on talk page
+ $discussType = 'talk';
+ $article = $record->getArticle();
+ if ( $article ) {
+ $discussPage =
$article->getTitle()->getTalkPage();
+ }
+ } elseif ( $record->getUser() ) {
+ // contact user
+ $discussType = 'user';
+ $user = $record->getUser();
+ if ( $user ) {
+ $discussPage =
$user->getTalkPage();
+ }
+ }
+
+ if ( $discussPage ) {
+ global $wgLang, $wgUser;
+ $sectionTitle = wfMessage(
"articlefeedbackv5-discuss-$discussType-section-title", $record->aft_comment );
+ $sectionTitleTruncated =
$wgLang->truncate( $sectionTitle, 70 );
+
+ $sectionAnchor = '';
+ // check if feedback is being discussed
already
+ $article = Article::newFromId(
$discussPage->getArticleID() );
+ if ( $article ) {
+ $sections =
$article->getParserOutput()->getSections();
+ foreach ( $sections as $section
) {
+ if ( $section['line']
== $sectionTitleTruncated ) {
+ $sectionAnchor
= $section['anchor'];
+ break;
+ }
+ }
+ }
+ $sectionExists = ( $sectionAnchor !==
'' );
+
+ if ( $sectionExists ) {
+ $discussLink =
$discussPage->getLinkURL() . '#' . $sectionAnchor;
+ } else {
+ $discussLink =
$discussPage->getLinkURL( array( 'action' => 'edit', 'section' => 'new',
'preloadtitle' => $sectionTitleTruncated ) );
+ }
+
+ $title = Title::newFromId(
$record->aft_page )->getPrefixedDBkey();
+ $userText = $record->aft_user_text; //
anon users
+ if ( $record->getUser() ) {
+ $userText = '[[' .
$record->getUser()->getUserPage()->getPrefixedDBKey() . '|]]'; // link to user
page
+ }
+
+ $comment = '';
+ if ( $sectionTitle !=
$sectionTitleTruncated ) {
+ // if comment has been
truncated to fit section title, display it in full in content
+ $comment = Html::rawElement(
'blockquote', array(), $record->aft_comment );
+ }
+ $sectionContent = wfMessage(
"articlefeedbackv5-discuss-$discussType-section-content" )
+ ->params(
+ $userText,
+
SpecialPage::getTitleFor( 'ArticleFeedbackv5', "$title/$record->aft_id" ),
+ $wgLang->date(
$record->aft_timestamp ),
+ $wgLang->time(
$record->aft_timestamp ),
+
SpecialPage::getTitleFor( 'ArticleFeedbackv5', $title ),
+ $comment
+ )
+ ->text();
+
+ $action = 'discuss';
+ $tools .= Html::rawElement(
+ 'li',
+ array(),
+ Html::element(
+ 'a',
+ array(
+ 'id' =>
"articleFeedbackv5-$action-link-$record->aft_id",
+ 'class' =>
"articleFeedbackv5-$action-link articleFeedbackv5-$action-$discussType-link",
+ 'title' =>
wfMessage( "articlefeedbackv5-form-tooltip-$action-$discussType" )->text(),
+ 'href' =>
$discussLink,
+ 'data-action'
=> $action,
+ // expose some
additional details to JS
+ 'data-type' =>
$discussType,
+
'data-section-exists' => (int) $sectionExists,
+
'data-section-title' => $sectionTitleTruncated,
+
'data-section-content' => $sectionContent,
+
'data-section-edittime' => wfTimestampNow(),
+
'data-section-edittoken' => $wgUser->getEditToken()
+ ),
+ wfMessage(
"articlefeedbackv5-form-$action-$discussType" . ( $sectionExists ? '-exists' :
'' ) )->text()
+ )
+ );
+ }
+
$activityLink = '';
if (
// there is a comment - display it
diff --git
a/modules/jquery.articleFeedbackv5/jquery.articleFeedbackv5.special.js
b/modules/jquery.articleFeedbackv5/jquery.articleFeedbackv5.special.js
index 2d876f0..017db7b 100644
--- a/modules/jquery.articleFeedbackv5/jquery.articleFeedbackv5.special.js
+++ b/modules/jquery.articleFeedbackv5/jquery.articleFeedbackv5.special.js
@@ -1674,6 +1674,55 @@
$( e.target ).data( 'started', true );
}
}
+ },
+
+ // }}}
+ // {{{ Discuss feedback on article/user's talk page
+
+ 'discuss': {
+ 'click': function( e ) {
+ var exists = $( e.target ).data(
'section-exists' );
+
+ if ( !exists ) {
+ e.preventDefault();
+
+ /*
+ * The href set for an already existing
section will lead to the
+ * edit-form to create a new section
(with the title already
+ * filled out). However, there's no way
to already preload the
+ * content. Let's fake the submission
of the edit form with some
+ * preset content.
+ */
+
+ var link = $( e.target ).attr( 'href' )
+ '#editform';
+ var title = $( e.target ).data(
'section-title' );
+ var content = $( e.target ).data(
'section-content' );
+ var editTime = $( e.target ).data(
'section-edittime' );
+ var editToken = $( e.target ).data(
'section-edittoken' );
+
+ var $form = $( '\
+ <form method="post">\
+ <input type="text"
name="wpSummary" />\
+ <textarea
name="wpTextbox1" />\
+ <input type="hidden"
name="wpEdittime" />\
+ <input type="hidden"
name="wpEditToken" />\
+ <input type="hidden"
name="wpPreview" />\
+ <input type="submit" />\
+ </form>' );
+
+ $form.attr( 'action', link );
+ $( '[name=wpSummary]', $form ).val(
title );
+ $( '[name=wpTextbox1]', $form ).val(
content );
+ $( '[name=wpEdittime]', $form ).val(
editTime );
+ $( '[name=wpEditToken]', $form ).val(
editToken );
+ $( '[name=wpPreview]', $form ).val( 1 );
+
+ $( e.target ).append( $form );
+ $form
+ .hide()
+ .submit();
+ }
+ }
}
// }}}
--
To view, visit https://gerrit.wikimedia.org/r/51173
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ife2452d5343512c6093c6f68a498ef8d2ec22eb8
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/ArticleFeedbackv5
Gerrit-Branch: master
Gerrit-Owner: Matthias Mullie <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits