r19199 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r19198‎ | r19199 | r19200 >
Date:06:59, 13 January 2007
Author:brion
Status:old
Tags:
Comment:
move the remaining naked extensions into subdirectories
Modified paths:
  • /trunk/extensions/Autoincrement (added) (history)
  • /trunk/extensions/Autoincrement.php (deleted) (history)
  • /trunk/extensions/Autoincrement/Autoincrement.php (added) (history)
  • /trunk/extensions/Autoincrement/Autoincrement.php (added) (history)
  • /trunk/extensions/Citation (added) (history)
  • /trunk/extensions/Citation.php (deleted) (history)
  • /trunk/extensions/Citation/Citation.php (added) (history)
  • /trunk/extensions/Citation/Citation.php (added) (history)
  • /trunk/extensions/ExtensionLoader (added) (history)
  • /trunk/extensions/ExtensionLoader.php (deleted) (history)
  • /trunk/extensions/ExtensionLoader/ExtensionLoader.php (added) (history)
  • /trunk/extensions/ExtensionLoader/ExtensionLoader.php (added) (history)
  • /trunk/extensions/HTTPRedirect (added) (history)
  • /trunk/extensions/HTTPRedirect.php (deleted) (history)
  • /trunk/extensions/HTTPRedirect/HTTPRedirect.php (added) (history)
  • /trunk/extensions/HTTPRedirect/HTTPRedirect.php (added) (history)
  • /trunk/extensions/NopurgeRC (added) (history)
  • /trunk/extensions/NopurgeRC/NopurgeRC.php (added) (history)
  • /trunk/extensions/NopurgeRC/NopurgeRC.php (added) (history)
  • /trunk/extensions/Purge (added) (history)
  • /trunk/extensions/Purge.php (deleted) (history)
  • /trunk/extensions/Purge/Purge.php (added) (history)
  • /trunk/extensions/Purge/Purge.php (added) (history)
  • /trunk/extensions/Seealso (added) (history)
  • /trunk/extensions/Seealso/Seealso.php (added) (history)
  • /trunk/extensions/Seealso/Seealso.php (added) (history)
  • /trunk/extensions/SpecialTalk (added) (history)
  • /trunk/extensions/SpecialTalk/SpecialTalk.php (added) (history)
  • /trunk/extensions/SpecialTalk/SpecialTalk.php (added) (history)
  • /trunk/extensions/Special_talk.php (deleted) (history)
  • /trunk/extensions/StaticWiki (added) (history)
  • /trunk/extensions/StaticWiki/StaticWiki.php (added) (history)
  • /trunk/extensions/StaticWiki/StaticWiki.php (added) (history)
  • /trunk/extensions/Syslog (added) (history)
  • /trunk/extensions/Syslog.php (deleted) (history)
  • /trunk/extensions/Syslog/Syslog.php (added) (history)
  • /trunk/extensions/Syslog/Syslog.php (added) (history)
  • /trunk/extensions/Tidy.php (deleted) (history)
  • /trunk/extensions/TidyTab (added) (history)
  • /trunk/extensions/TidyTab/Tidy.php (added) (history)
  • /trunk/extensions/TidyTab/Tidy.php (added) (history)
  • /trunk/extensions/nopurgeRC.php (deleted) (history)
  • /trunk/extensions/seealso.php (deleted) (history)
  • /trunk/extensions/staticwiki.php (deleted) (history)

Diff [purge]

