Hi everyone!
I'm trying to write my notification for Echo and I'm a bit stuck coding the formatter. The standard way to write a formatter seems to override the processParam function (like in Thanks extension). There is a lot of magic in the code below, I can't figure out how the processParam function must be handled. My questions are in the comments and if someone can explain a little bit of what's possible to do inside processParam, I'd be very grateful.
class EchoThanksFormatter extends EchoBasicFormatter {
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-thanks-diff-link' )->text(), 'param' => array( // what is the possible structure of this param array? 'oldid' => $eventData['revid'], 'diff' => 'prev', //what is that? Are diff and prev some kind of reserved words? Where can I find the whole list of these words? ) ) );
} else { parent::processParam( $event, $param, $message, $user ); } } }
Cheers,
----- Yury Katkov
Following the code through, we are starting with your call to EchoBasicFormatter::setTitleLink(). The third argument you are asking about is labeled props, and gets passed on to EchoBasicFormatter::buildLinkParams(). This is the function that deals with the contents of that argument. From reading the code the following are valid keys in the props array: param, fragment, attribs, linkText. All of these are used as arguments for a call to Linker::link() which is the canonical anchor(<a>) generator in mediawiki.
Unfortunatly this means the contents of the param array are entirely arbitrary, they are used as part of the query string in an anchor generated by calling setTitleLink(). In mediawiki visiting any wikitext page with the query string 'oldid=XXXXX&diff=prev' will load up the revision specified by XXXXX and output the diff between it and its prior revision. I'm not aware of any list anywhere that summarizes the possible query parameters mediawiki accepts for wikitext pages.
Erik B.
On Wed, Dec 3, 2014 at 7:56 AM, Yury Katkov katkov.juriy@gmail.com wrote:
Hi everyone!
I'm trying to write my notification for Echo and I'm a bit stuck coding the formatter. The standard way to write a formatter seems to override the processParam function (like in Thanks extension). There is a lot of magic in the code below, I can't figure out how the processParam function must be handled. My questions are in the comments and if someone can explain a little bit of what's possible to do inside processParam, I'd be very grateful.
class EchoThanksFormatter extends EchoBasicFormatter {
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-thanks-diff-link' )->text(), 'param' => array( // what is the possible structure of this param array? 'oldid' => $eventData['revid'], 'diff' => 'prev', //what is that? Are diff and prev some kind of reserved words? Where can I find the whole list of these words? ) ) );
} else { parent::processParam( $event, $param, $message, $user ); }
} }
Cheers,
Yury Katkov _______________________________________________ Wikitech-l mailing list Wikitech-l@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/wikitech-l
On Wed, 03 Dec 2014 18:56:27 +0100, Erik Bernhardson ebernhardson@wikimedia.org wrote:
I'm not aware of any list anywhere that summarizes the possible query parameters mediawiki accepts for wikitext pages.
There is https://www.mediawiki.org/wiki/Manual:Parameters_to_index.php . It discussed the possible values of 'diff' and 'oldid' at https://www.mediawiki.org/wiki/Manual:Parameters_to_index.php#View_and_rende... .
Thank you so much guys, now it's clear!
----- Yury Katkov
On Wed, Dec 3, 2014 at 10:43 PM, Bartosz Dziewoński matma.rex@gmail.com wrote:
On Wed, 03 Dec 2014 18:56:27 +0100, Erik Bernhardson < ebernhardson@wikimedia.org> wrote:
I'm not aware of any list anywhere that summarizes the possible query
parameters mediawiki accepts for wikitext pages.
There is https://www.mediawiki.org/wiki/Manual:Parameters_to_index.php . It discussed the possible values of 'diff' and 'oldid' at https://www.mediawiki.org/wiki/Manual:Parameters_to_ index.php#View_and_render .
-- Bartosz Dziewoński
Wikitech-l mailing list Wikitech-l@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/wikitech-l
wikitech-l@lists.wikimedia.org