/** * Get the URL for the primary or secondary link for an event * * @param EchoEvent $event * @param User $user The user receiving the notification * @param String $rank 'primary' or 'secondary' (default is 'primary') * @param boolean $local True to return a local (relative) URL, false to * return a full URL (for email for example) (default is true) * @param boolean $urlOnly True to return only the URL without the <a> tag, * false to return a full anchor link (default is false) * @param String $style A style attribute to apply to the anchor, e.g. * 'border: 1px solid green; text-decoration: none;' (optional) * @return String URL for link, or HTML for anchor tag, or empty string */ public function getLink($event, $user, $rank = 'primary', $local = true, $urlOnly = false, $style = '') { $destination = $event->getLinkDestination($rank); if (!$destination) { return ''; } // Get link parameters based on the destination list($target, $query) = $this->getLinkParams($event, $user, $destination); if (!$target) { return ''; } if ($urlOnly) { if ($local) { return $target->getLinkURL($query); } else { return $target->getFullURL($query, false, PROTO_HTTPS); } } else { $message = $this->getMessage($event->getLinkMessage($rank))->text(); $attribs = array('class' => "mw-echo-notification-{$rank}-link"); if ($style) { $attribs['style'] = $style; } $options = array(); // If local is false, return an absolute url using HTTP protocol if (!$local) { $options[] = 'https'; } return Linker::link($target, $message, $attribs, $query, $options); } }