Skip to content

Mediawiki_integration

Cameron edited this page Jan 28, 2017 · 1 revision

title: Mediawiki integration permalink: /Mediawiki_integration/

Category:HOWTOs

What is Mediawiki?

Mediawiki is one the most developed wiki software available at the moment. It's extensive development is coming from the popularity of Wikipedia and other Wikimedia Foundation projects.

A Wiki is a type of website that allows anyone visiting the site to add, to remove, or otherwise to edit all content, very quickly and easily, sometimes without the need for registration. This ease of interaction and operation makes a wiki an effective tool for collaborative writing.

The interface you are currently reading is made out of Mediawiki.

What Mediawiki is not

Mediawiki doesn't include the functionality of a web portal like e107; it is only a collaborative publication software application. (a good one ^_^) You won't find within Mediawiki applications like a forum, chatbox or other plugins frequently available in common CMS.

Why use Mediawiki with e107?

If you are creating a large database of information, originating from many people who are not necessarily administrators on your site. Using typical publication procedures, your administrator would have to check out the majority of the submitted content before it would appear somewhere on your site. Using a wiki interface, you could get loads of contributions from simple users, and they are available to everyone immediately.

Integrating Mediawiki into a e107 website

In order to create your own mediawiki plugin like this one, you could use the following tool: Integration_of_Mediawiki_into_e107.zip

--- EDIT: 03/19/08 --- This link above does not work anymore. The origial .zip file is no longer at this address. See Edits below for alternate downloads.

--- EDIT: 02/16/08 Alternate Downloads List Below ---

--- EDIT: 2/14/07 List of Working Integrations --- This above integration still works for the following MediaWiki versions. There is one minor change needed that is discussed in the last section of the document that applies to the 1.9.2 version and probably beyond.

  • MediaWiki v1.9.2 - Requires information at the end of the document.
  • MediaWiki v1.12.0rc2 - Requires the information at the end of the document. Same files work as 1.9.2. Example of this installation at the .zip link above.

--DWagner (Illydth)

Explanation found here included.

Integration is not a big workaround as you won't have to work into the e107 file system. The manipulations you'll have to do are into the Mediawiki file system essentially. Next, you'll have to put links to the wiki into your site using the admin board.

Keep in mind that you are installing a second website for your site. This is because Mediawiki is fully independent of e107, we will make it dependent into those next explanation:

First thing first: Installing the Mediawiki software

You can install the wiki anywhere you'd like to. On the same server as your e107 website or on another server. It is however recommended to use the same MySQL database. Just upload the Mediawiki to your server and launch the installation service.

  • You should not specify a prefix for the mediawiki database tables:
    • To avoid using the same tables as e107
    • The file Auth_e107.php is not set to search for prefixed tables.

--- EDIT 2/17/07: It is not a requirement to have the Wiki and e107 databases merged together. It works either way. See "Connecting to an External Database" below. --DWagner (Illydth)

Using the user table of e107 for Mediawiki

Since you already have a user registration method with e107, you don't want your users to have to register again on your wiki. That's why you're going to have to link the Mediawiki 'user' table to your e107 'e107_user' table.

To do this, you have to:

  1. Copy the file extensions/Auth_e107.php to your mediawiki.
  2. Add some code to the file LocalSettings.php of your Mediawiki:

This will block the registration process into Mediawiki.

  • Be sure to change the pages in Special:Allmessages of your Mediawiki in consequence
    • userlogin => to Connect to the wiki instead of Register or connect to..
    • nologin => to Don't have a login? Register on YOURSITE first instead of ''Don't have a login? $1. ''

Note: you need to change a file within Mediawiki to put a link to your signup page; I haven't looked for it yet

Connecting to an External e107 Database

As noted above, it is not a requirement to have your e107 and MediaWiki databases merged together (you can have the databases on different databases on the same server or on completely different servers).

There is a configuration section that is not discussed here in the WIKI that is in the Integration text file that ships with the zip package above. In the text file is a third section of code (shown below) that allows a MediaWiki installation to connect to a separate database for it's e107 authentication.