Index: trunk/extensions/HTTPRedirect.php
@@ -1,39 +0,0 @@
2 -<?php
3 -/**
4 - * An extension to make the wiki issue HTTP redirects rather than wiki redirects
5 - *
6 - * @author Ævar Arnfjörð Bjarmason <avarab@gmail.com>
7 - * @copyright Copyright © 2005, Ævar Arnfjörð Bjarmason
8 - * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later
9 - */
10 -
11 -$wgExtensionCredits['other'][] = array(
12 - 'name' => 'HTTP redirect',
13 - 'description' => 'A hook to make the wiki issue HTTP redirects rather than wiki redirects',
14 - 'author' => 'Ævar Arnfjörð Bjarmason',
15 -);
16 -
17 -function wfHTTPRedirect() {
18 - wfUsePHP( 5.0 );
19 - wfUseMW( '1.6alpha' );
20 -
21 - class HTTPRedirect {
22 - public function __construct() {
23 - global $wgHooks;
24 -
25 - $wgHooks['ArticleViewRedirect'][] = array( &$this, 'redirectHook' );
26 - }
27 -
28 -
29 - public static function redirectHook( Article &$article ) {
30 - global $wgOut;
31 -
32 - $wgOut->redirect( $article->mTitle->escapeFullURL(), 302 );
33 -
34 - return false;
35 - }
36 - }
37 -
38 - // Establish a singleton.
39 - new HTTPRedirect;
40 -}
Index: trunk/extensions/Tidy.php
@@ -1,84 +0,0 @@
2 -<?php
3 -/**
4 - * An extension that adds a tidy tab on each page
5 - *
6 - * @author Ævar Arnfjörð Bjarmason <avarab@gmail.com>
7 - * @copyright Copyright © 2005, Ævar Arnfjörð Bjarmason
8 - * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later
9 - */
10 -
11 -$wgExtensionFunctions[] = 'wfTidy';
12 -$wgExtensionCredits['other'][] = array(
13 - 'name' => 'Tidy',
14 - 'author' => 'Ævar Arnfjörð Bjarmason',
15 - 'description' => 'Adds a tidy or untidy tab (depending on $wgUseTidy) on normal pages allowing for overriding the global HTML tidy setting for a single view'
16 -);
17 -
18 -
19 -function wfTidy() {
20 - wfUsePHP( 5.1 );
21 - wfUseMW( '1.6alpha' );
22 -
23 - class TidyAction {
24 - public function __construct() {
25 - global $wgUseTidy, $wgMessageCache, $wgHooks;
26 -
27 - $wgMessageCache->addMessages(
28 - array(
29 - 'tidy' => 'Tidy',
30 - 'untidy' => 'Untidy',
31 - )
32 - );
33 -
34 - $wgHooks['SkinTemplateContentActions'][] = array( &$this, 'tidyHook' );
35 - $wgHooks['UnknownAction'][] = array( &$this, 'tidyAction' );
36 - }
37 -
38 - public function tidyHook( array &$content_actions ) {
39 - global $wgRequest, $wgUseTidy, $wgTitle;
40 -
41 - $action = $wgRequest->getText( 'action' );
42 -
43 - if ( $wgTitle->getNamespace() !== NS_SPECIAL )
44 - if ( $action === 'tidy' || $action === 'untidy' )
45 - self::setTidy( $content_actions, $action, $action === 'tidy' );
46 - else if ( $wgUseTidy )
47 - self::setTidy( $content_actions, $action, false );
48 - else
49 - self::setTidy( $content_actions, $action, true );
50 -
51 - return true;
52 - }
53 -
54 - private static function setTidy( array &$content_actions, $action, $tidy ) {
55 - global $wgTitle;
56 -
57 - if ( $tidy )
58 - $content_actions['tidy'] = array(
59 - 'class' => $action === 'tidy' ? 'selected' : false,
60 - 'text' => wfMsg( 'tidy' ),
61 - 'href' => $wgTitle->getLocalUrl( 'action=tidy' )
62 - );
63 - else
64 - $content_actions['untidy'] = array(
65 - 'class' => $action === 'untidy' ? 'selected' : false,
66 - 'text' => wfMsg( 'untidy' ),
67 - 'href' => $wgTitle->getLocalUrl( 'action=untidy' )
68 - );
69 - }
70 -
71 - public static function tidyAction( $action, Article &$article ) {
72 - global $wgUseTidy;
73 -
74 - if ( $action === 'tidy' || $action === 'untidy' )
75 - $wgUseTidy = $action === 'tidy';
76 -
77 - $article->purge();
78 -
79 - return false;
80 - }
81 - }
82 -
83 - // Establish a singleton.
84 - new TidyAction;
85 -}
Index: trunk/extensions/Autoincrement.php
@@ -1,54 +0,0 @@
2 -<?php
3 -if (!defined('MEDIAWIKI')) die();
4 -/**
5 - * An example parser hook that defines a new variable, {{AUTOINCREMENT}},
6 - * useful for maintaining a citation count with {{ref|}} and {{note|}} pairs
7 - *
8 - * @package MediaWiki
9 - * @subpackage Extensions
10 - *
11 - * @author Ævar Arnfjörð Bjarmason <avarab@gmail.com>
12 - * @copyright Copyright © 2005, Ævar Arnfjörð Bjarmason
13 - * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later
14 - */
15 -
16 -$wgExtensionCredits['variable'][] = array(
17 - 'name' => 'Autoincrement',
18 - 'description' => 'a variable hook that adds an autoincrementing variable, <nowiki>{{AUTOINCREMENT}}</nowiki>',
19 - 'author' => 'Ævar Arnfjörð Bjarmason'
20 -);
21 -
22 -class Autoincrement {
23 - var $mCount;
24 -
25 - function Autoincrement() {
26 - global $wgHooks;
27 -
28 - $this->mCount = 0;
29 -
30 - $wgHooks['MagicWordwgVariableIDs'][] = array( $this, 'wfAutoincrementHookVariables' );
31 - $wgHooks['LanguageGetMagic'][] = array( $this, 'wfAutoincrementHookRaw' );
32 - $wgHooks['ParserGetVariableValueSwitch'][] = array( $this, 'wfAutoincrementHookSwitch' );
33 - }
34 -
35 - function wfAutoincrementHookVariables( &$wgVariableIDs ) {
36 - $wgVariableIDs[] = 'autoincrement';
37 -
38 - return true;
39 - }
40 -
41 - function wfAutoincrementHookRaw( &$raw ) {
42 - $raw['autoincrement'] = array( 0, 'AUTOINCREMENT' );;
43 -
44 - return true;
45 - }
46 -
47 - function wfAutoincrementHookSwitch( &$parser, &$varCache, &$index, &$ret ) {
48 - if ( $index === 'autoincrement' )
49 - $ret = ++$this->mCount; // No formatNum() just like url autonumbering
50 -
51 - return true;
52 - }
53 -}
54 -
55 -new Autoincrement;
Index: trunk/extensions/Purge.php
@@ -1,55 +0,0 @@
2 -<?php
3 -/**
4 - * An extension that adds a purge tab on each page
5 - *
6 - * @author Ævar Arnfjörð Bjarmason <avarab@gmail.com>
7 - * @copyright Copyright © 2005, Ævar Arnfjörð Bjarmason
8 - * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later
9 - */
10 -
11 -$wgExtensionFunctions[] = 'wfPurge';
12 -$wgExtensionCredits['other'][] = array(
13 - 'name' => 'Purge',
14 - 'author' => 'Ævar Arnfjörð Bjarmason',
15 - 'description' => 'Adds a purge tab on all normal pages and bypasses the purge check for anonymous users allowing for quick purging of the cache'
16 -);
17 -
18 -
19 -function wfPurge() {
20 - wfUsePHP( 5.1 );
21 - wfUseMW( '1.6alpha' );
22 -
23 - class PurgeAction {
24 - public function __construct() {
25 - global $wgMessageCache, $wgHooks;
26 -
27 - $wgMessageCache->addMessage( 'purge', 'Purge' );
28 -
29 - $wgHooks['SkinTemplateContentActions'][] = array( &$this, 'contentHook' );
30 - $wgHooks['ArticlePurge'][] = array( &$this, 'purgeHook' );
31 - }
32 -
33 - public static function contentHook( array &$content_actions ) {
34 - global $wgRequest, $wgTitle;
35 -
36 - if ( $wgTitle->getNamespace() !== NS_SPECIAL ) {
37 - $action = $wgRequest->getText( 'action' );
38 -
39 - $content_actions['purge'] = array(
40 - 'class' => $action === 'purge' ? 'selected' : false,
41 - 'text' => wfMsg( 'purge' ),
42 - 'href' => $wgTitle->getLocalUrl( 'action=purge' )
43 - );
44 - }
45 -
46 - return true;
47 - }
48 -
49 - public static function purgeHook( Article &$article ) {
50 - return false;
51 - }
52 - }
53 -
54 - // Establish a singleton.
55 - new PurgeAction;
56 -}
Index: trunk/extensions/seealso.php
@@ -1,39 +0,0 @@
2 -<?php
3 -/*
4 -Usage :
5 -
6 -<seealso>
7 -Item1
8 -Item2|Text
9 -</seealso>
10 -
11 -Set system message "seealso" to head text, e.g., "See also"
12 -Set system message "seealso_local" to use a localized version, e.g., to "sieheauch"
13 -*/
14 -
15 -
16 -$wgExtensionFunctions[] = "wfSeealso";
17 -
18 -function wfSeealso () {
19 - global $wgParser ;
20 - $wgParser->setHook ( "seealso" , 'parse_seealso' ) ;
21 - $l = trim ( wfMsg ( "seealso_local" , "" ) ) ;
22 - if ( $l != "" )
23 - $wgParser->setHook ( $l , 'parse_seealso' ) ;
24 -}
25 -
26 -function parse_seealso ( $text, $params, &$parser ) {
27 - $a = explode ( "\n" , $text ) ;
28 - $ret = "== " . trim ( wfMsg ( "seealso" ) ) . " ==\n" ;
29 - foreach ( $a AS $x ) {
30 - $x = trim ( $x ) ;
31 - if ( $x == "" ) continue ;
32 - $ret .= "* [[" . $x . "]]\n" ;
33 - }
34 - $p = new Parser ;
35 - $ret = $p->parse ( $ret , $parser->mTitle , $parser->mOptions, false ) ;
36 - $ret = $ret->getText();
37 - return $ret ;
38 -}
39 -
40 -?>
Index: trunk/extensions/nopurgeRC.php
@@ -1,19 +0,0 @@
2 -<?php
3 -/**
4 - * An extension that prevents old recentchanges entries from being deleted
5 - *
6 - * @author Ævar Arnfjörð Bjarmason <avarab@gmail.com>
7 - * @copyright Copyright © 2005, Ævar Arnfjörð Bjarmason
8 - * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later
9 - */
10 -
11 -$wgHooks['ArticleEditUpdatesDeleteFromRecentchanges'][] = 'wfNopurgeRCHook';
12 -$wgExtensionCredits['other'][] = array(
13 - 'name' => 'NopurgeRC',
14 - 'description' => 'A hook that prevents old recentchanges entries from being deleted',
15 - 'author' => 'Ævar Arnfjörð Bjarmason',
16 -);
17 -
18 -function wfNopurgeRCHook() {
19 - return false;
20 -}
Index: trunk/extensions/Citation.php
@@ -1,107 +0,0 @@
2 -<?php
3 -# Example use :
4 -#
5 -# There is a <citation>author=Manske M ||title="The best paper ever" ||journal=''Biochemistry'' ||volume='''5''', 11</citation> citation here!
6 -
7 -
8 -$wgHooks['ParserBeforeTidy'][] = 'citation_hooker' ;
9 -$wgHooks['ParserClearState'][] = 'citation_clear_state';
10 -
11 -$wgExtensionFunctions[] = "wfCitation";
12 -
13 -function wfCitation () {
14 - global $wgParser ;
15 - $wgParser->setHook ( "citation" , 'parse_citation' ) ;
16 - $wgParser->isMainParser = true ;
17 -}
18 -
19 -$wgCitationCache = array () ;
20 -$wgCitationCounter = 1 ;
21 -$wgCitationRunning = false ;
22 -
23 -function citation_hooker ( $parser , $text ) {
24 - global $wgCitationCache , $wgCitationCounter , $wgCitationRunning ;
25 - if ( $wgCitationRunning ) return ;
26 - if ( count ( $wgCitationCache ) == 0 ) return ;
27 - if ( !isset ( $parser->isMainParser ) ) return ;
28 - $ret = "" ;
29 - foreach ( $wgCitationCache AS $num => $entry ) {
30 - $x = "<li>" . $entry . " <a href='#citeback{$num}'>&uarr;</a></li>\n" ;
31 - $ret .= $x ;
32 - }
33 - $ret = "<hr /><ol>" . $ret . "</ol>" ;
34 -
35 - $text .= $ret ;
36 -}
37 -
38 -function citation_clear_state() {
39 - global $wgCitationCache, $wgCitationCounter, $wgCitationRunning;
40 - $wgCitationCache = array () ;
41 - $wgCitationCounter = 1 ;
42 - $wgCitationRunning = false ;
43 -}
44 -
45 -function parse_citation ( $text , $params , $parser ) {
46 - global $wgCitationRunning ;
47 - if ( $wgCitationRunning ) return ;
48 - $ret = "" ;
49 - $attheend = false ;
50 - $res = array () ;
51 - $res2 = array () ;
52 - $href = "" ;
53 - $a = explode ( "||" , $text ) ;
54 -
55 - foreach ( $a AS $line ) {
56 - $data = explode ( "=" , $line , 2 ) ;
57 - while ( count ( $data ) < 2 ) $data[] = "" ;
58 - $key = urlencode ( trim ( strtolower ( array_shift ( $data ) ) ) ) ;
59 - $value = array_shift ( $data ) ;
60 -
61 - // Parsed now : "$key" = "$value"
62 - if ( substr ( $value , 0 , 3 ) == "{{{" ) {} // Unset variable, ignore
63 - else if ( $key == "attheend" ) $attheend = true ;
64 - else if ( $key == "href" ) $href = $value ;
65 - else if ( $value != "" ) {
66 - $x = array ( "key" => $key , "value" => $value ) ;
67 - $res[] = $x ;
68 - $res2[$key] = $value ;
69 - }
70 - }
71 -
72 - // Creating output string
73 - foreach ( $res AS $item ) {
74 - $key = $item["key"] ;
75 - $value = $item["value"] ;
76 - $key2 = urldecode ( $key ) ;
77 - if ( strtolower ( substr ( $key2 , 0 , 3 ) ) == "if:" ) {
78 - $key2 = trim ( substr ( $key2 , 3 ) ) ;
79 - $key = urlencode ( $key2 ) ;
80 - }
81 - if ( isset ( $res2[$key] ) ) $ret .= $value ;
82 - }
83 -
84 - if ( $href != "" ) $ret .= " [{$href}]" ;
85 -
86 - // Adding to footer list or showing inline
87 - $localParser = new Parser ;
88 - $wgCitationRunning = true ;
89 - $ret = $localParser->parse ( $ret , $parser->mTitle , $parser->mOptions, false ) ;
90 - $wgCitationRunning = false ;
91 - $ret = $ret->getText();
92 -
93 - if ( $attheend ) {
94 - global $wgCitationCache , $wgCitationCounter ;
95 - $ret = "<a name='citation{$wgCitationCounter}'></a>{$ret}" ;
96 - $wgCitationCache[$wgCitationCounter] = $ret ;
97 - $ret = "<a href='#citation{$wgCitationCounter}' name='citeback{$wgCitationCounter}'>{" . $wgCitationCounter . "}</a>" ;
98 - $wgCitationCounter++ ;
99 - } else {
100 - $ret = "<span style='font-size:8pt'>[{$ret}]</span>" ;
101 - }
102 -
103 - return $ret ;
104 -}
105 -
106 -
107 -
108 -?>
Index: trunk/extensions/Special_talk.php
@@ -1,54 +0,0 @@
2 -<?php
3 -if ( ! defined( 'MEDIAWIKI' ) ) die();
4 -/**
5 - * A hook that adds a talk tab to Special Pages
6 - *
7 - * @package MediaWiki
8 - * @subpackage Extensions
9 - *
10 - * @bug 4078
11 - *
12 - * @author Ævar Arnfjörð Bjarmason <avarab@gmail.com>
13 - * @copyright Copyright © 2005, Ævar Arnfjörð Bjarmason
14 - * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later
15 - */
16 -$wgExtensionFunctions[] = 'wfSpecialTalk';
17 -$wgExtensionCredits['other'][] = array(
18 - 'name' => 'Special talk',
19 - 'description' => 'Adds a talk tab to Special Pages',
20 - 'author' => 'Ævar Arnfjörð Bjarmason'
21 -);
22 -
23 -function wfSpecialTalk() {
24 - wfUsePHP( 5.1 );
25 - wfUseMW( '1.6alpha' );
26 -
27 - class SpecialTalk {
28 - public function __construct() {
29 - global $wgHooks;
30 -
31 - $wgHooks['SkinTemplateBuildContentActionUrlsAfterSpecialPage'][] = array( &$this, 'SpecialTalkHook' );
32 - }
33 -
34 - public function SpecialTalkHook( SkinTemplate &$skin_template, array &$content_actions ) {
35 - global $wgTitle;
36 -
37 - $title = Title::makeTitle( NS_PROJECT_TALK, $skin_template->mTitle->getText() );
38 -
39 - $content_actions['talk'] = $skin_template->tabAction(
40 - $title,
41 - // msg
42 - 'talk',
43 - // selected
44 - false,
45 - // &query=
46 - '',
47 - // check existance
48 - true
49 - );
50 - }
51 - }
52 -
53 - // Establish a singleton.
54 - new SpecialTalk;
55 -}
Index: trunk/extensions/ExtensionLoader.php
@@ -1,53 +0,0 @@
2 -<?php
3 -if ( ! defined( 'MEDIAWIKI' ) )
4 - die( -1 );
5 -/**
6 - * A small extension that makes it easy to load other extensions during
7 - * initialization, use it by adding this to LocalSettings.php (or equivalent)
8 - *
9 - * <code>
10 - * require_once '/path/to/extension/dir/extensions/ExtensionLoader.php';
11 - * </code>
12 - *
13 - * Then call it as:
14 - *
15 - * <code>
16 - * wfExtensionLoader(
17 - * 'Extension.php',
18 - * 'ExtensionDir/*php' // Everything in this directory (uses glob())
19 - * // ...
20 - * ) or die( "Failed to load" );
21 - * </code>
22 - *
23 - * @package MediaWiki
24 - * @subpackage Extensions
25 - *
26 - * @author Ævar Arnfjörð Bjarmason <avarab@gmail.com>
27 - * @copyright Copyright © 2006, Ævar Arnfjörð Bjarmason
28 - * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later
29 - */
30 -
31 -/**
32 - * @param string $x, ... A variable number of strings
33 - * @return bool True on success, False on failure
34 - */
35 -function wfExtensionLoader() {
36 - // Stuff might break without all of the globals
37 - extract( $GLOBALS, EXTR_REFS );
38 -
39 - $extensions = func_get_args();
40 -
41 - $dir = dirname( __FILE__ ) . DIRECTORY_SEPARATOR;
42 -
43 - $ret = true;
44 - foreach ( $extensions as $extension ) {
45 - $glob = glob( $dir . $extension );
46 - if ( count( $glob ) )
47 - foreach ( glob( $dir . $extension ) as $file )
48 - require_once $file;
49 - else
50 - $ret = false;
51 - }
52 -
53 - return $ret;
54 -}
Index: trunk/extensions/staticwiki.php
@@ -1,119 +0,0 @@
2 -<?php
3 -/*
4 -This extension will turn a MediaWiki installation into "import-only" mode, at least for the article namespace.
5 -
6 -CONFIGURATION:
7 -Set $wgStaticWikiExternalSite to the URL of the "target" wiki, like "http://.../w/". Do this AFTER the include in LocalSettings.php, otherwise en.wikipedia will become the default.
8 -Set $wgStaticWikiNamespaces as an array of namespace numbers to import. By default, namespaces 0 (main), 10 (templates), 14 (categories) are imported.
9 -*/
10 -
11 -# BEGIN CONFIGURATION
12 -
13 -$wgStaticWikiExternalSite = "http://en.wikipedia.org/w/" ; # Default, change in LocalSettings.php
14 -$wgStaticWikiNamespaces = array ( 0 , 10 , 14 ) ;
15 -
16 -# END CONFIGURATION
17 -
18 -if (!defined('MEDIAWIKI')) die();
19 -
20 -$wgHooks['AlternateEdit'][] = 'wfStaticEditHook' ;
21 -
22 -function wfStaticWikiGetRevisionText ( $url_title , $revision ) {
23 - global $wgStaticWikiExternalSite ;
24 - $url = $wgStaticWikiExternalSite . "index.php?title=" . $url_title . "&oldid=" . $revision . "&action=raw" ;
25 - $text = @file_get_contents ( $url ) ;
26 - return $text ;
27 - }
28 -
29 -function wfStaticEditHook ( $a ) {
30 - global $wgStaticWikiExternalSite , $wgStaticWikiNamespaces ;
31 - global $wgOut , $wgTitle , $wgRequest ;
32 -
33 - if ( !in_array ( $wgTitle->getNamespace() , $wgStaticWikiNamespaces ) ) return true ; # This article namespace is not imported => normal edit
34 -
35 - if ( ! $a->mTitle->userCanEdit() ) { # Only users that can edit may import as well
36 - wfDebug( "$fname: user can't edit\n" );
37 - $wgOut->readOnlyPage( $this->mArticle->getContent( true ), true );
38 - wfProfileOut( $fname );
39 - return true;
40 - }
41 -
42 - $url_title = $wgTitle->getPrefixedDBkey() ;
43 - $title = $wgTitle->getText () ;
44 - $wgOut->setPageTitle ( wfMsg( 'importing', $wgTitle->getPrefixedText() ) ) ;
45 -
46 - if ( $wgRequest->getVal( 'wpSection', $wgRequest->getVal( 'section' ) ) != '' ) {
47 - $wgOut->addHTML ( "<h2>No section importing, sorry!</h2>" ) ;
48 - return false ;
49 - }
50 -
51 - $do_import = $wgRequest->getText ( "importrevision" , "" ) ;
52 - if ( $do_import != "" ) {
53 - $a->textbox1 = wfStaticWikiGetRevisionText ( $url_title , $do_import ) ;
54 - $a->summary = "Import of revision " . $do_import ;
55 - $a->minoredit = false ;
56 - $a->edittime = $a->mArticle->getTimestamp() ;
57 - $a->attemptSave () ;
58 - return false ;
59 - }
60 -
61 - $pstyle = "style='border-bottom:1px solid black; font-size:12pt; font-weight:bold'" ;
62 -
63 - # Read list of latest revisions
64 - $side = "" ;
65 - $history = file_get_contents ( $wgStaticWikiExternalSite . "index.php?title=" . urlencode ( $url_title ) . "&action=history" ) ;
66 - $history = explode ( "<li>" , $history ) ;
67 - array_shift ( $history ) ;
68 - $match = "/w/index.php?title=" . str_replace ( "%3A" , ":" , urlencode ( $url_title ) ) . "&amp;oldid=" ;
69 - $revisions = array () ;
70 - foreach ( $history AS $line ) {
71 - $a = explode ( 'href="' , $line ) ;
72 - array_shift ( $a ) ;
73 - foreach ( $a AS $x ) {
74 - $y = explode ( '"' , $x ) ;
75 - $x = array_shift ( $y ) ;
76 - if ( substr ( $x , 0 , strlen ( $match ) ) != $match ) continue ;
77 - $x = substr ( $x , strlen ( $match ) ) ;
78 - $revisions[] = $x ;
79 - array_shift ( $y ) ;
80 - $y = implode ( '"' , $y ) ;
81 - $y = explode ( '>' , $y ) ;
82 - array_shift ( $y ) ;
83 - $y = implode ( ">" , $y ) ;
84 - $y = explode ( "<" , $y ) ;
85 - $y = trim ( array_shift ( $y ) ) ;
86 - $date[$x] = $y ;
87 - }
88 - }
89 -
90 - # Revision to view
91 - $show_revision = $wgRequest->getText ( "showrevision" , $revisions[0] ) ;
92 -
93 - # Generating list of links for the sidebar
94 - $side = "<p {$pstyle}>" . "The last " . count ( $revisions ) . " revisions" . "</p>\n" ;
95 - $side .= "<table cellspacing=0 cellpadding=2>" ;
96 - foreach ( $revisions AS $r ) {
97 - $link_title = ' title="#' . $r . " (" . $date[$r] . ')"' ;
98 - $l1 = '<a href="?title=' . $url_title . '&action=edit&showrevision=' . $r . '"' . $link_title . '>' . $date[$r] . '</a>' ;
99 - $l2 = '<a href="?title=' . $url_title . '&action=edit&importrevision=' . $r . '"' . $link_title . '>' . "Import" . '</a>' ;
100 - $l3 = '<a href="' . $wgStaticWikiExternalSite . 'index.php?title=' . $url_title . '&oldid=' . $r . '"' . $link_title . '>' . "Original" . '</a>' ;
101 - $s = "<td align='right'>" . $l1 . "</td><td>" . $l2 . "</td><td>" . $l3 . "</td>\n" ;
102 - if ( $r == $show_revision ) $s = "<tr style='background-color:#DDDDDD'>{$s}</tr>" ;
103 - else $s = "<tr>{$s}</tr>" ;
104 - $side .= $s ;
105 - }
106 - $side .= "</table>" ;
107 -
108 - # Retrieving source text for the revision
109 - $text = wfStaticWikiGetRevisionText ( $url_title , $show_revision ) ;
110 -
111 - # Output
112 - $wgOut->addHTML ( "<table width='100%'><tr><td style='border-right:1px solid black' valign='top' width='100%'>" ) ;
113 - $wgOut->addHTML ( "<p {$pstyle}>Revision #" . $show_revision . " at " . $date[$show_revision] . " of <i>" . $wgTitle->getPrefixedText() . "</i></p>\n" ) ;
114 - $wgOut->addWikiText ( $text ) ;
115 - $wgOut->addHTML ( "</td><td nowrap valign='top'>" . $side . "</td></tr></table>" ) ;
116 - return false ;
117 -}
118 -
119 -
120 -?>
Index: trunk/extensions/Syslog.php
@@ -1,136 +0,0 @@
2 -<?php
3 -/* Syslog.php -- an extension to log events to the system logger
4 - * Copyright 2004 Evan Prodromou <evan@wikitravel.org>
5 - *
6 - * This program is free software; you can redistribute it and/or modify
7 - * it under the terms of the GNU General Public License as published by
8 - * the Free Software Foundation; either version 2 of the License, or
9 - * (at your option) any later version.
10 - *
11 - * This program is distributed in the hope that it will be useful,
12 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 - * GNU General Public License for more details.
15 - *
16 - * You should have received a copy of the GNU General Public License
17 - * along with this program; if not, write to the Free Software
18 - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 - *
20 - * @author Evan Prodromou <evan@wikitravel.org>
21 - * @package MediaWiki
22 - * @subpackage Extensions
23 - */
24 -
25 -if (defined('MEDIAWIKI')) {
26 -
27 - # Setup globals
28 -
29 - if (!isset($wgSyslogIdentity)) {
30 - $wgSyslogIdentity = $wgDBname;
31 - }
32 - if (!isset($wgSyslogFacility)) {
33 - $wgSyslogFacility = LOG_USER;
34 - }
35 -
36 - # Hook for article protection
37 -
38 - function syslogArticleProtect(&$article, &$user, $protect, &$reason, &$moveonly) {
39 - $title = $article->mTitle;
40 - syslog(LOG_NOTICE, "User '" . $user->getName() . "' " .
41 - (($protect) ? "protected" : "unprotected") . " article '" .
42 - $title->getPrefixedText() .
43 - "' for '" . $reason . "' " . (($moveonly) ? "(moves only)" : "") );
44 - return true;
45 - }
46 -
47 - # Hook for article deletion
48 -
49 - function syslogArticleDelete(&$article, &$user, &$reason) {
50 - $title = $article->mTitle;
51 - syslog(LOG_NOTICE, "User '" . $user->getName() . "' deleted '" .
52 - $title->getPrefixedText() .
53 - "' for '" . $reason . "' ");
54 - return true;
55 - }
56 -
57 - # Hook for article save
58 -
59 - function syslogArticleSave(&$article, &$user, &$text, $summary,
60 - $isminor, $iswatch, $section)
61 - {
62 - $title = $article->mTitle;
63 - syslog(LOG_NOTICE, "User '" . $user->getName() . "' saved '" .
64 - $title->getPrefixedText() .
65 - "' with comment '" . $summary . "' ");
66 - return true;
67 - }
68 -
69 - # Hook for IP & user blocks
70 -
71 - function syslogBlockIp(&$block, &$user) {
72 - syslog(LOG_NOTICE, "User '" . $user->getName() .
73 - "' blocked '" . (($block->mUser) ? $block->mUser : $block->mAddress) .
74 - "' for '" . $block->mReason . "' until '" . $block->mExpiry . "'");
75 - return true;
76 - }
77 -
78 - function syslogEmailUser(&$to, &$from, &$subject, &$text) {
79 - syslog(LOG_INFO, "Email sent from '$from' to '$to' with subject '$subject'");
80 - }
81 -
82 - # Hook for unwatch
83 -
84 - function syslogUnwatch(&$user, &$article) {
85 - syslog(LOG_INFO, "User '" . $user->getName() . "' stopped watching '" .
86 - $article->mTitle->getPrefixedText() . "'");
87 - }
88 -
89 - # Hook for login
90 -
91 - function syslogUserLogin(&$user) {
92 - syslog(LOG_INFO, "User '" . $user->getName() . "' logged in");
93 - return true;
94 - }
95 -
96 - # Hook for logout
97 -
98 - function syslogUserLogout(&$user) {
99 - syslog(LOG_INFO, "User '" . $user->getName() . "' logged out");
100 - return true;
101 - }
102 -
103 - # Hook for watch
104 -
105 - function syslogWatch(&$user, &$article) {
106 - syslog(LOG_INFO, "User '" . $user->getName() . "' started watching '" .
107 - $article->mTitle->getPrefixedText() . "'");
108 - }
109 -
110 - # Setup -- called once environment is configured
111 -
112 - function setupSyslog() {
113 -
114 - global $wgSyslogIdentity, $wgSyslogFacility, $_syslogId;
115 - global $wgHooks;
116 -
117 - openlog($wgSyslogIdentity, LOG_ODELAY | LOG_PID, $wgSyslogFacility);
118 -
119 - $wgHooks['UserLoginComplete'][] = 'syslogUserLogin';
120 - $wgHooks['UserLogout'][] = 'syslogUserLogout';
121 - $wgHooks['BlockIpComplete'][] = 'syslogBlockIp';
122 - $wgHooks['ArticleProtectComplete'][] = 'syslogArticleProtect';
123 - $wgHooks['ArticleDeleteComplete'][] = 'syslogArticleDelete';
124 - $wgHooks['ArticleSaveComplete'][] = 'syslogArticleSave';
125 - $wgHooks['EmailUserComplete'][] = 'syslogEmailUser';
126 - $wgHooks['WatchArticleComplete'][] = 'syslogWatch';
127 - $wgHooks['UnwatchArticleComplete'][] = 'syslogUnwatch';
128 -
129 - return true;
130 - }
131 -
132 - # Add to global list of extensions
133 -
134 - $wgExtensionFunctions[] = 'setupSyslog';
135 -}
136 -
137 -?>
Index: trunk/extensions/Seealso/Seealso.php
@@ -0,0 +1,39 @@
 2+<?php
 3+/*
 4+Usage :
 5+
 6+<seealso>
 7+Item1
 8+Item2|Text
 9+</seealso>
 10+
 11+Set system message "seealso" to head text, e.g., "See also"
 12+Set system message "seealso_local" to use a localized version, e.g., to "sieheauch"
 13+*/
 14+
 15+
 16+$wgExtensionFunctions[] = "wfSeealso";
 17+
 18+function wfSeealso () {
 19+ global $wgParser ;
 20+ $wgParser->setHook ( "seealso" , 'parse_seealso' ) ;
 21+ $l = trim ( wfMsg ( "seealso_local" , "" ) ) ;
 22+ if ( $l != "" )
 23+ $wgParser->setHook ( $l , 'parse_seealso' ) ;
 24+}
 25+
 26+function parse_seealso ( $text, $params, &$parser ) {
 27+ $a = explode ( "\n" , $text ) ;
 28+ $ret = "== " . trim ( wfMsg ( "seealso" ) ) . " ==\n" ;
 29+ foreach ( $a AS $x ) {
 30+ $x = trim ( $x ) ;
 31+ if ( $x == "" ) continue ;
 32+ $ret .= "* [[" . $x . "]]\n" ;
 33+ }
 34+ $p = new Parser ;
 35+ $ret = $p->parse ( $ret , $parser->mTitle , $parser->mOptions, false ) ;
 36+ $ret = $ret->getText();
 37+ return $ret ;
 38+}
 39+
 40+?>
