Hacking MediaWiki

지각생 연습장

페이지에 header 넣기 (연구중)

  • includes/
    1. Article.php
    2. OutputPage.php
      $wgOut = new OutputPage();
      $wgOut->addHtml() 등의 메소드로 변경

The MediaWiki codebase

The MediaWiki codebase is large and ugly. Don't be overwhelmed by it. When you're first starting off, aim to write features or fix bugs which are contained to a small region of code.

See also: (generated documentation)

One of the best ways to learn about MediaWiki is to read the code. Here are some starting points:

  • index.php is the main entry point, although where things go from there is not very obvious.
  • Article.php contains code for page view, delete, rollback, watch and unwatch. It also contains some general utilities for dealing with articles, such as fetching a revision or saving a page.
  • EditPage.php has about half of the code related to editing, the half that's close to the user interface. The rest is in Article.php and the various *Update.php files.
  • Parser.php has most of the code that converts wikitext to HTML. A few bits and pieces are in Skin.php
  • Linker.php has functions to generate the HTML for links and images
  • Code for most special pages is in the Special*.php files.
  • Database.php contains stacks of functions for accessing the database.
  • OutputPage.php is the home of the OutputPage class, which is an output buffer. Send your text here and it will be sent to stdout just before the script exits.
  • Title.php is all about titles -- and that includes interwiki titles and "#" fragments. There's some functions in here that will fetch information about an article from the database.
  • User.php contains the User class, which represents user preferences and permissions.
  • Setup.php does all sorts of initialisation, and seems to account for a large proportion of running time. Among other things, it initialises lots of global variables, mostly containing objects.
  • DefaultSettings.php contains defaults for lots of global variables, which may or may not be overridden in LocalSettings.php. Don't use isset(), always add a default for any global variable you introduce.

For getting started with debugging, see How to debug MediaWiki.

개인 도구