Manual:File page warnings

From mediawiki.org
Jump to navigation Jump to search
A new feature for MediaWiki PDF file pages - a warning symbol and pop-up information box.

Gerrit change 194565 creates a framework for adding warnings about different file types to file pages. Here's how to implement it:

  1. Add messages for the warning. There will be a maximum of four, only one of them is required:
    1. 'main' - this will be the text of the warning.
    2. 'header' - a title for the warning to grab the user's attention
    3. 'footer' - a qualification of the warning, for example "This is a warning about all PDF files, not this particular file."
    4. 'info' - text for a link to more information. The URL can be supplied later.
  2. Create and register a ResourceLoader module with the messages you just created. This will be used to load them onto the client.
  3. Create or locate a MediaHandler subclass for the type of file you're trying to handle. Most files get handled by ImageHandler or a subclass thereof by default, if a specialized handler doesn't exist for your filetype, you can create it.
  4. Override the default implementations of the needsWarning and getWarningConfig methods on your MediaHandler class. needsWarning should return true if you want a warning to be used, and getWarningConfig should return an object of the following structure:
return array(
  'module' => 'pdfhandler.filewarning', // The name of the module you created above
  'link' => 'http://example.com', // The link for your link to more information about the problem or solutions
  'messages' => array(
    // The names of the messages you created above
    'main' => '...', 'header' => '...', 'footer' => '...', 'info' => '...'
  )
);

After that, your warning should show up! Report any bugs in Phabricator and we'll get to it as soon as we can.