Index: trunk/phpwiki/fpw/basicFunctions.php |
— | — | @@ -88,7 +88,7 @@ |
89 | 89 | } |
90 | 90 | |
91 | 91 | function doEdit ( $title ) { |
92 | | - global $THESCRIPT ; |
| 92 | + global $THESCRIPT , $headerScript ; |
93 | 93 | global $vpage , $action , $wasSaved ; |
94 | 94 | $wasSaved = false ; |
95 | 95 | $vpage = new WikiPage ; |
— | — | @@ -101,8 +101,11 @@ |
102 | 102 | |
103 | 103 | $theMiddle = edit ( $title ) ; |
104 | 104 | if ( $wasSaved ) { |
105 | | - $theMiddle = "<h1>Your page [[$title]] was successfully saved!</h1>" ; |
106 | | - $theMiddle .= "<META HTTP-EQUIV=Refresh CONTENT=\"0; URL=$THESCRIPT?title=$vpage->secureTitle\">"; |
| 105 | + $ti = new wikiTitle ; |
| 106 | + $ti->setTitle ( $title ) ; |
| 107 | + $theMiddle = "<h1>Your page <a href=\"$THESCRIPT?title=$ti->secureTitle\">$title</a> was successfully saved!</h1>" ; |
| 108 | + $theMiddle .= "(If this page doesn't forward automatically, you have a really lame browser...)" ; |
| 109 | + $headerScript .= "<META HTTP-EQUIV=Refresh CONTENT=\"0; URL=$THESCRIPT?title=$vpage->secureTitle\">"; |
107 | 110 | } |
108 | 111 | $ret .= $vpage->getMiddle ( $theMiddle ) ; |
109 | 112 | |
— | — | @@ -118,4 +121,11 @@ |
119 | 122 | $vpage->load ( $title ) ; |
120 | 123 | return $vpage->renderPage () ; |
121 | 124 | } |
| 125 | + |
| 126 | +function doPrint ( $title ) { |
| 127 | + global $vpage ; |
| 128 | + $vpage = new WikiPage ; |
| 129 | + $vpage->load ( $title ) ; |
| 130 | + return $vpage->renderPage ( true ) ; |
| 131 | + } |
122 | 132 | ?> |
\ No newline at end of file |
Index: trunk/phpwiki/fpw/specialPages.php |
— | — | @@ -434,8 +434,7 @@ |
435 | 435 | } |
436 | 436 | |
437 | 437 | function randompage () { |
438 | | - global $THESCRIPT ; |
439 | | - global $vpage ; |
| 438 | + global $THESCRIPT , $headerScript , $vpage ; |
440 | 439 | $connection=getDBconnection() ; |
441 | 440 | mysql_select_db ( "wikipedia" , $connection ) ; |
442 | 441 | $sql = "SELECT COUNT(*) AS number FROM cur" ; |
— | — | @@ -455,7 +454,7 @@ |
456 | 455 | $nt = $vpage->getNiceTitle($thelink) ; |
457 | 456 | if ( count ( explode ( ":" , $thelink ) ) == 1 ) $thelink = ":".$thelink ; |
458 | 457 | $ret = "<h2>Loading random page [[$thelink|".$nt."]]...</h2>" ; |
459 | | - $ret .= "<nowiki><META HTTP-EQUIV=Refresh CONTENT=\"0; URL=$THESCRIPT?title=$thelink\"></nowiki>" ; |
| 458 | + $headerScript .= "<nowiki><META HTTP-EQUIV=Refresh CONTENT=\"0; URL=$THESCRIPT?title=$thelink\"></nowiki>" ; |
460 | 459 | mysql_free_result ( $result ) ; |
461 | 460 | mysql_close ( $connection ) ; |
462 | 461 | |
Index: trunk/phpwiki/fpw/wiki.phtml |
— | — | @@ -41,9 +41,11 @@ |
42 | 42 | unset ( $search ) ; |
43 | 43 | } else if ( $action == "watch" ) { |
44 | 44 | global $mode ; |
| 45 | + include_once ( "./specialPages.php" ) ; |
45 | 46 | $out = watch ( $title , $mode ) ; |
46 | 47 | } else if ( $action == "view" ) $out = view ( $title ) ; |
47 | 48 | else if ( $action == "edit" ) $out = doEdit ( $title ) ; |
| 49 | + else if ( $action == "print" ) $out = doPrint ( $title ) ; |
48 | 50 | else if ( $action == "history" ) { |
49 | 51 | include_once ( "./specialPages.php" ) ; |
50 | 52 | $out = doHistory ( $title ) ; |
Index: trunk/phpwiki/fpw/wikiPage.php |
— | — | @@ -264,6 +264,7 @@ |
265 | 265 | $a = explode ( "[http://" , " ".$s ) ; |
266 | 266 | $s = array_shift ( $a ) ; |
267 | 267 | $s = substr ( $s , 1 ) ; |
| 268 | + $image = "<img src=earth_small.png valign=center border=0>" ; # Remove or set to blank for no image |
268 | 269 | foreach ( $a as $t ) { |
269 | 270 | $b = spliti ( "]" , $t , 2 ) ; |
270 | 271 | if ( count($b) < 2 ) $s .= "Illegal link : ?$b[0]?" ; |
— | — | @@ -280,13 +281,13 @@ |
281 | 282 | if ( substr_count ( $b[1] , "<hr>" ) > 0 ) $cnt = 1 ; |
282 | 283 | $link = "~http://".$link ; |
283 | 284 | if ( $user->options["showHover"] == "yes" ) $hover = "title=\"$link\"" ; |
284 | | - $s .= "<a href=\"$link\" $hover>$text</a>" ; |
| 285 | + $s .= "<a href=\"$link\" $hover>$image$text</a>" ; |
285 | 286 | $s .= $b[1] ; |
286 | 287 | } |
287 | 288 | } |
288 | 289 | |
289 | 290 | $o = "A-Za-z0-9/\.:?&=_~%-@^" ; |
290 | | - $s = eregi_replace ( "([^~\"])http://([$o]+)([^$o])" , "\\1<a href=\"http://\\2\">[http://\\2]</a>\\3" , $s ) ; |
| 291 | + $s = eregi_replace ( "([^~\"])http://([$o]+)([^$o])" , "\\1<a href=\"http://\\2\">".$image."http://\\2</a>\\3" , $s ) ; |
291 | 292 | $s = str_replace ( "~http://" , "http://" , $s ) ; |
292 | 293 | |
293 | 294 | return $s ; |
— | — | @@ -325,6 +326,7 @@ |
326 | 327 | # This function is called to replace wiki-style tags with HTML, e.g., the first occurrence of ''' with <b>, the second with </b> |
327 | 328 | function pingPongReplace ( $f , $r1 , $r2 , $s ) { |
328 | 329 | $a = explode ( $f , " ".$s ) ; |
| 330 | + if ( count ( $a ) == 1 ) return $s ; |
329 | 331 | $s = substr ( array_shift ( $a ) , 1 ) ; |
330 | 332 | $r = $r1 ; |
331 | 333 | foreach ( $a as $t ) { |
— | — | @@ -373,25 +375,30 @@ |
374 | 376 | |
375 | 377 | # This function removes "forbidden" HTML tags |
376 | 378 | function removeHTMLtags ( $s ) { |
377 | | - $s = eregi_replace ( "<a (.*)>" , "<a \\1>" , $s ) ; |
378 | | - $s = eregi_replace ( "</a(.*)>" , "</a\\1>" , $s ) ; |
379 | | - $s = eregi_replace ( "<script(.*)>" , "<script\\1>" , $s ) ; |
380 | | - $s = eregi_replace ( "</script(.*)>" , "</script\\1>" , $s ) ; |
| 379 | + $forbidden = array ( "a" , "script" , "title" , "html" , "body" , "header" ) ; |
| 380 | + foreach ( $forbidden as $x ) { |
| 381 | + $s = eregi_replace ( "<".$x." (.*)>" , "<".$x." \\1>" , $s ) ; |
| 382 | + $s = eregi_replace ( "</".$x."(.*)>" , "</".$x."\\1>" , $s ) ; |
| 383 | + } |
381 | 384 | return $s ; |
382 | 385 | } |
383 | 386 | |
384 | | - # This function does the actual parsing of the wiki parts of the article |
| 387 | + # This function does the actual parsing of the wiki parts of the article, for regions NOT marked with <nowiki> |
385 | 388 | function subParseContents ( $s ) { |
386 | 389 | global $user ; |
387 | 390 | # Removed automatic links for mixedThings; wasn't working, anyway... |
388 | 391 | # $s = ereg_replace ( "([\.|\n| )([a-z0-9]*[A-Z0-9]+[A-Za-z0-9]*)( |\n|\.)" , "\\1[[\\2]]\\3" , $s ) ; |
389 | 392 | $s = $this->removeHTMLtags ( $s ) ; # Removing "forbidden" HTML tags |
| 393 | + |
390 | 394 | # Now some repalcements wiki->HTML |
391 | 395 | $s = ereg_replace ( "-----*" , "<hr>" , $s ) ; |
392 | 396 | $s = str_replace ( "<HR>" , "<hr>" , $s ) ; |
393 | 397 | $s = $this->replaceVariables ( $s ) ; |
| 398 | + $s = $this->pingPongReplace ( "'''''" , "<i><b>" , "</b></i>" , $s ) ; |
394 | 399 | $s = $this->pingPongReplace ( "'''" , "<b>" , "</b>" , $s ) ; |
395 | 400 | $s = $this->pingPongReplace ( "''" , "<i>" , "</i>" , $s ) ; |
| 401 | + $s = $this->pingPongReplace ( "====" , "<h4>" , "</h4>" , $s ) ; |
| 402 | + $s = $this->pingPongReplace ( "===" , "<h3>" , "</h3>" , $s ) ; |
396 | 403 | |
397 | 404 | # Automatic links to subpages (e.g., /Talk -> [[/Talk]] |
398 | 405 | $s = ereg_replace ( "([\n| ])/([a-zA-Z0-9_]*)" , "\\1[[/\\2|/\\2]]" , $s ) ; |
— | — | @@ -484,7 +491,7 @@ |
485 | 492 | global $user , $oldID , $version ; |
486 | 493 | $editOldVersion = "" ; |
487 | 494 | if ( $oldID != "" ) $editOldVersion="&oldID=$oldID&version=$version" ; |
488 | | - $ret = "<a href=\"$THESCRIPT?\">HomePage</a>" ; |
| 495 | + $ret = "<a href=\"$THESCRIPT\">Homepage</a>" ; |
489 | 496 | |
490 | 497 | $spl = $this->getSubpageList () ; |
491 | 498 | if ( count ( $spl ) > 0 and $this->subpageTitle != "" ) { |
— | — | @@ -522,11 +529,14 @@ |
523 | 530 | } else $ret .= "<font size=+3>".$t."</font>" ; |
524 | 531 | } else { |
525 | 532 | $ret .= "<font size=+3><a href=\"$THESCRIPT?search=$this->title\">".$this->getNiceTitle($t)."</a>$this->thisVersion</font>" ; |
| 533 | + $subText = array () ; |
526 | 534 | if ( $user->isLoggedIn ) { |
527 | 535 | if ( $user->doWatch($this->title) ) |
528 | | - $ret.="<br><a href=\"$THESCRIPT?action=watch&title=$this->secureTitle&mode=no\">Stop watching this article for me</a>"; |
529 | | - else $ret .= "<br><a href=\"$THESCRIPT?action=watch&title=$this->secureTitle&mode=yes\">Watch this article for me</a>" ; |
| 536 | + array_push($subText,"<br><a href=\"$THESCRIPT?action=watch&title=$this->secureTitle&mode=no\">Stop watching this article for me</a>"); |
| 537 | + else array_push($subText,"<br><a href=\"$THESCRIPT?action=watch&title=$this->secureTitle&mode=yes\">Watch this article for me</a>") ; |
530 | 538 | } |
| 539 | + if ( $action == "view" and !$this->isSpecialPage ) array_push ( $subText , "<a href=\"$THESCRIPT?action=print&title=$this->secureTitle\">Printable version</a>" ) ; |
| 540 | + $ret .= implode ( " | " , $subText ) ; |
531 | 541 | } |
532 | 542 | $ret .= "</td>\n<td valign=top width=200 rowspan=2 nowrap>".$user->getLink()."<br>" ; |
533 | 543 | if ( $user->isLoggedIn ) $ret .= "<a href=\"$THESCRIPT?title=special:userLogout\">Log out</a> | <a href=\"$THESCRIPT?title=special:editUserSettings\">Preferences</a>" ; |
— | — | @@ -577,6 +587,7 @@ |
578 | 588 | # Some special pages have their own rendering function |
579 | 589 | function getMiddle ( $ret ) { |
580 | 590 | global $user , $action ; |
| 591 | + if ( $action == "print" ) return $ret ; |
581 | 592 | $oaction = $action ; |
582 | 593 | if ( $action == "edit" ) $action = "" ; |
583 | 594 | if ( $user->options["quickBar"] == "right" or $user->options["quickBar"] == "left" or $user->options["forceQuickBar"] != "" ) { |
— | — | @@ -617,13 +628,20 @@ |
618 | 629 | |
619 | 630 | # This generates header, diff (if wanted), article body (with QuickBar), and footer |
620 | 631 | # The whole page (for normal pages) is generated here |
621 | | - function renderPage () { |
622 | | - global $pageTitle , $diff ; |
| 632 | + function renderPage ( $doPrint = false ) { |
| 633 | + global $pageTitle , $diff , $THESCRIPT ; |
623 | 634 | $pageTitle = $this->title ; |
624 | 635 | if ( isset ( $diff ) ) $middle = $this->doDiff().$this->contents ; |
625 | 636 | else $middle = $this->contents ; |
626 | 637 | $middle = $this->getMiddle($this->parseContents($middle)) ; |
627 | | - return $this->getHeader().$middle.$this->getFooter() ; |
| 638 | + if ( $doPrint ) { |
| 639 | + $header = "<h1>".$this->getNiceTitle($pageTitle)."</h1>\n" ; |
| 640 | + $link = "http://wikipedia.sourceforge.net/fpw/wiki.phtml?title=$this->secureTitle" ; |
| 641 | +# $link = "http://127.0.0.1/fpw/wiki.phtml?title=$this->secureTitle" ; |
| 642 | + $footer = "<hr>This article is from <b>Wikipedia</b> (<a href=\"http://wikipedia.com\">http://wikipedia.com</a>), " ; |
| 643 | + $footer .= "the free online encyclopedia. You can find this article at <a href=\"$link\">$link</a>" ; |
| 644 | + return $header.$middle.$footer ; |
| 645 | + } else return $this->getHeader().$middle.$this->getFooter() ; |
628 | 646 | } |
629 | 647 | |
630 | 648 | # This displays the diff. Currently, only diff with the last edit! |
Index: trunk/phpwiki/fpw/wikiUser.php |
— | — | @@ -18,7 +18,7 @@ |
19 | 19 | |
20 | 20 | # This sets the options for the standard skin |
21 | 21 | function skinBlank () { |
22 | | - $this->options["background"] = "" ; |
| 22 | + $this->options["background"] = " BGCOLOR=#FFFFFF" ; |
23 | 23 | $this->options["text"] = "" ; |
24 | 24 | $this->options["forceQuickBar"] = "" ; |
25 | 25 | $this->options["quickBarBackground"] = "" ; |
Index: trunk/phpwiki/fpw/wikiTitle.php |
— | — | @@ -108,9 +108,11 @@ |
109 | 109 | $this->namespace = strtolower ( $this->namespace ) ; |
110 | 110 | } |
111 | 111 | |
112 | | - # I don't remember what this does, or if I use it somewhere... |
| 112 | + # This converts an internal link to stay in the same namespace, if desired. Used in wikiPage-getInternalLinks() |
113 | 113 | function getLinkTo ( $target ) { |
114 | | - $n = $this->namespace ; |
| 114 | + $keepNamespace = array ( "stable" ) ; # For future use |
| 115 | + $n = "" ; |
| 116 | + if ( in_array ( strtolower ( $this->namespace ) , $keepNamespace ) ) $n = $this->namespace ; |
115 | 117 | if ( $target->hasNamespace ) $n = $target->namespace ; |
116 | 118 | if ( $n != "" ) $n .= ":" ; |
117 | 119 | $p = $target->mainTitle ; |