0

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?

Dereckson
  • 1,340
  • 17
  • 30
Kalaiyarasan
  • 12,134
  • 8
  • 31
  • 49
  • (1) If you wish to code the upload information yourself, browse the MediaWiki classes documentation at https://doc.wikimedia.org/mediawiki-core/master/php/html/annotated.html. Good starting points should be File for the media, and Page for the description page. – Dereckson Sep 18 '13 at 18:45
  • (2) You can also ask your upload form to use the upload API https://www.mediawiki.org/wiki/API:Upload. That will allow you to automate all these steps, letting you have the total control of the upload form. – Dereckson Sep 18 '13 at 18:46
  • The second paragraph in your question doesn't make any sense to me. It looks like part of the sentence is missing, or maybe it should be two sentences that have been run together. Anyway, I'm not quite sure what you want to do. If it's to import a separately uploaded image into MediaWiki, you could try looking at the source of [maintenance/importImages.php](http://www.mediawiki.org/wiki/Manual:ImportImages.php) to see how it does it. – Ilmari Karonen Sep 18 '13 at 19:49

1 Answers1

0

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.

Ilmari Karonen
  • 49,047
  • 9
  • 93
  • 153