Extension:Backup.php

From Organic Design wiki
Revision as of 09:17, 9 June 2007 by Nad (talk | contribs) (interface to backup.pl)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

<?php

  1. Extension:Backups
Info.svg These are the MediaWiki extensions we're using and/or developing. Please refer to the information on the mediawiki.org wiki for installation and usage details. Extensions here which have no corresponding mediawiki article are either not ready for use or have been superseded. You can also browse our extension code in our local Subversion repository or our GitHub mirror.

Template:Php

  1. - Licenced under LGPL (http://www.gnu.org/copyleft/lesser.html)
  2. - Author: User:NadCategory:Extensions created with Template:SpecialPage
  3. - Started: 2007-06-09
  4. - This is a SpecialPage which acts as an in-wiki interface to backup.pl which reduces the backup/compress/distribute queue

if (!defined('MEDIAWIKI')) die('Not an entry point.');

define('BACKUPS_VERSION','0.0.0, 2007-06-09');

$wgExtensionFunctions[] = 'wfSetupBackups';

$wgExtensionCredits['specialpage'][] = array( 'name' => 'Special:Backups', 'author' => 'User:Nad', 'description' => 'A special page for backing up and restoring multiple wikis on a server', 'url' => 'http://www.organicdesign.co.nz/Extension:Backup_&_Restore', 'version' => BACKUPS_VERSION );

require_once "$IP/includes/SpecialPage.php";

  1. Define a new class based on the SpecialPage class

class SpecialBackups extends SpecialPage {

# Constructor function SpecialSearchLog() { SpecialPage::SpecialPage('Backups','sysop'); }

# Override SpecialPage::execute() # - $param is from the URL, eg Special:Backups/param function execute($param) { global $wgOut; $title = Title::makeTitle(NS_SPECIAL,'Backups'); $wgOut->addWikiText(wfMsg('example-message','exampleParameter')); $wgOut->addHTML( wfElement('form',array('action' => $title->getLocalURL('action=submit'),'method' => 'post'),null) . '<textarea name="target" cols=25 rows=10></textarea>' . wfElement('input',array('type' => 'submit')) . '</form>' ); }

}

  1. Called from $wgExtensionFunctions array when initialising extensions

function wfSetupBackups() { global $wgLanguageCode,$wgMessageCache;

# Add the messages used by the specialpage if ($wgLanguageCode == 'en') { $wgMessageCache->addMessages(array( 'backups' => 'Backup & restore wikis', 'exampleMessage' => "Example message: $1", )); }

# Add the specialpage to the environment SpecialPage::addPage(new SpecialBackups()); } ?>