Property changes on: trunk/extensions/Seealso/Seealso.php
___________________________________________________________________
Added: svn:keywords
141 + Author Date Id Revision
Added: svn:eol-style
242 + native
Index: trunk/extensions/HTTPRedirect/HTTPRedirect.php
@@ -0,0 +1,39 @@
 2+<?php
 3+/**
 4+ * An extension to make the wiki issue HTTP redirects rather than wiki redirects
 5+ *
 6+ * @author Ævar Arnfjörð Bjarmason <avarab@gmail.com>
 7+ * @copyright Copyright © 2005, Ævar Arnfjörð Bjarmason
 8+ * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later
 9+ */
 10+
 11+$wgExtensionCredits['other'][] = array(
 12+ 'name' => 'HTTP redirect',
 13+ 'description' => 'A hook to make the wiki issue HTTP redirects rather than wiki redirects',
 14+ 'author' => 'Ævar Arnfjörð Bjarmason',
 15+);
 16+
 17+function wfHTTPRedirect() {
 18+ wfUsePHP( 5.0 );
 19+ wfUseMW( '1.6alpha' );
 20+
 21+ class HTTPRedirect {
 22+ public function __construct() {
 23+ global $wgHooks;
 24+
 25+ $wgHooks['ArticleViewRedirect'][] = array( &$this, 'redirectHook' );
 26+ }
 27+
 28+
 29+ public static function redirectHook( Article &$article ) {
 30+ global $wgOut;
 31+
 32+ $wgOut->redirect( $article->mTitle->escapeFullURL(), 302 );
 33+
 34+ return false;
 35+ }
 36+ }
 37+
 38+ // Establish a singleton.
 39+ new HTTPRedirect;
 40+}
