BlueSpice MediaWiki master
 All Classes Namespaces Files Functions Variables Groups Pages
EchoEventPresentationModel Class Reference
Inheritance diagram for EchoEventPresentationModel:
Collaboration diagram for EchoEventPresentationModel:

Public Member Functions

 getType ()
 
 getUser ()
 
 getCategory ()
 
 getBundledIds ()
 
 getIconType ()
 
 getTimestamp ()
 
 canRender ()
 
 getHeaderMessage ()
 
 getCompactHeaderMessageKey ()
 
 getCompactHeaderMessage ()
 
 getSubjectMessage ()
 
 getBodyMessage ()
 
 getPrimaryLink ()
 
 getPrimaryLinkWithMarkAsRead ()
 
 getSecondaryLinks ()
 
 getEventId ()
 
 jsonSerialize ()
 

Static Public Member Functions

static supportsPresentationModel ($type)
 
static factory (EchoEvent $event, $language, User $user, $distributionType= 'web')
 

Public Attributes

const USERNAME_RECOMMENDED_LENGTH = 20
 
const USERNAME_AS_LABEL_RECOMMENDED_LENGTH = 15
 
const PAGE_NAME_RECOMMENDED_LENGTH = 50
 
const PAGE_NAME_AS_LABEL_RECOMMENDED_LENGTH = 15
 
const SECTION_TITLE_RECOMMENDED_LENGTH = 50
 

Protected Member Functions

 __construct (EchoEvent $event, $language, User $user, $distributionType)
 
 getBundledEvents ()
 
 isBundled ()
 
 getBundleCount ($includeCurrent=true, $groupCallback=null)
 
 getNotificationCountForOutput ($includeCurrent=true, $groupCallback=null)
 
 userCan ($type)
 
 getAgentForOutput ()
 
 getMessageWithAgent ($key)
 
 getViewingUserForGender ()
 
 getAgentLink ()
 
 getHeaderMessageKey ()
 
 getSubjectMessageKey ()
 
 getTruncatedUsername (User $user)
 
 getTruncatedTitleText (Title $title, $includeNamespace=false)
 
 getUserLink ($user)
 
 getPageLink (Title $title, $description, $prioritized, $query=[])
 
 getDynamicActionLink (Title $title, $icon, $label, $description=null, $data=[], $query=[])
 
 getWatchActionLink (Title $title)
 

Protected Attributes

 $event
 
 $language
 
 $type
 

Detailed Description

Class that returns structured data based on the provided event.

Constructor & Destructor Documentation

EchoEventPresentationModel::__construct ( EchoEvent  $event,
  $language,
User  $user,
  $distributionType 
)
protected
Parameters
EchoEvent$event
Language | string$language
User$userOnly used for permissions checking and GENDER
string$distributionType

Member Function Documentation

EchoEventPresentationModel::canRender ( )

To be overridden by subclasses if they are unable to render the notification, for example when a page is deleted. If this function returns false, no other methods will be called on the object.

Returns
bool
static EchoEventPresentationModel::factory ( EchoEvent  $event,
  $language,
User  $user,
  $distributionType = 'web' 
)
static
Parameters
EchoEvent$event
Language | string$language
User$user
string$distributionType'web' or 'email'
Returns
EchoEventPresentationModel
EchoEventPresentationModel::getAgentForOutput ( )
finalprotected
Returns
array|bool ['wikitext to display', 'username for GENDER'], false if no agent

We have to display wikitext so we can add CSS classes for revision deleted user. The goal of this function is for callers not to worry about whether the user is visible or not.

Example:
list( $formattedName, $genderName ) = $this->getAgentForOutput();
$msg->params( $formattedName, $genderName );
EchoEventPresentationModel::getAgentLink ( )
finalprotected
Returns
array|null Link object to the user's page or Special:Contributions for anon users. Can be used for primary or secondary links. Same format as secondary link. Returns null if the current user cannot see the agent.
EchoEventPresentationModel::getBodyMessage ( )

Get a message for the notification's body, false if it has no body

