User:Edwardmolasses/ExportForm

 
A proposal to move this page to MediaWiki.org was rejected.
File:Col-trans.jpeg

Hello, I'm Andrew and I have used MediaWiki to setup an online dictionary of terms related to plant genetic resources. This work was done with the collaboration of the Commonwealth of Learning and the International Plant Genetic Resources Institute.

File:Ipgri.gif

I have produced a couple of MediaWiki extensions while setting up the dictionary. I will be uploading them to Meta-Wiki and linking to them from this page in the next little while.

I have done some other work involving Wikis with both organizations. A paper I co-authored on the subject of Wikis entitled 'Innovative Use of Internet-Based Collaboration Tools and Methods in an Institutional Context' was presented at the 2004 Pan-Commonwealth Forum on Open Learning and can be found here (pdf).



Export Form Extension

edit
 

The input of the Export Form function is an HTML input form which accepts the page names of existing wiki pages. To make it easier there is a search function which can be used to populate the list with wiki search query results. The output of the export is the content of the pages listed by the user in the format they have indicated (either XML, PDF or HTML), which can be downloaded by the user. It can be accessed from the Navigation Menu on the left hand margin of the Wiki, or through the Special pages link which is also in the Navigation Menu.


The Input List of Wiki Pages in the export form can be edited manually by typing in page names or by using the Search Query Input below (the search method is easier if you don't know the exact names of the pages).

You can use the search function by typing the term into the Search Query Input and clicking the Add Search Results button (labelled 'Search' in the diagram above). The resulting list of pages will be appended to the Input List of Wiki Pages.

You can select the format radio button corresponding to the format you would like to dump the list of pages to (XML, PDF or HTML) and then dump the pages using the Dump button.

This extension was tested on MediaWiki 1.5.6. This extension can be seen in action at IPGRI's Plant Genetic Resources dictionary.


How the extension works with HTML2FPDF

You will have to have installed HTML2FPDF and configured it for use with MediaWiki. Instructions for doing this can be found at: http://meta.wikimedia.org/wiki/HTML2FPDF_and_Mediawiki . HTML2FPDF has some limitations such as not being able to process coloured sections of text. See the homepage at: http://html2fpdf.sourceforge.net/ for more details.


Installing the ExportForm Extension

Step 1: Installing the PDF Export Component

(We used a modified version of the HTML2FPDF and Mediawiki page for setting up the PDF export functionality)

By using HTML2FPDF (http://sourceforge.net/projects/html2fpdf/) it is possible to generate PDF pages interactively on the Mediawiki site without the need for extra plugins. Only PHP is required.

  1. If you are using the HTML2FPDF software provided with the install package, skip steps 2 and 3. You can unpackage the file in the install package with the command 'tar -xvzf html2fpdf.tar.gz'.
  2. Download and unzip
  3. HTML2FPDF (http://sourceforge.net/projects/html2fpdf/) (According to the documentation this includes a modified FPDF (http://www.fpdf.org) (PHP class for generating PDFs) ) Get updated html2fpdf.php (http://sourceforge.net/tracker/download.php?group_id=114602&atid=668890&file_id=131263&aid=1185473). (valid for 3.0.2b), reported in HTML2PDF request (http://sourceforge.net/tracker/index.php?func=detail&aid=1185473&group_id=114602&atid=668890). Replace the html2fpdf.php file in the HTML2FPDF package with the version you just downloaded.
  4. For ease of use, install both in the 'includes' directory of the wiki (I did not investigate in detail how to install them in the extensions directory). To install, copy the files you unzipped from the HTML2FPDF package into the includes directory of your MediaWiki installation(s).
  5. Update the index.php of your Mediawiki with the following (this code implements the parsing of a 'pdf=yes' setting in the URL) somewhere near the top between 'Query string fields' and the delete action, as shown (the first 3 lines are presented for context):
if ($wgRequest->getVal( 'printable' ) == 'yes') {
$wgOut->setPrintable();
}
if ($wgRequest->getText( 'format' ) == 'PDF') {

require_once('html2fpdf.php');
// activate Output-Buffer:
ob_start();
}
  1. and at the end of the file right before the php code enclosure '?>':
if ($wgRequest->getText( 'format' ) == 'PDF') {

// activate Output-Buffer:
// Output-Buffer in variable:
$html=ob_get_contents();
// delete Output-Buffer
ob_end_clean();
$pdf = new HTML2FPDF();
$pdf->DisplayPreferences('HideWindowUI');
$pdf->AddPage();
$pdf->setBasePath("./../wi");
$pdf->WriteHTML($html);
$pdf->Output('doc.pdf','D');
}
  1. Select the Monobook skin. In the monobook skin, the printable version is implicit since the use of the MEDIA setting permits configuration through the CSS (try 'print preview' in your browser).
  2. For the other skins, some other operations are needed.
    • In Skin.php,
      • find the 'printableLink' function, duplicate it and name the duplication 'pdfLink'. In 'pdfLink' add '&pdf=yes' after 'printable=yes'.
      • In the pageTitle function, add a line like this just before the the line 'return $s;':
$s .= ' | ' . $this->pdfLink();


Step 2: Installing the Export Form Special Page

  • Download the source code:
  • Copy the contents in pdf out, and create corresponding php source files. You can do this by opening the pdf's in your pdf reader of choice (Acrobat, XPdf, etc.) and selecting all the text, using the clipboard to copy paste it into a new php file.
    • Note: There has been a little bit of trouble with the PDF version of the code, so while I figure out what the problem is here is a link to a text version of the code. It hasn't yet been cleaned and contains some debugging comments, but they won't affect the extension's function.
  • Move the .php special page file into your wiki's "extensions" directory.
  • Change ownership of the file:
chown apache:apache filename.php
  • To let MediaWiki recognize that it exists, you would add the following line to the end of your wiki's LocalSettings.php file:
include("extensions/DocumentExport.php");

Keyword Wiki-Linking Scan Extension

edit

Coming soon...