Property changes on: trunk/extensions/HTTPRedirect/HTTPRedirect.php
___________________________________________________________________
Added: svn:keywords
141 + Author Date Id Revision
Added: svn:eol-style
242 + native
Index: trunk/extensions/Purge/Purge.php
@@ -0,0 +1,55 @@
 2+<?php
 3+/**
 4+ * An extension that adds a purge tab on each page
 5+ *
 6+ * @author Ævar Arnfjörð Bjarmason <avarab@gmail.com>
 7+ * @copyright Copyright © 2005, Ævar Arnfjörð Bjarmason
 8+ * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later
 9+ */
 10+
 11+$wgExtensionFunctions[] = 'wfPurge';
 12+$wgExtensionCredits['other'][] = array(
 13+ 'name' => 'Purge',
 14+ 'author' => 'Ævar Arnfjörð Bjarmason',
 15+ 'description' => 'Adds a purge tab on all normal pages and bypasses the purge check for anonymous users allowing for quick purging of the cache'
 16+);
 17+
 18+
 19+function wfPurge() {
 20+ wfUsePHP( 5.1 );
 21+ wfUseMW( '1.6alpha' );
 22+
 23+ class PurgeAction {
 24+ public function __construct() {
 25+ global $wgMessageCache, $wgHooks;
 26+
 27+ $wgMessageCache->addMessage( 'purge', 'Purge' );
 28+
 29+ $wgHooks['SkinTemplateContentActions'][] = array( &$this, 'contentHook' );
 30+ $wgHooks['ArticlePurge'][] = array( &$this, 'purgeHook' );
 31+ }
 32+
 33+ public static function contentHook( array &$content_actions ) {
 34+ global $wgRequest, $wgTitle;
 35+
 36+ if ( $wgTitle->getNamespace() !== NS_SPECIAL ) {
 37+ $action = $wgRequest->getText( 'action' );
 38+
 39+ $content_actions['purge'] = array(
 40+ 'class' => $action === 'purge' ? 'selected' : false,
 41+ 'text' => wfMsg( 'purge' ),
 42+ 'href' => $wgTitle->getLocalUrl( 'action=purge' )
 43+ );
 44+ }
 45+
 46+ return true;
 47+ }
 48+
 49+ public static function purgeHook( Article &$article ) {
 50+ return false;
 51+ }
 52+ }
 53+
 54+ // Establish a singleton.
 55+ new PurgeAction;
 56+}