Returns
bool|Message
EchoEventPresentationModel::getBundleCount (   $includeCurrent = true,
  $groupCallback = null 
)
finalprotected

Count the number of event groups in this bundle.

By default, each event is in its own group, and this method returns the number of events. To group events differently, pass $groupCallback. For example, to group events with the same title together, use $callback = function ( $event ) { return $event->getTitle()->getPrefixedText(); }

If $includeCurrent is false, all events in the same group as the current one will be ignored.

Parameters
bool$includeCurrentInclude the current event (and its group)
callable$groupCallbackCallback that takes an EchoEvent and returns a grouping value
Returns
int Number of bundled events or groups
Exceptions
InvalidArgumentException
EchoEventPresentationModel::getBundledEvents ( )
finalprotected
Returns
EchoEvent[]
EchoEventPresentationModel::getBundledIds ( )

Get the ids of the bundled notifications or false if it's not bundled

Returns
int[]|bool
EchoEventPresentationModel::getCategory ( )
final

Get the category of event

Returns
string
EchoEventPresentationModel::getCompactHeaderMessage ( )

Get a message object and add the performer's name as a parameter. It is expected that subclasses will override this.

This message should be more compact than the header message ( getHeaderMessage() ). It is displayed when a notification is part of an expanded bundle.

Returns
Message
EchoEventPresentationModel::getCompactHeaderMessageKey ( )
Returns
string Message key that will be used in getCompactHeaderMessage
EchoEventPresentationModel::getDynamicActionLink ( Title  $title,
  $icon,
  $label,
  $description = null,
  $data = [],
  $query = [] 
)
finalprotected

Get a dynamic action link

Parameters
Title$titleTitle relating to this action
bool$iconOptional. Symbolic name of the OOUI icon to use
string$labellink text (non-escaped)
string$descriptiondescriptive text (optional, non-escaped)
array$dataAction data
array$query
Returns
array Array compatible with the structure of secondary links
EchoEventPresentationModel::getEventId ( )

Get the ID of the associated event

Returns
int Event id
EchoEventPresentationModel::getHeaderMessage ( )

Get a message object and add the performer's name as a parameter. It is expected that subclasses will override this.

Returns
Message
EchoEventPresentationModel::getHeaderMessageKey ( )
protected
Returns
string Message key that will be used in getHeaderMessage
EchoEventPresentationModel::getIconType ( )
abstract
Returns
string The symbolic icon name as defined in $wgEchoNotificationIcons
EchoEventPresentationModel::getMessageWithAgent (   $key)
finalprotected

Return a message with the given key and the agent's formatted name and name for GENDER as 1st and 2nd parameters.

Parameters
string$key
Returns
Message
EchoEventPresentationModel::getNotificationCountForOutput (   $includeCurrent = true,
  $groupCallback = null 
)
finalprotected

Return the count of notifications bundled together.

For parameters, see getBundleCount().

Parameters
bool$includeCurrent
callable$groupCallback
Returns
int count
EchoEventPresentationModel::getPageLink ( Title  $title,
  $description,
  $prioritized,
  $query = [] 
)
finalprotected
Parameters
Title$title
string$description
bool$prioritized
array$query
Returns
array
EchoEventPresentationModel::getPrimaryLink ( )
abstract

Array of primary link details, with possibly-relative URL & label.

Returns
array|bool Array of link data, or false for no link: ['url' => (string) url, 'label' => (string) link text (non-escaped)]
EchoEventPresentationModel::getPrimaryLinkWithMarkAsRead ( )
final

Like getPrimaryLink(), but with the URL altered to add ?markasread=XYZ. When this link is followed, the notification is marked as read.

When the notification is a bundle, the notification IDs are added to the parameter value separated by a "|".

Returns
array|bool
EchoEventPresentationModel::getSecondaryLinks ( )

Array of secondary link details, including possibly-relative URLs, label, description & icon name.

