1 | <?php |
||
17 | class EchoNotificationsManager { |
||
18 | |||
19 | /** |
||
20 | * @see Echo::BeforeCreateEchoEvent |
||
21 | * |
||
22 | * @since 1.0 |
||
23 | * |
||
24 | * @param array &$notifications |
||
25 | * @param array &$notificationCategories |
||
26 | * @param array &$icons |
||
27 | */ |
||
28 | 2 | public function addNotificationsDefinitions( array &$notifications, array &$notificationCategories, array &$icons ) { |
|
29 | |||
30 | 1 | $valueChangeNotificationType = ChangeNotificationFilter::VALUE_CHANGE; |
|
31 | 1 | $specificationChangeNotificationType = ChangeNotificationFilter::SPECIFICATION_CHANGE; |
|
32 | |||
33 | 1 | $notificationCategories[$valueChangeNotificationType] = array( |
|
34 | 1 | 'priority' => 5, |
|
35 | 1 | 'tooltip' => 'echo-pref-tooltip-smw-value-change', |
|
36 | ); |
||
37 | |||
38 | 1 | $notificationCategories[$specificationChangeNotificationType] = array( |
|
39 | 1 | 'priority' => 5, |
|
40 | 1 | 'tooltip' => 'echo-pref-tooltip-smw-specification-change', |
|
41 | ); |
||
42 | |||
43 | 1 | $notifications[$valueChangeNotificationType] = array( |
|
44 | 1 | EchoAttributeManager::ATTR_LOCATORS => [ |
|
45 | '\SMW\Notifications\ChangeNotification\UserLocator::doLocateEventSubscribers' |
||
46 | 1 | ], |
|
47 | 1 | 'category' => 'smw-value-change', |
|
48 | 1 | 'group' => 'neutral', |
|
49 | 1 | 'section' => 'alert', |
|
50 | 1 | 'presentation-model' => ChangeNotificationPresentationModel::class, |
|
51 | 1 | 'formatter-class' => ChangeNotificationFormatter::class, |
|
52 | 1 | 'title-message' => "notification-{$valueChangeNotificationType}", |
|
53 | 'title-params' => array( |
||
54 | 1 | 'agent', 'difflink', 'title' |
|
55 | 1 | ), |
|
56 | 1 | 'flyout-message' => "notification-{$valueChangeNotificationType}-flyout", |
|
57 | 'flyout-params' => array( |
||
58 | 1 | 'agent', 'difflink', 'title' |
|
59 | 1 | ), |
|
60 | 1 | 'payload' => array( 'extra' ), |
|
61 | 'bundle' => array( |
||
62 | 1 | 'web' => true, |
|
63 | 'email' => false |
||
64 | 1 | ), |
|
65 | 1 | 'email-subject-message' => "notification-{$valueChangeNotificationType}-email-subject", |
|
66 | 'email-subject-params' => array( |
||
67 | 1 | 'user', |
|
68 | 1 | 'agent', |
|
69 | 'page-count' |
||
70 | 1 | ), |
|
71 | 1 | 'email-body-batch-message' => "notification-{$valueChangeNotificationType}-email-batch-body", |
|
72 | 'email-body-batch-params' => array( |
||
73 | 1 | 'title', |
|
74 | 1 | 'agent', |
|
75 | 'item' |
||
76 | 1 | ), |
|
77 | 1 | 'icon' => $valueChangeNotificationType, |
|
78 | ); |
||
79 | |||
80 | 1 | $notifications[$specificationChangeNotificationType] = array( |
|
81 | 1 | EchoAttributeManager::ATTR_LOCATORS => [ |
|
82 | '\SMW\Notifications\ChangeNotification\UserLocator::doLocateEventSubscribers' |
||
83 | 1 | ], |
|
84 | 1 | 'category' => 'smw-specification-change', |
|
85 | 1 | 'group' => 'neutral', |
|
86 | 1 | 'section' => 'alert', |
|
87 | 1 | 'presentation-model' => ChangeNotificationPresentationModel::class, |
|
88 | 1 | 'formatter-class' => ChangeNotificationFormatter::class, |
|
89 | 1 | 'title-message' => "notification-{$valueChangeNotificationType}", |
|
90 | 'title-params' => array( |
||
91 | 2 | 'agent', 'difflink', 'title' |
|
92 | 1 | ), |
|
93 | 1 | 'flyout-message' => "notification-{$valueChangeNotificationType}-flyout", |
|
94 | 'flyout-params' => array( |
||
95 | 1 | 'agent', 'difflink', 'title' |
|
96 | 1 | ), |
|
97 | 1 | 'payload' => array( 'extra' ), |
|
98 | 'bundle' => array( |
||
99 | 1 | 'web' => true, |
|
100 | 'email' => false |
||
101 | 1 | ), |
|
102 | 1 | 'email-subject-message' => "notification-{$valueChangeNotificationType}-email-subject", |
|
103 | 'email-subject-params' => array( |
||
104 | 1 | 'user', |
|
105 | 1 | 'agent', |
|
106 | 'page-count' |
||
107 | 1 | ), |
|
108 | 1 | 'email-body-batch-message' => "notification-{$valueChangeNotificationType}-email-batch-body", |
|
109 | 'email-body-batch-params' => array( |
||
110 | 1 | 'title', |
|
111 | 1 | 'agent', |
|
112 | 'item' |
||
113 | 1 | ) |
|
114 | 1 | ); |
|
115 | |||
116 | 1 | $icons[$valueChangeNotificationType] = array( |
|
117 | 'path' => "SemanticNotifications/res/smw-entity-change-yellow.png" |
||
118 | 1 | ); |
|
119 | |||
120 | // Resolved in ChangeNotificationPresentationModel::getIconType |
||
121 | 1 | $icons[$specificationChangeNotificationType . '-property'] = array( |
|
122 | 'path' => "SemanticNotifications/res/smw-entity-change-blue.png" |
||
123 | 1 | ); |
|
124 | |||
125 | 1 | $icons[$specificationChangeNotificationType . '-category'] = array( |
|
126 | 'path' => "SemanticNotifications/res/smw-entity-change-green.png" |
||
127 | 1 | ); |
|
128 | 1 | } |
|
129 | |||
130 | /** |
||
131 | * @see https://www.mediawiki.org/wiki/Notifications/Developer_guide#Conventions |
||
132 | * |
||
133 | * @since 1.0 |
||
134 | * |
||
135 | * @param array &$defaultOptions |
||
136 | * |
||
137 | */ |
||
138 | 1 | public function addDefaultOptions( array &$defaultOptions ) { |
|
142 | |||
143 | /** |
||
144 | * @see https://www.mediawiki.org/wiki/Notifications/Developer_guide#Bundled_notification |
||
145 | * |
||
146 | * @since 1.0 |
||
147 | * |
||
148 | * @param EchoEvent $event |
||
149 | * @param string &$bundleString |
||
150 | */ |
||
151 | 1 | public function getNotificationsBundle( EchoEvent $event, &$bundleString ) { |
|
152 | |||
153 | 1 | $extra = $event->getExtra(); |
|
154 | |||
155 | if ( |
||
156 | 1 | $event->getType() === ChangeNotificationFilter::VALUE_CHANGE || |
|
157 | 1 | $event->getType() === ChangeNotificationFilter::SPECIFICATION_CHANGE ) { |
|
158 | 1 | $bundleString = $extra['subject']->getHash() . $extra['revid']; |
|
159 | 1 | } |
|
160 | 1 | } |
|
161 | |||
162 | /** |
||
163 | * @since 1.0 |
||
164 | * |
||
165 | * @param array $event |
||
166 | * |
||
167 | * @return EchoEvent |
||
168 | */ |
||
169 | 1 | public function createEvent( array $event ) { |
|
179 | |||
180 | /** |
||
181 | * @see https://www.mediawiki.org/wiki/Notifications/Developer_guide#Create_the_notification_via_the_Echo_extension |
||
182 | * |
||
183 | * @since 1.0 |
||
184 | * |
||
185 | * @param EchoEvent $event |
||
186 | * @param array &$users |
||
187 | */ |
||
188 | 1 | public function getDefaultRecipientsByType( EchoEvent $event, &$users ) { |
|
200 | |||
201 | } |
||
202 |