Property changes on: trunk/extensions/Purge/Purge.php
___________________________________________________________________
Added: svn:keywords
157 + Author Date Id Revision
Added: svn:eol-style
258 + native
Index: trunk/extensions/TidyTab/Tidy.php
@@ -0,0 +1,84 @@
 2+<?php
 3+/**
 4+ * An extension that adds a tidy tab on each page
 5+ *
 6+ * @author Ævar Arnfjörð Bjarmason <avarab@gmail.com>
 7+ * @copyright Copyright © 2005, Ævar Arnfjörð Bjarmason
 8+ * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later
 9+ */
 10+
 11+$wgExtensionFunctions[] = 'wfTidy';
 12+$wgExtensionCredits['other'][] = array(
 13+ 'name' => 'Tidy',
 14+ 'author' => 'Ævar Arnfjörð Bjarmason',
 15+ 'description' => 'Adds a tidy or untidy tab (depending on $wgUseTidy) on normal pages allowing for overriding the global HTML tidy setting for a single view'
 16+);
 17+
 18+
 19+function wfTidy() {
 20+ wfUsePHP( 5.1 );
 21+ wfUseMW( '1.6alpha' );
 22+
 23+ class TidyAction {
 24+ public function __construct() {
 25+ global $wgUseTidy, $wgMessageCache, $wgHooks;
 26+
 27+ $wgMessageCache->addMessages(
 28+ array(
 29+ 'tidy' => 'Tidy',
 30+ 'untidy' => 'Untidy',
 31+ )
 32+ );
 33+
 34+ $wgHooks['SkinTemplateContentActions'][] = array( &$this, 'tidyHook' );
 35+ $wgHooks['UnknownAction'][] = array( &$this, 'tidyAction' );
 36+ }
 37+
 38+ public function tidyHook( array &$content_actions ) {
 39+ global $wgRequest, $wgUseTidy, $wgTitle;
 40+
 41+ $action = $wgRequest->getText( 'action' );
 42+
 43+ if ( $wgTitle->getNamespace() !== NS_SPECIAL )
 44+ if ( $action === 'tidy' || $action === 'untidy' )
 45+ self::setTidy( $content_actions, $action, $action === 'tidy' );
 46+ else if ( $wgUseTidy )
 47+ self::setTidy( $content_actions, $action, false );
 48+ else
 49+ self::setTidy( $content_actions, $action, true );
 50+
 51+ return true;
 52+ }
 53+
 54+ private static function setTidy( array &$content_actions, $action, $tidy ) {
 55+ global $wgTitle;
 56+
 57+ if ( $tidy )
 58+ $content_actions['tidy'] = array(
 59+ 'class' => $action === 'tidy' ? 'selected' : false,
 60+ 'text' => wfMsg( 'tidy' ),
 61+ 'href' => $wgTitle->getLocalUrl( 'action=tidy' )
 62+ );
 63+ else
 64+ $content_actions['untidy'] = array(
 65+ 'class' => $action === 'untidy' ? 'selected' : false,
 66+ 'text' => wfMsg( 'untidy' ),
 67+ 'href' => $wgTitle->getLocalUrl( 'action=untidy' )
 68+ );
 69+ }
 70+
 71+ public static function tidyAction( $action, Article &$article ) {
 72+ global $wgUseTidy;
 73+
 74+ if ( $action === 'tidy' || $action === 'untidy' )
 75+ $wgUseTidy = $action === 'tidy';
 76+
 77+ $article->purge();
 78+
 79+ return false;
 80+ }
 81+ }
 82+
 83+ // Establish a singleton.
 84+ new TidyAction;
 85+}