For the above, if you use an external database for your e107 installation (e107 and MediaWiki aren't installed into the same DB) set $wge107_UseExtDatabase to true, otherwise set to false.

If you are NOT using an external Datbase ($wge107_UseExtDatabase = false) comment (//) the 4 MYSQL variables following UseExtDatabase, otherwise keep them uncommented. See the Integration text file that ships in the zip package above.

--DWagner (Illydth)

Permissions on the wiki

At installation time, you have to decide whether you want anybody or only members to be able to edit your wiki. If you want to restrict access for editing pages to member only or to a particular class of your e107 site, you'll need to add these lines:

Make the Mediawiki appear in the Main page of your e107 website

1- You need to create a php file linking to your Mediawiki site (i.e. wiki.php) using an IFRAME 2- You'll need to add // to the mediawiki file skins/common/wikibits.js on line 40

  • This prevent Mediawiki from popping out of the Iframe.

''--EDIT: Note for 1.9.2 the wikibits.js lines are lines 51 - 56 and this line no longer needs to be commented. '' There's now an "if" check surrounding a wgBreakFrames variable. If wgBreakFrames is set true (in LocalSettings.php) '' the wiki window will do what it can to break out of being a child window, if wgBreakFrames is not set or set false '' (Default setting is "false" for this) it will allow itself to be a child window. --DWagner (Illydth)

Known issue :

Mediawiki send Parse_error about all the variables added to LocalSettings.php. Solution: 1- Copy every added lines in LocalSettings.php BEFORE

require_once( "includes/DefaultSettings.php" );

---EDIT 2/17/04 Version 1.9.2 Media Wiki---

Actually this is no longer correct by my findings for Version 1.9.2 of MediaWiki.

For MediaWiki 1.9.2, the file includes/DefaultSettings.php on line 1962 includes the following:

$wgAuth = null;

Thus forceably setting any external authenticators blank. What happens if you follow the above suggestion and put the added lines before the load of DefaultSettings is you end up setting wgAuth to new Auth_e107() and then turn around and load DefaultSettings.php and blanking it back to null.

For this to work in any way AT LEAST the $wgAuth setting in the first section MUST be after the load of includes/DefaultSettings.php.

If you try to log in and cannot access any of the users in your e107 database the reason is most likely because the wgAuth variable is being unset.

Really the WHOLE configuration of the e107 integration should be put somewhere after the DefaultSettings.php file.

--DWagner (Illydth)

Theming

Into the .zip file, you'll find a theme integrating the classical color of the mediawiki monobook. You can use it if you want to. It is designed so that the left column of jayya vanishes completely when displaying the wiki into e107. You need to set the visibility of the left menu to : Hide when wiki.php file is loaded.

See jayya/style_wiki.css file in the .zip file to adapt the color.

Important Note

Mediawiki uses the field user_loginname of table e107_user as it's own user table. This is the name used to register with e107 => not the Display name !!

For installations of this integration prior to 15th May 2006 login uses the display name as the user table.

This has been changed due to several complaints; now the same combination of username/password is required for both e107 and mediawiki.

How to integrate better

 Mediawiki is not currently totally integrated into e107, follow the development or help here..   For now, it is using an Iframe to display the wiki.

What is yet to do :

  • Create a skin for Mediawiki that would use the Header/Footer and class2.php of e107...
  • Use of the same cookie for authentification...

Cookie use and integration are now better than ever.. coming soon a new version of the mediawiki integration.--Daddy Cool 13:38, 22 September 2006 (CDT)

Downloading Mediawiki

You can find the latest Mediawiki here

Needed Change to Integrate with MediaWiki 1.9.2

There is one required change that needs to be made to one of the files in the Integration zip package from above to get recent versions of MediaWiki and e107 to play together correctly. This information has been tested working with 1.9.2 but it could apply to various versions pre and post 1.9.2.

In the above package in the extensions/Auth_e107.php file there is a function "setPassword" which is a public function in the Auth_e107 class. The setPassword function is as follows:

       /**
         * Set the given password in the authentication database.
         * Return true if successful.
         *
         * NOTE: We only allow the user to change their password via e107.
         *
         * @param string $password
         * @return bool
         * @access public
         */
        function setPassword( $password ) {
            return false;
        } // End: setPassword()

Note the intent of setPassword in the code is to tell the calling function that it is not able to change the password in the e107 database. The problem is with newer versions of MediaWiki, a failure returned from this function denotes a failure to connect to the authentication database, not simply a check whether MediaWiki is or is not allowed to update a password.

In includes/User.php, lines 1341-1343:

if( !$wgAuth->setPassword( $this, $str ) ) {
    throw new PasswordError( wfMsg( 'externaldberror' ) );
}

This whole section of code is part of creating a "parallel" user in the MediaWiki database with what's in the e107 user database when the user doesn't already exist in MediaWiki. There has to be a user in the MediaWiki database for MediaWiki functionality to work, so in essence the code is synchronizing the users that log in to MediaWiki. The setPassword part is just one of the settings in the newly created MediaWiki user record being changed. However since a "false" is being returned the user cannot be created and the whole process fails.

The initial fix to get around setPassword() throwing an external db error is to set the return to "true" in the setPassword function in the Auth_e107.php file.

After modification the setPassword code in Auth_e107.php, lines 418-431 would be:

        /**
         * Set the given password in the authentication database.
         * Return true if successful.
         *
         * NOTE: We only allow the user to change their password via e107.
         *
         * @param string $password
         * @return bool
         * @access public
         */
        function setPassword( $password ) {
            return true;
        } // End: setPassword()

Last Step after Integration - Recovering the SysOp User

If you follow the Wiki here, you should at this point have an integrated e107/MediaWiki installation. You should now be able to log in to MediaWiki as one of your e107 users, and any newly created e107 users should be able to then log into MediaWiki.

However the next thing you realize is that you've lost the SysOP account you setup when you intitially installed MediaWiki...SysOp still exists in the database, but it's no longer accessable (there is no "WikiSysop" account in e107 by default). There are two things you can do in this process of integrating e107 and MediaWiki to make sure you have a SysOp user when MediaWiki is finally integrated.

The first thing you can do is to set the SysOp account name to an e107 account name when MediaWiki is initially installed. Theoretically, when you then log in to MediaWiki as the username, the account should exist on the e107 side but will pick up the permissions and groups of the account installed on the MediaWiki database and SysOp privs should be granted.

As this might not have occurred to anyone at the point of installation, the other thing you can do is to edit the database and change the current SysOp user to an existing e107 user. If you follow the default MediaWiki installation, your Users table in the MediaWiki database (NOT the e107 database or users table, the MediaWiki users table) should contain a "WikiSysop" user. You'll note that MediaWiki uses a "blob" field (read binary data) to store User Options (including user groups and permissions) so you can't simply edit a user to give them SysOp privs, also since you cannot log in to the SysOp account in your MediaWiki installation you can't use the Special:Usersettings pages either to edit a user.

To get SysOp privs to an account you will need to EDIT the WikiSysop record (through either mysql if you're a masochist or preferably a GUI tool like phpMyAdmin) and change it's Username to the username of an account in your e107 installation that should have the SysOp privileges. Once you update the username on the WikiSysop account it's a simple as logging out of MediaWiki and logging back in as the e107 user who should have MediaWiki SysOp privs. You should then be able to go to the special pages link and go to Special:Userrights (the User Rights Management page) and assign any privileges you want to any of the other accounts that have logged into MediaWiki.

Note: In case this isn't clear, your e107 users DO NOT automatically have accounts with MediaWiki, there is no "inital copy" of all the e107 users to the MediaWiki database. To assign user rights to any e107 user that user MUST login to MediaWiki first to get their initial user record created, then they will be available under the user administration functions of MediaWiki.

''There is already some basic integration between e107 usergroups and MediaWiki privliges (particularly the edit privilege), is there any other integration between e107 privs and MediaWiki privs?

Clone this wiki locally