Storing a content like a page in MediaWiki

128 Views Asked by At

I have started to develop a website using MediaWiki. I designed an upload page (I have not used the MediaWiki's default upload page Special:upload). I have created it manually and did my operations like uploading images and stored details in the separate table (not MediaWiki 's existing table).

Now what I need is have to store the group of image details in a particular page should be stored in the MediaWikidatabase for getting the history of that image group, revisions ,etc., and i found the uploading images are storing in the following tables:

  • image — for current version
  • oldimage — for old versions

and pages are stored in the following tables:

  • page — for current page details
  • revision — for old page versions

Can anyone please explain me how to store the contents into the MediaWiki database and getting from the database with all the MediaWiki features manually?

1

There are 1 best solutions below

0
On

If I understand you correctly, you have a file that has been uploaded to the server by some script that's not part of MediaWiki, and you want to import it into MediaWiki.

There's an existing maintenance script called importImages.php which does something very much like that, so you could take a look at its source to see how it does it, or you could maybe even use the script directly.

Anyway, in case wading through the source code seems daunting, the important stuff consists of just two steps:

  1. get a LocalFile object using the wfLocalFile() function, and
  2. call the publish() upload() method on it.

The importImages.php code also does some extra stuff to guess the MIME type of the file and set some HTTP headers based on that. I'm not sure why the publish() method couldn't or shouldn't do that by itself, but since importImages.php does it, you probably should too. *shrug*

Edit: Instead of calling publish(), you probably want to call upload(), which takes care of the MIME type sniffing stuff and a bunch of other details, like creating the file description page.