Property changes on: trunk/extensions/TidyTab/Tidy.php
___________________________________________________________________
Added: svn:keywords
186 + Author Date Id Revision
Added: svn:eol-style
287 + native
Index: trunk/extensions/StaticWiki/StaticWiki.php
@@ -0,0 +1,119 @@
 2+<?php
 3+/*
 4+This extension will turn a MediaWiki installation into "import-only" mode, at least for the article namespace.
 5+
 6+CONFIGURATION:
 7+Set $wgStaticWikiExternalSite to the URL of the "target" wiki, like "http://.../w/". Do this AFTER the include in LocalSettings.php, otherwise en.wikipedia will become the default.
 8+Set $wgStaticWikiNamespaces as an array of namespace numbers to import. By default, namespaces 0 (main), 10 (templates), 14 (categories) are imported.
 9+*/
 10+
 11+# BEGIN CONFIGURATION
 12+
 13+$wgStaticWikiExternalSite = "http://en.wikipedia.org/w/" ; # Default, change in LocalSettings.php
 14+$wgStaticWikiNamespaces = array ( 0 , 10 , 14 ) ;
 15+
 16+# END CONFIGURATION
 17+
 18+if (!defined('MEDIAWIKI')) die();
 19+
 20+$wgHooks['AlternateEdit'][] = 'wfStaticEditHook' ;
 21+
 22+function wfStaticWikiGetRevisionText ( $url_title , $revision ) {
 23+ global $wgStaticWikiExternalSite ;
 24+ $url = $wgStaticWikiExternalSite . "index.php?title=" . $url_title . "&oldid=" . $revision . "&action=raw" ;
 25+ $text = @file_get_contents ( $url ) ;
 26+ return $text ;
 27+ }
 28+
 29+function wfStaticEditHook ( $a ) {
 30+ global $wgStaticWikiExternalSite , $wgStaticWikiNamespaces ;
 31+ global $wgOut , $wgTitle , $wgRequest ;
 32+
 33+ if ( !in_array ( $wgTitle->getNamespace() , $wgStaticWikiNamespaces ) ) return true ; # This article namespace is not imported => normal edit
 34+
 35+ if ( ! $a->mTitle->userCanEdit() ) { # Only users that can edit may import as well
 36+ wfDebug( "$fname: user can't edit\n" );
 37+ $wgOut->readOnlyPage( $this->mArticle->getContent( true ), true );
 38+ wfProfileOut( $fname );
 39+ return true;
 40+ }
 41+
 42+ $url_title = $wgTitle->getPrefixedDBkey() ;
 43+ $title = $wgTitle->getText () ;
 44+ $wgOut->setPageTitle ( wfMsg( 'importing', $wgTitle->getPrefixedText() ) ) ;
 45+
 46+ if ( $wgRequest->getVal( 'wpSection', $wgRequest->getVal( 'section' ) ) != '' ) {
 47+ $wgOut->addHTML ( "<h2>No section importing, sorry!</h2>" ) ;
 48+ return false ;
 49+ }
 50+
 51+ $do_import = $wgRequest->getText ( "importrevision" , "" ) ;
 52+ if ( $do_import != "" ) {
 53+ $a->textbox1 = wfStaticWikiGetRevisionText ( $url_title , $do_import ) ;
 54+ $a->summary = "Import of revision " . $do_import ;
 55+ $a->minoredit = false ;
 56+ $a->edittime = $a->mArticle->getTimestamp() ;
 57+ $a->attemptSave () ;
 58+ return false ;
 59+ }
 60+
 61+ $pstyle = "style='border-bottom:1px solid black; font-size:12pt; font-weight:bold'" ;
 62+
 63+ # Read list of latest revisions
 64+ $side = "" ;
 65+ $history = file_get_contents ( $wgStaticWikiExternalSite . "index.php?title=" . urlencode ( $url_title ) . "&action=history" ) ;
 66+ $history = explode ( "<li>" , $history ) ;
 67+ array_shift ( $history ) ;
 68+ $match = "/w/index.php?title=" . str_replace ( "%3A" , ":" , urlencode ( $url_title ) ) . "&amp;oldid=" ;
 69+ $revisions = array () ;
 70+ foreach ( $history AS $line ) {
 71+ $a = explode ( 'href="' , $line ) ;
 72+ array_shift ( $a ) ;
 73+ foreach ( $a AS $x ) {
 74+ $y = explode ( '"' , $x ) ;
 75+ $x = array_shift ( $y ) ;
 76+ if ( substr ( $x , 0 , strlen ( $match ) ) != $match ) continue ;
 77+ $x = substr ( $x , strlen ( $match ) ) ;
 78+ $revisions[] = $x ;
 79+ array_shift ( $y ) ;
 80+ $y = implode ( '"' , $y ) ;
 81+ $y = explode ( '>' , $y ) ;
 82+ array_shift ( $y ) ;
 83+ $y = implode ( ">" , $y ) ;
 84+ $y = explode ( "<" , $y ) ;
 85+ $y = trim ( array_shift ( $y ) ) ;
 86+ $date[$x] = $y ;
 87+ }
 88+ }
 89+
 90+ # Revision to view
 91+ $show_revision = $wgRequest->getText ( "showrevision" , $revisions[0] ) ;
 92+
 93+ # Generating list of links for the sidebar
 94+ $side = "<p {$pstyle}>" . "The last " . count ( $revisions ) . " revisions" . "</p>\n" ;
 95+ $side .= "<table cellspacing=0 cellpadding=2>" ;
 96+ foreach ( $revisions AS $r ) {
 97+ $link_title = ' title="#' . $r . " (" . $date[$r] . ')"' ;
 98+ $l1 = '<a href="?title=' . $url_title . '&action=edit&showrevision=' . $r . '"' . $link_title . '>' . $date[$r] . '</a>' ;
 99+ $l2 = '<a href="?title=' . $url_title . '&action=edit&importrevision=' . $r . '"' . $link_title . '>' . "Import" . '</a>' ;
 100+ $l3 = '<a href="' . $wgStaticWikiExternalSite . 'index.php?title=' . $url_title . '&oldid=' . $r . '"' . $link_title . '>' . "Original" . '</a>' ;
 101+ $s = "<td align='right'>" . $l1 . "</td><td>" . $l2 . "</td><td>" . $l3 . "</td>\n" ;
 102+ if ( $r == $show_revision ) $s = "<tr style='background-color:#DDDDDD'>{$s}</tr>" ;
 103+ else $s = "<tr>{$s}</tr>" ;
 104+ $side .= $s ;
 105+ }
 106+ $side .= "</table>" ;
 107+
 108+ # Retrieving source text for the revision
 109+ $text = wfStaticWikiGetRevisionText ( $url_title , $show_revision ) ;
 110+
 111+ # Output
 112+ $wgOut->addHTML ( "<table width='100%'><tr><td style='border-right:1px solid black' valign='top' width='100%'>" ) ;
 113+ $wgOut->addHTML ( "<p {$pstyle}>Revision #" . $show_revision . " at " . $date[$show_revision] . " of <i>" . $wgTitle->getPrefixedText() . "</i></p>\n" ) ;
 114+ $wgOut->addWikiText ( $text ) ;
 115+ $wgOut->addHTML ( "</td><td nowrap valign='top'>" . $side . "</td></tr></table>" ) ;
 116+ return false ;
 117+}
 118+
 119+
 120+?>
