mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Echo
synced 2024-12-01 10:56:44 +00:00
a73d63d1a4
Some notifications return relative urls in their primary or secondary links. This change makes those urls absolute so they point to the right wiki when viewed from another wiki (cross-wiki notifications). Bug: T125738 Bug: T127697 Change-Id: Ib65337430eb2484f9491668a9998deef70589fb1
27 lines
746 B
PHP
27 lines
746 B
PHP
<?php
|
|
|
|
/**
|
|
* A formatter for the notification flyout popup. Just the bare data needed to
|
|
* render everything client-side.
|
|
*/
|
|
class EchoModelFormatter extends EchoEventFormatter {
|
|
/**
|
|
* @param EchoEventPresentationModel $model
|
|
* @return array
|
|
*/
|
|
protected function formatModel( EchoEventPresentationModel $model ) {
|
|
$data = $model->jsonSerialize();
|
|
$data['iconUrl'] = EchoNotificationFormatter::getIconUrl( $model->getIconType(), $this->language->getDir() );
|
|
|
|
if ( isset( $data['links']['primary']['url'] ) ) {
|
|
$data['links']['primary']['url'] = wfExpandUrl( $data['links']['primary']['url'] );
|
|
}
|
|
|
|
foreach ( $data['links']['secondary'] as &$link ) {
|
|
$link['url'] = wfExpandUrl( $link['url'] );
|
|
}
|
|
|
|
return $data;
|
|
}
|
|
}
|