summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'Echo/includes/special')
-rw-r--r--Echo/includes/special/NotificationPager.php19
-rw-r--r--Echo/includes/special/SpecialDisplayNotificationsConfiguration.php40
-rw-r--r--Echo/includes/special/SpecialNotifications.php13
-rw-r--r--Echo/includes/special/SpecialNotificationsMarkRead.php6
4 files changed, 34 insertions, 44 deletions
diff --git a/Echo/includes/special/NotificationPager.php b/Echo/includes/special/NotificationPager.php
index 9aa85cd8..2dfc1238 100644
--- a/Echo/includes/special/NotificationPager.php
+++ b/Echo/includes/special/NotificationPager.php
@@ -6,25 +6,28 @@
* It paginates on notification_event for a specific user, only for the enabled event types.
*/
class NotificationPager extends ReverseChronologicalPager {
- public function __construct() {
+ /**
+ * @param IContextSource $context
+ */
+ public function __construct( IContextSource $context ) {
$dbFactory = MWEchoDbFactory::newFromDefault();
$this->mDb = $dbFactory->getEchoDb( DB_REPLICA );
- parent::__construct();
+ parent::__construct( $context );
}
- function formatRow( $row ) {
- $msg = "This pager does not support row formatting. Use 'getNotifications()' to get a list of EchoNotification objects.";
- throw new Exception( $msg );
+ public function formatRow( $row ) {
+ throw new Exception( "This pager does not support row formatting. " .
+ "Use 'getNotifications()' to get a list of EchoNotification objects." );
}
- function getQueryInfo() {
+ public function getQueryInfo() {
$attributeManager = EchoAttributeManager::newFromGlobalVars();
$eventTypes = $attributeManager->getUserEnabledEvents( $this->getUser(), 'web' );
return [
'tables' => [ 'echo_notification', 'echo_event' ],
- 'fields' => '*',
+ 'fields' => EchoNotification::selectFields(),
'conds' => [
'notification_user' => $this->getUser()->getId(),
'event_type' => $eventTypes,
@@ -63,7 +66,7 @@ class NotificationPager extends ReverseChronologicalPager {
return $notifications;
}
- function getIndexField() {
+ public function getIndexField() {
return 'notification_event';
}
}
diff --git a/Echo/includes/special/SpecialDisplayNotificationsConfiguration.php b/Echo/includes/special/SpecialDisplayNotificationsConfiguration.php
index f5d71e24..c644c043 100644
--- a/Echo/includes/special/SpecialDisplayNotificationsConfiguration.php
+++ b/Echo/includes/special/SpecialDisplayNotificationsConfiguration.php
@@ -84,7 +84,8 @@ class SpecialDisplayNotificationsConfiguration extends UnlistedSpecialPage {
)
)->parse();
- $this->categoryNames[$internalCategoryName] = $formattedFriendlyCategoryName . ' ' . $formattedInternalCategoryName;
+ $this->categoryNames[$internalCategoryName] = $formattedFriendlyCategoryName . ' '
+ . $formattedInternalCategoryName;
}
$this->flippedCategoryNames = array_flip( $this->categoryNames );
@@ -128,7 +129,13 @@ class SpecialDisplayNotificationsConfiguration extends UnlistedSpecialPage {
* @param array $columnLabelMapping Associative array mapping label to tag
* @param array $value Array consisting of strings in the format '$columnTag-$rowTag'
*/
- protected function outputCheckMatrix( $id, $legendMsgKey, array $rowLabelMapping, array $columnLabelMapping, array $value ) {
+ protected function outputCheckMatrix(
+ $id,
+ $legendMsgKey,
+ array $rowLabelMapping,
+ array $columnLabelMapping,
+ array $value
+ ) {
$form = new HTMLForm(
[
$id => [
@@ -174,7 +181,8 @@ class SpecialDisplayNotificationsConfiguration extends UnlistedSpecialPage {
Html::rawElement(
'li',
[],
- $this->categoryNames[$categoryName] . $this->msg( 'colon-separator' )->escaped() . ' ' . $implodedTypes
+ $this->categoryNames[$categoryName] . $this->msg( 'colon-separator' )->escaped() . ' '
+ . $implodedTypes
)
);
}
@@ -199,7 +207,8 @@ class SpecialDisplayNotificationsConfiguration extends UnlistedSpecialPage {
$types = $this->attributeManager->getEventsForSection( $section );
// echo-notification-alert-text-only, echo-notification-notice-text-only
$msgSection = $section == 'message' ? 'notice' : $section;
- $flippedSectionNames[$this->msg( 'echo-notification-' . $msgSection . '-text-only' )->escaped()] = $section;
+ $flippedSectionNames[$this->msg( 'echo-notification-' . $msgSection . '-text-only' )->escaped()]
+ = $section;
foreach ( $types as $type ) {
$bySectionValue[] = "$section-$type";
}
@@ -218,8 +227,6 @@ class SpecialDisplayNotificationsConfiguration extends UnlistedSpecialPage {
* Output which notify types are available for each category
*/
protected function outputAvailability() {
- global $wgEchoNotifications;
-
$this->getOutput()->addHTML( Html::element(
'h2',
[ 'id' => 'mw-echo-displaynotificationsconfiguration-available-notification-methods' ],
@@ -243,27 +250,6 @@ class SpecialDisplayNotificationsConfiguration extends UnlistedSpecialPage {
$this->flippedNotifyTypes,
$byCategoryValue
);
-
- $byTypeValue = [];
-
- $specialNotificationTypes = array_keys( array_filter( $wgEchoNotifications, function ( $val ) {
- return isset( $val['notify-type-availability'] );
- } ) );
- foreach ( $specialNotificationTypes as $notificationType ) {
- $allowedNotifyTypes = $this->notificationController->getEventNotifyTypes( $notificationType );
- foreach ( $allowedNotifyTypes as $notifyType ) {
- $byTypeValue[] = "$notifyType-$notificationType";
- }
- }
-
- // No user-friendly label for rows yet
- $this->outputCheckMatrix(
- 'availability-by-type',
- 'echo-displaynotificationsconfiguration-available-notification-methods-by-type-legend',
- array_combine( $specialNotificationTypes, $specialNotificationTypes ),
- $this->flippedNotifyTypes,
- $byTypeValue
- );
}
/**
diff --git a/Echo/includes/special/SpecialNotifications.php b/Echo/includes/special/SpecialNotifications.php
index aae26e4b..3c775628 100644
--- a/Echo/includes/special/SpecialNotifications.php
+++ b/Echo/includes/special/SpecialNotifications.php
@@ -12,8 +12,7 @@ class SpecialNotifications extends SpecialPage {
}
/**
- * @param string $par
- * @suppress SecurityCheck-DoubleEscaped Different members of $notifArray being conflated
+ * @param string|null $par
*/
public function execute( $par ) {
$this->setHeaders();
@@ -24,7 +23,6 @@ class SpecialNotifications extends SpecialPage {
$this->addHelpLink( 'Help:Notifications/Special:Notifications' );
$out->addJsConfigVars( 'wgNotificationsSpecialPageLinks', [
- 'help' => '//www.mediawiki.org/wiki/Special:MyLanguage/Help:Notifications/Special:Notifications',
'preferences' => SpecialPage::getTitleFor( 'Preferences' )->getLinkURL() . '#mw-prefsection-echo',
] );
@@ -41,7 +39,7 @@ class SpecialNotifications extends SpecialPage {
$pager = new NotificationPager( $this->getContext() );
$pager->setOffset( $this->getRequest()->getVal( 'offset' ) );
- $pager->setLimit( $this->getRequest()->getVal( 'limit', self::DISPLAY_NUM ) );
+ $pager->setLimit( $this->getRequest()->getInt( 'limit', self::DISPLAY_NUM ) );
$notifications = $pager->getNotifications();
$noJSDiv = new OOUI\Tag();
@@ -124,6 +122,7 @@ class SpecialNotifications extends SpecialPage {
// Ensure there are some unread notifications
if ( $anyUnread ) {
$markReadSpecialPage = new SpecialNotificationsMarkRead();
+ $markReadSpecialPage->setContext( $this->getContext() );
$markAllAsReadText = $this->msg( 'echo-mark-all-as-read' )->text();
$markAllAsReadLabelIcon = new EchoOOUI\LabelIconWidget( [
@@ -151,8 +150,8 @@ class SpecialNotifications extends SpecialPage {
$notices->addClasses( [ 'mw-echo-special-notifications' ] );
$markReadSpecialPage = new SpecialNotificationsMarkRead();
+ $markReadSpecialPage->setContext( $this->getContext() );
foreach ( $notifArray as $section => $data ) {
- // Heading
$heading = ( new OOUI\Tag( 'li' ) )->addClasses( [ 'mw-echo-date-section' ] );
$dateTitle = new OOUI\LabelWidget( [
@@ -232,8 +231,8 @@ class SpecialNotifications extends SpecialPage {
$out->addModuleStyles( [
'ext.echo.styles.notifications',
'ext.echo.styles.special',
- // We already load badgeicons in the BeforePageDisplay hook, but not for minerva
- 'ext.echo.badgeicons'
+ // We already load OOUI icons in the BeforePageDisplay hook, but not for minerva
+ 'oojs-ui.styles.icons-alerts'
] );
// Log visit
diff --git a/Echo/includes/special/SpecialNotificationsMarkRead.php b/Echo/includes/special/SpecialNotificationsMarkRead.php
index 1fb873a8..bac4d8a8 100644
--- a/Echo/includes/special/SpecialNotificationsMarkRead.php
+++ b/Echo/includes/special/SpecialNotificationsMarkRead.php
@@ -103,7 +103,9 @@ class SpecialNotificationsMarkRead extends FormSpecialPage {
// manually.
$form->suppressDefaultSubmit();
- $form->setAction( $this->getPageTitle()->getLocalURL() );
+ $pageTitle = $this->getPageTitle();
+ $form->setTitle( $pageTitle );
+ $form->setAction( $pageTitle->getLocalURL() );
$form->addButton( [
'name' => 'submit',
@@ -146,6 +148,6 @@ class SpecialNotificationsMarkRead extends FormSpecialPage {
public function onSuccess() {
$page = SpecialPage::getTitleFor( 'Notifications' );
- $this->getOutput()->redirect( $page->getFullUrl() );
+ $this->getOutput()->redirect( $page->getFullURL() );
}
}