Property changes on: trunk/extensions/StaticWiki/StaticWiki.php
___________________________________________________________________
Added: svn:keywords
1121 + Author Date Id Revision
Added: svn:eol-style
2122 + native
Index: trunk/extensions/Citation/Citation.php
@@ -0,0 +1,107 @@
 2+<?php
 3+# Example use :
 4+#
 5+# There is a <citation>author=Manske M ||title="The best paper ever" ||journal=''Biochemistry'' ||volume='''5''', 11</citation> citation here!
 6+
 7+
 8+$wgHooks['ParserBeforeTidy'][] = 'citation_hooker' ;
 9+$wgHooks['ParserClearState'][] = 'citation_clear_state';
 10+
 11+$wgExtensionFunctions[] = "wfCitation";
 12+
 13+function wfCitation () {
 14+ global $wgParser ;
 15+ $wgParser->setHook ( "citation" , 'parse_citation' ) ;
 16+ $wgParser->isMainParser = true ;
 17+}
 18+
 19+$wgCitationCache = array () ;
 20+$wgCitationCounter = 1 ;
 21+$wgCitationRunning = false ;
 22+
 23+function citation_hooker ( $parser , $text ) {
 24+ global $wgCitationCache , $wgCitationCounter , $wgCitationRunning ;
 25+ if ( $wgCitationRunning ) return ;
 26+ if ( count ( $wgCitationCache ) == 0 ) return ;
 27+ if ( !isset ( $parser->isMainParser ) ) return ;
 28+ $ret = "" ;
 29+ foreach ( $wgCitationCache AS $num => $entry ) {
 30+ $x = "<li>" . $entry . " <a href='#citeback{$num}'>&uarr;</a></li>\n" ;
 31+ $ret .= $x ;
 32+ }
 33+ $ret = "<hr /><ol>" . $ret . "</ol>" ;
 34+
 35+ $text .= $ret ;
 36+}
 37+
 38+function citation_clear_state() {
 39+ global $wgCitationCache, $wgCitationCounter, $wgCitationRunning;
 40+ $wgCitationCache = array () ;
 41+ $wgCitationCounter = 1 ;
 42+ $wgCitationRunning = false ;
 43+}
 44+
 45+function parse_citation ( $text , $params , $parser ) {
 46+ global $wgCitationRunning ;
 47+ if ( $wgCitationRunning ) return ;
 48+ $ret = "" ;
 49+ $attheend = false ;
 50+ $res = array () ;
 51+ $res2 = array () ;
 52+ $href = "" ;
 53+ $a = explode ( "||" , $text ) ;
 54+
 55+ foreach ( $a AS $line ) {
 56+ $data = explode ( "=" , $line , 2 ) ;
 57+ while ( count ( $data ) < 2 ) $data[] = "" ;
 58+ $key = urlencode ( trim ( strtolower ( array_shift ( $data ) ) ) ) ;
 59+ $value = array_shift ( $data ) ;
 60+
 61+ // Parsed now : "$key" = "$value"
 62+ if ( substr ( $value , 0 , 3 ) == "{{{" ) {} // Unset variable, ignore
 63+ else if ( $key == "attheend" ) $attheend = true ;
 64+ else if ( $key == "href" ) $href = $value ;
 65+ else if ( $value != "" ) {
 66+ $x = array ( "key" => $key , "value" => $value ) ;
 67+ $res[] = $x ;
 68+ $res2[$key] = $value ;
 69+ }
 70+ }
 71+
 72+ // Creating output string
 73+ foreach ( $res AS $item ) {
 74+ $key = $item["key"] ;
 75+ $value = $item["value"] ;
 76+ $key2 = urldecode ( $key ) ;
 77+ if ( strtolower ( substr ( $key2 , 0 , 3 ) ) == "if:" ) {
 78+ $key2 = trim ( substr ( $key2 , 3 ) ) ;
 79+ $key = urlencode ( $key2 ) ;
 80+ }
 81+ if ( isset ( $res2[$key] ) ) $ret .= $value ;
 82+ }
 83+
 84+ if ( $href != "" ) $ret .= " [{$href}]" ;
 85+
 86+ // Adding to footer list or showing inline
 87+ $localParser = new Parser ;
 88+ $wgCitationRunning = true ;
 89+ $ret = $localParser->parse ( $ret , $parser->mTitle , $parser->mOptions, false ) ;
 90+ $wgCitationRunning = false ;
 91+ $ret = $ret->getText();
 92+
 93+ if ( $attheend ) {
 94+ global $wgCitationCache , $wgCitationCounter ;
 95+ $ret = "<a name='citation{$wgCitationCounter}'></a>{$ret}" ;
 96+ $wgCitationCache[$wgCitationCounter] = $ret ;
 97+ $ret = "<a href='#citation{$wgCitationCounter}' name='citeback{$wgCitationCounter}'>{" . $wgCitationCounter . "}</a>" ;
 98+ $wgCitationCounter++ ;
 99+ } else {
 100+ $ret = "<span style='font-size:8pt'>[{$ret}]</span>" ;
 101+ }
 102+
 103+ return $ret ;
 104+}
 105+
 106+
 107+
 108+?>
Property changes on: trunk/extensions/Citation/Citation.php
___________________________________________________________________
Added: svn:keywords
1109 + Author Date Id Revision
Added: svn:eol-style
2110 + native
Index: trunk/extensions/Syslog/Syslog.php
@@ -0,0 +1,136 @@
 2+<?php
 3+/* Syslog.php -- an extension to log events to the system logger
 4+ * Copyright 2004 Evan Prodromou <evan@wikitravel.org>
 5+ *
 6+ * This program is free software; you can redistribute it and/or modify
 7+ * it under the terms of the GNU General Public License as published by
 8+ * the Free Software Foundation; either version 2 of the License, or
 9+ * (at your option) any later version.
 10+ *
 11+ * This program is distributed in the hope that it will be useful,
 12+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
 13+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 14+ * GNU General Public License for more details.
 15+ *
 16+ * You should have received a copy of the GNU General Public License
 17+ * along with this program; if not, write to the Free Software
 18+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 19+ *
 20+ * @author Evan Prodromou <evan@wikitravel.org>
 21+ * @package MediaWiki
 22+ * @subpackage Extensions
 23+ */
 24+
 25+if (defined('MEDIAWIKI')) {
 26+
 27+ # Setup globals
 28+
 29+ if (!isset($wgSyslogIdentity)) {
 30+ $wgSyslogIdentity = $wgDBname;
 31+ }
 32+ if (!isset($wgSyslogFacility)) {
 33+ $wgSyslogFacility = LOG_USER;
 34+ }
 35+
 36+ # Hook for article protection
 37+
 38+ function syslogArticleProtect(&$article, &$user, $protect, &$reason, &$moveonly) {
 39+ $title = $article->mTitle;
 40+ syslog(LOG_NOTICE, "User '" . $user->getName() . "' " .
 41+ (($protect) ? "protected" : "unprotected") . " article '" .
 42+ $title->getPrefixedText() .
 43+ "' for '" . $reason . "' " . (($moveonly) ? "(moves only)" : "") );
 44+ return true;
 45+ }
 46+
 47+ # Hook for article deletion
 48+
 49+ function syslogArticleDelete(&$article, &$user, &$reason) {
 50+ $title = $article->mTitle;
 51+ syslog(LOG_NOTICE, "User '" . $user->getName() . "' deleted '" .
 52+ $title->getPrefixedText() .
 53+ "' for '" . $reason . "' ");
 54+ return true;
 55+ }
 56+
 57+ # Hook for article save
 58+
 59+ function syslogArticleSave(&$article, &$user, &$text, $summary,
 60+ $isminor, $iswatch, $section)
 61+ {
 62+ $title = $article->mTitle;
 63+ syslog(LOG_NOTICE, "User '" . $user->getName() . "' saved '" .
 64+ $title->getPrefixedText() .
 65+ "' with comment '" . $summary . "' ");
 66+ return true;
 67+ }
 68+
 69+ # Hook for IP & user blocks
 70+
 71+ function syslogBlockIp(&$block, &$user) {
 72+ syslog(LOG_NOTICE, "User '" . $user->getName() .
 73+ "' blocked '" . (($block->mUser) ? $block->mUser : $block->mAddress) .
 74+ "' for '" . $block->mReason . "' until '" . $block->mExpiry . "'");
 75+ return true;
 76+ }
 77+
 78+ function syslogEmailUser(&$to, &$from, &$subject, &$text) {
 79+ syslog(LOG_INFO, "Email sent from '$from' to '$to' with subject '$subject'");
 80+ }
 81+
 82+ # Hook for unwatch
 83+
 84+ function syslogUnwatch(&$user, &$article) {
 85+ syslog(LOG_INFO, "User '" . $user->getName() . "' stopped watching '" .
 86+ $article->mTitle->getPrefixedText() . "'");
 87+ }
 88+
 89+ # Hook for login
 90+
 91+ function syslogUserLogin(&$user) {
 92+ syslog(LOG_INFO, "User '" . $user->getName() . "' logged in");
 93+ return true;
 94+ }
 95+
 96+ # Hook for logout
 97+
 98+ function syslogUserLogout(&$user) {
 99+ syslog(LOG_INFO, "User '" . $user->getName() . "' logged out");
 100+ return true;
 101+ }
 102+
 103+ # Hook for watch
 104+
 105+ function syslogWatch(&$user, &$article) {
 106+ syslog(LOG_INFO, "User '" . $user->getName() . "' started watching '" .
 107+ $article->mTitle->getPrefixedText() . "'");
 108+ }
 109+
 110+ # Setup -- called once environment is configured
 111+
 112+ function setupSyslog() {
 113+
 114+ global $wgSyslogIdentity, $wgSyslogFacility, $_syslogId;
 115+ global $wgHooks;
 116+
 117+ openlog($wgSyslogIdentity, LOG_ODELAY | LOG_PID, $wgSyslogFacility);
 118+
 119+ $wgHooks['UserLoginComplete'][] = 'syslogUserLogin';
 120+ $wgHooks['UserLogout'][] = 'syslogUserLogout';
 121+ $wgHooks['BlockIpComplete'][] = 'syslogBlockIp';
 122+ $wgHooks['ArticleProtectComplete'][] = 'syslogArticleProtect';
 123+ $wgHooks['ArticleDeleteComplete'][] = 'syslogArticleDelete';
 124+ $wgHooks['ArticleSaveComplete'][] = 'syslogArticleSave';
 125+ $wgHooks['EmailUserComplete'][] = 'syslogEmailUser';
 126+ $wgHooks['WatchArticleComplete'][] = 'syslogWatch';
 127+ $wgHooks['UnwatchArticleComplete'][] = 'syslogUnwatch';
 128+
 129+ return true;
 130+ }
 131+
 132+ # Add to global list of extensions
 133+
 134+ $wgExtensionFunctions[] = 'setupSyslog';
 135+}
 136+
 137+?>
