Cicalese has submitted this change and it was merged. (
https://gerrit.wikimedia.org/r/360379 )
Change subject: Added Special:AllComments
......................................................................
Added Special:AllComments
T167464
Change-Id: Ie10988e3420420a3aea548760d548ff272071969
---
M extension.json
M i18n/en.json
M i18n/qqq.json
A includes/CommentStreamsAllComments.alias.php
A includes/CommentStreamsAllComments.php
A resources/CommentStreamsAllComments.css
6 files changed, 273 insertions(+), 4 deletions(-)
Approvals:
Cicalese: Looks good to me, approved
jenkins-bot: Verified
diff --git a/extension.json b/extension.json
index 3f81f06..0c9c0e0 100644
--- a/extension.json
+++ b/extension.json
@@ -1,6 +1,6 @@
{
"name": "CommentStreams",
- "version": "3.6",
+ "version": "3.7",
"author": [
"[http://www.mediawiki.org/wiki/User:Jji Jason Ji]",
"[http://www.mediawiki.org/wiki/User:Cindy.cicalese Cindy
Cicalese]"
@@ -9,10 +9,16 @@
"descriptionmsg": "commentstreams-desc",
"manifest_version": 1,
"type": "parserhook",
+ "SpecialPages": {
+ "CommentStreamsAllComments": "CommentStreamsAllComments"
+ },
"MessagesDirs": {
"CommentStreams": [
"i18n"
]
+ },
+ "ExtensionMessagesFiles": {
+ "CommentStreamsAlias":
"includes/CommentStreamsAllComments.alias.php"
},
"ResourceModules": {
"ext.CommentStreams": {
@@ -75,6 +81,17 @@
]
}
},
+ "ResourceModules": {
+ "ext.CommentStreamsAllComments": {
+ "styles": [
+ "CommentStreamsAllComments.css"
+ ],
+ "targets": [
+ "desktop",
+ "mobile"
+ ]
+ }
+ },
"ResourceFileModulePaths": {
"localBasePath": "resources",
"remoteExtPath": "CommentStreams/resources"
@@ -92,7 +109,8 @@
"EchoCSFormatter": "includes/EchoCSFormatter.php",
"EchoCSReplyPresentationModel":
"includes/EchoCSReplyPresentationModel.php",
"EchoCSWatchedPresentationModel":
- "includes/EchoCSWatchedPresentationModel.php"
+ "includes/EchoCSWatchedPresentationModel.php",
+ "CommentStreamsAllComments":
"includes/CommentStreamsAllComments.php"
},
"APIModules": {
"csPostComment": "ApiCSPostComment",
diff --git a/i18n/en.json b/i18n/en.json
index 7372da8..98070bb 100644
--- a/i18n/en.json
+++ b/i18n/en.json
@@ -106,5 +106,16 @@
"logentry-commentstreams-comment-delete": "$1 {{GENDER:$2|deleted}}
comment $3",
"logentry-commentstreams-comment-moderator-delete": "$1
{{GENDER:$2|(moderator) deleted}} comment $3",
"logentry-commentstreams-reply-delete": "$1 {{GENDER:$2|deleted}} reply
$3",
- "logentry-commentstreams-reply-moderator-delete": "$1
{{GENDER:$2|(moderator) deleted}} reply $3"
+ "logentry-commentstreams-reply-moderator-delete": "$1
{{GENDER:$2|(moderator) deleted}} reply $3",
+ "commentstreamsallcomments": "All Comments",
+ "commentstreams-allcomments-label-page": "Comment Page",
+ "commentstreams-allcomments-label-associatedpage": "Associated Page",
+ "commentstreams-allcomments-label-commenttitle": "Comment Title",
+ "commentstreams-allcomments-label-wikitext": "Comment",
+ "commentstreams-allcomments-label-author": "Author",
+ "commentstreams-allcomments-label-created": "Created",
+ "commentstreams-allcomments-label-lasteditor": "Last Editor",
+ "commentstreams-allcomments-label-lastedited": "Last Edited",
+ "commentstreams-allcomments-button-next": "Next",
+ "commentstreams-allcomments-button-previous": "Previous"
}
diff --git a/i18n/qqq.json b/i18n/qqq.json
index b10351b..7f95426 100644
--- a/i18n/qqq.json
+++ b/i18n/qqq.json
@@ -106,5 +106,16 @@
"logentry-commentstreams-comment-delete": "The template of the log
entry message",
"logentry-commentstreams-comment-moderator-delete": "The template of
the log entry message",
"logentry-commentstreams-reply-delete": "The template of the log entry
message",
- "logentry-commentstreams-reply-moderator-delete": "The template of the
log entry message"
+ "logentry-commentstreams-reply-moderator-delete": "The template of the
log entry message",
+ "commentstreamsallcomments": "Special page title",
+ "commentstreams-allcomments-label-page": "Table column label",
+ "commentstreams-allcomments-label-associatedpage": "Table column label",
+ "commentstreams-allcomments-label-commenttitle": "Table column label",
+ "commentstreams-allcomments-label-wikitext": "Table column label",
+ "commentstreams-allcomments-label-author": "Table column label",
+ "commentstreams-allcomments-label-created": "Table column label",
+ "commentstreams-allcomments-label-lasteditor": "Table column label",
+ "commentstreams-allcomments-label-lastedited": "Table column label",
+ "commentstreams-allcomments-button-next": "Button label",
+ "commentstreams-allcomments-button-previous": "Button label"
}
diff --git a/includes/CommentStreamsAllComments.alias.php
b/includes/CommentStreamsAllComments.alias.php
new file mode 100644
index 0000000..76c5d1f
--- /dev/null
+++ b/includes/CommentStreamsAllComments.alias.php
@@ -0,0 +1,30 @@
+<?php
+
+/*
+ * Copyright (c) 2017 The MITRE Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+
+$specialPageAliases = [];
+
+/** English */
+$specialPageAliases['en'] = [
+ 'CommentStreamsAllComments' => [ 'AllComments' ]
+];
diff --git a/includes/CommentStreamsAllComments.php
b/includes/CommentStreamsAllComments.php
new file mode 100644
index 0000000..a1cfa52
--- /dev/null
+++ b/includes/CommentStreamsAllComments.php
@@ -0,0 +1,173 @@
+<?php
+
+/*
+ * Copyright (c) 2017 The MITRE Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+
+class CommentStreamsAllComments extends SpecialPage {
+
+ function __construct() {
+ parent::__construct( 'CommentStreamsAllComments' );
+ }
+
+ function execute( $par ) {
+ $request = $this->getRequest();
+ $this->setHeaders();
+ $this->getOutput()->addModuleStyles(
'ext.CommentStreamsAllComments' );
+
+ $offset = $request->getText( 'offset', 0 );
+ $limit = 20;
+ $pages = self::getCommentPages( $limit + 1, $offset );
+
+ if ( !$pages->valid() ) {
+ $offset = 0;
+ $pages = self::getCommentPages( $limit + 1, $offset );
+ if ( !$pages->valid() ) {
+ $this->displayMessage(
+ wfMessage(
'commentstreams-allcomments-nocommentsfound' )
+ );
+ return;
+ }
+ }
+
+ $wikitext = '{| class="wikitable csall-wikitable"' . PHP_EOL;
+ $wikitext .=
+ '!' . wfMessage(
'commentstreams-allcomments-label-page' ) . PHP_EOL;
+ $wikitext .=
+ '!' . wfMessage(
'commentstreams-allcomments-label-associatedpage' ) . PHP_EOL;
+ $wikitext .=
+ '!' . wfMessage(
'commentstreams-allcomments-label-commenttitle' ) . PHP_EOL;
+ $wikitext .=
+ '!' . wfMessage(
'commentstreams-allcomments-label-wikitext' ) . PHP_EOL;
+ $wikitext .=
+ '!' . wfMessage(
'commentstreams-allcomments-label-author' ) . PHP_EOL;
+ $wikitext .=
+ '!' . wfMessage(
'commentstreams-allcomments-label-lasteditor' ) . PHP_EOL;
+ $wikitext .=
+ '!' . wfMessage(
'commentstreams-allcomments-label-created' ) . PHP_EOL;
+ $wikitext .=
+ '!' . wfMessage(
'commentstreams-allcomments-label-lastedited' ) . PHP_EOL;
+
+ $index = 0;
+ $more = false;
+ foreach ( $pages as $page ) {
+ if ( $index < $limit ) {
+ $wikipage = WikiPage::newFromId( $page->page_id
);
+ $comment = Comment::newFromWikiPage( $wikipage
);
+ $pagename =
$comment->getWikiPage()->getTitle()->getPrefixedText() ;
+ $associatedpageid = $comment->getAssociatedId();
+ $associatedpagename =
+ WikiPage::newFromId( $associatedpageid
)->getTitle()->getPrefixedText();
+ $lasteditor = User::newFromId(
$wikipage->getRevision()->getUser() )->getName();
+ $wikitext .= '|-' . PHP_EOL;
+ $wikitext .= '|[[' . $pagename . ']]' . PHP_EOL;
+ $wikitext .= '|[[' . $associatedpagename . ']]'
. PHP_EOL;
+ $wikitext .= '|' . $comment->getCommentTitle()
. PHP_EOL;
+ $wikitext .= '|' . $comment->getWikiText() .
PHP_EOL;
+ $wikitext .= '|' .
$comment->getUser()->getName() . PHP_EOL;
+ $wikitext .= '|' . $lasteditor . PHP_EOL;
+ $wikitext .= '|' . $comment->getCreationDate()
. PHP_EOL;
+ $wikitext .= '|' .
$comment->getModificationDate() . PHP_EOL;
+ $index ++;
+ } else {
+ $more = true;
+ }
+ }
+
+ $wikitext .= '|}' . PHP_EOL;
+ $this->getOutput()->addWikiText( $wikitext );
+
+ if ( $offset > 0 || $more ) {
+ $this->addTableNavigation( $offset, $more, $limit,
'offset' );
+ }
+ }
+
+ private function displayMessage( $message ) {
+ $html = Html::openElement( 'p', [
+ 'class' => 'csall-message'
+ ] )
+ . $message
+ . Html::closeElement( 'p' );
+ $this->getOutput()->addHtml( $html );
+ }
+
+ private function addTableNavigation( $offset, $more, $limit, $paramname
) {
+
+ $title = Title::newFromText( 'Special:' . __CLASS__ );
+ $url = $title->getFullURL();
+
+ $html = Html::openElement( 'table', [
+ 'class' => 'csall-navigationtable'
+ ] )
+ . Html::openElement( 'tr' )
+ . Html::openElement( 'td' );
+
+ if ( $offset > 0 ) {
+ $prevurl = $url . '?' . $paramname . '=' . ( $offset -
$limit );
+ $html .= Html::openElement( 'a', [
+ 'href' => $prevurl,
+ 'class' => 'csall-button'
+ ] )
+ . wfMessage(
'commentstreams-allcomments-button-previous' )
+ . Html::closeElement( 'a' );
+ }
+
+ $html .= Html::closeElement( 'td' )
+ . Html::openElement( 'td', [
+ 'style' => 'text-align:right;'
+ ] );
+
+ if ( $more ) {
+ $nexturl = $url . '?' . $paramname . '=' . ( $offset +
$limit );
+ $html .= Html::openElement( 'a', [
+ 'href' => $nexturl,
+ 'class' => 'csall-button'
+ ] )
+ . wfMessage(
'commentstreams-allcomments-button-next' )
+ . Html::closeElement( 'a' );
+ }
+
+ $html .= Html::closeElement( 'td' )
+ . Html::closeElement( 'tr' )
+ . Html::closeElement( 'table' );
+ $this->getOutput()->addHtml( $html );
+ }
+
+ private static function getCommentPages( $limit, $offset ) {
+ $dbr = wfGetDB( DB_SLAVE );
+ $pages = $dbr->select(
+ 'page',
+ [
+ 'page_id'
+ ],
+ [
+ 'page_namespace' =>
$GLOBALS['wgCommentStreamsNamespaceIndex']
+ ],
+ __METHOD__,
+ [
+ 'ORDER BY' => 'page_latest DESC' ,
+ 'LIMIT' => $limit,
+ 'OFFSET' => $offset
+ ]
+ );
+ return $pages;
+ }
+}
diff --git a/resources/CommentStreamsAllComments.css
b/resources/CommentStreamsAllComments.css
new file mode 100644
index 0000000..d1c905e
--- /dev/null
+++ b/resources/CommentStreamsAllComments.css
@@ -0,0 +1,26 @@
+.csall-message {
+ background-color: #ddd;
+ padding-top: 5px;
+ padding-bottom: 5px;
+ padding-left: 10px;
+ padding-right: 10px;
+}
+
+.csall-wikitable {
+ width: 100%;
+}
+
+.csall-navigationtable {
+ width: 100%;
+}
+
+.csall-button {
+ font-size: 1em;
+ padding:5px 15px;
+ margin:5px 5px;
+ background:#ccc;
+ border:0 none;
+ cursor:pointer;
+ -webkit-border-radius: 5px;
+ border-radius: 5px;
+}
--
To view, visit https://gerrit.wikimedia.org/r/360379
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Ie10988e3420420a3aea548760d548ff272071969
Gerrit-PatchSet: 4
Gerrit-Project: mediawiki/extensions/CommentStreams
Gerrit-Branch: master
Gerrit-Owner: Cicalese <[email protected]>
Gerrit-Reviewer: Cicalese <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits