r52685 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r52684‎ | r52685 | r52686 >
Date:10:04, 2 July 2009
Author:siebrand
Status:ok
Tags:
Comment:
* svn:eol-style native
* stylize.php, trailing whitespace removed
Modified paths:
  • /trunk/extensions/CodeTest/CodeTest.class.php (modified) (history)
  • /trunk/extensions/CodeTest/CodeTest.php (modified) (history)
  • /trunk/extensions/Negref/Negref.php (modified) (history)
  • /trunk/extensions/ReplaceSet/ReplaceSet.class.php (modified) (history)
  • /trunk/extensions/ReplaceSet/ReplaceSet.i18n.php (modified) (history)
  • /trunk/extensions/ReplaceSet/ReplaceSet.php (modified) (history)
  • /trunk/extensions/SidebarDonateBox/SidebarDonateBox.php (modified) (history)
  • /trunk/extensions/StarterWiki/README (modified) (history)
  • /trunk/extensions/StarterWiki/maintenance/createWikiDBFromStarter.php (modified) (history)
  • /trunk/extensions/SwarmExport/swarmExport.php (modified) (history)
  • /trunk/extensions/WikiCategoryTagCloud/WikiCategoryTagCloud.php (modified) (history)

Diff [purge]

Index: trunk/extensions/WikiCategoryTagCloud/WikiCategoryTagCloud.php
@@ -5,25 +5,25 @@
66 * @ingroup Extensions
77 * @author Daniel Friesen http://daniel.friesen.name
88 * @version 1.0.1
9 - *
 9+ *
1010 * Derived from: YetAnotherTagCloud http://orangedino.com
11 - *
 11+ *
1212 * This program is free software; you can redistribute it and/or
1313 * modify it under the terms of the GNU General Public License
1414 * as published by the Free Software Foundation; either version 2
1515 * of the License, or (at your option) any later version.
16 - *
 16+ *
1717 * This program is distributed in the hope that it will be useful,
1818 * but WITHOUT ANY WARRANTY; without even the implied warranty of
1919 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2020 * GNU General Public License for more details.
21 - *
 21+ *
2222 * You should have received a copy of the GNU General Public License
2323 * along with this program; if not, write to the Free Software
2424 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
2525 */
2626
27 -if( !defined( 'MEDIAWIKI' ) ) die( "This is an extension to the MediaWiki package and cannot be run standalone." );
 27+if ( !defined( 'MEDIAWIKI' ) ) die( "This is an extension to the MediaWiki package and cannot be run standalone." );