Property changes on: trunk/extensions/Syslog/Syslog.php
___________________________________________________________________
Added: svn:keywords
1138 + Author Date Id Revision
Added: svn:eol-style
2139 + native
Index: trunk/extensions/ExtensionLoader/ExtensionLoader.php
@@ -0,0 +1,53 @@
 2+<?php
 3+if ( ! defined( 'MEDIAWIKI' ) )
 4+ die( -1 );
 5+/**
 6+ * A small extension that makes it easy to load other extensions during
 7+ * initialization, use it by adding this to LocalSettings.php (or equivalent)
 8+ *
 9+ * <code>
 10+ * require_once '/path/to/extension/dir/extensions/ExtensionLoader.php';
 11+ * </code>
 12+ *
 13+ * Then call it as:
 14+ *
 15+ * <code>
 16+ * wfExtensionLoader(
 17+ * 'Extension.php',
 18+ * 'ExtensionDir/*php' // Everything in this directory (uses glob())
 19+ * // ...
 20+ * ) or die( "Failed to load" );
 21+ * </code>
 22+ *
 23+ * @package MediaWiki
 24+ * @subpackage Extensions
 25+ *
 26+ * @author Ævar Arnfjörð Bjarmason <avarab@gmail.com>
 27+ * @copyright Copyright © 2006, Ævar Arnfjörð Bjarmason
 28+ * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later
 29+ */
 30+
 31+/**
 32+ * @param string $x, ... A variable number of strings
 33+ * @return bool True on success, False on failure
 34+ */
 35+function wfExtensionLoader() {
 36+ // Stuff might break without all of the globals
 37+ extract( $GLOBALS, EXTR_REFS );
 38+
 39+ $extensions = func_get_args();
 40+
 41+ $dir = dirname( __FILE__ ) . DIRECTORY_SEPARATOR;
 42+
 43+ $ret = true;
 44+ foreach ( $extensions as $extension ) {
 45+ $glob = glob( $dir . $extension );
 46+ if ( count( $glob ) )
 47+ foreach ( glob( $dir . $extension ) as $file )
 48+ require_once $file;
 49+ else
 50+ $ret = false;
 51+ }
 52+
 53+ return $ret;
 54+}
Property changes on: trunk/extensions/ExtensionLoader/ExtensionLoader.php
___________________________________________________________________
Added: svn:keywords
155 + Author Date Id Revision
Added: svn:eol-style
256 + native
Index: trunk/extensions/Autoincrement/Autoincrement.php
@@ -0,0 +1,54 @@
 2+<?php
 3+if (!defined('MEDIAWIKI')) die();
 4+/**
 5+ * An example parser hook that defines a new variable, {{AUTOINCREMENT}},
 6+ * useful for maintaining a citation count with {{ref|}} and {{note|}} pairs
 7+ *
 8+ * @package MediaWiki
 9+ * @subpackage Extensions
 10+ *
 11+ * @author Ævar Arnfjörð Bjarmason <avarab@gmail.com>
 12+ * @copyright Copyright © 2005, Ævar Arnfjörð Bjarmason
 13+ * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later
 14+ */
 15+
 16+$wgExtensionCredits['variable'][] = array(
 17+ 'name' => 'Autoincrement',
 18+ 'description' => 'a variable hook that adds an autoincrementing variable, <nowiki>{{AUTOINCREMENT}}</nowiki>',
 19+ 'author' => 'Ævar Arnfjörð Bjarmason'
 20+);
 21+
 22+class Autoincrement {
 23+ var $mCount;
 24+
 25+ function Autoincrement() {
 26+ global $wgHooks;
 27+
 28+ $this->mCount = 0;
 29+
 30+ $wgHooks['MagicWordwgVariableIDs'][] = array( $this, 'wfAutoincrementHookVariables' );
 31+ $wgHooks['LanguageGetMagic'][] = array( $this, 'wfAutoincrementHookRaw' );
 32+ $wgHooks['ParserGetVariableValueSwitch'][] = array( $this, 'wfAutoincrementHookSwitch' );
 33+ }
 34+
 35+ function wfAutoincrementHookVariables( &$wgVariableIDs ) {
 36+ $wgVariableIDs[] = 'autoincrement';
 37+
 38+ return true;
 39+ }
 40+
 41+ function wfAutoincrementHookRaw( &$raw ) {
 42+ $raw['autoincrement'] = array( 0, 'AUTOINCREMENT' );;
 43+
 44+ return true;
 45+ }
 46+
 47+ function wfAutoincrementHookSwitch( &$parser, &$varCache, &$index, &$ret ) {
 48+ if ( $index === 'autoincrement' )
 49+ $ret = ++$this->mCount; // No formatNum() just like url autonumbering
 50+
 51+ return true;
 52+ }
 53+}
 54+
 55+new Autoincrement;
Property changes on: trunk/extensions/Autoincrement/Autoincrement.php
___________________________________________________________________
Added: svn:keywords
156 + Author Date Id Revision
Added: svn:eol-style
257 + native
Index: trunk/extensions/SpecialTalk/SpecialTalk.php
@@ -0,0 +1,54 @@
 2+<?php
 3+if ( ! defined( 'MEDIAWIKI' ) ) die();
 4+/**
 5+ * A hook that adds a talk tab to Special Pages
 6+ *
 7+ * @package MediaWiki
 8+ * @subpackage Extensions
 9+ *
 10+ * @bug 4078
 11+ *
 12+ * @author Ævar Arnfjörð Bjarmason <avarab@gmail.com>
 13+ * @copyright Copyright © 2005, Ævar Arnfjörð Bjarmason
 14+ * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later
 15+ */
 16+$wgExtensionFunctions[] = 'wfSpecialTalk';
 17+$wgExtensionCredits['other'][] = array(
 18+ 'name' => 'Special talk',
 19+ 'description' => 'Adds a talk tab to Special Pages',
 20+ 'author' => 'Ævar Arnfjörð Bjarmason'
 21+);
 22+
 23+function wfSpecialTalk() {
 24+ wfUsePHP( 5.1 );
 25+ wfUseMW( '1.6alpha' );
 26+
 27+ class SpecialTalk {
 28+ public function __construct() {
 29+ global $wgHooks;
 30+
 31+ $wgHooks['SkinTemplateBuildContentActionUrlsAfterSpecialPage'][] = array( &$this, 'SpecialTalkHook' );
 32+ }
 33+
 34+ public function SpecialTalkHook( SkinTemplate &$skin_template, array &$content_actions ) {
 35+ global $wgTitle;
 36+
 37+ $title = Title::makeTitle( NS_PROJECT_TALK, $skin_template->mTitle->getText() );
 38+
 39+ $content_actions['talk'] = $skin_template->tabAction(
 40+ $title,
 41+ // msg
 42+ 'talk',
 43+ // selected
 44+ false,
 45+ // &query=
 46+ '',
 47+ // check existance
 48+ true
 49+ );
 50+ }
 51+ }
 52+
 53+ // Establish a singleton.
 54+ new SpecialTalk;
 55+}
Property changes on: trunk/extensions/SpecialTalk/SpecialTalk.php
___________________________________________________________________
Added: svn:keywords
156 + Author Date Id Revision
Added: svn:eol-style
257 + native
Index: trunk/extensions/NopurgeRC/NopurgeRC.php
@@ -0,0 +1,19 @@
 2+<?php
 3+/**
 4+ * An extension that prevents old recentchanges entries from being deleted
 5+ *
 6+ * @author Ævar Arnfjörð Bjarmason <avarab@gmail.com>
 7+ * @copyright Copyright © 2005, Ævar Arnfjörð Bjarmason
 8+ * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later
 9+ */
 10+
 11+$wgHooks['ArticleEditUpdatesDeleteFromRecentchanges'][] = 'wfNopurgeRCHook';
 12+$wgExtensionCredits['other'][] = array(
 13+ 'name' => 'NopurgeRC',
 14+ 'description' => 'A hook that prevents old recentchanges entries from being deleted',
 15+ 'author' => 'Ævar Arnfjörð Bjarmason',
 16+);
 17+
 18+function wfNopurgeRCHook() {
 19+ return false;
 20+}
Property changes on: trunk/extensions/NopurgeRC/NopurgeRC.php
___________________________________________________________________
Added: svn:keywords
121 + Author Date Id Revision
Added: svn:eol-style
222 + native