Returns
array Array of links in the format of: [['url' => (string) url, 'label' => (string) link text (non-escaped), 'description' => (string) descriptive text (optional, non-escaped), 'icon' => (bool|string) symbolic ooui icon name (or false if there is none), 'type' => (string) optional action type. Used to note a dynamic action, by setting it to 'dynamic-action' 'data' => (array) optional array containing information about the dynamic action. It must include 'tokenType' (string), 'messages' (array) with messages supplied for the item and the confirmation dialog and 'params' (array) for the API operation needed to complete the action. For example: 'data' => [ 'tokenType' => 'watch', 'params' => [ 'action' => 'watch', 'titles' => 'Namespace:SomeTitle' ], 'messages' => [ 'confirmation' => [ 'title' => 'message (parsed as HTML)', 'description' => 'optional message (parsed as HTML)' ] ] ] 'prioritized' => (bool) true if the link should be outside the action menu, false for inside)], ...]

Note that you should call array_values(array_filter()) on the result of this function (FIXME).

EchoEventPresentationModel::getSubjectMessage ( )

Get a message object and add the performer's name as a parameter. It is expected that subclasses will override this. The output of the message should be plaintext.

This message is used as the subject line in single-notification emails.

For backward compatibility, if this is not defined, the header message ( getHeaderMessage() ) is used instead.

Returns
Message
EchoEventPresentationModel::getSubjectMessageKey ( )
protected
Returns
string Message key that will be used in getSubjectMessage
EchoEventPresentationModel::getTimestamp ( )
final
Returns
string Timestamp the event occurred at
EchoEventPresentationModel::getTruncatedTitleText ( Title  $title,
  $includeNamespace = false 
)
protected
Parameters
Title$title
bool$includeNamespace
Returns
string
EchoEventPresentationModel::getTruncatedUsername ( User  $user)
protected
Parameters
User$user
Returns
string
EchoEventPresentationModel::getType ( )
final

Get the type of event

Returns
string
EchoEventPresentationModel::getUser ( )
final

Get the user receiving the notification

Returns
User
EchoEventPresentationModel::getUserLink (   $user)
finalprotected
Parameters
User | null$user
Returns
array|null
EchoEventPresentationModel::getViewingUserForGender ( )
finalprotected

Get the viewing user's name for usage in GENDER

Returns
string
EchoEventPresentationModel::getWatchActionLink ( Title  $title)
finalprotected

Get an 'watch' or 'unwatch' dynamic action link

Parameters
Title$titleTitle to watch or unwatch
Returns
array Array compatible with dynamic action link
EchoEventPresentationModel::isBundled ( )
finalprotected

This method returns true when there are bundled notifications, even if they are all in the same group according to getBundleGrouping(). For presentation purposes, you may want to check if getBundleCount( true, $yourCallback ) > 1 instead.

Returns
bool Whether there are other notifications bundled with this one.
EchoEventPresentationModel::jsonSerialize ( )
Returns
array
Exceptions
TimestampException

Implements JsonSerializable.

static EchoEventPresentationModel::supportsPresentationModel (   $type)
static

Convenience function to detect whether the event type has been updated to use the presentation model system

Parameters
string$typeevent type
Returns
bool
EchoEventPresentationModel::userCan (   $type)
finalprotected

Helper for EchoEvent::userCan

Parameters
int$typeRevision::DELETED_* constant
Returns
bool

Member Data Documentation

const EchoEventPresentationModel::PAGE_NAME_AS_LABEL_RECOMMENDED_LENGTH = 15

Recommended length of page names used as link label

const EchoEventPresentationModel::PAGE_NAME_RECOMMENDED_LENGTH = 50

Recommended length of page names included in messages

const EchoEventPresentationModel::SECTION_TITLE_RECOMMENDED_LENGTH = 50

Recommended length of section titles included in messages

const EchoEventPresentationModel::USERNAME_AS_LABEL_RECOMMENDED_LENGTH = 15

Recommended length of usernames used as link label

const EchoEventPresentationModel::USERNAME_RECOMMENDED_LENGTH = 20

Recommended length of usernames included in messages


The documentation for this class was generated from the following file: