Index: trunk/extensions/WikiCategoryTagCloud/WikiCategoryTagCloud.php |
— | — | @@ -5,25 +5,25 @@ |
6 | 6 | * @ingroup Extensions |
7 | 7 | * @author Daniel Friesen http://daniel.friesen.name |
8 | 8 | * @version 1.0.1 |
9 | | - * |
| 9 | + * |
10 | 10 | * Derived from: YetAnotherTagCloud http://orangedino.com |
11 | | - * |
| 11 | + * |
12 | 12 | * This program is free software; you can redistribute it and/or |
13 | 13 | * modify it under the terms of the GNU General Public License |
14 | 14 | * as published by the Free Software Foundation; either version 2 |
15 | 15 | * of the License, or (at your option) any later version. |
16 | | - * |
| 16 | + * |
17 | 17 | * This program is distributed in the hope that it will be useful, |
18 | 18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
19 | 19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
20 | 20 | * GNU General Public License for more details. |
21 | | - * |
| 21 | + * |
22 | 22 | * You should have received a copy of the GNU General Public License |
23 | 23 | * along with this program; if not, write to the Free Software |
24 | 24 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
25 | 25 | */ |
26 | 26 | |
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." ); |
28 | 28 | |
29 | 29 | $wgExtensionCredits['parserhook'][] = array( |
30 | 30 | 'name' => 'Wiki Category Tag Cloud', |
— | — | @@ -52,7 +52,7 @@ |
53 | 53 | function invalidateCache() { |
54 | 54 | $titles[0] = explode( "\n", wfMsg( 'tagcloudpages' ) ); |
55 | 55 | |
56 | | - for( $i = 0; $i < count( $titles ); $i++) { |
| 56 | + for ( $i = 0; $i < count( $titles ); $i++ ) { |
57 | 57 | Title::newFromText( $titles[$i] )->invalidateCache(); |
58 | 58 | } |
59 | 59 | return true; |
— | — | @@ -73,26 +73,26 @@ |
74 | 74 | $min_count_input = getBoxExtensionOption( $input, 'min_count' ); |
75 | 75 | $min_size_input = getBoxExtensionOption( $input, 'min_size' ); |
76 | 76 | $increase_factor_input = getBoxExtensionOption( $input, 'increase_factor' ); |
77 | | - if( $min_size_input != null ) { |
| 77 | + if ( $min_size_input != null ) { |
78 | 78 | $MIN_SIZE = $min_size_input; |
79 | 79 | } |
80 | | - if( $increase_factor_input != null ) { |
| 80 | + if ( $increase_factor_input != null ) { |
81 | 81 | $INCREASE_FACTOR = $increase_factor_input; |
82 | 82 | } |
83 | | - if( $min_count_input == null ) { |
| 83 | + if ( $min_count_input == null ) { |
84 | 84 | $min_count_input = 0; |
85 | 85 | } |
86 | 86 | |
87 | 87 | $excluded_input = getBoxExtensionOption( $input, 'exclude' ); |
88 | 88 | |
89 | 89 | $exclude_condition = ''; |
90 | | - if( strlen( $excluded_input ) > 0 ) { |
| 90 | + if ( strlen( $excluded_input ) > 0 ) { |
91 | 91 | $excluded_categories = explode( ",", $excluded_input ); |
92 | | - if( count( $excluded_categories ) > 0 ) { |
| 92 | + if ( count( $excluded_categories ) > 0 ) { |
93 | 93 | $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++ ) { |
95 | 95 | $exclude_condition = $exclude_condition . "'" . trim( $excluded_categories[$i] ) . "'"; |
96 | | - if( $i < count( $excluded_categories ) - 1 ) { |
| 96 | + if ( $i < count( $excluded_categories ) - 1 ) { |
97 | 97 | $exclude_condition = $exclude_condition . ","; |
98 | 98 | } |
99 | 99 | } |
— | — | @@ -109,25 +109,25 @@ |
110 | 110 | $htmlOut = $htmlOut . "<div class=\"" . implode( ' ', $cloud_classes ) . "\" style=\"{$cloud_style}\">"; |
111 | 111 | |
112 | 112 | $min = 1000000; |
113 | | - $max = -1; |
| 113 | + $max = - 1; |
114 | 114 | |
115 | | - for( $i = 0; $i < $count; $i++ ) { |
| 115 | + for ( $i = 0; $i < $count; $i++ ) { |
116 | 116 | $obj = $dbr->fetchObject( $res ); |
117 | 117 | $tags[$i][0] = $obj->title; |
118 | 118 | $tags[$i][1] = $obj->count; |
119 | | - if( $obj->count < $min ) { |
| 119 | + if ( $obj->count < $min ) { |
120 | 120 | $min = $obj->count; |
121 | 121 | } |
122 | | - if( $obj->count > $max ) { |
| 122 | + if ( $obj->count > $max ) { |
123 | 123 | $max = $obj->count; |
124 | 124 | } |
125 | 125 | } |
126 | 126 | |
127 | | - for( $i = 0; $i < $count; $i++ ) { |
| 127 | + for ( $i = 0; $i < $count; $i++ ) { |
128 | 128 | $textSize = $MIN_SIZE + ( $INCREASE_FACTOR * ( $tags[$i][1] ) ) / ( $max ); |
129 | 129 | $title = Title::makeTitle( NS_CATEGORY, $tags[$i][0] ); |
130 | 130 | $style = $link_style; |
131 | | - if( $style != '' && $style{-1} != ';' ) $style .= ';'; |
| 131 | + if ( $style != '' && $style { -1 } != ';' ) $style .= ';'; |
132 | 132 | $style .= "font-size: {$textSize}%;"; |
133 | 133 | $currentRow = "<a class=\"" . implode( ' ', $link_classes ) . "\" style=\"{$style}\" href=\"" . $title->getLocalURL() . "\">" . $title->getText() . "</a> "; |
134 | 134 | $htmlOut = $htmlOut . $currentRow; |
— | — | @@ -137,11 +137,11 @@ |
138 | 138 | } |
139 | 139 | |
140 | 140 | 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 ) { |
143 | 143 | return intval( $matches[1] ); |
144 | 144 | } else { |
145 | 145 | return htmlspecialchars( $matches[1] ); |
146 | 146 | } |
147 | 147 | } |
148 | | -} |
\ No newline at end of file |
| 148 | +} |
Property changes on: trunk/extensions/WikiCategoryTagCloud/WikiCategoryTagCloud.php |
___________________________________________________________________ |
Name: svn:eol-style |
149 | 149 | + native |
Index: trunk/extensions/SidebarDonateBox/SidebarDonateBox.php |
— | — | @@ -4,23 +4,23 @@ |
5 | 5 | * @package SidebarDonateBox |
6 | 6 | * @author Daniel Friesen (http://mediawiki.org/wiki/User:Dantman) <mediawiki@danielfriesen.name> |
7 | 7 | * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later |
8 | | - * |
| 8 | + * |
9 | 9 | * This program is free software; you can redistribute it and/or |
10 | 10 | * modify it under the terms of the GNU General Public License |
11 | 11 | * as published by the Free Software Foundation; either version 2 |
12 | 12 | * of the License, or (at your option) any later version. |
13 | | - * |
| 13 | + * |
14 | 14 | * This program is distributed in the hope that it will be useful, |
15 | 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
16 | 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
17 | 17 | * GNU General Public License for more details. |
18 | | - * |
| 18 | + * |
19 | 19 | * You should have received a copy of the GNU General Public License |
20 | 20 | * along with this program; if not, write to the Free Software |
21 | 21 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
22 | 22 | */ |
23 | 23 | |
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." ); |
25 | 25 | |
26 | 26 | $wgExtensionCredits['parserhook'][] = array ( |
27 | 27 | 'name' => 'SidebarDonateBox', |
Property changes on: trunk/extensions/SidebarDonateBox/SidebarDonateBox.php |
___________________________________________________________________ |
Name: svn:eol-style |
28 | 28 | + 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 | + |
211 | 211 | tryRunCreate( $wgDatabase ); |
Property changes on: trunk/extensions/StarterWiki/maintenance/createWikiDBFromStarter.php |
___________________________________________________________________ |
Name: svn:eol-style |
212 | 212 | + 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 |
3 | 3 | + native |
Index: trunk/extensions/CodeTest/CodeTest.php |
— | — | @@ -4,23 +4,23 @@ |
5 | 5 | * @package CodeTest |
6 | 6 | * @author Daniel Friesen (http://mediawiki.org/wiki/User:Dantman) <mediawiki@danielfriesen.name> |
7 | 7 | * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later |
8 | | - * |
| 8 | + * |
9 | 9 | * This program is free software; you can redistribute it and/or |
10 | 10 | * modify it under the terms of the GNU General Public License |
11 | 11 | * as published by the Free Software Foundation; either version 2 |
12 | 12 | * of the License, or (at your option) any later version. |
13 | | - * |
| 13 | + * |
14 | 14 | * This program is distributed in the hope that it will be useful, |
15 | 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
16 | 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
17 | 17 | * GNU General Public License for more details. |
18 | | - * |
| 18 | + * |
19 | 19 | * You should have received a copy of the GNU General Public License |
20 | 20 | * along with this program; if not, write to the Free Software |
21 | 21 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
22 | 22 | */ |
23 | 23 | |
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." ); |
25 | 25 | |
26 | 26 | $wgExtensionCredits['parserhook'][] = array ( |
27 | 27 | 'name' => 'CodeTest', |
— | — | @@ -31,4 +31,4 @@ |
32 | 32 | ); |
33 | 33 | |
34 | 34 | $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 |
36 | 36 | + native |
Index: trunk/extensions/CodeTest/CodeTest.class.php |
— | — | @@ -4,69 +4,68 @@ |
5 | 5 | * @package CodeTest |
6 | 6 | * @author Daniel Friesen (http://mediawiki.org/wiki/User:Dantman) <mediawiki@danielfriesen.name> |
7 | 7 | * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later |
8 | | - * |
| 8 | + * |
9 | 9 | * This program is free software; you can redistribute it and/or |
10 | 10 | * modify it under the terms of the GNU General Public License |
11 | 11 | * as published by the Free Software Foundation; either version 2 |
12 | 12 | * of the License, or (at your option) any later version. |
13 | | - * |
| 13 | + * |
14 | 14 | * This program is distributed in the hope that it will be useful, |
15 | 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
16 | 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
17 | 17 | * GNU General Public License for more details. |
18 | | - * |
| 18 | + * |
19 | 19 | * You should have received a copy of the GNU General Public License |
20 | 20 | * along with this program; if not, write to the Free Software |
21 | 21 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
22 | 22 | */ |
23 | 23 | |
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." ); |
25 | 25 | |
26 | 26 | class CodeTest { |
27 | | - |
| 27 | + |
28 | 28 | static function ParserAfterStrip( &$parser, &$text, &$stripState ) { |
29 | 29 | $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 ) { |
32 | 32 | list( $tag, $content, $params, $original ) = $data; |
33 | | - if( $tag != 'codetest' ) { |
| 33 | + if ( $tag != 'codetest' ) { |
34 | 34 | # This sometimes happends with comments, but in the case of |
35 | 35 | # anything unforseen, just spit the original back out |
36 | | - $text = str_replace($uniq,$original,$text); |
| 36 | + $text = str_replace( $uniq, $original, $text ); |
37 | 37 | continue; |
38 | 38 | } |
39 | | - |
40 | | - $codeData = array_map( 'trim', explode( "\n", trim($content) ) ); |
| 39 | + |
| 40 | + $codeData = array_map( 'trim', explode( "\n", trim( $content ) ) ); |
41 | 41 | $expected = array(); |
42 | | - if( isset($params['sep']) ) |
43 | | - foreach( $codeData as &$code ) |
| 42 | + if ( isset( $params['sep'] ) ) |
| 43 | + foreach ( $codeData as &$code ) |
44 | 44 | list( $code, $expected[] ) = explode( $params['sep'], $code, 2 ); |
45 | 45 | switch( $params['mode'] ) { |
46 | 46 | case 'table': |
47 | | - $content = self::tableModeReplace($codeData,$expected); |
| 47 | + $content = self::tableModeReplace( $codeData, $expected ); |
48 | 48 | break; |
49 | 49 | } |
50 | | - |
51 | | - $text = str_replace($uniq,$content,$text); |
| 50 | + |
| 51 | + $text = str_replace( $uniq, $content, $text ); |
52 | 52 | } |
53 | 53 | return true; |
54 | 54 | } |
55 | | - |
| 55 | + |
56 | 56 | static function tableModeReplace( $codeData, $expected = array() ) { |
57 | | - $expecting = count($codeData) == count($expected); |
| 57 | + $expecting = count( $codeData ) == count( $expected ); |
58 | 58 | $table = "\n{|\n"; |
59 | 59 | $table .= "|-\n"; |
60 | 60 | $table .= "!| Code\n"; |
61 | 61 | $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 ) { |
64 | 64 | $table .= "|-\n"; |
65 | | - $table .= "||\n<nowiki>".htmlspecialchars($code)."</nowiki>\n"; |
| 65 | + $table .= "||\n<nowiki>" . htmlspecialchars( $code ) . "</nowiki>\n"; |
66 | 66 | $table .= "||\n{$code}\n"; |
67 | | - if( $expecting ) $table .= "||\n{$expected[$n]}\n"; |
| 67 | + if ( $expecting ) $table .= "||\n{$expected[$n]}\n"; |
68 | 68 | } |
69 | 69 | $table .= "|}\n"; |
70 | 70 | return $table; |
71 | 71 | } |
72 | | - |
73 | 72 | } |
Property changes on: trunk/extensions/CodeTest/CodeTest.class.php |
___________________________________________________________________ |
Name: svn:eol-style |
74 | 73 | + native |
Index: trunk/extensions/Negref/Negref.php |
— | — | @@ -4,23 +4,23 @@ |
5 | 5 | * @package WikiRuby |
6 | 6 | * @author Daniel Friesen (http://mediawiki.org/wiki/User:Dantman) <mediawiki@danielfriesen.name> |
7 | 7 | * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later |
8 | | - * |
| 8 | + * |
9 | 9 | * This program is free software; you can redistribute it and/or |
10 | 10 | * modify it under the terms of the GNU General Public License |
11 | 11 | * as published by the Free Software Foundation; either version 2 |
12 | 12 | * of the License, or (at your option) any later version. |
13 | | - * |
| 13 | + * |
14 | 14 | * This program is distributed in the hope that it will be useful, |
15 | 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
16 | 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
17 | 17 | * GNU General Public License for more details. |
18 | | - * |
| 18 | + * |
19 | 19 | * You should have received a copy of the GNU General Public License |
20 | 20 | * along with this program; if not, write to the Free Software |
21 | 21 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
22 | 22 | */ |
23 | 23 | |
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." ); |
25 | 25 | |
26 | 26 | $wgExtensionCredits['parserhook'][] = array ( |
27 | 27 | "path" => __FILE__, |
— | — | @@ -34,7 +34,7 @@ |
35 | 35 | |
36 | 36 | function efNegrefSetup() { |
37 | 37 | global $wgParser, $wgHooks; |
38 | | - |
| 38 | + |
39 | 39 | // Check for SFH_OBJECT_ARGS capability |
40 | 40 | if ( defined( 'MW_SUPPORTS_PARSERFIRSTCALLINIT' ) ) { |
41 | 41 | $wgHooks['ParserFirstCallInit'][] = 'efNegrefRegisterParser'; |
— | — | @@ -44,7 +44,7 @@ |
45 | 45 | } |
46 | 46 | efNegrefRegisterParser( $wgParser ); |
47 | 47 | } |
48 | | - |
| 48 | + |
49 | 49 | return true; |
50 | 50 | } |
51 | 51 | |
— | — | @@ -54,23 +54,23 @@ |
55 | 55 | } |
56 | 56 | |
57 | 57 | function efNegrefSetupLanguageMagic( &$magicWords, $langCode ) { |
58 | | - $magicWords['negref'] = array( 0, 'negref' ); |
59 | | - return true; |
| 58 | + $magicWords['negref'] = array( 0, 'negref' ); |
| 59 | + return true; |
60 | 60 | } |
61 | 61 | |
62 | 62 | function efNegrefHook( $parser, $input, $replaceData, $replaceRef, $pattern ) { |
63 | 63 | $data = $input; |
64 | 64 | $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 ); |
71 | 71 | $ref .= $key; |
72 | 72 | } |
73 | 73 | } |
74 | 74 | } |
75 | | - |
76 | | - return str_replace($replaceRef, $ref, str_replace($replaceData, $data, $pattern)); |
| 75 | + |
| 76 | + return str_replace( $replaceRef, $ref, str_replace( $replaceData, $data, $pattern ) ); |
77 | 77 | } |
Index: trunk/extensions/ReplaceSet/ReplaceSet.class.php |
— | — | @@ -4,90 +4,91 @@ |
5 | 5 | * @package ReplaceSet |
6 | 6 | * @author Daniel Friesen (http://mediawiki.org/wiki/User:Dantman) <mediawiki@danielfriesen.name> |
7 | 7 | * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later |
8 | | - * |
| 8 | + * |
9 | 9 | * This program is free software; you can redistribute it and/or |
10 | 10 | * modify it under the terms of the GNU General Public License |
11 | 11 | * as published by the Free Software Foundation; either version 2 |
12 | 12 | * of the License, or (at your option) any later version. |
13 | | - * |
| 13 | + * |
14 | 14 | * This program is distributed in the hope that it will be useful, |
15 | 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
16 | 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
17 | 17 | * GNU General Public License for more details. |
18 | | - * |
| 18 | + * |
19 | 19 | * You should have received a copy of the GNU General Public License |
20 | 20 | * along with this program; if not, write to the Free Software |
21 | 21 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
22 | 22 | */ |
23 | 23 | |
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." ); |
25 | 25 | |
26 | 26 | class ReplaceSet { |
27 | 27 | static function parserFunction( &$parser, $string ) { |
28 | 28 | 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; |
31 | 31 | static $called = 0; |
32 | 32 | $called++; |
33 | | - if( $called > $egReplaceSetCallLimit ) |
34 | | - return self::error('replaceset-error-calllimit'); |
| 33 | + if ( $called > $egReplaceSetCallLimit ) |
| 34 | + return self::error( 'replaceset-error-calllimit' ); |
35 | 35 | // Set basic statics |
36 | 36 | static $regexStarts = '/!#=([{'; |
37 | 37 | static $regexEnds = '/!#=)]}'; |
38 | 38 | static $regexModifiers = 'imsxADU'; |
39 | 39 | // Grab our args |
40 | 40 | $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 | + |
44 | 44 | // Create our list of replacements |
45 | 45 | $replacements = array(); |
46 | 46 | $withs = array(); |
47 | | - foreach( $args as $arg ) { |
| 47 | + foreach ( $args as $arg ) { |
48 | 48 | // Replacements without a = are invalid. |
49 | | - if( strpos($arg,'=') === false ) continue; |
| 49 | + if ( strpos( $arg, '=' ) === false ) continue; |
50 | 50 | 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] ) ) { |
54 | 54 | // Is Regex Replace |
55 | 55 | $start = $replace[0]; |
56 | 56 | $end = $regexEnds[$delimPos]; |
57 | | - |
| 57 | + |
58 | 58 | $pos = 1; |
59 | 59 | $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 ); |
63 | 63 | $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++; |
66 | 66 | else break; |
67 | 67 | } |
68 | | - if($backslashes % 2 == 0) $endPos = $pos; |
| 68 | + if ( $backslashes % 2 == 0 ) $endPos = $pos; |
69 | 69 | $pos++; |
70 | 70 | } |
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] ); |
77 | 77 | } |
78 | | - $finalRegex = $startRegex.$endRegex.'u'; |
79 | | - |
| 78 | + $finalRegex = $startRegex . $endRegex . 'u'; |
| 79 | + |
80 | 80 | $replacements[] = $finalRegex; |
81 | 81 | $withs[] = $with; |
82 | 82 | } else { |
83 | 83 | // Is String Replace |
84 | | - $replacements[] = '/'.preg_quote($replace,'/').'/'; |
85 | | - $withs[] = str_replace('\\','\\\\',$with); |
| 84 | + $replacements[] = '/' . preg_quote( $replace, '/' ) . '/'; |
| 85 | + $withs[] = str_replace( '\\', '\\\\', $with ); |
86 | 86 | } |
87 | 87 | } |
88 | | - return preg_replace($replacements, $withs, $string, $egReplaceSetPregLimit); |
| 88 | + return preg_replace( $replacements, $withs, $string, $egReplaceSetPregLimit ); |
89 | 89 | } |
| 90 | + |
90 | 91 | static function error( $msg /*, ... */ ) { |
91 | | - wfLoadExtensionMessages('ReplaceSet'); |
| 92 | + wfLoadExtensionMessages( 'ReplaceSet' ); |
92 | 93 | $args = func_get_args(); |
93 | 94 | return '<strong class="error">' . call_user_func_array( 'wfMsgForContent', $args ) . '</strong>'; |
94 | 95 | } |
Property changes on: trunk/extensions/ReplaceSet/ReplaceSet.class.php |
___________________________________________________________________ |
Name: svn:eol-style |
95 | 96 | + 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 |
33 | 31 | + native |
Index: trunk/extensions/ReplaceSet/ReplaceSet.php |
— | — | @@ -4,23 +4,23 @@ |
5 | 5 | * @package ReplaceSet |
6 | 6 | * @author Daniel Friesen (http://mediawiki.org/wiki/User:Dantman) <mediawiki@danielfriesen.name> |
7 | 7 | * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later |
8 | | - * |
| 8 | + * |
9 | 9 | * This program is free software; you can redistribute it and/or |
10 | 10 | * modify it under the terms of the GNU General Public License |
11 | 11 | * as published by the Free Software Foundation; either version 2 |
12 | 12 | * of the License, or (at your option) any later version. |
13 | | - * |
| 13 | + * |
14 | 14 | * This program is distributed in the hope that it will be useful, |
15 | 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
16 | 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
17 | 17 | * GNU General Public License for more details. |
18 | | - * |
| 18 | + * |
19 | 19 | * You should have received a copy of the GNU General Public License |
20 | 20 | * along with this program; if not, write to the Free Software |
21 | 21 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
22 | 22 | */ |
23 | 23 | |
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." ); |
25 | 25 | |
26 | 26 | $wgExtensionCredits['parserhook'][] = array ( |
27 | 27 | 'name' => 'ReplaceSet', |
— | — | @@ -32,12 +32,14 @@ |
33 | 33 | |
34 | 34 | $wgExtensionFunctions[] = 'efReplaceSetSetup'; |
35 | 35 | $wgHooks['LanguageGetMagic'][] = 'efReplaceSetSetupLanguageMagic'; |
36 | | -$wgAutoloadClasses['ReplaceSet'] = dirname(__FILE__).'/ReplaceSet.class.php'; |
37 | | -$wgExtensionMessagesFiles['ReplaceSet'] = dirname(__FILE__).'/ReplaceSet.i18n.php'; |
38 | 36 | |
| 37 | +$dir = dirname( __FILE__ ) . '/'; |
| 38 | +$wgAutoloadClasses['ReplaceSet'] = $dir . 'ReplaceSet.class.php'; |
| 39 | +$wgExtensionMessagesFiles['ReplaceSet'] = $dir . 'ReplaceSet.i18n.php'; |
| 40 | + |
39 | 41 | function efReplaceSetSetup() { |
40 | 42 | global $wgParser; |
41 | | - |
| 43 | + |
42 | 44 | // Check for SFH_OBJECT_ARGS capability |
43 | 45 | if ( defined( 'MW_SUPPORTS_PARSERFIRSTCALLINIT' ) ) { |
44 | 46 | $wgHooks['ParserFirstCallInit'][] = 'efReplaceSetRegisterParser'; |
— | — | @@ -54,6 +56,6 @@ |
55 | 57 | } |
56 | 58 | |
57 | 59 | function efReplaceSetSetupLanguageMagic( &$magicWords, $langCode ) { |
58 | | - $magicWords['replaceset'] = array( 0, 'replaceset' ); |
59 | | - return true; |
| 60 | + $magicWords['replaceset'] = array( 0, 'replaceset' ); |
| 61 | + return true; |
60 | 62 | } |
Property changes on: trunk/extensions/ReplaceSet/ReplaceSet.php |
___________________________________________________________________ |
Name: svn:eol-style |
61 | 63 | + native |
Index: trunk/extensions/SwarmExport/swarmExport.php |
— | — | @@ -3,27 +3,27 @@ |
4 | 4 | * SwarmExport |
5 | 5 | * @author Daniel Friesen http://mediawiki.org/wiki/User:Dantman |
6 | 6 | * @version 1.0 |
7 | | - * |
| 7 | + * |
8 | 8 | * This program is free software; you can redistribute it and/or |
9 | 9 | * modify it under the terms of the GNU General Public License |
10 | 10 | * as published by the Free Software Foundation; either version 2 |
11 | 11 | * of the License, or (at your option) any later version. |
12 | | - * |
| 12 | + * |
13 | 13 | * This program is distributed in the hope that it will be useful, |
14 | 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 | 16 | * GNU General Public License for more details. |
17 | | - * |
| 17 | + * |
18 | 18 | * You should have received a copy of the GNU General Public License |
19 | 19 | * along with this program; if not, write to the Free Software |
20 | 20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
21 | 21 | */ |
22 | 22 | |
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' ); |
26 | 26 | |
27 | | -if( !isset($options['outfile']) ) { |
| 27 | +if ( !isset( $options['outfile'] ) ) { |
28 | 28 | echo <<<SH |
29 | 29 | Usage: php swarmExport.php --outfile=... [options...] |
30 | 30 | |
— | — | @@ -36,34 +36,34 @@ |
37 | 37 | --namespaces=<ids> Comma separated list of namespace id's to restrict to |
38 | 38 | --usersonly Ignore anon users and system users (anyone with id=0) |
39 | 39 | SH; |
40 | | - exit(0); |
| 40 | + exit( 0 ); |
41 | 41 | } |
42 | 42 | $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'] ) ) |
48 | 48 | : null; |
49 | 49 | |
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 ) ) { |
54 | 54 | $line = fgets( $f ); |
55 | | - $x = explode('|', $line); |
| 55 | + $x = explode( '|', $line ); |
56 | 56 | $num = $x[0]; |
57 | | - if( is_numeric($num) ) $start = intval($num); |
58 | | - } |
| 57 | + if ( is_numeric( $num ) ) $start = intval( $num ); |
| 58 | + } |
59 | 59 | } |
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' ); |
61 | 61 | } else $start = 0; |
62 | 62 | } |
63 | 63 | |
64 | | -if( $append ) { |
| 64 | +if ( $append ) { |
65 | 65 | echo "Appending new history items to file starting at revision $start\n"; |
66 | 66 | } else { |
67 | | - if( $start == 0 ) echo "Generating complete history report\n"; |
| 67 | + if ( $start == 0 ) echo "Generating complete history report\n"; |
68 | 68 | else echo "Generating history report with only revision $start onwards\n"; |
69 | 69 | } |
70 | 70 | |
— | — | @@ -71,8 +71,8 @@ |
72 | 72 | |
73 | 73 | $db =& wfGetDB( DB_SLAVE ); |
74 | 74 | $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'; |
77 | 77 | |
78 | 78 | echo "Starting db query:\n"; |
79 | 79 | |
— | — | @@ -80,12 +80,12 @@ |
81 | 81 | array( 'rev_id', 'page_namespace', 'page_title', 'rev_user_text', /*'rev_minor_edit',*/ 'rev_timestamp' ), |
82 | 82 | $conds, null, array( 'ORDER BY' => 'rev_id' ) ); |
83 | 83 | |
84 | | -printf("Writing data for %s rows\n", $res->numRows()); |
| 84 | +printf( "Writing data for %s rows\n", $res->numRows() ); |
85 | 85 | |
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; |
89 | 89 | fwrite( $f, "{$row->rev_id}|{$title}|{$row->rev_user_text}|{$time}\n" ); |
90 | 90 | } |
91 | 91 | |
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 |
93 | 93 | + native |