Ejemplo n.º 1
0
 /**
  * @param EchoEvent $event
  * @param $param
  * @param $message Message
  * @param $user User
  */
 protected function processParam($event, $param, $message, $user)
 {
     if ($param === 'subject-anchor') {
         $message->params($this->formatSubjectAnchor($event));
     } elseif ($param === 'section-title') {
         $message->params($this->getSectionTitle($event, $user));
     } elseif ($param === 'difflink') {
         $revid = $event->getExtraParam('revid');
         if (!$revid) {
             $message->params('');
             return;
         }
         $diff = $event->getExtraParam('diffid', 'prev');
         $props = array('attribs' => array('class' => 'mw-echo-diff'), 'linkText' => $this->getMessage('parentheses')->params($this->getMessage('showdiff')->text())->escaped(), 'param' => array('oldid' => $revid, 'diff' => $diff), 'fragment' => '');
         $this->setTitleLink($event, $message, $props);
     } elseif ($param === 'summary') {
         $message->params($this->getRevisionSnippet($event, $user));
     } elseif ($param === 'number') {
         $eventData = $event->getExtra();
         // The folliwing is a bit of a hack...
         // If the edit is a rollback, we want to say 'your edits' in the
         // notification. If the edit is an undo, we want to say 'your edit'
         // in the notification. To accomplish this, we pass a 'number' param
         // to the message which is set to 1 or 2 and formatted with {{PLURAL}}.
         if (isset($eventData['method']) && $eventData['method'] === 'rollback') {
             $message->params(2);
         } else {
             $message->params(1);
         }
     } else {
         parent::processParam($event, $param, $message, $user);
     }
 }
Ejemplo n.º 2
0
 /**
  * @param $event EchoEvent
  * @param $param
  * @param $message Message
  * @param $user User
  */
 protected function processParam($event, $param, $message, $user)
 {
     if ($param === 'difflink') {
         $eventData = $event->getExtra();
         if (!isset($eventData['revid'])) {
             $message->params();
             return;
         }
         $this->setTitleLink($event, $message, array('class' => 'mw-echo-diff', 'linkText' => wfMessage('notification-thumbs-up-diff-link')->text(), 'param' => array('oldid' => $eventData['revid'], 'diff' => 'prev')));
     } else {
         parent::processParam($event, $param, $message, $user);
     }
 }
 protected function processParam($event, $param, $message, $user)
 {
     if ($param === 'instance') {
         $extra = $event->getExtra();
         // PHP 5.3 compatability...
         $instance = $extra['instanceName'];
         if ($instance) {
             $message->params($instance);
         } else {
             $message->params('');
         }
     } else {
         parent::processParam($event, $param, $message, $user);
     }
 }
 /**
  *
  * @param EchoEvent $event
  * @param type $param
  * @param Message $message
  * @param User $user
  */
 protected function processParam($event, $param, $message, $user)
 {
     if ($param === 'summary') {
         $aEventData = $event->getExtra();
         $message->params($aEventData['summary']);
     } else {
         if ($param === 'titlelink') {
             $this->setTitleLink($event, $message, array('class' => 'mw-echo-title'));
         } else {
             if ($param === 'difflink') {
                 $aEvent = $event->getExtra();
                 $diffparams = isset($aEvent['difflink']) ? $aEvent['difflink']['diffparams'] : '';
                 $this->setDiffLink($event, $message, array('class' => 'mw-echo-diff', 'param' => $diffparams));
             } else {
                 if ($param === 'agentlink') {
                     if ($event->getAgent()->isAnon()) {
                         $message->params("'''" . wfMessage('bs-echo-anon-user') . "'''")->parse();
                     } else {
                         $this->setUserpageLink($event, $message, array('class' => 'mw-echo-userpage'));
                     }
                 } else {
                     if ($param === 'userlink') {
                         $this->setUserpageLink($event, $message, array('class' => 'mw-echo-userpage', 'created' => true));
                     } else {
                         if ($param === 'newtitle') {
                             $aExtra = $event->getExtra();
                             $oNewTitle = $aExtra['newtitle'];
                             $message->params($oNewTitle->getPrefixedText());
                         } else {
                             if ($param === 'newtitlelink') {
                                 $aExtra = $event->getExtra();
                                 $oNewTitle = $aExtra['newtitle'];
                                 $this->buildLink($oNewTitle, $message, array('class' => 'mw-echo-title'));
                             } else {
                                 if ($param === 'deletereason') {
                                     $aExtra = $event->getExtra();
                                     $message->params($aExtra['deletereason']);
                                 } else {
                                     if ($param === 'shoutmsg') {
                                         $aExtra = $event->getExtra();
                                         $sMessage = $aExtra['shoutmsg'];
                                         $message->params($sMessage);
                                     } else {
                                         if ($param === 'username') {
                                             $aExtra = $event->getExtra();
                                             $sMessage = $aExtra['username'];
                                             $message->params($sMessage);
                                         } else {
                                             if ($param === 'realname') {
                                                 $aExtra = $event->getExtra();
                                                 $sMessage = $aExtra['realname'];
                                                 $message->params($sMessage);
                                             } else {
                                                 parent::processParam($event, $param, $message, $user);
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
 }
Ejemplo n.º 5
0
 /**
  * Helper function for getLink()
  *
  * @param EchoEvent $event
  * @param User $user The user receiving the notification
  * @param String $destination The destination type for the link
  * @return Array including target and query parameters
  */
 protected function getLinkParams($event, $user, $destination)
 {
     $target = null;
     $query = array();
     // Set up link parameters based on the destination (or pass to parent)
     switch ($destination) {
         case 'link-from-page':
             if ($this->bundleData['use-bundle']) {
                 if ($event->getTitle()) {
                     $target = SpecialPage::getTitleFor('WhatLinksHere', $event->getTitle()->getPrefixedText());
                 }
             } else {
                 $extra = self::extractExtra($event->getExtra());
                 if ($this->isTitleSet($extra)) {
                     $target = Title::newFromId($extra['link-from-page-id']);
                 }
             }
             break;
         default:
             return parent::getLinkParams($event, $user, $destination);
     }
     return array($target, $query);
 }
Ejemplo n.º 6
0
 protected function formatPayload($payload, $event, $user)
 {
     switch ($payload) {
         case 'text':
             try {
                 return Post::newFromId(UUID::fromBin($event->getExtraParam('postid')))->text;
             } catch (\Exception $e) {
                 return wfMessage('notification-flowthread-payload-error');
             }
         default:
             return parent::formatPayload($payload, $event, $user);
             break;
     }
 }
Ejemplo n.º 7
0
 /**
  * Build the email icon component
  * @return string
  */
 public function buildEmailIcon()
 {
     return EchoEmailMode::getNotifIcon($this->notifFormatter->getValue('icon'));
 }