2828
2929 $wgExtensionCredits['parserhook'][] = array(
3030 'name' => 'Wiki Category Tag Cloud',
@@ -52,7 +52,7 @@
5353 function invalidateCache() {
5454 $titles[0] = explode( "\n", wfMsg( 'tagcloudpages' ) );
5555
56 - for( $i = 0; $i < count( $titles ); $i++) {
 56+ for ( $i = 0; $i < count( $titles ); $i++ ) {
5757 Title::newFromText( $titles[$i] )->invalidateCache();
5858 }
5959 return true;
@@ -73,26 +73,26 @@
7474 $min_count_input = getBoxExtensionOption( $input, 'min_count' );
7575 $min_size_input = getBoxExtensionOption( $input, 'min_size' );
7676 $increase_factor_input = getBoxExtensionOption( $input, 'increase_factor' );
77 - if( $min_size_input != null ) {
 77+ if ( $min_size_input != null ) {
7878 $MIN_SIZE = $min_size_input;
7979 }
80 - if( $increase_factor_input != null ) {
 80+ if ( $increase_factor_input != null ) {
8181 $INCREASE_FACTOR = $increase_factor_input;
8282 }
83 - if( $min_count_input == null ) {
 83+ if ( $min_count_input == null ) {
8484 $min_count_input = 0;
8585 }
8686
8787 $excluded_input = getBoxExtensionOption( $input, 'exclude' );
8888
8989 $exclude_condition = '';
90 - if( strlen( $excluded_input ) > 0 ) {
 90+ if ( strlen( $excluded_input ) > 0 ) {
9191 $excluded_categories = explode( ",", $excluded_input );
92 - if( count( $excluded_categories ) > 0 ) {
 92+ if ( count( $excluded_categories ) > 0 ) {
9393 $exclude_condition = " WHERE cl_to NOT IN (";
94 - for( $i = 0; $i < count( $excluded_categories ); $i++ ) {
 94+ for ( $i = 0; $i < count( $excluded_categories ); $i++ ) {
9595 $exclude_condition = $exclude_condition . "'" . trim( $excluded_categories[$i] ) . "'";
96 - if( $i < count( $excluded_categories ) - 1 ) {
 96+ if ( $i < count( $excluded_categories ) - 1 ) {
9797 $exclude_condition = $exclude_condition . ",";
9898 }
9999 }
@@ -109,25 +109,25 @@
110110 $htmlOut = $htmlOut . "<div class=\"" . implode( ' ', $cloud_classes ) . "\" style=\"{$cloud_style}\">";
111111
112112 $min = 1000000;
113 - $max = -1;
 113+ $max = - 1;
114114
115 - for( $i = 0; $i < $count; $i++ ) {
 115+ for ( $i = 0; $i < $count; $i++ ) {
116116 $obj = $dbr->fetchObject( $res );
117117 $tags[$i][0] = $obj->title;
118118 $tags[$i][1] = $obj->count;
119 - if( $obj->count < $min ) {
 119+ if ( $obj->count < $min ) {
120120 $min = $obj->count;
121121 }
122 - if( $obj->count > $max ) {
 122+ if ( $obj->count > $max ) {
123123 $max = $obj->count;
124124 }
125125 }
126126
127 - for( $i = 0; $i < $count; $i++ ) {
 127+ for ( $i = 0; $i < $count; $i++ ) {
128128 $textSize = $MIN_SIZE + ( $INCREASE_FACTOR * ( $tags[$i][1] ) ) / ( $max );
129129 $title = Title::makeTitle( NS_CATEGORY, $tags[$i][0] );
130130 $style = $link_style;
131 - if( $style != '' && $style{-1} != ';' ) $style .= ';';
 131+ if ( $style != '' && $style { -1 } != ';' ) $style .= ';';
132132 $style .= "font-size: {$textSize}%;";
133133 $currentRow = "<a class=\"" . implode( ' ', $link_classes ) . "\" style=\"{$style}\" href=\"" . $title->getLocalURL() . "\">" . $title->getText() . "</a>&nbsp; ";
134134 $htmlOut = $htmlOut . $currentRow;
@@ -137,11 +137,11 @@
138138 }
139139
140140 function getBoxExtensionOption( $input, $name, $isNumber = false ) {
141 - if( preg_match( "/^\s*$name\s*=\s*(.*)/mi", $input, $matches ) ) {
142 - if( $isNumber ) {
 141+ if ( preg_match( "/^\s*$name\s*=\s*(.*)/mi", $input, $matches ) ) {
 142+ if ( $isNumber ) {
143143 return intval( $matches[1] );
144144 } else {
145145 return htmlspecialchars( $matches[1] );
146146 }
147147 }
148 -}
\ No newline at end of file
 148+}
Property changes on: trunk/extensions/WikiCategoryTagCloud/WikiCategoryTagCloud.php
___________________________________________________________________
Name: svn:eol-style
149149 + native
Index: trunk/extensions/SidebarDonateBox/SidebarDonateBox.php
@@ -4,23 +4,23 @@
55 * @package SidebarDonateBox
66 * @author Daniel Friesen (http://mediawiki.org/wiki/User:Dantman) <mediawiki@danielfriesen.name>
77 * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later
8 - *
 8+ *
99 * This program is free software; you can redistribute it and/or
1010 * modify it under the terms of the GNU General Public License
1111 * as published by the Free Software Foundation; either version 2
1212 * of the License, or (at your option) any later version.
13 - *
 13+ *
1414 * This program is distributed in the hope that it will be useful,
1515 * but WITHOUT ANY WARRANTY; without even the implied warranty of
1616 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1717 * GNU General Public License for more details.
18 - *
 18+ *
1919 * You should have received a copy of the GNU General Public License
2020 * along with this program; if not, write to the Free Software
2121 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
2222 */
2323
24 -if( !defined( 'MEDIAWIKI' ) ) die( "This is an extension to the MediaWiki package and cannot be run standalone." );
 24+if ( !defined( 'MEDIAWIKI' ) ) die( "This is an extension to the MediaWiki package and cannot be run standalone." );
2525
2626 $wgExtensionCredits['parserhook'][] = array (
2727 'name' => 'SidebarDonateBox',
Property changes on: trunk/extensions/SidebarDonateBox/SidebarDonateBox.php
___________________________________________________________________
Name: svn:eol-style
2828 + native
Index: trunk/extensions/StarterWiki/maintenance/createWikiDBFromStarter.php
@@ -1,210 +1,210 @@
2 -<?php
3 -/**
4 - * StarterWiki
5 - * @package StarterWiki
6 - * @author Daniel Friesen (http://mediawiki.org/wiki/User:Dantman) <mediawiki@danielfriesen.name>
7 - * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later
8 - *
9 - * This program is free software; you can redistribute it and/or
10 - * modify it under the terms of the GNU General Public License
11 - * as published by the Free Software Foundation; either version 2
12 - * of the License, or (at your option) any later version.
13 - *
14 - * This program is distributed in the hope that it will be useful,
15 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 - * GNU General Public License for more details.
18 - *
19 - * You should have received a copy of the GNU General Public License
20 - * along with this program; if not, write to the Free Software
21 - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
22 - */
23 -
24 -/**
25 - * Use the current wiki database (starter) as a base for creating a new one.
26 - */
27 -
28 -$optionsWithArgs = array( 'database' );
29 -$wgUseMasterForMaintenance = true;
30 -require_once( "commandLine.inc" );
31 -$wgTitle = Title::newFromText( "StarterWiki Database Creator" );
32 -$dbclass = 'Database' . ucfirst( $wgDBtype );
33 -
34 -# Do a pre-emptive check to ensure we've got credentials supplied
35 -# We can't, at this stage, check them, but we can detect their absence,
36 -# which seems to cause most of the problems people whinge about
37 -if( !isset( $wgDBadminuser ) || !isset( $wgDBadminpassword ) ) {
38 - echo( "No superuser credentials could be found. Please provide the details\n" );
39 - echo( "of a user with appropriate permissions to update the database. See\n" );
40 - echo( "AdminSettings.sample for more details.\n\n" );
41 - exit();
42 -}
43 -
44 -# Attempt to connect to the database as a privileged user
45 -# This will vomit up an error if there are permissions problems
46 -$wgDatabase = new $dbclass( $wgDBserver, $wgDBadminuser, $wgDBadminpassword, $wgDBname, 1 );
47 -
48 -if( !isset($wgDatabase) || !$wgDatabase->isOpen() ) {
49 - # Appears to have failed
50 - echo( "A connection to the database could not be established. Check the\n" );
51 - echo( "values of \$wgDBadminuser and \$wgDBadminpassword.\n" );
52 - exit();
53 -}
54 -
55 -function usageInfo() {
56 - echo <<<TEXT
57 -Usage:
58 - php createWikiDBFromStarter.php --help
59 - php createWikiDBFromStarter.php --database=<database>
60 -
61 - --help : This help message
62 - --database=<database> : The name of the database to create.
63 -
64 -TEXT;
65 - exit(0);
66 -}
67 -
68 -function tryRunCreate( $db ) {
69 - global $options;
70 - if( isset( $options['help'] ) || !isset( $options['database'] ) ) usageInfo();
71 - if( doCreateWiki( $db, $options['database'] ) ) {
72 - echo "Finished...\n";
73 - exit(0);
74 - } else {
75 - echo "Failed...\n";
76 - exit(1);
77 - }
78 -}
79 -
80 -function doCreateWiki( $db, $newDB ) {
81 - global $wgDBname, $wgStarterWikiPageAliases, $wgStarterWikiOmitNamespaces;
82 - // Create the new Database, and make sure to use the same character set and collation as this one.
83 - $dbData = $db->selectRow( '`INFORMATION_SCHEMA`.`SCHEMATA`',
84 - array( "DEFAULT_CHARACTER_SET_NAME AS 'character_set'", "DEFAULT_COLLATION_NAME AS 'collation'" ),
85 - array( 'SCHEMA_NAME' => $wgDBname ), __METHOD__ );
86 -
87 - if( (bool) $db->query("CREATE DATABASE `{$newDB}` CHARACTER SET {$dbData->character_set} COLLATE {$dbData->collation}") ) {
88 - echo "New database created\n";
89 - } else {
90 - echo "Could not create the database, it may already exist.\n";
91 - return false;
92 - }
93 -
94 - // Copy the structure of all the Starter tables to the new wiki.
95 - $res = $db->query("SHOW TABLES FROM `{$wgDBname}`");
96 - while( $row = $db->fetchRow($res) ) {
97 - $table = $row["Tables_in_{$wgDBname}"];
98 - if( (bool) $db->query("CREATE TABLE `{$newDB}`.`{$table}` LIKE `{$wgDBname}`.`{$table}`") ) {
99 - echo "Cloned structure for table `{$table}` from starter.\n";
100 - } else {
101 - echo "Failed to clone structure for table `{$table}` from starter.\n";
102 - return false;
103 - }
104 - }
105 -
106 - // We need a common time to add things in at.
107 - $now = $db->timestamp(time());
108 - if( isset($wgStarterWikiOmitNamespaces) && is_array($wgStarterWikiOmitNamespaces) ) {
109 - // Output a nice SELECT statment that gives us only the starter data we need.
110 - $notNamespaces = $db->makeList( $wgStarterWikiOmitNamespaces, LIST_COMMA );
111 - if( $notNamespaces !='' ) {
112 - $notNamespaces = "AND page_namespace NOT IN ({$notNamespaces})";
113 - }
114 - }
115 - $res = $db->query("
116 -SELECT
117 - page_namespace AS namespace,
118 - page_title AS title,
119 - page_restrictions AS restrictions,
120 - 0 AS page_counter,
121 - page_is_redirect AS is_redirect,
122 - 0 AS page_is_new,
123 - page_random AS random,
124 - rev_comment AS comment,
125 - rev_len AS length,
126 - old_text AS text,
127 - old_flags AS flags
128 -FROM
129 - `{$wgDBname}`.`page`,
130 - `{$wgDBname}`.`revision`,
131 - `{$wgDBname}`.`text`
132 -WHERE
133 - page_id=rev_page
134 - AND page_latest=rev_id
135 - AND rev_text_id=old_id
136 - {$notNamespaces}
137 -GROUP BY page_id ASC
138 -ORDER BY rev_id DESC");
139 -
140 - while( $row = $db->fetchObject($res) ) {
141 - // Don't copy overrided pages.
142 - if( in_array( "{$row->namespace}:{$row->title}", $wgStarterWikiPageAliases ) ) continue;
143 -
144 - // Insert Text Data into the Database.
145 - $oldId = $db->nextSequenceValue('text_old_id_seq');
146 - $db->insert( "`{$newDB}`.`text`", array(
147 - 'old_id' => $oldId,
148 - 'old_text' => $row->text,
149 - 'old_flags' => $row->flags
150 - ) );
151 - $oldId = $db->insertId();
152 - if( $db->affectedRows() > 0 ) {
153 - echo "Inserted text data for {$row->namespace}:{$row->title}\n";
154 - } else {
155 - echo "Failed to insert text data for {$row->namespace}:{$row->title}\n";
156 - return false;
157 - }
158 - // Insert Revision Data into the Database.
159 - $revId = $db->nextSequenceValue('revision_rev_id_seq');
160 - $db->insert( "`{$newDB}`.`revision`", array(
161 - 'rev_id' => $revId,
162 - 'rev_text_id' => $oldId,
163 - 'rev_comment' => $row->comment,
164 - 'rev_user' => 0,
165 - 'rev_user_text' => "MediaWiki default",
166 - 'rev_timestamp' => $now,
167 - 'rev_len' => $row->length
168 - ) );
169 - $revId = $db->insertId();
170 - if( $db->affectedRows() > 0 ) {
171 - echo "Created initial revision for {$row->namespace}:{$row->title}\n";
172 - } else {
173 - echo "Failed to create initial revision for {$row->namespace}:{$row->title}\n";
174 - return false;
175 - }
176 - // Insert Page Data into the Database.
177 - $pageId = $db->nextSequenceValue('page_page_id_seq');
178 - $alias = null;
179 - if( isset($wgStarterWikiPageAliases["{$row->namespace}:{$row->title}"]) ) {
180 - $alias = array();
181 - list( $alias['namespace'], $alias['title'] ) = explode( ':', $wgStarterWikiPageAliases["{$row->namespace}:{$row->title}"], 2 );
182 - }
183 - $db->insert( "`{$newDB}`.`page`", array(
184 - 'page_id' => $pageId,
185 - 'page_namespace' => isset($alias) ? $alias['namespace'] : $row->namespace,
186 - 'page_title' => isset($alias) ? $alias['title'] : $row->title,
187 - 'page_is_redirect' => $row->is_redirect,
188 - 'page_random' => $row->random,
189 - 'page_touched' => $now,
190 - 'page_latest' => $revId,
191 - 'page_len' => $row->length
192 - ) );
193 - $pageId = $db->insertId();
194 - if( $db->affectedRows() > 0 ) {
195 - echo "Inserted page row for {$row->namespace}:[]$row->title}\n";
196 - } else {
197 - echo "Failed to insert page row for {$row->namespace}:[]$row->title}\n";
198 - return false;
199 - }
200 - if( $db->set( "`{$newDB}`.`revision`",
201 - 'rev_page', $pageId,
202 - "rev_id = {$revId}" ) ) {
203 - echo "Set rev_id for {$row->namespace}:{$row->title} to the correct value.\n";
204 - } else {
205 - echo "Failed to set rev_id for {$row->namespace}:{$row->title} to the correct value.\n";
206 - }
207 - }
208 - return true;
209 -}
210 -
 2+<?php
 3+/**
 4+ * StarterWiki
 5+ * @package StarterWiki
 6+ * @author Daniel Friesen (http://mediawiki.org/wiki/User:Dantman) <mediawiki@danielfriesen.name>
 7+ * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later
 8+ *
 9+ * This program is free software; you can redistribute it and/or
 10+ * modify it under the terms of the GNU General Public License
 11+ * as published by the Free Software Foundation; either version 2
 12+ * of the License, or (at your option) any later version.
 13+ *
 14+ * This program is distributed in the hope that it will be useful,
 15+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
 16+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 17+ * GNU General Public License for more details.
 18+ *
 19+ * You should have received a copy of the GNU General Public License
 20+ * along with this program; if not, write to the Free Software
 21+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 22+ */
 23+
 24+/**
 25+ * Use the current wiki database (starter) as a base for creating a new one.
 26+ */
 27+
 28+$optionsWithArgs = array( 'database' );
 29+$wgUseMasterForMaintenance = true;
 30+require_once( "commandLine.inc" );
 31+$wgTitle = Title::newFromText( "StarterWiki Database Creator" );
 32+$dbclass = 'Database' . ucfirst( $wgDBtype );
 33+
 34+# Do a pre-emptive check to ensure we've got credentials supplied
 35+# We can't, at this stage, check them, but we can detect their absence,
 36+# which seems to cause most of the problems people whinge about
 37+if ( !isset( $wgDBadminuser ) || !isset( $wgDBadminpassword ) ) {
 38+ echo( "No superuser credentials could be found. Please provide the details\n" );
 39+ echo( "of a user with appropriate permissions to update the database. See\n" );
 40+ echo( "AdminSettings.sample for more details.\n\n" );
 41+ exit();
 42+}
 43+
 44+# Attempt to connect to the database as a privileged user
 45+# This will vomit up an error if there are permissions problems
 46+$wgDatabase = new $dbclass( $wgDBserver, $wgDBadminuser, $wgDBadminpassword, $wgDBname, 1 );
 47+
 48+if ( !isset( $wgDatabase ) || !$wgDatabase->isOpen() ) {
 49+ # Appears to have failed
 50+ echo( "A connection to the database could not be established. Check the\n" );
 51+ echo( "values of \$wgDBadminuser and \$wgDBadminpassword.\n" );
 52+ exit();
 53+}
 54+
 55+function usageInfo() {
 56+ echo <<<TEXT
 57+Usage:
 58+ php createWikiDBFromStarter.php --help
 59+ php createWikiDBFromStarter.php --database=<database>
 60+
 61+ --help : This help message
 62+ --database=<database> : The name of the database to create.
 63+
 64+TEXT;
 65+ exit( 0 );
 66+}
 67+
 68+function tryRunCreate( $db ) {
 69+ global $options;
 70+ if ( isset( $options['help'] ) || !isset( $options['database'] ) ) usageInfo();
 71+ if ( doCreateWiki( $db, $options['database'] ) ) {
 72+ echo "Finished...\n";
 73+ exit( 0 );
 74+ } else {
 75+ echo "Failed...\n";
 76+ exit( 1 );
 77+ }
 78+}
 79+
 80+function doCreateWiki( $db, $newDB ) {
 81+ global $wgDBname, $wgStarterWikiPageAliases, $wgStarterWikiOmitNamespaces;
 82+ // Create the new Database, and make sure to use the same character set and collation as this one.
 83+ $dbData = $db->selectRow( '`INFORMATION_SCHEMA`.`SCHEMATA`',
 84+ array( "DEFAULT_CHARACTER_SET_NAME AS 'character_set'", "DEFAULT_COLLATION_NAME AS 'collation'" ),
 85+ array( 'SCHEMA_NAME' => $wgDBname ), __METHOD__ );
 86+
 87+ if ( (bool) $db->query( "CREATE DATABASE `{$newDB}` CHARACTER SET {$dbData->character_set} COLLATE {$dbData->collation}" ) ) {
 88+ echo "New database created\n";
 89+ } else {
 90+ echo "Could not create the database, it may already exist.\n";
 91+ return false;
 92+ }
 93+
 94+ // Copy the structure of all the Starter tables to the new wiki.
 95+ $res = $db->query( "SHOW TABLES FROM `{$wgDBname}`" );
 96+ while ( $row = $db->fetchRow( $res ) ) {
 97+ $table = $row["Tables_in_{$wgDBname}"];
 98+ if ( (bool) $db->query( "CREATE TABLE `{$newDB}`.`{$table}` LIKE `{$wgDBname}`.`{$table}`" ) ) {
 99+ echo "Cloned structure for table `{$table}` from starter.\n";
 100+ } else {
 101+ echo "Failed to clone structure for table `{$table}` from starter.\n";
 102+ return false;
 103+ }
 104+ }
 105+
 106+ // We need a common time to add things in at.
 107+ $now = $db->timestamp( time() );
 108+ if ( isset( $wgStarterWikiOmitNamespaces ) && is_array( $wgStarterWikiOmitNamespaces ) ) {
 109+ // Output a nice SELECT statment that gives us only the starter data we need.
 110+ $notNamespaces = $db->makeList( $wgStarterWikiOmitNamespaces, LIST_COMMA );
 111+ if ( $notNamespaces != '' ) {
 112+ $notNamespaces = "AND page_namespace NOT IN ({$notNamespaces})";
 113+ }
 114+ }
 115+ $res = $db->query( "
 116+SELECT
 117+ page_namespace AS namespace,
 118+ page_title AS title,
 119+ page_restrictions AS restrictions,
 120+ 0 AS page_counter,
 121+ page_is_redirect AS is_redirect,
 122+ 0 AS page_is_new,
 123+ page_random AS random,
 124+ rev_comment AS comment,
 125+ rev_len AS length,
 126+ old_text AS text,
 127+ old_flags AS flags
 128+FROM
 129+ `{$wgDBname}`.`page`,
 130+ `{$wgDBname}`.`revision`,
 131+ `{$wgDBname}`.`text`
 132+WHERE
 133+ page_id=rev_page
 134+ AND page_latest=rev_id
 135+ AND rev_text_id=old_id
 136+ {$notNamespaces}
 137+GROUP BY page_id ASC
 138+ORDER BY rev_id DESC" );
 139+
 140+ while ( $row = $db->fetchObject( $res ) ) {
 141+ // Don't copy overrided pages.
 142+ if ( in_array( "{$row->namespace}:{$row->title}", $wgStarterWikiPageAliases ) ) continue;
 143+
 144+ // Insert Text Data into the Database.
 145+ $oldId = $db->nextSequenceValue( 'text_old_id_seq' );
 146+ $db->insert( "`{$newDB}`.`text`", array(
 147+ 'old_id' => $oldId,
 148+ 'old_text' => $row->text,
 149+ 'old_flags' => $row->flags
 150+ ) );
 151+ $oldId = $db->insertId();
 152+ if ( $db->affectedRows() > 0 ) {
 153+ echo "Inserted text data for {$row->namespace}:{$row->title}\n";
 154+ } else {
 155+ echo "Failed to insert text data for {$row->namespace}:{$row->title}\n";
 156+ return false;
 157+ }
 158+ // Insert Revision Data into the Database.
 159+ $revId = $db->nextSequenceValue( 'revision_rev_id_seq' );
 160+ $db->insert( "`{$newDB}`.`revision`", array(
 161+ 'rev_id' => $revId,
 162+ 'rev_text_id' => $oldId,
 163+ 'rev_comment' => $row->comment,
 164+ 'rev_user' => 0,
 165+ 'rev_user_text' => "MediaWiki default",
 166+ 'rev_timestamp' => $now,
 167+ 'rev_len' => $row->length
 168+ ) );
 169+ $revId = $db->insertId();
 170+ if ( $db->affectedRows() > 0 ) {
 171+ echo "Created initial revision for {$row->namespace}:{$row->title}\n";
 172+ } else {
 173+ echo "Failed to create initial revision for {$row->namespace}:{$row->title}\n";
 174+ return false;
 175+ }
 176+ // Insert Page Data into the Database.
 177+ $pageId = $db->nextSequenceValue( 'page_page_id_seq' );
 178+ $alias = null;
 179+ if ( isset( $wgStarterWikiPageAliases["{$row->namespace}:{$row->title}"] ) ) {
 180+ $alias = array();
 181+ list( $alias['namespace'], $alias['title'] ) = explode( ':', $wgStarterWikiPageAliases["{$row->namespace}:{$row->title}"], 2 );
 182+ }
 183+ $db->insert( "`{$newDB}`.`page`", array(
 184+ 'page_id' => $pageId,
 185+ 'page_namespace' => isset( $alias ) ? $alias['namespace'] : $row->namespace,
 186+ 'page_title' => isset( $alias ) ? $alias['title'] : $row->title,
 187+ 'page_is_redirect' => $row->is_redirect,
 188+ 'page_random' => $row->random,
 189+ 'page_touched' => $now,
 190+ 'page_latest' => $revId,
 191+ 'page_len' => $row->length
 192+ ) );
 193+ $pageId = $db->insertId();
 194+ if ( $db->affectedRows() > 0 ) {
 195+ echo "Inserted page row for {$row->namespace}:[]$row->title}\n";
 196+ } else {
 197+ echo "Failed to insert page row for {$row->namespace}:[]$row->title}\n";
 198+ return false;
 199+ }
 200+ if ( $db->set( "`{$newDB}`.`revision`",
 201+ 'rev_page', $pageId,
 202+ "rev_id = {$revId}" ) ) {
 203+ echo "Set rev_id for {$row->namespace}:{$row->title} to the correct value.\n";
 204+ } else {
 205+ echo "Failed to set rev_id for {$row->namespace}:{$row->title} to the correct value.\n";
 206+ }
 207+ }
 208+ return true;
 209+}
 210+
211211 tryRunCreate( $wgDatabase );
Property changes on: trunk/extensions/StarterWiki/maintenance/createWikiDBFromStarter.php
___________________________________________________________________
Name: svn:eol-style
212212 + native
Index: trunk/extensions/StarterWiki/README
@@ -1 +1 @@
2 -Please see the INSTALL file for information on how to install the extension.
\ No newline at end of file
 2+Please see the INSTALL file for information on how to install the extension.
Property changes on: trunk/extensions/StarterWiki/README
___________________________________________________________________
Name: svn:eol-style
33 + native
Index: trunk/extensions/CodeTest/CodeTest.php
@@ -4,23 +4,23 @@
55 * @package CodeTest
66 * @author Daniel Friesen (http://mediawiki.org/wiki/User:Dantman) <mediawiki@danielfriesen.name>
77 * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later
8 - *
 8+ *
99 * This program is free software; you can redistribute it and/or
1010 * modify it under the terms of the GNU General Public License
1111 * as published by the Free Software Foundation; either version 2
1212 * of the License, or (at your option) any later version.
13 - *
 13+ *
1414 * This program is distributed in the hope that it will be useful,
1515 * but WITHOUT ANY WARRANTY; without even the implied warranty of
1616 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1717 * GNU General Public License for more details.
18 - *
 18+ *
1919 * You should have received a copy of the GNU General Public License
2020 * along with this program; if not, write to the Free Software
2121 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
2222 */
2323
24 -if( !defined( 'MEDIAWIKI' ) ) die( "This is an extension to the MediaWiki package and cannot be run standalone." );
 24+if ( !defined( 'MEDIAWIKI' ) ) die( "This is an extension to the MediaWiki package and cannot be run standalone." );
2525
2626 $wgExtensionCredits['parserhook'][] = array (
2727 'name' => 'CodeTest',
@@ -31,4 +31,4 @@
3232 );
3333
3434 $wgHooks['ParserAfterStrip'][] = 'CodeTest::ParserAfterStrip';
35 -$wgAutoloadClasses['CodeTest'] = dirname(__FILE__).'/CodeTest.class.php';
 35+$wgAutoloadClasses['CodeTest'] = dirname( __FILE__ ) . '/CodeTest.class.php';
Property changes on: trunk/extensions/CodeTest/CodeTest.php
___________________________________________________________________
Name: svn:eol-style
3636 + native
Index: trunk/extensions/CodeTest/CodeTest.class.php
@@ -4,69 +4,68 @@
55 * @package CodeTest
66 * @author Daniel Friesen (http://mediawiki.org/wiki/User:Dantman) <mediawiki@danielfriesen.name>
77 * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later
8 - *
 8+ *
99 * This program is free software; you can redistribute it and/or
1010 * modify it under the terms of the GNU General Public License
1111 * as published by the Free Software Foundation; either version 2
1212 * of the License, or (at your option) any later version.
13 - *
 13+ *
1414 * This program is distributed in the hope that it will be useful,
1515 * but WITHOUT ANY WARRANTY; without even the implied warranty of
1616 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1717 * GNU General Public License for more details.
18 - *
 18+ *
1919 * You should have received a copy of the GNU General Public License
2020 * along with this program; if not, write to the Free Software
2121 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
2222 */
2323
24 -if( !defined( 'MEDIAWIKI' ) ) die( "This is an extension to the MediaWiki package and cannot be run standalone." );
 24+if ( !defined( 'MEDIAWIKI' ) ) die( "This is an extension to the MediaWiki package and cannot be run standalone." );
2525
2626 class CodeTest {
27 -
 27+
2828 static function ParserAfterStrip( &$parser, &$text, &$stripState ) {
2929 $match = array();
30 - $text = $parser->extractTagsAndParams( array('codetest'), $text, $match, $parser->uniqPrefix() );
31 - foreach( $match as $uniq => $data ) {
 30+ $text = $parser->extractTagsAndParams( array( 'codetest' ), $text, $match, $parser->uniqPrefix() );
 31+ foreach ( $match as $uniq => $data ) {
3232 list( $tag, $content, $params, $original ) = $data;
33 - if( $tag != 'codetest' ) {
 33+ if ( $tag != 'codetest' ) {
3434 # This sometimes happends with comments, but in the case of
3535 # anything unforseen, just spit the original back out
36 - $text = str_replace($uniq,$original,$text);
 36+ $text = str_replace( $uniq, $original, $text );
3737 continue;
3838 }
39 -
40 - $codeData = array_map( 'trim', explode( "\n", trim($content) ) );
 39+
 40+ $codeData = array_map( 'trim', explode( "\n", trim( $content ) ) );
4141 $expected = array();
42 - if( isset($params['sep']) )
43 - foreach( $codeData as &$code )
 42+ if ( isset( $params['sep'] ) )
 43+ foreach ( $codeData as &$code )
4444 list( $code, $expected[] ) = explode( $params['sep'], $code, 2 );
4545 switch( $params['mode'] ) {
4646 case 'table':
47 - $content = self::tableModeReplace($codeData,$expected);
 47+ $content = self::tableModeReplace( $codeData, $expected );
4848 break;
4949 }
50 -
51 - $text = str_replace($uniq,$content,$text);
 50+
 51+ $text = str_replace( $uniq, $content, $text );
5252 }
5353 return true;
5454 }
55 -
 55+
5656 static function tableModeReplace( $codeData, $expected = array() ) {
57 - $expecting = count($codeData) == count($expected);
 57+ $expecting = count( $codeData ) == count( $expected );
5858 $table = "\n{|\n";
5959 $table .= "|-\n";
6060 $table .= "!| Code\n";
6161 $table .= "!| Result\n";
62 - if( $expecting ) $table .= "!| Expecting\n";
63 - foreach( $codeData as $n => $code ) {
 62+ if ( $expecting ) $table .= "!| Expecting\n";
 63+ foreach ( $codeData as $n => $code ) {
6464 $table .= "|-\n";
65 - $table .= "||\n<nowiki>".htmlspecialchars($code)."</nowiki>\n";
 65+ $table .= "||\n<nowiki>" . htmlspecialchars( $code ) . "</nowiki>\n";
6666 $table .= "||\n{$code}\n";
67 - if( $expecting ) $table .= "||\n{$expected[$n]}\n";
 67+ if ( $expecting ) $table .= "||\n{$expected[$n]}\n";
6868 }
6969 $table .= "|}\n";
7070 return $table;
7171 }
72 -
7372 }
Property changes on: trunk/extensions/CodeTest/CodeTest.class.php
___________________________________________________________________
Name: svn:eol-style
7473 + native
Index: trunk/extensions/Negref/Negref.php
@@ -4,23 +4,23 @@
55 * @package WikiRuby
66 * @author Daniel Friesen (http://mediawiki.org/wiki/User:Dantman) <mediawiki@danielfriesen.name>
77 * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later
8 - *
 8+ *
99 * This program is free software; you can redistribute it and/or
1010 * modify it under the terms of the GNU General Public License
1111 * as published by the Free Software Foundation; either version 2
1212 * of the License, or (at your option) any later version.
13 - *
 13+ *
1414 * This program is distributed in the hope that it will be useful,
1515 * but WITHOUT ANY WARRANTY; without even the implied warranty of
1616 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1717 * GNU General Public License for more details.
18 - *
 18+ *
1919 * You should have received a copy of the GNU General Public License
2020 * along with this program; if not, write to the Free Software
2121 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
2222 */
2323
24 -if( !defined( 'MEDIAWIKI' ) ) die( "This is an extension to the MediaWiki package and cannot be run standalone." );
 24+if ( !defined( 'MEDIAWIKI' ) ) die( "This is an extension to the MediaWiki package and cannot be run standalone." );
2525
2626 $wgExtensionCredits['parserhook'][] = array (
2727 "path" => __FILE__,
@@ -34,7 +34,7 @@
3535
3636 function efNegrefSetup() {
3737 global $wgParser, $wgHooks;
38 -
 38+
3939 // Check for SFH_OBJECT_ARGS capability
4040 if ( defined( 'MW_SUPPORTS_PARSERFIRSTCALLINIT' ) ) {
4141 $wgHooks['ParserFirstCallInit'][] = 'efNegrefRegisterParser';
@@ -44,7 +44,7 @@
4545 }
4646 efNegrefRegisterParser( $wgParser );
4747 }
48 -
 48+
4949 return true;
5050 }
5151
@@ -54,23 +54,23 @@
5555 }
5656
5757 function efNegrefSetupLanguageMagic( &$magicWords, $langCode ) {
58 - $magicWords['negref'] = array( 0, 'negref' );
59 - return true;
 58+ $magicWords['negref'] = array( 0, 'negref' );
 59+ return true;
6060 }
6161
6262 function efNegrefHook( $parser, $input, $replaceData, $replaceRef, $pattern ) {
6363 $data = $input;
6464 $ref = '';
65 -
66 - $keys = array_keys($parser->mStripState->general->getArray());
67 - foreach($keys as $key) {
68 - if(preg_match('/^'.preg_quote($parser->uniqPrefix(), '/').'-(ref)-.*$/', $key)) {
69 - if(substr_count($input, $key) > 0) {
70 - $data = str_replace($key, '', $data);
 65+
 66+ $keys = array_keys( $parser->mStripState->general->getArray() );
 67+ foreach ( $keys as $key ) {
 68+ if ( preg_match( '/^' . preg_quote( $parser->uniqPrefix(), '/' ) . '-(ref)-.*$/', $key ) ) {
 69+ if ( substr_count( $input, $key ) > 0 ) {
 70+ $data = str_replace( $key, '', $data );
7171 $ref .= $key;
7272 }
7373 }
7474 }
75 -
76 - return str_replace($replaceRef, $ref, str_replace($replaceData, $data, $pattern));
 75+
 76+ return str_replace( $replaceRef, $ref, str_replace( $replaceData, $data, $pattern ) );
7777 }
Index: trunk/extensions/ReplaceSet/ReplaceSet.class.php
@@ -4,90 +4,91 @@
55 * @package ReplaceSet
66 * @author Daniel Friesen (http://mediawiki.org/wiki/User:Dantman) <mediawiki@danielfriesen.name>
77 * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later
8 - *
 8+ *
99 * This program is free software; you can redistribute it and/or
1010 * modify it under the terms of the GNU General Public License
1111 * as published by the Free Software Foundation; either version 2
1212 * of the License, or (at your option) any later version.
13 - *
 13+ *
1414 * This program is distributed in the hope that it will be useful,
1515 * but WITHOUT ANY WARRANTY; without even the implied warranty of
1616 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1717 * GNU General Public License for more details.
18 - *
 18+ *
1919 * You should have received a copy of the GNU General Public License
2020 * along with this program; if not, write to the Free Software
2121 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
2222 */
2323
24 -if( !defined( 'MEDIAWIKI' ) ) die( "This is an extension to the MediaWiki package and cannot be run standalone." );
 24+if ( !defined( 'MEDIAWIKI' ) ) die( "This is an extension to the MediaWiki package and cannot be run standalone." );
2525
2626 class ReplaceSet {
2727 static function parserFunction( &$parser, $string ) {
2828 global $egReplaceSetCallLimit, $egReplaceSetPregLimit;
29 - if( !isset($egReplaceSetCallLimit) ) $egReplaceSetCallLimit = 25;
30 - if( !isset($egReplaceSetPregLimit) ) $egReplaceSetPregLimit = 50;
 29+ if ( !isset( $egReplaceSetCallLimit ) ) $egReplaceSetCallLimit = 25;
 30+ if ( !isset( $egReplaceSetPregLimit ) ) $egReplaceSetPregLimit = 50;
3131 static $called = 0;
3232 $called++;
33 - if( $called > $egReplaceSetCallLimit )
34 - return self::error('replaceset-error-calllimit');
 33+ if ( $called > $egReplaceSetCallLimit )
 34+ return self::error( 'replaceset-error-calllimit' );
3535 // Set basic statics
3636 static $regexStarts = '/!#=([{';
3737 static $regexEnds = '/!#=)]}';
3838 static $regexModifiers = 'imsxADU';
3939 // Grab our args
4040 $args = func_get_args();
41 - array_shift($args);// Shift off the Parser
42 - array_shift($args);// Shift off the String
43 -
 41+ array_shift( $args );// Shift off the Parser
 42+ array_shift( $args );// Shift off the String
 43+
4444 // Create our list of replacements
4545 $replacements = array();
4646 $withs = array();
47 - foreach( $args as $arg ) {
 47+ foreach ( $args as $arg ) {
4848 // Replacements without a = are invalid.
49 - if( strpos($arg,'=') === false ) continue;
 49+ if ( strpos( $arg, '=' ) === false ) continue;
5050 list( $replace, $with ) = explode( '=', $arg, 2 );
51 - $replace = trim($replace);
52 - $with = trim($with);
53 - if( false !== $delimPos = strpos( $regexStarts, $replace[0] ) ) {
 51+ $replace = trim( $replace );
 52+ $with = trim( $with );
 53+ if ( false !== $delimPos = strpos( $regexStarts, $replace[0] ) ) {
5454 // Is Regex Replace
5555 $start = $replace[0];
5656 $end = $regexEnds[$delimPos];
57 -
 57+
5858 $pos = 1;
5959 $endPos = null;
60 - while(!isset($endPos)) {
61 - $pos = strpos($replace, $end, $pos);
62 - if( $pos === false ) return self::error('replaceset-error-regexnoend', $replace, $end);
 60+ while ( !isset( $endPos ) ) {
 61+ $pos = strpos( $replace, $end, $pos );
 62+ if ( $pos === false ) return self::error( 'replaceset-error-regexnoend', $replace, $end );
6363 $backslashes = 0;
64 - for( $l = $pos-1; $l >= 0; $l-- ) {
65 - if( $replace[$l] == '\\' ) $backslashes++;
 64+ for ( $l = $pos - 1; $l >= 0; $l-- ) {
 65+ if ( $replace[$l] == '\\' ) $backslashes++;
6666 else break;
6767 }
68 - if($backslashes % 2 == 0) $endPos = $pos;
 68+ if ( $backslashes % 2 == 0 ) $endPos = $pos;
6969 $pos++;
7070 }
71 - $startRegex = (string)substr($replace, 0, $endPos).$end;
72 - $endRegex = (string)substr($replace, $endPos+1);
73 - $len = strlen($endRegex);
74 - for( $c = 0; $c < $len; $c++ ) {
75 - if( strpos($regexModifiers, $endRegex[$c]) === false )
76 - return self::error('replaceset-error-regexbadmodifier', $endRegex[$c]);
 71+ $startRegex = (string)substr( $replace, 0, $endPos ) . $end;
 72+ $endRegex = (string)substr( $replace, $endPos + 1 );
 73+ $len = strlen( $endRegex );
 74+ for ( $c = 0; $c < $len; $c++ ) {
 75+ if ( strpos( $regexModifiers, $endRegex[$c] ) === false )
 76+ return self::error( 'replaceset-error-regexbadmodifier', $endRegex[$c] );
7777 }
78 - $finalRegex = $startRegex.$endRegex.'u';
79 -
 78+ $finalRegex = $startRegex . $endRegex . 'u';
 79+
8080 $replacements[] = $finalRegex;
8181 $withs[] = $with;
8282 } else {
8383 // Is String Replace
84 - $replacements[] = '/'.preg_quote($replace,'/').'/';
85 - $withs[] = str_replace('\\','\\\\',$with);
 84+ $replacements[] = '/' . preg_quote( $replace, '/' ) . '/';
 85+ $withs[] = str_replace( '\\', '\\\\', $with );
8686 }
8787 }
88 - return preg_replace($replacements, $withs, $string, $egReplaceSetPregLimit);
 88+ return preg_replace( $replacements, $withs, $string, $egReplaceSetPregLimit );
8989 }
 90+
9091 static function error( $msg /*, ... */ ) {
91 - wfLoadExtensionMessages('ReplaceSet');
 92+ wfLoadExtensionMessages( 'ReplaceSet' );
9293 $args = func_get_args();
9394 return '<strong class="error">' . call_user_func_array( 'wfMsgForContent', $args ) . '</strong>';
9495 }
Property changes on: trunk/extensions/ReplaceSet/ReplaceSet.class.php
___________________________________________________________________
Name: svn:eol-style
9596 + native
Index: trunk/extensions/ReplaceSet/ReplaceSet.i18n.php
@@ -1,31 +1,29 @@
2 -<?php
3 -/**
4 - * ReplaceSet
5 - * @package ReplaceSet
6 - * @author Daniel Friesen (http://mediawiki.org/wiki/User:Dantman) <mediawiki@danielfriesen.name>
7 - * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later
8 - *
9 - * This program is free software; you can redistribute it and/or
10 - * modify it under the terms of the GNU General Public License
11 - * as published by the Free Software Foundation; either version 2
12 - * of the License, or (at your option) any later version.
13 - *
14 - * This program is distributed in the hope that it will be useful,
15 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 - * GNU General Public License for more details.
18 - *
19 - * You should have received a copy of the GNU General Public License
20 - * along with this program; if not, write to the Free Software
21 - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
22 - */
23 -
24 -if( !defined( 'MEDIAWIKI' ) ) die( "This is an extension to the MediaWiki package and cannot be run standalone." );
25 -
26 -$messages = array();
27 -
28 -$messages['en'] = array(
29 - 'replaceset-error-calllimit' => 'The ReplaceSet call limit has been reached.',
30 - 'replaceset-error-regexnoend' => 'The regex pattern "$1" is missing the ending delimiter \'$2\'',
31 - 'replaceset-error-regexbadmodifier' => 'The regex modifier \'$1\' is not valid.'
32 -);
 2+<?php
 3+/**
 4+ * ReplaceSet
 5+ * @package ReplaceSet
 6+ * @author Daniel Friesen (http://mediawiki.org/wiki/User:Dantman) <mediawiki@danielfriesen.name>
 7+ * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later
 8+ *
 9+ * This program is free software; you can redistribute it and/or
 10+ * modify it under the terms of the GNU General Public License
 11+ * as published by the Free Software Foundation; either version 2
 12+ * of the License, or (at your option) any later version.
 13+ *
 14+ * This program is distributed in the hope that it will be useful,
 15+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
 16+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 17+ * GNU General Public License for more details.
 18+ *
 19+ * You should have received a copy of the GNU General Public License
 20+ * along with this program; if not, write to the Free Software
 21+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 22+ */
 23+
 24+$messages = array();
 25+
 26+$messages['en'] = array(
 27+ 'replaceset-error-calllimit' => 'The ReplaceSet call limit has been reached.',
 28+ 'replaceset-error-regexnoend' => 'The regex pattern "$1" is missing the ending delimiter \'$2\'',
 29+ 'replaceset-error-regexbadmodifier' => 'The regex modifier \'$1\' is not valid.'
 30+);
Property changes on: trunk/extensions/ReplaceSet/ReplaceSet.i18n.php
___________________________________________________________________
Name: svn:eol-style
3331 + native
Index: trunk/extensions/ReplaceSet/ReplaceSet.php
@@ -4,23 +4,23 @@
55 * @package ReplaceSet
66 * @author Daniel Friesen (http://mediawiki.org/wiki/User:Dantman) <mediawiki@danielfriesen.name>
77 * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later
8 - *
 8+ *
99 * This program is free software; you can redistribute it and/or
1010 * modify it under the terms of the GNU General Public License
1111 * as published by the Free Software Foundation; either version 2
1212 * of the License, or (at your option) any later version.
13 - *
 13+ *
1414 * This program is distributed in the hope that it will be useful,
1515 * but WITHOUT ANY WARRANTY; without even the implied warranty of
1616 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1717 * GNU General Public License for more details.
18 - *
 18+ *
1919 * You should have received a copy of the GNU General Public License
2020 * along with this program; if not, write to the Free Software
2121 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
2222 */
2323
24 -if( !defined( 'MEDIAWIKI' ) ) die( "This is an extension to the MediaWiki package and cannot be run standalone." );
 24+if ( !defined( 'MEDIAWIKI' ) ) die( "This is an extension to the MediaWiki package and cannot be run standalone." );
2525
2626 $wgExtensionCredits['parserhook'][] = array (
2727 'name' => 'ReplaceSet',
@@ -32,12 +32,14 @@
3333
3434 $wgExtensionFunctions[] = 'efReplaceSetSetup';
3535 $wgHooks['LanguageGetMagic'][] = 'efReplaceSetSetupLanguageMagic';
36 -$wgAutoloadClasses['ReplaceSet'] = dirname(__FILE__).'/ReplaceSet.class.php';
37 -$wgExtensionMessagesFiles['ReplaceSet'] = dirname(__FILE__).'/ReplaceSet.i18n.php';
3836
 37+$dir = dirname( __FILE__ ) . '/';
 38+$wgAutoloadClasses['ReplaceSet'] = $dir . 'ReplaceSet.class.php';
 39+$wgExtensionMessagesFiles['ReplaceSet'] = $dir . 'ReplaceSet.i18n.php';
 40+
3941 function efReplaceSetSetup() {
4042 global $wgParser;
41 -
 43+
4244 // Check for SFH_OBJECT_ARGS capability
4345 if ( defined( 'MW_SUPPORTS_PARSERFIRSTCALLINIT' ) ) {
4446 $wgHooks['ParserFirstCallInit'][] = 'efReplaceSetRegisterParser';
@@ -54,6 +56,6 @@
5557 }
5658
5759 function efReplaceSetSetupLanguageMagic( &$magicWords, $langCode ) {
58 - $magicWords['replaceset'] = array( 0, 'replaceset' );
59 - return true;
 60+ $magicWords['replaceset'] = array( 0, 'replaceset' );
 61+ return true;
6062 }
Property changes on: trunk/extensions/ReplaceSet/ReplaceSet.php
___________________________________________________________________
Name: svn:eol-style
6163 + native
Index: trunk/extensions/SwarmExport/swarmExport.php
@@ -3,27 +3,27 @@
44 * SwarmExport
55 * @author Daniel Friesen http://mediawiki.org/wiki/User:Dantman
66 * @version 1.0
7 - *
 7+ *
88 * This program is free software; you can redistribute it and/or
99 * modify it under the terms of the GNU General Public License
1010 * as published by the Free Software Foundation; either version 2
1111 * of the License, or (at your option) any later version.
12 - *
 12+ *
1313 * This program is distributed in the hope that it will be useful,
1414 * but WITHOUT ANY WARRANTY; without even the implied warranty of
1515 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1616 * GNU General Public License for more details.
17 - *
 17+ *
1818 * You should have received a copy of the GNU General Public License
1919 * along with this program; if not, write to the Free Software
2020 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
2121 */
2222
23 -require_once ( getenv('MW_INSTALL_PATH') !== false
24 - ? getenv('MW_INSTALL_PATH')."/maintenance/commandLine.inc"
25 - : dirname( __FILE__ ) . '/../../maintenance/commandLine.inc' );
 23+require_once ( getenv( 'MW_INSTALL_PATH' ) !== false
 24+ ? getenv( 'MW_INSTALL_PATH' ) . "/maintenance/commandLine.inc"
 25+ : dirname( __FILE__ ) . '/../../maintenance/commandLine.inc' );
2626
27 -if( !isset($options['outfile']) ) {
 27+if ( !isset( $options['outfile'] ) ) {
2828 echo <<<SH
2929 Usage: php swarmExport.php --outfile=... [options...]
3030
@@ -36,34 +36,34 @@
3737 --namespaces=<ids> Comma separated list of namespace id's to restrict to
3838 --usersonly Ignore anon users and system users (anyone with id=0)
3939 SH;
40 - exit(0);
 40+ exit( 0 );
4141 }
4242 $file = $options['outfile'];
43 -$append = isset($options['append']);
44 -$start = isset($options['startid']) ? $options['startid'] : null;
45 -$prefix = isset($options['pageprefix']) ? $options['pageprefix'] : '';
46 -$namespaces = isset($options['namespaces'])
47 - ? array_map('intval', explode(',', $options['namespaces']))
 43+$append = isset( $options['append'] );
 44+$start = isset( $options['startid'] ) ? $options['startid'] : null;
 45+$prefix = isset( $options['pageprefix'] ) ? $options['pageprefix'] : '';
 46+$namespaces = isset( $options['namespaces'] )
 47+ ? array_map( 'intval', explode( ',', $options['namespaces'] ) )
4848 : null;
4949
50 -if( !isset($start) ) {
51 - if( $append ) {
52 - if( $f = fopen( $file, 'r' ) ) {
53 - while(!feof($f)) {
 50+if ( !isset( $start ) ) {
 51+ if ( $append ) {
 52+ if ( $f = fopen( $file, 'r' ) ) {
 53+ while ( !feof( $f ) ) {
5454 $line = fgets( $f );
55 - $x = explode('|', $line);
 55+ $x = explode( '|', $line );
5656 $num = $x[0];
57 - if( is_numeric($num) ) $start = intval($num);
58 - }
 57+ if ( is_numeric( $num ) ) $start = intval( $num );
 58+ }
5959 }
60 - if( !isset($start) ) die('Failed, could not guess rev id to start with');
 60+ if ( !isset( $start ) ) die( 'Failed, could not guess rev id to start with' );
6161 } else $start = 0;
6262 }
6363
64 -if( $append ) {
 64+if ( $append ) {
6565 echo "Appending new history items to file starting at revision $start\n";
6666 } else {
67 - if( $start == 0 ) echo "Generating complete history report\n";
 67+ if ( $start == 0 ) echo "Generating complete history report\n";
6868 else echo "Generating history report with only revision $start onwards\n";
6969 }
7070
@@ -71,8 +71,8 @@
7272
7373 $db =& wfGetDB( DB_SLAVE );
7474 $conds = array( 'rev_page=page_id', 'rev_deleted' => 0, "rev_id > $start" );
75 -if( isset($namespaces) ) $conds['page_namespace'] = $namespaces;
76 -if( isset($options['usersonly']) ) $conds[] = 'rev_user != 0';
 75+if ( isset( $namespaces ) ) $conds['page_namespace'] = $namespaces;
 76+if ( isset( $options['usersonly'] ) ) $conds[] = 'rev_user != 0';
7777
7878 echo "Starting db query:\n";
7979
@@ -80,12 +80,12 @@
8181 array( 'rev_id', 'page_namespace', 'page_title', 'rev_user_text', /*'rev_minor_edit',*/ 'rev_timestamp' ),
8282 $conds, null, array( 'ORDER BY' => 'rev_id' ) );
8383
84 -printf("Writing data for %s rows\n", $res->numRows());
 84+printf( "Writing data for %s rows\n", $res->numRows() );
8585
86 -while( $row = $res->fetchObject() ) {
87 - $time = wfTimestamp(TS_UNIX, $row->rev_timestamp);
88 - $title = $prefix.$wgCanonicalNamespaceNames[$row->page_namespace].':'.$row->page_title;
 86+while ( $row = $res->fetchObject() ) {
 87+ $time = wfTimestamp( TS_UNIX, $row->rev_timestamp );
 88+ $title = $prefix . $wgCanonicalNamespaceNames[$row->page_namespace] . ':' . $row->page_title;
8989 fwrite( $f, "{$row->rev_id}|{$title}|{$row->rev_user_text}|{$time}\n" );
9090 }
9191
92 -printf("Completed output of %s history items to %s\n", $res->numRows(), $file);
 92+printf( "Completed output of %s history items to %s\n", $res->numRows(), $file );
Property changes on: trunk/extensions/SwarmExport/swarmExport.php
___________________________________________________________________
Name: svn:eol-style
9393 + native

Status & tagging log