Open main menu
MediaWiki extensions manual
OOjs UI icon advanced.svg
MHTML
Release status: beta
Implementation Tag , Skin , Ajax
Description Displays MHTML content in an IFRAME
Author(s) Joel Peshkin (jpeshkintalk)
Latest version 0.4 (2009-02-02)
MediaWiki 1.11+
License MIT License
Download mhtml_extension.tar.gz
mhtml
Translate the MHTML extension if it is available at translatewiki.net
Check usage and version matrix.

If MHTML text is pasted into a Wiki document between <mhtml> and </mhtml> tags, or uploaded via a provided button, it will render the MHTML in an IFRAME. This permits including Powerpoint, word, etc... in wiki pages (without losing the ability to further edit them in the original application) including those with Visio diagrams pasted into them.

Warning Warning: This is very dangerous on a publicly editable site, because it allows for arbitrary JavaScript code to be inserted, opening the door for session hijacking. Thus, you shouldn't enable it unless you've restricted editing to trusted users only with $wgGroupPermissions . See Manual:Preventing access for more information on restricting write access.

Contents

UsageEdit

Do not use this on public sites. When editing a page, a new button will appear at the far right end of the toolbar, which will allow you to upload saved MHTML files. The raw contents of the uploaded file will be inserted between mhtml tags in the source of the page, and the MHTML file will be deconstructed, saved to a local cache, and displayed in an IFRAME when someone visits the page. This facilitates placing documents, particularly from MS-OFFICE, into wiki pages.

The extension will attempt to guess which HTML file should be considered the main page. To tell it, set the page attribute, for example

<mhtml page="Test_files/slide0002.htm">

To force the cached version of the MHTML information to be rebuilt, add ?action=purge to the end of the url when viewing the page.

Download instructionsEdit

Download the tarball and then unpack it in your extensions directory. For example:

cd extensions
wget http://bucardo.org/mhtml_extension.04.tar.gz
tar xvfz mhtml_extension.04.tar.gz
rm mhtml_extension.04.tar.gz
cd MHTML

InstallationEdit

This extension requires the optional "mailparse" PECL module for php. Install according to the normal PECL procedures. However, mailparse must load AFTER mbstring. On many distributions, this is most easily ensured by changing the ini file for mailparse to "z-mailparse.ini" so it loads after "mbstring.ini".

To install this extension, add the following to LocalSettings.php :

require_once("$IP/extensions/MHTML/MHTML.php");

Do not forget that this means you will be uploading rather large pages so you almost certainly have to increase the size of the PHP memory limits and all the upload limits. Don't forget the limit in LocalSettings.php as well.

This extension also requires the use of symbolic links within the images/mhtml_files directory. This can be turned on in Apache with the FollowSymLinks directive.

WarningsEdit

  • Do not use on any site where use of raw html would be unsafe
  • The unpacked contents of each mhtml file are placed in the images/mhtml_files directory in directories hashed with the MD5 of the original mhtml file. If you delete them, you must make sure that the cached version of the module's output is also flushed. See the section below on how to clean up these files.

Cleaning upEdit

A script named purge_mhtml_cache.php is provided and can be used to remove any cached MHTML information that was created a certain number of days ago. By default, the script will remove all cached files that were created more than one day ago. The number of days can be controlled with the -d option. To remove all cached files, call the script with -d 0. The script should be run from the extensions/MHTML directory.

Keep in mind that this only removes the cached versions of the expanded MHTML files. The actual MHTML file is saved inside the mhtml tags of the page itself, and the cached versions will be regenerated when someone views the page. Thus, it is fairly safe to run the cleanup script as often as you want.