Index: trunk/phpwiki/newcodebase/GlobalFunctions.php |
— | — | @@ -48,10 +48,12 @@ |
49 | 49 | |
50 | 50 | function wfDebug( $text ) |
51 | 51 | { |
52 | | - global $wgOut; |
| 52 | + global $wgOut, $wgDebugLogFile; |
53 | 53 | $wgOut->debug( $text ); |
54 | 54 | |
55 | | - error_log( $text, 3, "/var/www/html/newwiki/logfile" ); |
| 55 | + if ( "" != $wgDebugLogFile ) { |
| 56 | + error_log( $text, 3, $wgDebugLogFile ); |
| 57 | + } |
56 | 58 | } |
57 | 59 | |
58 | 60 | function wfMsg( $key ) |
Index: trunk/phpwiki/newcodebase/Skin.php |
— | — | @@ -48,7 +48,7 @@ |
49 | 49 | { |
50 | 50 | global $wgTitle, $wgNamespaceBackgrounds; |
51 | 51 | |
52 | | - $ns = $wgTitle->getNamespace(); |
| 52 | + $ns = Namespace::getName( $wgTitle->getNamespace() ); |
53 | 53 | |
54 | 54 | if ( "" != $ns && key_exists( $ns, $wgNamespaceBackgrounds ) ) { |
55 | 55 | return array( "bgcolor" => $wgNamespaceBackgrounds[$ns] ); |
— | — | @@ -376,34 +376,25 @@ |
377 | 377 | { |
378 | 378 | global $wgTitle; |
379 | 379 | |
380 | | - $ns = $wgTitle->getNamespace(); |
| 380 | + $tns = $wgTitle->getNamespace(); |
| 381 | + if ( -1 == $tns ) { return ""; } |
| 382 | + |
381 | 383 | $pn = $wgTitle->getText(); |
382 | 384 | $tp = wfMsg( "talkpage" ); |
383 | 385 | $sp = wfMsg( "subjectpage" ); |
384 | 386 | |
385 | | - if ( "" == $ns ) { |
386 | | - $link = "Talk:$pn"; |
387 | | - $text = $tp; |
388 | | - } else if ( "Talk" == $ns ) { |
389 | | - $link = $pn; |
| 387 | + if ( Namespace::isTalk( $tns ) ) { |
| 388 | + $lns = Namespace::getSubject( $tns ); |
390 | 389 | $text = $sp; |
391 | 390 | } else { |
392 | | - $tail = substr( $ns, -5 ); |
393 | | - if ( "_talk" == $tail ) { |
394 | | - $n = substr( $ns, 0, strlen( $ns ) - 5 ); |
395 | | - $link = "$n:$pn"; |
396 | | - $text = $sp; |
397 | | - } else { |
398 | | - $link = "{$ns}_talk:$pn"; |
399 | | - $text = $tp; |
400 | | - } |
| 391 | + $lns = Namespace::getTalk( $tns ); |
| 392 | + $text = $tp; |
401 | 393 | } |
402 | | - $nt = Title::newFromText( $link ); |
403 | | - if ( 0 == $nt->getArticleID() ) { |
404 | | - $s = $this->makeBrokenLink( $link, $text ); |
405 | | - } else { |
406 | | - $s = $this->makeLink( $link, $text ); |
407 | | - } |
| 394 | + $n = Namespace::getName( $lns ); |
| 395 | + if ( "" == $n ) { $link = $pn; } |
| 396 | + else { $link = "$n:$pn"; } |
| 397 | + |
| 398 | + $s = $this->makeInternalLink( $link, $text ); |
408 | 399 | return $s; |
409 | 400 | } |
410 | 401 | |
— | — | @@ -415,12 +406,11 @@ |
416 | 407 | return $text; |
417 | 408 | } |
418 | 409 | |
419 | | - function makeInternalLink( $title, $text= "", $action = "", $target = "", |
420 | | - $trail = "" ) |
| 410 | + function makeInternalLink( $title, $text= "", $query = "", $trail = "" ) |
421 | 411 | { |
422 | 412 | $nt = Title::newFromText( $title ); |
423 | | - if ( "Special" == $nt->getNamespace() ) { |
424 | | - return $this->makeLink( $title, $text ); |
| 413 | + if ( -1 == $nt->getNamespace() ) { |
| 414 | + return $this->makeLink( $title, $text, $query, $trail ); |
425 | 415 | } |
426 | 416 | if ( 0 == $nt->getArticleID() ) { |
427 | 417 | return $this->makeBrokenLink( $title, $text ) . $trail; |
Index: trunk/phpwiki/newcodebase/sql/buildtables.sql |
— | — | @@ -7,7 +7,7 @@ |
8 | 8 | |
9 | 9 | CREATE TABLE cur ( |
10 | 10 | cur_id mediumint(8) unsigned NOT NULL auto_increment, |
11 | | - cur_namespace varchar(20) binary NOT NULL default '', |
| 11 | + cur_namespace tinyint(2) unsigned NOT NULL default '0', |
12 | 12 | cur_title varchar(255) binary NOT NULL default '', |
13 | 13 | cur_text mediumtext, |
14 | 14 | cur_comment tinyblob, |
— | — | @@ -21,6 +21,7 @@ |
22 | 22 | cur_counter bigint(20) unsigned default '0', |
23 | 23 | cur_cache mediumtext, |
24 | 24 | cur_ind_title varchar(255) default NULL, |
| 25 | + INDEX cur_namespace (cur_namespace), |
25 | 26 | INDEX cur_title (cur_title), |
26 | 27 | UNIQUE KEY cur_id (cur_id), |
27 | 28 | INDEX timeind (cur_timestamp), |
— | — | @@ -45,7 +46,7 @@ |
46 | 47 | |
47 | 48 | CREATE TABLE old ( |
48 | 49 | old_id mediumint(8) unsigned NOT NULL auto_increment, |
49 | | - old_namespace varchar(20) binary NOT NULL default '', |
| 50 | + old_namespace tinyint(2) unsigned NOT NULL default '0', |
50 | 51 | old_title varchar(255) binary NOT NULL default '', |
51 | 52 | old_text mediumtext, |
52 | 53 | old_comment tinyblob, |
Index: trunk/phpwiki/newcodebase/sql/convertdb.php |
— | — | @@ -3,6 +3,8 @@ |
4 | 4 | # database into the format for the "newwiki" software. |
5 | 5 | # Intended to be run from the php command line. |
6 | 6 | # |
| 7 | +include_once( "../Namespace.php" ); |
| 8 | + |
7 | 9 | $DBserver = "127.0.0.1"; |
8 | 10 | $DBname = "wikidb"; |
9 | 11 | $DBuser = "wikiuser"; |
— | — | @@ -19,6 +21,7 @@ |
20 | 22 | |
21 | 23 | set_time_limit(0); |
22 | 24 | |
| 25 | + |
23 | 26 | # USER |
24 | 27 | # |
25 | 28 | print "Converting USER table.\n"; |
— | — | @@ -38,6 +41,8 @@ |
39 | 42 | } else { |
40 | 43 | fwrite( $outf, "," ); |
41 | 44 | } |
| 45 | + # Need to do some tweaking of options here |
| 46 | + # |
42 | 47 | $ops = strencode(urldecode($row->user_options)); |
43 | 48 | $name = strencode($row->user_name); |
44 | 49 | $rights = strencode($row->user_rights); |
— | — | @@ -53,10 +58,9 @@ |
54 | 59 | fwrite( $outf, ";\n" ); |
55 | 60 | p_end(); |
56 | 61 | |
57 | | - |
58 | 62 | # CUR |
59 | 63 | # |
60 | | -/* |
| 64 | + |
61 | 65 | print "Converting CUR table.\n"; |
62 | 66 | $sql = "SELECT * FROM cur"; |
63 | 67 | $res = mysql_query( $sql, $conn ); |
— | — | @@ -84,7 +88,7 @@ |
85 | 89 | $ns = ""; |
86 | 90 | $t = $row->cur_title; |
87 | 91 | } |
88 | | - $namespace = strencode( $ns ); |
| 92 | + $namespace = Namespace::getIndex( $ns ); |
89 | 93 | $title = strencode( $t ); |
90 | 94 | $text = strencode( $row->cur_text ); |
91 | 95 | $com = strencode( $row->cur_comment ); |
— | — | @@ -93,7 +97,7 @@ |
94 | 98 | $cp = strencode( $row->cur_params ); |
95 | 99 | $cit = strencode( $row->cur_ind_title ); |
96 | 100 | |
97 | | - fwrite( $outf, "({$row->cur_id},'$namespace','$title','$text'," . |
| 101 | + fwrite( $outf, "({$row->cur_id},$namespace,'$title','$text'," . |
98 | 102 | "'$com',{$row->cur_user},'$cut',{$row->cur_old_version}," . |
99 | 103 | "'{$row->cur_timestamp}',{$row->cur_minor_edit},'$cr','$cp'," . |
100 | 104 | "{$row->cur_counter},'$cit')" ); |
— | — | @@ -102,8 +106,52 @@ |
103 | 107 | mysql_free_result( $res ); |
104 | 108 | fwrite( $outf, ";\n" ); |
105 | 109 | p_end(); |
106 | | -*/ |
107 | 110 | |
| 111 | +# OLD |
| 112 | +# |
| 113 | + |
| 114 | +print "Converting OLD table.\n"; |
| 115 | +$sql = "SELECT * FROM old"; |
| 116 | +$res = mysql_query( $sql, $conn ); |
| 117 | +if ( ! $res ) die( "Can't open \"old\" table." ); |
| 118 | + |
| 119 | +p_start(); |
| 120 | +while ( $row = mysql_fetch_object( $res ) ) { |
| 121 | + |
| 122 | + if ( 0 == ( $progressCount % 100 ) ) { |
| 123 | + if ( 0 != $progressCount ) { fwrite( $outf, ";\n" ) ; } |
| 124 | + |
| 125 | + fwrite( $outf, "INSERT INTO old (old_id,old_namespace," . |
| 126 | + "old_title,old_text,old_comment,old_user,old_user_text," . |
| 127 | + "old_old_version,old_timestamp,old_minor_edit) VALUES " ); |
| 128 | + } else { |
| 129 | + fwrite( $outf, "," ); |
| 130 | + } |
| 131 | + if ( preg_match( "/^([A-Za-z][A-Za-z0-9 _]*):(.*)$/", |
| 132 | + $row->old_title, $m ) ) { |
| 133 | + $ns = $m[1]; |
| 134 | + $t = $m[2]; |
| 135 | + } else { |
| 136 | + $ns = ""; |
| 137 | + $t = $row->old_title; |
| 138 | + } |
| 139 | + $namespace = Namespace::getIndex( $ns ); |
| 140 | + $title = strencode( $t ); |
| 141 | + $text = strencode( $row->old_text ); |
| 142 | + $com = strencode( $row->old_comment ); |
| 143 | + $cut = strencode( $row->old_user_text ); |
| 144 | + |
| 145 | + fwrite( $outf, "({$row->old_id},$namespace,'$title','$text'," . |
| 146 | + "'$com',{$row->old_user},'$cut',{$row->old_old_version}," . |
| 147 | + "'{$row->old_timestamp}',{$row->old_minor_edit} )" ); |
| 148 | + progress(); |
| 149 | +} |
| 150 | +mysql_free_result( $res ); |
| 151 | +fwrite( $outf, ";\n" ); |
| 152 | +p_end(); |
| 153 | + |
| 154 | + |
| 155 | + |
108 | 156 | fclose( $outf ); |
109 | 157 | |
110 | 158 | # All done |
Index: trunk/phpwiki/newcodebase/SpecialUserlogout.php |
— | — | @@ -8,14 +8,7 @@ |
9 | 9 | $wgOut->setPageTitle( wfMsg( "userlogout" ) ); |
10 | 10 | $wgOut->setRobotpolicy( "noindex,nofollow" ); |
11 | 11 | $wgOut->addHTML( wfMsg( "logouttext" ) . "\n<p>" ); |
12 | | - |
13 | | - if ( "" == $returnto ) { |
14 | | - $r = wfMsg( "returntomain" ); |
15 | | - } else { |
16 | | - $r = str_replace( "$1", $returnto, wfMsg( "returnto" ) ); |
17 | | - $wgOut->addMeta( "http:Refresh", "5;url=" . wfLocalLink( $returnto ) ); |
18 | | - } |
19 | | - $wgOut->addWikiText( $r ); |
| 12 | + $wgOut->returnToMain(); |
20 | 13 | } |
21 | 14 | |
22 | 15 | ?> |
Index: trunk/phpwiki/newcodebase/User.php |
— | — | @@ -65,26 +65,19 @@ |
66 | 66 | |
67 | 67 | $remaddr = getenv( "REMOTE_ADDR" ); |
68 | 68 | $conn = wfGetDB(); |
69 | | - $sql = "SELECT ipb_by,ipb_reason FROM ipblocks WHERE " . |
70 | | - "ipb_address='$remaddr'"; |
| 69 | + if ( 0 == $this->mId ) { |
| 70 | + $sql = "SELECT ipb_by,ipb_reason FROM ipblocks WHERE " . |
| 71 | + "ipb_address='$remaddr'"; |
| 72 | + } else { |
| 73 | + $sql = "SELECT ipb_by,ipb_reason FROM ipblocks WHERE " . |
| 74 | + "(ipb_address='$remaddr' OR ipb_user={$this->mId})"; |
| 75 | + } |
71 | 76 | wfDebug( "User: 5: $sql\n" ); |
72 | 77 | |
73 | 78 | $res = mysql_query( $sql, $conn ); |
74 | 79 | if ( ( false === $res ) || ( 0 == mysql_num_rows( $res ) ) ) { |
75 | | - if ( 0 == $this->mId ) { |
76 | | - $this->mBlockedby = 0; |
77 | | - return; |
78 | | - } |
79 | | - $conn = wfGetDB(); |
80 | | - $sql = "SELECT ipb_by,ipb_reason FROM ipblocks WHERE " . |
81 | | - "ipb_user={$this->mId}"; |
82 | | - wfDebug( "User: 6: $sql\n" ); |
83 | | - |
84 | | - $res = mysql_query( $sql, $conn ); |
85 | | - if ( ( false === $res ) || ( 0 == mysql_num_rows( $res ) ) ) { |
86 | | - $this->mBlockedby = 0; |
87 | | - return; |
88 | | - } |
| 80 | + $this->mBlockedby = 0; |
| 81 | + return; |
89 | 82 | } |
90 | 83 | $s = mysql_fetch_object( $res ); |
91 | 84 | $this->mBlockedby = $s->ipb_by; |
Index: trunk/phpwiki/newcodebase/Language.php |
— | — | @@ -72,6 +72,10 @@ |
73 | 73 | "noconnect" => "Could not connect to DB on $1", |
74 | 74 | "nodb" => "Could not select database $1", |
75 | 75 | "updatingarticle" => "updating an article", |
| 76 | +"readonly" => "Database locked", |
| 77 | +"readonlytext" => "The Wikipedia database is currently locked to |
| 78 | +new entries, probably because of database maintenance. |
| 79 | +Please try again later.\n", |
76 | 80 | |
77 | 81 | # Login and logout pages |
78 | 82 | # |
Index: trunk/phpwiki/newcodebase/OutputPage.php |
— | — | @@ -108,7 +108,7 @@ |
109 | 109 | |
110 | 110 | $this->mBodytext = ""; |
111 | 111 | $this->addHTML( "<p>" . wfMsg( $msg ) . "\n" ); |
112 | | - $this->addWikiText( "\n" . wfMsg( "returntomain" ) . "\n" ); |
| 112 | + $this->returnToMain(); |
113 | 113 | } |
114 | 114 | |
115 | 115 | function databaseError( $op ) |
— | — | @@ -119,9 +119,23 @@ |
120 | 120 | $this->setRobotpolicy( "noindex,nofollow" ); |
121 | 121 | |
122 | 122 | $this->mBodytext = str_replace( "$1", $op, wfMsg( "dberrortext" ) ); |
123 | | - $this->addWikiText( "\n" . wfMsg( "returntomain" ) . "\n" ); |
| 123 | + $this->returnToMain(); |
124 | 124 | } |
125 | 125 | |
| 126 | + function returnToMain() |
| 127 | + { |
| 128 | + global $wgOut, $returnto; |
| 129 | + |
| 130 | + if ( "" == $returnto ) { |
| 131 | + $r = wfMsg( "returntomain" ); |
| 132 | + } else { |
| 133 | + $r = str_replace( "$1", $returnto, wfMsg( "returnto" ) ); |
| 134 | + $wgOut->addMeta( "http:Refresh", "10;url=" . |
| 135 | + wfLocalLink( $returnto ) ); |
| 136 | + } |
| 137 | + $wgOut->addWikiText( "\n<p>$r\n" ); |
| 138 | + } |
| 139 | + |
126 | 140 | # Well, OK, it's actually about 14 passes. But since all the |
127 | 141 | # hard lifting is done inside PHP's regex code, it probably |
128 | 142 | # wouldn't speed things up much to add a real parser. |
— | — | @@ -307,14 +321,14 @@ |
308 | 322 | $l = $wgLang->getLanguageName( $pre ); |
309 | 323 | if ( "" == $l ) { |
310 | 324 | $s .= $sk->makeInternalLink( $link, $text, |
311 | | - "", "", $trail ); |
| 325 | + "", $trail ); |
312 | 326 | } else { |
313 | 327 | array_push( $this->mLanguageLinks, "$pre:$suf" ); |
314 | 328 | $s .= $trail; |
315 | 329 | } |
316 | 330 | } |
317 | 331 | } else { |
318 | | - $s .= $sk->makeInternalLink( $link, $text, "", "", $trail ); |
| 332 | + $s .= $sk->makeInternalLink( $link, $text, "", $trail ); |
319 | 333 | } |
320 | 334 | } |
321 | 335 | return $s; |
— | — | @@ -423,7 +437,7 @@ |
424 | 438 | |
425 | 439 | if ( ";" == substr( $pref, -1 ) ) { |
426 | 440 | $cpos = strpos( $t, ":" ); |
427 | | - if ( ! false === $cpos ) { |
| 441 | + if ( ! ( false === $cpos ) ) { |
428 | 442 | $term = substr( $t, 0, $cpos ); |
429 | 443 | $text .= $term . "</dt><dd>"; |
430 | 444 | $t = substr( $t, $cpos + 1 ); |
— | — | @@ -443,7 +457,7 @@ |
444 | 458 | |
445 | 459 | if ( ";" == $char ) { |
446 | 460 | $cpos = strpos( $t, ":" ); |
447 | | - if ( ! false === $cpos ) { |
| 461 | + if ( ! ( false === $cpos ) ) { |
448 | 462 | $term = substr( $t, 0, $cpos ); |
449 | 463 | $text .= $term . "</dt><dd>"; |
450 | 464 | $t = substr( $t, $cpos + 1 ); |
Index: trunk/phpwiki/newcodebase/wiki.phtml |
— | — | @@ -7,6 +7,7 @@ |
8 | 8 | include_once( "./LocalSettings.php" ); |
9 | 9 | include_once( "./GlobalFunctions.php" ); |
10 | 10 | include_once( "./InterText.php" ); |
| 11 | +include_once( "./Namespace.php" ); |
11 | 12 | include_once( "./Skin.php" ); |
12 | 13 | include_once( "./OutputPage.php" ); |
13 | 14 | include_once( "./User.php" ); |
— | — | @@ -34,7 +35,7 @@ |
35 | 36 | if ( "" == $title ) { $title = wfMsg( "mainpage" ); } |
36 | 37 | |
37 | 38 | $wgTitle = Title::newFromURL( $title ); |
38 | | -if ( 0 == strcmp( "Special", $wgTitle->getNamespace() ) ) { |
| 39 | +if ( -1 == $wgTitle->getNamespace() ) { |
39 | 40 | wfSpecialPage(); |
40 | 41 | } else if ( "" != $search ) { wfSearch( $search ); } |
41 | 42 | else { |
Index: trunk/phpwiki/newcodebase/SpecialUserlogin.php |
— | — | @@ -122,14 +122,7 @@ |
123 | 123 | $wgOut->setPageTitle( wfMsg( "loginsuccesstitle" ) ); |
124 | 124 | $wgOut->setRobotpolicy( "noindex,nofollow" ); |
125 | 125 | $wgOut->addHTML( $msg . "\n<p>" ); |
126 | | - |
127 | | - if ( "" == $returnto ) { |
128 | | - $r = wfMsg( "returntomain" ); |
129 | | - } else { |
130 | | - $r = str_replace( "$1", $returnto, wfMsg( "returnto" ) ); |
131 | | - $wgOut->addMeta( "http:Refresh", "5;url=" . wfLocalLink( $returnto ) ); |
132 | | - } |
133 | | - $wgOut->addWikiText( $r ); |
| 126 | + $wgOut->returnToMain(); |
134 | 127 | } |
135 | 128 | |
136 | 129 | /* private */ function mainLoginForm( $err ) |
Index: trunk/phpwiki/newcodebase/LocalSettings.php |
— | — | @@ -26,13 +26,14 @@ |
27 | 27 | |
28 | 28 | # Turn this on to get HTML debug comments |
29 | 29 | # |
30 | | -$wgDebugComments = true; |
| 30 | +$wgDebugComments = true; |
| 31 | +$wgDebugLogFile = ""; |
31 | 32 | |
32 | 33 | # Which interwiki prefix represents _this_ wiki? This |
33 | 34 | # only needs to be set when installing the software on |
34 | 35 | # on of the sites recognized as an interwiki. |
35 | 36 | # |
36 | 37 | $wgLocalInterwiki = "w"; |
37 | | -#$wgLanguageCode = "en"; |
| 38 | +#$wgLanguageCode = "en"; |
38 | 39 | |
39 | 40 | ?> |
Index: trunk/phpwiki/newcodebase/Title.php |
— | — | @@ -34,15 +34,15 @@ |
35 | 35 | /* private */ var $mTextform, $mUrlform, $mDbkeyform; |
36 | 36 | /* private */ var $mNamespace, $mInterwiki; |
37 | 37 | /* private */ var $mArticleID, $mRestrictions, $mRestrictionsLoaded; |
38 | | - /* private */ var $mOtherNamespaces, $mNamespacesLoaded; |
| 38 | + /* private */ var $mNamespacesLoaded; |
39 | 39 | |
40 | 40 | /* private */ function Title() |
41 | 41 | { |
42 | | - $this->mInterwiki = $this->mNamespace = |
43 | | - $this->mUrlform = $this->mTextform = $this->mDbkeyform = ""; |
| 42 | + $this->mInterwiki = $this->mUrlform = |
| 43 | + $this->mTextform = $this->mDbkeyform = ""; |
44 | 44 | $this->mArticleID = -1; |
| 45 | + $this->mNamespace = 0; |
45 | 46 | $this->mNamespacesLoaded = $this->mRestrictionsLoaded = false; |
46 | | - $this->mOtherNamespaces = array(); |
47 | 47 | $this->mRestrictions = array(); |
48 | 48 | } |
49 | 49 | |
— | — | @@ -118,7 +118,8 @@ |
119 | 119 | } else { |
120 | 120 | $p = $wgValidInterwikis[$this->mInterwiki]; |
121 | 121 | } |
122 | | - if ( "" != $this->mNamespace ) { $n = $this->mNamespace . "%3a"; } |
| 122 | + $n = Namespace::getName( $this->mNamespace ); |
| 123 | + if ( "" != $n ) { $n .= "$3a"; } |
123 | 124 | return str_replace( "$1", $n . $this->mUrlform, $p ); |
124 | 125 | } |
125 | 126 | |
— | — | @@ -139,9 +140,7 @@ |
140 | 141 | { |
141 | 142 | global $wgUser; |
142 | 143 | |
143 | | - if ( 0 == strcmp( "Special", $this->mNamespace ) ) { |
144 | | - return false; |
145 | | - } |
| 144 | + if ( -1 == $this->mNamespace ) { return false; } |
146 | 145 | $ur = $wgUser->getRights(); |
147 | 146 | foreach ( $this->getRestrictions() as $r ) { |
148 | 147 | if ( "" != $r && ( ! in_array( $r, $ur ) ) ) { |
— | — | @@ -151,31 +150,6 @@ |
152 | 151 | return true; |
153 | 152 | } |
154 | 153 | |
155 | | - function getOtherNamespaces() |
156 | | - { |
157 | | - if ( ! $this->mNamespacesLoaded ) { |
158 | | - $conn = wfGetDB(); |
159 | | - $sql = "SELECT cur_namespace,cur_id FROM cur " . |
160 | | - "WHERE cur_title='{$this->mDbkeyform}'"; |
161 | | - wfDebug( "Title: 2: $sql\n" ); |
162 | | - |
163 | | - $res = mysql_query( $sql, $conn ); |
164 | | - if ( ( false === $res ) || 0 == mysql_num_rows( $res ) ) { |
165 | | - return $this->mOtherNamespaces; |
166 | | - } |
167 | | - |
168 | | - while ( $row = mysql_fetch_object( $res ) ) { |
169 | | - $ns = $row->cur_namespace; |
170 | | - if ( 0 != strcmp( $this->mNamespace, $ns ) ) { |
171 | | - array_push( $this->mOtherNamspaces, $ns ); |
172 | | - } |
173 | | - } |
174 | | - $this->mNamespacesLoaded = true; |
175 | | - mysql_free_result( $res ); |
176 | | - } |
177 | | - return $this->mOtherNamespaces; |
178 | | - } |
179 | | - |
180 | 154 | function getRestrictions() |
181 | 155 | { |
182 | 156 | $id = $this->getArticleID(); |
— | — | @@ -198,8 +172,8 @@ |
199 | 173 | $this->mArticleID = $wgArticleIDcache[$pt]; |
200 | 174 | } else { |
201 | 175 | $conn = wfGetDB(); |
202 | | - $sql = "SELECT cur_id FROM cur WHERE cur_namespace=" . |
203 | | - "'{$this->mNamespace}' AND cur_title='{$this->mDbkeyform}'"; |
| 176 | + $sql = "SELECT cur_id FROM cur WHERE (cur_namespace=" . |
| 177 | + "{$this->mNamespace} AND cur_title='{$this->mDbkeyform}')"; |
204 | 178 | # wfDebug( "Title: 1: $sql\n" ); |
205 | 179 | $res = mysql_query( $sql, $conn ); |
206 | 180 | |
— | — | @@ -221,8 +195,10 @@ |
222 | 196 | if ( "" != $this->mInterwiki ) { |
223 | 197 | $p = $this->mInterwiki . ":"; |
224 | 198 | } |
225 | | - if ( "" != $this->mNamespace ) { |
226 | | - $p .= $this->mNamespace . ":"; |
| 199 | + if ( -1 == $this->mNamespace ) { |
| 200 | + $p .= "Special:"; |
| 201 | + } else if ( 0 != $this->mNamespace ) { |
| 202 | + $p .= Namespace::getName( $this->mNamespace ) . ":"; |
227 | 203 | } |
228 | 204 | return $p . $name; |
229 | 205 | } |
— | — | @@ -238,14 +214,15 @@ |
239 | 215 | global $wgLang, $wgValidInterwikis, $wgLocalInterwiki; |
240 | 216 | |
241 | 217 | $validNamespaces = $wgLang->getNamespaces(); |
242 | | - $this->mInterwiki = $this->mNamespace = ""; |
| 218 | + $this->mInterwiki = ""; |
| 219 | + $this->mNamespace = 0; |
243 | 220 | |
244 | 221 | $done = false; |
245 | 222 | $t = trim( $this->mDbkeyform ); |
246 | 223 | if ( ":" == $t{0} ) { |
247 | 224 | $r = substr( $t, 1 ); |
248 | 225 | } else { |
249 | | - if ( preg_match( "/^([A-Za-z][A-Za-z0-9 _]*):(.*)$/", $t, $m ) ) { |
| 226 | + if ( preg_match( "/^([A-Za-z][A-Za-z0-9 _]*):(.*)$/", $t, $m ) ) { |
250 | 227 | $p = strtolower( $m[1] ); |
251 | 228 | if ( key_exists( $p, $wgValidInterwikis ) ) { |
252 | 229 | $t = $m[2]; |
— | — | @@ -262,7 +239,8 @@ |
263 | 240 | $p = ucfirst( $p ); |
264 | 241 | if ( in_array( $p, $validNamespaces ) ) { |
265 | 242 | $t = $m[2]; |
266 | | - $this->mNamespace = str_replace( " ", "_", $p ); |
| 243 | + $this->mNamespace = Namespace::getIndex( |
| 244 | + str_replace( " ", "_", $p ) ); |
267 | 245 | } |
268 | 246 | } |
269 | 247 | } |
— | — | @@ -273,7 +251,7 @@ |
274 | 252 | } |
275 | 253 | # We already know that some pages won't be in the database! |
276 | 254 | # |
277 | | - if ( "" != $this->mInterwiki || "Special" == $this->mNamespace ) { |
| 255 | + if ( "" != $this->mInterwiki || -1 == $this->mNamespace ) { |
278 | 256 | $this->mArticleID = 0; |
279 | 257 | } |
280 | 258 | # Strip illegal characters. Note that since many troublesome |
Index: trunk/phpwiki/newcodebase/Article.php |
— | — | @@ -115,7 +115,7 @@ |
116 | 116 | |
117 | 117 | function edit() |
118 | 118 | { |
119 | | - global $wgOut, $wgUser, $wgTitle; |
| 119 | + global $wgOut, $wgUser, $wgTitle, $wgReadOnly; |
120 | 120 | global $wpTextbox1, $wpSummary, $wpSave, $wpPreview; |
121 | 121 | global $wpMinoredit, $wpEdittime, $wpTextbox2; |
122 | 122 | |
— | — | @@ -123,6 +123,14 @@ |
124 | 124 | $this->view(); |
125 | 125 | return; |
126 | 126 | } |
| 127 | + if ( $wgUser->isBlocked() ) { |
| 128 | + $this->blockedIPpage(); |
| 129 | + return; |
| 130 | + } |
| 131 | + if ( $wgReadOnly ) { |
| 132 | + $this->readOnlyPage(); |
| 133 | + return; |
| 134 | + } |
127 | 135 | if ( isset( $wpSave ) ) { |
128 | 136 | $this->editForm( "save" ); |
129 | 137 | } else if ( isset( $wpPreview ) ) { |
— | — | @@ -351,6 +359,7 @@ |
352 | 360 | global $wgOut, $wgUser; |
353 | 361 | |
354 | 362 | $wgOut->setPageTitle( wfMsg( "blockedtitle" ) ); |
| 363 | + $wgOut->setRobotpolicy( "noindex,nofollow" ); |
355 | 364 | $id = $wgUser->blockedBy(); |
356 | 365 | $reason = $wgUser->blockedFor(); |
357 | 366 | |
— | — | @@ -360,7 +369,18 @@ |
361 | 370 | $text = str_replace( "$1", $link, wfMsg( "blockedtext" ) ); |
362 | 371 | $text = str_replace( "$2", $reason, $text ); |
363 | 372 | $wgOut->addWikiText( $text ); |
| 373 | + $wgOut->returnToMain(); |
364 | 374 | } |
| 375 | + |
| 376 | + function readOnlyPage() |
| 377 | + { |
| 378 | + global $wgOut, $wgUser; |
| 379 | + |
| 380 | + $wgOut->setPageTitle( wfMsg( "readonly" ) ); |
| 381 | + $wgOut->setRobotpolicy( "noindex,nofollow" ); |
| 382 | + $wgOut->addWikiText( wfMsg( "readonlytext" ) ); |
| 383 | + $wgOut->returnToMain(); |
| 384 | + } |
365 | 385 | } |
366 | 386 | |
367 | 387 | ?> |