Index: trunk/phpwiki/newcodebase/LanguageDe.php |
— | — | @@ -1,5 +1,7 @@ |
2 | 2 | <? |
3 | 3 | |
| 4 | +class LanguageDe extends Language { |
| 5 | + |
4 | 6 | /* private */ $wgValidNamespacesDe = array( |
5 | 7 | "Special", "Diskussion", "Benutzer", "Benutzer_diskussion", |
6 | 8 | "Wikipedia", "Wikipedia_diskussion" |
Index: trunk/phpwiki/newcodebase/Skin.php |
— | — | @@ -166,8 +166,7 @@ |
167 | 167 | . " | " . $this->makeLink( "Special:Whatlinkshere", |
168 | 168 | wfMsg( "whatlinkshere" ), "", $wgTitle->getPrefixedURL() ); |
169 | 169 | |
170 | | - $ol = $this->otherLanguages(); |
171 | | - if ( "" != $ol ) { $s .= $ol; } |
| 170 | + $s .= $this->otherLanguages(); |
172 | 171 | } |
173 | 172 | } |
174 | 173 | return $s; |
— | — | @@ -227,6 +226,7 @@ |
228 | 227 | if ( $wgOut->isArticle() ) { |
229 | 228 | $s .= " | " . $this->talkLink(); |
230 | 229 | } |
| 230 | + $s .= $this->otherLanguages(); |
231 | 231 | return $s; |
232 | 232 | } |
233 | 233 | |
— | — | @@ -320,7 +320,28 @@ |
321 | 321 | |
322 | 322 | function otherLanguages() |
323 | 323 | { |
324 | | - return ""; |
| 324 | + global $wgOut, $wgLang; |
| 325 | + |
| 326 | + $a = $wgOut->getLanguageLinks(); |
| 327 | + if ( 0 == count( $a ) ) { return ""; } |
| 328 | + |
| 329 | + $s = "<br>" . wfMsg( "otherlanguages" ) . ": "; |
| 330 | + $first = true; |
| 331 | + foreach( $a as $l ) { |
| 332 | + if ( ! $first ) { $s .= " | "; } |
| 333 | + $first = false; |
| 334 | + |
| 335 | + preg_match( "/([a-z]+):([^\|]+)/", $l, $m ); |
| 336 | + $urltemp = Title::getInterwikiLink( $m[1] ); |
| 337 | + $link = $m[2]; |
| 338 | + $text = $wgLang->getLanguageName( $m[1] ); |
| 339 | + $url = str_replace( "$1", $link, $urltemp ); |
| 340 | + |
| 341 | + if ( "" == $text ) { $text = $link; } |
| 342 | + $style = $this->getExternalLinkAttributes( $link, $text ); |
| 343 | + $s .= "<a href=\"$url\"$style>$text</a>"; |
| 344 | + } |
| 345 | + return $s . "\n"; |
325 | 346 | } |
326 | 347 | |
327 | 348 | function bugReportsLink() |
— | — | @@ -391,6 +412,19 @@ |
392 | 413 | return $text; |
393 | 414 | } |
394 | 415 | |
| 416 | + function makeInternalLink( $title, $text= "", $action = "", $target = "" ) |
| 417 | + { |
| 418 | + $nt = Title::newFromText( $title ); |
| 419 | + if ( "Special" == $nt->getNamespace() ) { |
| 420 | + return $this->makeLink( $title, $text ); |
| 421 | + } |
| 422 | + if ( 0 == $nt->getArticleID() ) { |
| 423 | + return $this->makeBrokenLink( $title, $text ); |
| 424 | + } else { |
| 425 | + return $this->makeLink( $title, $text, $action, $target ); |
| 426 | + } |
| 427 | + } |
| 428 | + |
395 | 429 | function makeLink( $title, $text = "", $action = "", $target = "" ) |
396 | 430 | { |
397 | 431 | global $wgServer, $wgScript, $wgArticlePath, $wgTitle; |
— | — | @@ -432,6 +466,13 @@ |
433 | 467 | return $s; |
434 | 468 | } |
435 | 469 | |
| 470 | + function makeImageLink( $url, $alt = "" ) |
| 471 | + { |
| 472 | + if ( "" == $alt ) { $alt = "[Image]"; } |
| 473 | + $s = "<img src=\"$url\" alt=\"$alt\">"; |
| 474 | + return $s; |
| 475 | + } |
| 476 | + |
436 | 477 | function specialLink( $name ) |
437 | 478 | { |
438 | 479 | $key = strtolower( $name ); |
Index: trunk/phpwiki/newcodebase/Title.php |
— | — | @@ -73,6 +73,15 @@ |
74 | 74 | return $t; |
75 | 75 | } |
76 | 76 | |
| 77 | + function getInterwikiLink( $key ) |
| 78 | + { |
| 79 | + global $wgValidInterwikis; |
| 80 | + |
| 81 | + if ( key_exists( $key, $wgValidInterwikis ) ) { |
| 82 | + return $wgValidInterwikis[$key]; |
| 83 | + } else return ""; |
| 84 | + } |
| 85 | + |
77 | 86 | function getText() { return $this->mTextform; } |
78 | 87 | function getURL() { return $this->mUrlform; } |
79 | 88 | function getDBKey() { return $this->mDbkeyform; } |
Index: trunk/phpwiki/newcodebase/Language.php |
— | — | @@ -10,7 +10,7 @@ |
11 | 11 | ); |
12 | 12 | |
13 | 13 | /* private */ $wgSkinNamesEn = array( |
14 | | - "Standard", "Star Trek", "Nostalgia", "Cologne Blue" |
| 14 | + "Standard", "StarTrek", "Nostalgia", "CologneBlue" |
15 | 15 | ); |
16 | 16 | |
17 | 17 | /* private */ $wgUserTogglesEn = array( |
— | — | @@ -23,6 +23,18 @@ |
24 | 24 | "rememberPassword" => "Remember my password" |
25 | 25 | ); |
26 | 26 | |
| 27 | +/* private */ $wgLanguageNamesEn= array( |
| 28 | + "w" => "English", "af" => "Afrikaans", "ar" => "Arabic", |
| 29 | + "ca" => "Catalan", "zh" => "Chinese", "dk" => "Danish", |
| 30 | + "nl" => "Dutch", "de" => "German", "eo" => "Esperanto", |
| 31 | + "fr" => "French", "he" => "Hebrew", "hu" => "Hungarian", |
| 32 | + "it" => "Italian", "ja" => "Japanese", "no" => "Norwegian", |
| 33 | + "pl" => "Polish", "pt" => "Portugese", "ru" => "Russian", |
| 34 | + "sh" => "Serbocroatian", "si" => "Slovene", |
| 35 | + "simple" => "Simple English", "es" => "Spanish", |
| 36 | + "sv" => "Swedish", "en" => "English" |
| 37 | +); |
| 38 | + |
27 | 39 | /* private */ $wgAllMessagesEn = array( |
28 | 40 | |
29 | 41 | # Bits of text used by many pages: |
— | — | @@ -39,6 +51,7 @@ |
40 | 52 | "editthispage" => "Edit this page", |
41 | 53 | "talkpage" => "Talk page", |
42 | 54 | "subjectpage" => "Subject page", |
| 55 | +"otherlanguages" => "Other languages", |
43 | 56 | |
44 | 57 | # Main script and global functions |
45 | 58 | # |
— | — | @@ -297,6 +310,11 @@ |
298 | 311 | return $wgUserTogglesEn; |
299 | 312 | } |
300 | 313 | |
| 314 | + function getLanguageName( $code ) { |
| 315 | + global $wgLanguageNamesEn; |
| 316 | + return $wgLanguageNamesEn[$code]; |
| 317 | + } |
| 318 | + |
301 | 319 | function getMonthName( $key ) |
302 | 320 | { |
303 | 321 | return ucfirst( $key ); |
— | — | @@ -326,6 +344,6 @@ |
327 | 345 | } |
328 | 346 | } |
329 | 347 | |
330 | | -include_once( "Language" . ucfirst( $wgLanguageCode ) . ".php" ); |
| 348 | +include_once( "./Language" . ucfirst( $wgLanguageCode ) . ".php" ); |
331 | 349 | |
332 | 350 | ?> |
Index: trunk/phpwiki/newcodebase/Article.php |
— | — | @@ -248,6 +248,8 @@ |
249 | 249 | |
250 | 250 | if ( $minor) { $me = 1; } else { $me = 0; } |
251 | 251 | |
| 252 | + # TODO: Backup to old table |
| 253 | + # |
252 | 254 | $conn = wfGetDB(); |
253 | 255 | $sql = "UPDATE cur SET cur_text='" . wfStrencode( $text ) . |
254 | 256 | "',cur_comment='" . wfStrencode( $summary ) . |
Index: trunk/phpwiki/newcodebase/OutputPage.php |
— | — | @@ -7,6 +7,7 @@ |
8 | 8 | var $mHTMLtitle, $mRobotpolicy, $mIsarticle, $mPrintable; |
9 | 9 | |
10 | 10 | var $mDTopen, $mLastSection; # Used for processing DL, PRE |
| 11 | + var $mLanguageLinks; |
11 | 12 | |
12 | 13 | function OutputPage() |
13 | 14 | { |
— | — | @@ -15,6 +16,7 @@ |
16 | 17 | $this->mHTMLtitle = $this->mPagetitle = $this->mBodytext = |
17 | 18 | $this->mDebugtext = $this->mRobotpolicy = ""; |
18 | 19 | $this->mIsarticle = $this->mPrintable = true; |
| 20 | + $this->mLanguageLinks = array(); |
19 | 21 | } |
20 | 22 | |
21 | 23 | function addHeader( $name, $val ) { array_push( $this->mHeaders, "$name: $val" ) ; } |
— | — | @@ -33,6 +35,7 @@ |
34 | 36 | function isArticle() { return $this->mIsarticle; } |
35 | 37 | function setPrintable() { $this->mPrintable = true; } |
36 | 38 | function isPrintable() { return $this->mPrintable; } |
| 39 | + function getLanguageLinks() { return $this->mLanguageLinks; } |
37 | 40 | |
38 | 41 | function addHTML( $text ) { $this->mBodytext .= $text; } |
39 | 42 | function debug( $text ) { $this->mDebugtext .= $text; } |
— | — | @@ -159,9 +162,12 @@ |
160 | 163 | |
161 | 164 | /* private */ function parseImages( $text ) |
162 | 165 | { |
| 166 | + global $wgUser; |
| 167 | + $sk = $wgUser->getSkin(); |
| 168 | + |
163 | 169 | $text = preg_replace( |
164 | 170 | "/(^|[^[])http:\/\/([a-zA-Z0-9_\/:.~\%\-]+)\.(png|PNG|jpg|JPG|jpeg|JPEG|gif|GIF)/", |
165 | | - "$1<img src=\"http://$2.$3\">", $text ); |
| 171 | + "$1" . $sk->makeImageLink( "http://$2.$3", "[Image]" ), $text ); |
166 | 172 | return $text; |
167 | 173 | } |
168 | 174 | |
— | — | @@ -223,7 +229,7 @@ |
224 | 230 | |
225 | 231 | /* private */ function replaceInternalLinks( $s ) |
226 | 232 | { |
227 | | - global $wgTitle, $wgUser; |
| 233 | + global $wgTitle, $wgUser, $wgServer, $wgUploadPath, $wgLang; |
228 | 234 | |
229 | 235 | $tc = "[\\-,.\\(\\)' _0-9A-Za-z\\/:\\x80-\\xff]"; # from Title |
230 | 236 | $sk = $wgUser->getSkin(); |
— | — | @@ -278,29 +284,24 @@ |
279 | 285 | |
280 | 286 | # $link, $text, and $trail should all be set now |
281 | 287 | # |
282 | | - $nt = Title::newFromText( $link ); |
283 | | - $id = $nt->getArticleID(); |
284 | | - $linkStyle = $sk->getInternalLinkAttributes( $link, $text ); |
285 | | - $isSpecialPage = ( "Special" == $nt->getNamespace() ); |
286 | | - |
287 | | - # TODO: I should be calling a Skin function here... |
288 | | - # |
289 | | - if ( 0 == $id && ( ! $isSpecialPage ) ) { |
290 | | - if ( 1 == $wgUser->getOption( "markupNewTopics" ) ) { |
291 | | - $s .= "<a class=\"new\" href=\"" . $nt->getEditURL() . |
292 | | - "\"$linkStyle>$text</a>" . $trail; |
| 288 | + if ( preg_match( "/^([a-z]+):(.*)/", $link, $m ) ) { |
| 289 | + $pre = strtolower( $m[1] ); |
| 290 | + $suf = $m[2]; |
| 291 | + if ( "image" == $pre ) { |
| 292 | + $s .= $sk->makeImageLink( "$wgServer$wgUploadPath/" . |
| 293 | + $suf, $text ); |
293 | 294 | } else { |
294 | | - $s .= $text . "<a href=\"" . $nt->getEditURL() . |
295 | | - "\"$linkStyle>?</a>" . $trail; |
| 295 | + $l = $wgLang->getLanguageName( $pre ); |
| 296 | + if ( "" == $l ) { |
| 297 | + $s .= $sk->makeInternalLink( $link, $text ); |
| 298 | + } else { |
| 299 | + array_push( $this->mLanguageLinks, "$pre:$suf" ); |
| 300 | + } |
296 | 301 | } |
297 | 302 | } else { |
298 | | - $s .= "<a href=\"" . $nt->getFullURL() . "\"$linkStyle>$text"; |
299 | | - if ( preg_match( "/^([a-z]+)/", $trail, $m ) ) { |
300 | | - $s .= $m[1]; |
301 | | - $trail = substr( $trail, strlen( $m[1] ) ); |
302 | | - } |
303 | | - $s .= "</a>" . $trail; |
| 303 | + $s .= $sk->makeInternalLink( $link, $text ); |
304 | 304 | } |
| 305 | + $s .= $trail; |
305 | 306 | } |
306 | 307 | return $s; |
307 | 308 | } |
Index: trunk/phpwiki/newcodebase/wiki.phtml |
— | — | @@ -13,13 +13,13 @@ |
14 | 14 | include_once( "./Title.php" ); |
15 | 15 | include_once( "./Article.php" ); |
16 | 16 | |
17 | | -global $action, $title, $search $target; # From query string |
| 17 | +global $action, $title, $search, $target; # From query string |
18 | 18 | global $wgUser, $wgLang, $wgOut, $wgTitle; # Objects to handle output |
19 | 19 | global $wgArticle, $wgDeferredUpdateList; |
20 | 20 | |
21 | 21 | $wgOut = new OutputPage(); |
22 | 22 | $wgLangClass = "Language" . ucfirst( $wgLanguageCode ); |
23 | | -$wgLang = new $wgLanguageClass(); |
| 23 | +$wgLang = new $wgLangClass(); |
24 | 24 | $wgOut->addHeader( "Content-type", "text/html; charset=iso-8859-1" ); |
25 | 25 | |
26 | 26 | $wgUser = new User(); |
Index: trunk/phpwiki/newcodebase/LanguageEn.php |
— | — | @@ -1,7 +1,7 @@ |
2 | 2 | <? |
3 | 3 | # See language.doc |
4 | 4 | |
5 | | -class LanguageEn { |
| 5 | +class LanguageEn extends Language { |
6 | 6 | # Inherit everything |
7 | 7 | } |
8 | 8 | |