summaryrefslogtreecommitdiff
path: root/includes/specials/SpecialEditWatchlist.php
diff options
context:
space:
mode:
authorPierre Schmitz <pierre@archlinux.de>2013-01-18 16:46:04 +0100
committerPierre Schmitz <pierre@archlinux.de>2013-01-18 16:46:04 +0100
commit63601400e476c6cf43d985f3e7b9864681695ed4 (patch)
treef7846203a952e38aaf66989d0a4702779f549962 /includes/specials/SpecialEditWatchlist.php
parent8ff01378c9e0207f9169b81966a51def645b6a51 (diff)
Update to MediaWiki 1.20.2
this update includes: * adjusted Arch Linux skin * updated FluxBBAuthPlugin * patch for https://bugzilla.wikimedia.org/show_bug.cgi?id=44024
Diffstat (limited to 'includes/specials/SpecialEditWatchlist.php')
-rw-r--r--includes/specials/SpecialEditWatchlist.php84
1 files changed, 64 insertions, 20 deletions
diff --git a/includes/specials/SpecialEditWatchlist.php b/includes/specials/SpecialEditWatchlist.php
index 9c9689ae..23cd9aa6 100644
--- a/includes/specials/SpecialEditWatchlist.php
+++ b/includes/specials/SpecialEditWatchlist.php
@@ -1,9 +1,36 @@
<?php
+/**
+ * @defgroup Watchlist Users watchlist handling
+ */
+
+/**
+ * Implements Special:EditWatchlist
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * http://www.gnu.org/copyleft/gpl.html
+ *
+ * @file
+ * @ingroup SpecialPage
+ * @ingroup Watchlist
+ */
/**
* Provides the UI through which users can perform editing
* operations on their watchlist
*
+ * @ingroup SpecialPage
* @ingroup Watchlist
* @author Rob Church <robchur@gmail.com>
*/
@@ -76,7 +103,7 @@ class SpecialEditWatchlist extends UnlistedSpecialPage {
$form = $this->getRawForm();
if( $form->show() ){
$out->addHTML( $this->successMessage );
- $out->returnToMain();
+ $out->addReturnTo( SpecialPage::getTitleFor( 'Watchlist' ) );
}
break;
@@ -86,7 +113,7 @@ class SpecialEditWatchlist extends UnlistedSpecialPage {
$form = $this->getNormalForm();
if( $form->show() ){
$out->addHTML( $this->successMessage );
- $out->returnToMain();
+ $out->addReturnTo( SpecialPage::getTitleFor( 'Watchlist' ) );
} elseif ( $this->toc !== false ) {
$out->prependHTML( $this->toc );
}
@@ -102,21 +129,28 @@ class SpecialEditWatchlist extends UnlistedSpecialPage {
* @return array
*/
private function extractTitles( $list ) {
- $titles = array();
$list = explode( "\n", trim( $list ) );
if( !is_array( $list ) ) {
return array();
}
+ $titles = array();
foreach( $list as $text ) {
$text = trim( $text );
if( strlen( $text ) > 0 ) {
$title = Title::newFromText( $text );
if( $title instanceof Title && $title->isWatchable() ) {
- $titles[] = $title->getPrefixedText();
+ $titles[] = $title;
}
}
}
- return array_unique( $titles );
+
+ GenderCache::singleton()->doTitlesArray( $titles );
+
+ $list = array();
+ foreach( $titles as $title ) {
+ $list[] = $title->getPrefixedText();
+ }
+ return array_unique( $list );
}
public function submitRaw( $data ){
@@ -214,22 +248,30 @@ class SpecialEditWatchlist extends UnlistedSpecialPage {
$dbr = wfGetDB( DB_MASTER );
$res = $dbr->select(
'watchlist',
- '*',
array(
+ 'wl_namespace', 'wl_title'
+ ), array(
'wl_user' => $this->getUser()->getId(),
),
__METHOD__
);
if( $res->numRows() > 0 ) {
+ $titles = array();
foreach ( $res as $row ) {
$title = Title::makeTitleSafe( $row->wl_namespace, $row->wl_title );
if ( $this->checkTitle( $title, $row->wl_namespace, $row->wl_title )
&& !$title->isTalkPage()
) {
- $list[] = $title->getPrefixedText();
+ $titles[] = $title;
}
}
$res->free();
+
+ GenderCache::singleton()->doTitlesArray( $titles );
+
+ foreach( $titles as $title ) {
+ $list[] = $title->getPrefixedText();
+ }
}
$this->cleanupWatchlist();
return $list;
@@ -250,7 +292,7 @@ class SpecialEditWatchlist extends UnlistedSpecialPage {
array( 'wl_namespace', 'wl_title' ),
array( 'wl_user' => $this->getUser()->getId() ),
__METHOD__,
- array( 'ORDER BY' => 'wl_namespace, wl_title' )
+ array( 'ORDER BY' => array( 'wl_namespace', 'wl_title' ) )
);
$lb = new LinkBatch();
@@ -270,7 +312,7 @@ class SpecialEditWatchlist extends UnlistedSpecialPage {
*
* @param Title $title
* @param int $namespace
- * @param String $dbKey
+ * @param String $dbKey
* @return bool: Whether this item is valid
*/
private function checkTitle( $title, $namespace, $dbKey ) {
@@ -294,18 +336,20 @@ class SpecialEditWatchlist extends UnlistedSpecialPage {
* Attempts to clean up broken items
*/
private function cleanupWatchlist() {
- if ( count( $this->badItems ) ) {
- $dbw = wfGetDB( DB_MASTER );
+ if( !count( $this->badItems ) ) {
+ return; //nothing to do
}
+ $dbw = wfGetDB( DB_MASTER );
+ $user = $this->getUser();
foreach ( $this->badItems as $row ) {
list( $title, $namespace, $dbKey ) = $row;
- wfDebug( "User {$this->getUser()} has broken watchlist item ns($namespace):$dbKey, "
+ wfDebug( "User {$user->getName()} has broken watchlist item ns($namespace):$dbKey, "
. ( $title ? 'cleaning up' : 'deleting' ) . ".\n"
);
$dbw->delete( 'watchlist',
array(
- 'wl_user' => $this->getUser()->getId(),
+ 'wl_user' => $user->getId(),
'wl_namespace' => $namespace,
'wl_title' => $dbKey,
),
@@ -314,7 +358,7 @@ class SpecialEditWatchlist extends UnlistedSpecialPage {
// Can't just do an UPDATE instead of DELETE/INSERT due to unique index
if ( $title ) {
- $this->getUser()->addWatch( $title );
+ $user->addWatch( $title );
}
}
}
@@ -408,7 +452,7 @@ class SpecialEditWatchlist extends UnlistedSpecialPage {
foreach( $data as $titles ) {
$this->unwatchTitles( $titles );
- $removed += $titles;
+ $removed = array_merge( $removed, $titles );
}
if( count( $removed ) > 0 ) {
@@ -445,7 +489,7 @@ class SpecialEditWatchlist extends UnlistedSpecialPage {
$title = Title::makeTitleSafe( $namespace, $dbkey );
if ( $this->checkTitle( $title, $namespace, $dbkey ) ) {
$text = $this->buildRemoveLine( $title );
- $fields['TitlesNs'.$namespace]['options'][$text] = $title->getEscapedText();
+ $fields['TitlesNs'.$namespace]['options'][$text] = htmlspecialchars( $title->getPrefixedText() );
$count++;
}
}
@@ -455,7 +499,7 @@ class SpecialEditWatchlist extends UnlistedSpecialPage {
if ( count( $fields ) > 1 && $count > 30 ) {
$this->toc = Linker::tocIndent();
$tocLength = 0;
- foreach( $fields as $key => $data ) {
+ foreach( $fields as $data ) {
# strip out the 'ns' prefix from the section name:
$ns = substr( $data['section'], 2 );
@@ -572,7 +616,7 @@ class SpecialEditWatchlist extends UnlistedSpecialPage {
* Build a set of links for convenient navigation
* between watchlist viewing and editing modes
*
- * @param $unused Unused
+ * @param $unused
* @return string
*/
public static function buildTools( $unused ) {
@@ -588,12 +632,12 @@ class SpecialEditWatchlist extends UnlistedSpecialPage {
// can use messages 'watchlisttools-view', 'watchlisttools-edit', 'watchlisttools-raw'
$tools[] = Linker::linkKnown(
SpecialPage::getTitleFor( $arr[0], $arr[1] ),
- wfMsgHtml( "watchlisttools-{$mode}" )
+ wfMessage( "watchlisttools-{$mode}" )->escaped()
);
}
return Html::rawElement( 'span',
array( 'class' => 'mw-watchlist-toollinks' ),
- wfMsg( 'parentheses', $wgLang->pipeList( $tools ) ) );
+ wfMessage( 'parentheses', $wgLang->pipeList( $tools ) )->text() );
}
}