Important: This is a development wiki, so things might be a little unstable. If something doesn't work properly, try refreshing the page. If that fails, come back later!

WikiDB/Files/WikiDB.php

From TestWiki

Jump to: navigation, search

+ + + WARNING + + +

  1. This code is provided primarily for the purposes of receiving feedback from the wiki community. This code is not suitable for use on production servers. Install it at your own risk.
  2. This is pre-release software and has only been tested on my testwiki. I am not responsible for any damage, database corruption, alien invasion, bad weather or any other problem that arises directly, indirectly or co-incidentally from the use of this software. Did I include database corruption in that list?
  3. The code on these pages is live code. This means that at any point it may be in an unstable or dangerous state. It also means that between downloading one file and the next the code may have changed in an incompatible way.
  4. I am happy to answer questions, receive suggestions for improvements or troubleshoot problems about the code.

Live sourcecode viewer: WikiDB.php
Last modified: 2010-01-15 02:59:12

<?php
if (!defined('MEDIAWIKI')) die("MediaWiki extensions cannot be run directly.");
/**
 * An extension to implement a wiki database system.
 * Very much under development, and liable to change.
 * Has external dependencies (e.g. tables need to be
 * created in the wikis database), which I will
 * define once fully known.
 *
 * Full usage instructions can be found on my test wiki,
 * available via the URL defined below ($pWikiDB_URL).
 *
 * @package MediaWiki
 * @subpackage Extensions
 *
 * @author Mark Clements <mclements at kennel17 dot co dot uk>
 * @copyright copyright © 2006-2008, Mark Clements
 * @license http://creativecommons.org/licenses/by-sa/2.5/ cc-by-sa 2.5 or later
 * @version $Rev: 136 $
 */
 
//////////////////////////
// Credit information
 
// The version is an integer, and is incremented manually every time incompatible changes are 
// introduced.  Changes that will not break existing wikis do not cause this number to be
// updated.
	$pWikiDB_Version = 2;
 
// The revision is also an integer, and will hold the highest revision number of any WikiDB
// files.  Each file needs to call WikiDB_RegisterRevision() with it's SVN revision string, 
// and the function uses the highest number registered.  We set it to 0 initially, so that 
// the variable holds an integer.  This does not need any manual intervention, once set up 
// in the files.
	$pWikiDB_Revision = 0;
	WikiDB_RegisterRevision('$Rev: 136 $');
 
// Set these variables here so they can be re-used for each registered item.
// Needs to be done before SpecialPages.php is included.
	$pWikiDB_Author = "Mark Clements";
	$pWikiDB_URL = "http://www.kennel17.co.uk/testwiki/WikiDB";
 
 
//////////////////////////
// Include files
 
// Need to ensure that the IncludableSpecialPage class is defined before we define our own special pages.	
	require_once("SpecialPage.php");
 
// Include all the other WikiDB files:
// Need to define WikiDB to let them know that it is safe to load.
	define("WikiDB", true);
 
// Support files
	require_once("WikiDB/Constants.php");
	require_once("WikiDB/Utility.php");
	require_once("WikiDB/Regex.php");
	require_once("WikiDB/Messages.php");
	require_once("WikiDB/BuiltInTypes.php");
 
// Core WikiDB classes
	require_once("WikiDB/classWikiDB_Table.php");
	require_once("WikiDB/classWikiDB_Query.php");
	require_once("WikiDB/classWikiDB_Parser.php");
 
// MW interface hooks
	require_once("WikiDB/Hooks.php");
	require_once("WikiDB/ParserTags.php");
	require_once("WikiDB/SpecialPages.php");
//	require_once("WikiDB/MagicWords.php");
 
 
//////////////////////////
// Extension credits:
// Note that special page credits are registered in WikiDB/SpecialPages.php.
 
// Main extension credits
	$wgExtensionCredits['other'][] = array(
		'name' => "WikiDB",
		'author' => $pWikiDB_Author,
		'description' => "a wiki-based database system",
		'version' => $pWikiDB_Version . ", r" . $pWikiDB_Revision,
		'url' => $pWikiDB_URL,
	);
 
 
//////////////////////////
// Variable initialisation
 
// If $wgWikiDBNamespaces has not been set, initialise it to an empty array.
	if (!isset($wgWikiDBNamespaces))
		$wgWikiDBNamespaces = array();
 
 
//////////////////////////
// Extension registration
 
	$wgExtensionFunctions[] = "wfWikiDB";
 
	function wfWikiDB() {
		global $wgMessageCache, $wgHooks, $wgParser, $wgVersion;
		global $pWikiDB_Messages;
 
	// Localisable messages
		$wgMessageCache->addMessages($pWikiDB_Messages);
 
	// Application hooks
		$wgHooks['SkinTemplateContentActions'][] = "wfWikiDB_AddActionTabs";
		$wgHooks['UnknownAction'][] = "wfWikiDB_SpecialActions";
		$wgHooks['ParserAfterStrip'][] = "wfWikiDB_ParserAfterStrip";
		$wgHooks['ArticleSaveComplete'][] = "wfWikiDB_ArticleSaveComplete";
		$wgHooks['ArticleDeleteComplete'][] = "wfWikiDB_ArticleDeleteComplete";
		$wgHooks['TitleMoveComplete'][] = 'wfWikiDB_TitleMoveComplete';
 
	// If MW version < 1.9.1, the ArticleDelete hook wasn't present, so we need to use a 
	// bit of a cheeky workaround...
		if (version_compare($wgVersion, '1.9.1', '<')) {
			$wgHooks['SpecialPageExecuteAfterPage'][] = 'wfWikiDB_SpecialPageExecuteAfterPage';
		}
	// Otherwise we use ArticleUndelete
		else {
			$wgHooks['ArticleUndelete'][] = 'wfWikiDB_ArticleUndelete';
		}
 
	// Parser hooks
	     $wgParser->setHook("data", "wfWikiDB_DataTag");
	     $wgParser->setHook("guesstypes", "wfWikiDB_GuessTypes");
	     $wgParser->setHook("repeat", "wfWikiDB_RepeatTag");
 
	// Special pages
		SpecialPage::addPage(new WikiDB_SP_UndefinedTables());
		SpecialPage::addPage(new WikiDB_SP_EmptyTables());
		SpecialPage::addPage(new WikiDB_SP_AllTables());
	}
 
 
//////////////////////////
// Other registration functions
 
	function WikiDB_RegisterRevision($RevString) {
		global $pWikiDB_Revision;
 
		if (preg_match('/\$.*:\s?(\d+)\s?\$/', $RevString, $Matches)) {
			$Revision = intval($Matches[1]);
			if ($Revision > $pWikiDB_Revision)
				$pWikiDB_Revision = $Revision;
		}
	}
Personal tools