r113 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r112‎ | r113 | r114 >
Date:21:13, 10 February 2002
Author:hidders
Status:old
Tags:
Comment:
set timestamp in page object with timestamp of old version when oldId is set
Modified paths:
  • /trunk/phpwiki/fpw/wikiPage.php (modified) (history)

Diff [purge]

Index: trunk/phpwiki/fpw/wikiPage.php
@@ -3,1168 +3,1169 @@
44 # It inherits some functions and variables from the wikiTitle class
55
66 class WikiPage extends WikiTitle {
7 - var $contents ; # The actual article body
8 - var $backLink ; # For redirects
9 - var $knownLinkedLinks , $knownUnlinkedLinks ; # Used for faster display
10 - var $otherLanguages ; # This article in other languages
11 - var $params ; # For the params entry; updated on Save only
12 - var $counter ; # Page view counter
13 - var $timestamp ; # Time and date of last edit
14 - var $cache ; # For cached pages
15 - var $canBeCached ;
16 -
 7+ var $contents ; # The actual article body
 8+ var $backLink ; # For redirects
 9+ var $knownLinkedLinks , $knownUnlinkedLinks ; # Used for faster display
 10+ var $otherLanguages ; # This article in other languages
 11+ var $params ; # For the params entry; updated on Save only
 12+ var $counter ; # Page view counter
 13+ var $timestamp ; # Time and date of last edit
 14+ var $cache ; # For cached pages
 15+ var $canBeCached ;
 16+
1717 #### Database management functions
1818
19 - # This loads an article from the database, or calls a special function instead (all pages with "special:" namespace)
20 - function load ( $t , $doRedirect = true ) {
21 - global $action , $user , $wikiNoSuchSpecialPage , $wikiAllowedSpecialPages ;
22 - if ( $doRedirect ) $this->backLink = "" ;
23 - $updateCounter = "" ;
24 - $this->knownLinkedLinks = array () ;
25 - $this->knownUnlinkedLinks = array () ;
26 - $this->SetTitle ( $t ) ;
27 - $this->isSpecialPage = false ;
28 - $this->canBeCached = true ;
29 - $this->revision = "current" ;
30 - if ( $this->namespace == "special" ) { # Special page, calling appropriate function
31 - $allowed = $wikiAllowedSpecialPages ; # List of allowed special pages
32 - if ( in_array ( "is_sysop" , $user->rights ) ) array_push ( $allowed , "asksql" ) ; # Another function just for sysops
33 - $call = $this->mainTitle ;
34 - if ( !in_array ( strtolower ( $call ) , $allowed ) ) {
35 - $this->isSpecialPage = true ;
36 - $this->contents = str_replace ( "$1" , $call , $wikiNoSuchSpecialPage ) ;
37 - return ;
38 - }
39 - $this->title = $call ;
40 - $inc = "./special_".strtolower($call).".php" ;
41 - include_once ( $inc ) ;
42 -# include_once ( "./specialPages.php") ;
43 - $this->contents = $call () ;
44 - $this->isSpecialPage = true ;
45 - $this->canBeCached = false ;
46 - return ; # contents of special page is returned here!!!
47 - }
 19+ # This loads an article from the database, or calls a special function instead (all pages with "special:" namespace)
 20+ function load ( $t , $doRedirect = true ) {
 21+ global $action , $user , $wikiNoSuchSpecialPage , $wikiAllowedSpecialPages ;
 22+ if ( $doRedirect ) $this->backLink = "" ;
 23+ $updateCounter = "" ;
 24+ $this->knownLinkedLinks = array () ;
 25+ $this->knownUnlinkedLinks = array () ;
 26+ $this->SetTitle ( $t ) ;
 27+ $this->isSpecialPage = false ;
 28+ $this->canBeCached = true ;
 29+ $this->revision = "current" ;
 30+ if ( $this->namespace == "special" ) { # Special page, calling appropriate function
 31+ $allowed = $wikiAllowedSpecialPages ; # List of allowed special pages
 32+ if ( in_array ( "is_sysop" , $user->rights ) ) array_push ( $allowed , "asksql" ) ; # Another function just for sysops
 33+ $call = $this->mainTitle ;
 34+ if ( !in_array ( strtolower ( $call ) , $allowed ) ) {
 35+ $this->isSpecialPage = true ;
 36+ $this->contents = str_replace ( "$1" , $call , $wikiNoSuchSpecialPage ) ;
 37+ return ;
 38+ }
 39+ $this->title = $call ;
 40+ $inc = "./special_".strtolower($call).".php" ;
 41+ include_once ( $inc ) ;
 42+# include_once ( "./specialPages.php") ;
 43+ $this->contents = $call () ;
 44+ $this->isSpecialPage = true ;
 45+ $this->canBeCached = false ;
 46+ return ; # contents of special page is returned here!!!
 47+ }
4848
49 - # No special page, loading article form the database
50 - global $wikiSQLServer , $useCachedPages ;
51 - $connection = getDBconnection () ;
52 - mysql_select_db ( $wikiSQLServer , $connection ) ;
53 - $thisVersion = "" ;
54 - $this->params = array () ;
55 - global $oldID , $version , $wikiOldVersion , $wikiDescribePage , $wikiRedirectFrom ;
56 - if ( isset ( $oldID ) ) { # an old article version
57 - $sql = "SELECT * FROM old WHERE old_id=$oldID" ;
58 - $result = mysql_query ( $sql , $connection ) ;
59 - if ( $s = mysql_fetch_object ( $result ) ) {
60 - $this->SetTitle ( $s->old_title ) ;
61 - $this->contents = $s->old_text ;
62 - $this->thisVersion = str_replace ( "$1" , $version , $wikiOldVersion ) ;
63 - $this->thisVersion = str_replace ( "$2" , $this->secureTitle , $this->thisVersion ) ;
64 - $this->thisVersion = "<br><font size=-1>".$this->thisVersion."</font>" ;
65 - }
66 - else $this->contents = $wikiDescribePage ;
67 - } else { # The current article version
68 - $sql = "SELECT * FROM cur WHERE cur_title=\"".$this->secureTitle."\"" ;
69 - $result = mysql_query ( $sql , $connection ) ;
70 - if ( $s = mysql_fetch_object ( $result ) ) {
71 - $this->SetTitle ( $s->cur_title ) ;
72 - $this->contents = $s->cur_text ;
73 - $this->knownLinkedLinks = explode ( "\n" , $s->cur_linked_links ) ;
74 - $this->knownUnlinkedLinks = explode ( "\n" , $s->cur_unlinked_links ) ;
75 - $this->timestamp = $s->cur_timestamp ;
76 - if ( $useCachedPages ) $this->cache = $s->cur_cache ;
77 - if ( $s->cur_params != "" ) $this->params = explode ( "\n" , $s->cur_params ) ;
78 - $this->counter = $s->cur_counter+1 ;
79 - $updateCounter = $this->counter ;
80 - }
81 - else $this->contents = $wikiDescribePage ;
82 - }
83 - mysql_free_result ( $result ) ;
 49+ # No special page, loading article form the database
 50+ global $wikiSQLServer , $useCachedPages ;
 51+ $connection = getDBconnection () ;
 52+ mysql_select_db ( $wikiSQLServer , $connection ) ;
 53+ $thisVersion = "" ;
 54+ $this->params = array () ;
 55+ global $oldID , $version , $wikiOldVersion , $wikiDescribePage , $wikiRedirectFrom ;
 56+ if ( isset ( $oldID ) ) { # an old article version
 57+ $sql = "SELECT * FROM old WHERE old_id=$oldID" ;
 58+ $result = mysql_query ( $sql , $connection ) ;
 59+ if ( $s = mysql_fetch_object ( $result ) ) {
 60+ $this->SetTitle ( $s->old_title ) ;
 61+ $this->contents = $s->old_text ;
 62+ $this->timestamp = $s->old_timestamp ;
 63+ $this->thisVersion = str_replace ( "$1" , $version , $wikiOldVersion ) ;
 64+ $this->thisVersion = str_replace ( "$2" , $this->secureTitle , $this->thisVersion ) ;
 65+ $this->thisVersion = "<br><font size=-1>".$this->thisVersion."</font>" ;
 66+ }
 67+ else $this->contents = $wikiDescribePage ;
 68+ } else { # The current article version
 69+ $sql = "SELECT * FROM cur WHERE cur_title=\"".$this->secureTitle."\"" ;
 70+ $result = mysql_query ( $sql , $connection ) ;
 71+ if ( $s = mysql_fetch_object ( $result ) ) {
 72+ $this->SetTitle ( $s->cur_title ) ;
 73+ $this->contents = $s->cur_text ;
 74+ $this->knownLinkedLinks = explode ( "\n" , $s->cur_linked_links ) ;
 75+ $this->knownUnlinkedLinks = explode ( "\n" , $s->cur_unlinked_links ) ;
 76+ $this->timestamp = $s->cur_timestamp ;
 77+ if ( $useCachedPages ) $this->cache = $s->cur_cache ;
 78+ if ( $s->cur_params != "" ) $this->params = explode ( "\n" , $s->cur_params ) ;
 79+ $this->counter = $s->cur_counter+1 ;
 80+ $updateCounter = $this->counter ;
 81+ }
 82+ else $this->contents = $wikiDescribePage ;
 83+ }
 84+ mysql_free_result ( $result ) ;
8485
85 - if ( $updateCounter != "" ) {
86 - $sql = "UPDATE cur SET cur_counter=$updateCounter,cur_timestamp=cur_timestamp WHERE cur_title=\"".$this->secureTitle."\"" ;
87 - $result = mysql_query ( $sql , $connection ) ;
88 - }
 86+ if ( $updateCounter != "" ) {
 87+ $sql = "UPDATE cur SET cur_counter=$updateCounter,cur_timestamp=cur_timestamp WHERE cur_title=\"".$this->secureTitle."\"" ;
 88+ $result = mysql_query ( $sql , $connection ) ;
 89+ }
8990
90 - if ( strtolower ( substr ( $this->contents , 0 , 9 ) ) == "#redirect" and $doRedirect and $action != "edit" ) { # #REDIRECT
91 - $this->backLink = str_replace ( "$1" , $this->url , $wikiRedirectFrom ) ;
92 - $this->backLink = str_replace ( "$2" , $this->getNiceTitle() , $this->backLink ) ;
93 - $z = $this->contents ;
94 - $z = substr ( $z , 10 ) ;
95 - $z = explode ( "\n" , $z ) ; # Ignoring comments after redirect
96 - $z = $z[0] ;
97 - $z = str_replace ( "[" , "" , $z ) ;
98 - $z = str_replace ( "]" , "" , $z ) ;
99 - $this->load ( trim($z) , false , $backLink ) ;
100 - }
101 - #@mysql_close ( $connection ) ;
102 - }
 91+ if ( strtolower ( substr ( $this->contents , 0 , 9 ) ) == "#redirect" and $doRedirect and $action != "edit" ) { # #REDIRECT
 92+ $this->backLink = str_replace ( "$1" , $this->url , $wikiRedirectFrom ) ;
 93+ $this->backLink = str_replace ( "$2" , $this->getNiceTitle() , $this->backLink ) ;
 94+ $z = $this->contents ;
 95+ $z = substr ( $z , 10 ) ;
 96+ $z = explode ( "\n" , $z ) ; # Ignoring comments after redirect
 97+ $z = $z[0] ;
 98+ $z = str_replace ( "[" , "" , $z ) ;
 99+ $z = str_replace ( "]" , "" , $z ) ;
 100+ $this->load ( trim($z) , false , $backLink ) ;
 101+ }
 102+ #@mysql_close ( $connection ) ;
 103+ }
103104
104 - # This function - well, you know...
105 - function special ( $t ) {
106 - $this->title = $t ;
107 - $this->isSpecialPage = true ;
108 - }
 105+ # This function - well, you know...
 106+ function special ( $t ) {
 107+ $this->title = $t ;
 108+ $this->isSpecialPage = true ;
 109+ }
109110
110 - # Look for all matches in $this->params
111 - function getParam ( $p ) {
112 - $ret = array () ;
113 - if ( !isset ( $this->params ) or count ( $this->params ) == 0 ) return $ret ;
114 - $p = strtolower ( $p ) ;
115 - foreach ( $this->params as $x ) {
116 - $y = explode ( " " , $x , 2 ) ;
117 - if ( count ( $y ) > 1 and strtolower ( trim ( $y[0] ) ) == $p ) array_push ( $ret , trim ( $y[1] ) ) ;
118 - }
119 - return $ret ;
120 - }
 111+ # Look for all matches in $this->params
 112+ function getParam ( $p ) {
 113+ $ret = array () ;
 114+ if ( !isset ( $this->params ) or count ( $this->params ) == 0 ) return $ret ;
 115+ $p = strtolower ( $p ) ;
 116+ foreach ( $this->params as $x ) {
 117+ $y = explode ( " " , $x , 2 ) ;
 118+ if ( count ( $y ) > 1 and strtolower ( trim ( $y[0] ) ) == $p ) array_push ( $ret , trim ( $y[1] ) ) ;
 119+ }
 120+ return $ret ;
 121+ }
121122
122 - # This lists all the subpages of a page (for the QuickBar)
123 - # Not in use since we don't have subpages anymore
124 - function getSubpageList () {
125 - $a = array () ;
126 - $t = ucfirst ( $this->namespace ) ;
127 - if ( $t != "" ) $t .= ":" ;
128 - $t .= $this->mainTitle ;
129 - $mother = $t ;
130 - $t .= "/" ;
131 - global $wikiSQLServer ;
132 - $connection = getDBconnection () ;
133 - mysql_select_db ( $wikiSQLServer , $connection ) ;
134 - $sql = "SELECT cur_title FROM cur WHERE cur_title LIKE \"$t%\"" ;
135 - $result = mysql_query ( $sql , $connection ) ;
136 - $u = new WikiTitle ;
137 - while ( $s = mysql_fetch_object ( $result ) ) {
138 - $t = strstr ( $s->cur_title , "/" ) ;
139 - $z = explode ( ":" , $t , 2 ) ;
140 - $t = "[[$t|- ".$this->getNiceTitle(substr($z[count($z)-1],1))."]]" ;
141 - array_push ( $a , $t ) ;
142 - }
143 - if ( $result != "" ) mysql_free_result ( $result ) ;
144 - #mysql_close ( $connection ) ;
145 - if ( count ( $a ) > 0 ) array_unshift ( $a , "[[$mother]]" ) ;
146 - return $a ;
147 - }
 123+ # This lists all the subpages of a page (for the QuickBar)
 124+ # Not in use since we don't have subpages anymore
 125+ function getSubpageList () {
 126+ $a = array () ;
 127+ $t = ucfirst ( $this->namespace ) ;
 128+ if ( $t != "" ) $t .= ":" ;
 129+ $t .= $this->mainTitle ;
 130+ $mother = $t ;
 131+ $t .= "/" ;
 132+ global $wikiSQLServer ;
 133+ $connection = getDBconnection () ;
 134+ mysql_select_db ( $wikiSQLServer , $connection ) ;
 135+ $sql = "SELECT cur_title FROM cur WHERE cur_title LIKE \"$t%\"" ;
 136+ $result = mysql_query ( $sql , $connection ) ;
 137+ $u = new WikiTitle ;
 138+ while ( $s = mysql_fetch_object ( $result ) ) {
 139+ $t = strstr ( $s->cur_title , "/" ) ;
 140+ $z = explode ( ":" , $t , 2 ) ;
 141+ $t = "[[$t|- ".$this->getNiceTitle(substr($z[count($z)-1],1))."]]" ;
 142+ array_push ( $a , $t ) ;
 143+ }
 144+ if ( $result != "" ) mysql_free_result ( $result ) ;
 145+ #mysql_close ( $connection ) ;
 146+ if ( count ( $a ) > 0 ) array_unshift ( $a , "[[$mother]]" ) ;
 147+ return $a ;
 148+ }
148149
149 - # This lists all namespaces that contain an article with the same name
150 - # Called by QuickBar() and getFooter()
151 - function getOtherNamespaces () {
152 - $a = array () ;
153 - if ( $this->isSpecialPage ) return $a ;
154 - $n = explode ( ":" , $this->title ) ;
155 - if ( count ( $n ) == 1 ) $n = $n[0] ;
156 - else $n = $n[1] ;
157 - global $wikiSQLServer , $wikiTalk , $wikiUser , $wikiNamespaceTalk ;
158 - $connection = getDBconnection () ;
159 - mysql_select_db ( $wikiSQLServer , $connection ) ;
160 - $sql = "SELECT cur_title FROM cur WHERE cur_title LIKE \"%:$n\"" ;
161 - $result = mysql_query ( $sql , $connection ) ;
162 - $u = new WikiTitle ;
163 - if ( $this->namespace != "" ) {
164 - $dummy = new wikiTitle ;
165 - $dummy->setTitle ( $n ) ;
166 - if ( $dummy->doesTopicExist ( $connection ) )
167 - #array_push ( $a , "<a style=\"color:green;text-decoration:none\" href=\"".wikiLink($n)."\">:".$this->getNiceTitle($n)."</a>" ) ;
168 - array_push ( $a , "<a class=\"green\" href=\"".wikiLink($n)."\">:".$this->getNiceTitle($n)."</a>" ) ;
169 - }
 150+ # This lists all namespaces that contain an article with the same name
 151+ # Called by QuickBar() and getFooter()
 152+ function getOtherNamespaces () {
 153+ $a = array () ;
 154+ if ( $this->isSpecialPage ) return $a ;
 155+ $n = explode ( ":" , $this->title ) ;
 156+ if ( count ( $n ) == 1 ) $n = $n[0] ;
 157+ else $n = $n[1] ;
 158+ global $wikiSQLServer , $wikiTalk , $wikiUser , $wikiNamespaceTalk ;
 159+ $connection = getDBconnection () ;
 160+ mysql_select_db ( $wikiSQLServer , $connection ) ;
 161+ $sql = "SELECT cur_title FROM cur WHERE cur_title LIKE \"%:$n\"" ;
 162+ $result = mysql_query ( $sql , $connection ) ;
 163+ $u = new WikiTitle ;
 164+ if ( $this->namespace != "" ) {
 165+ $dummy = new wikiTitle ;
 166+ $dummy->setTitle ( $n ) ;
 167+ if ( $dummy->doesTopicExist ( $connection ) )
 168+ #array_push ( $a , "<a style=\"color:green;text-decoration:none\" href=\"".wikiLink($n)."\">:".$this->getNiceTitle($n)."</a>" ) ;
 169+ array_push ( $a , "<a class=\"green\" href=\"".wikiLink($n)."\">:".$this->getNiceTitle($n)."</a>" ) ;
 170+ }
170171
171 - if ( stristr ( $this->namespace , $wikiTalk ) == false ) {
172 - #$n2 = ucfirst ( $this->namespace ) ;
173 - #if ( $n2 != "" ) $n2 .= " " ;
174 - #$n2 .= ucfirst ( $wikiTalk ) ;
175 - if ( $this->namespace != "" )
176 - $n2 = str_replace ( "$1" , ucfirst ( $this->namespace ) , $wikiNamespaceTalk ) ;
177 - else
178 - $n2 = ucfirst ( $wikiTalk ) ;
179 - $dummy = new wikiTitle ;
180 - $dummy->setTitle ( $n2.":$n" ) ;
181 - #if ( $dummy->doesTopicExist ( $connection ) ) $style = "color:green;text-decoration:none" ;
182 - #else $style = "color:red;text-decoration:none" ;
183 - $style = $dummy->doesTopicExist ( $connection ) ? "green" : "red";
184 - array_push ( $a , "<a class=\"$style\" href=\"".wikiLink($dummy->url)."\">$n2</a>" ) ;
185 - }
 172+ if ( stristr ( $this->namespace , $wikiTalk ) == false ) {
 173+ #$n2 = ucfirst ( $this->namespace ) ;
 174+ #if ( $n2 != "" ) $n2 .= " " ;
 175+ #$n2 .= ucfirst ( $wikiTalk ) ;
 176+ if ( $this->namespace != "" )
 177+ $n2 = str_replace ( "$1" , ucfirst ( $this->namespace ) , $wikiNamespaceTalk ) ;
 178+ else
 179+ $n2 = ucfirst ( $wikiTalk ) ;
 180+ $dummy = new wikiTitle ;
 181+ $dummy->setTitle ( $n2.":$n" ) ;
 182+ #if ( $dummy->doesTopicExist ( $connection ) ) $style = "color:green;text-decoration:none" ;
 183+ #else $style = "color:red;text-decoration:none" ;
 184+ $style = $dummy->doesTopicExist ( $connection ) ? "green" : "red";
 185+ array_push ( $a , "<a class=\"$style\" href=\"".wikiLink($dummy->url)."\">$n2</a>" ) ;
 186+ }
186187
187 - while ( $s = mysql_fetch_object ( $result ) ) {
188 - $t = explode ( ":" , $s->cur_title ) ;
189 - $t = $u->getNiceTitle ( $t[0] ) ;
190 - #if ( strtolower ( substr ( $t , -strlen($wikiTalk) ) ) != $wikiTalk and strtolower ( $t ) != $this->namespace )
191 - # Assumes that $wikiTalk is a substring of $wikiNamespaceTalk
192 - if ( !stristr ( $t, $wikiTalk ) and strtolower ( $t ) != $this->namespace )
193 - #array_push ( $a , "<a style=\"color:green;text-decoration:none\" href=\"".wikiLink("$t:$n")."\">$t</a>" ) ;
194 - array_push ( $a , "<a class=\"green\" href=\"".wikiLink("$t:$n")."\">$t</a>" ) ;
195 - }
196 - if ( $result != "" ) mysql_free_result ( $result ) ;
197 - #mysql_close ( $connection ) ;
198 - return $a ;
199 - }
 188+ while ( $s = mysql_fetch_object ( $result ) ) {
 189+ $t = explode ( ":" , $s->cur_title ) ;
 190+ $t = $u->getNiceTitle ( $t[0] ) ;
 191+ #if ( strtolower ( substr ( $t , -strlen($wikiTalk) ) ) != $wikiTalk and strtolower ( $t ) != $this->namespace )
 192+ # Assumes that $wikiTalk is a substring of $wikiNamespaceTalk
 193+ if ( !stristr ( $t, $wikiTalk ) and strtolower ( $t ) != $this->namespace )
 194+ #array_push ( $a , "<a style=\"color:green;text-decoration:none\" href=\"".wikiLink("$t:$n")."\">$t</a>" ) ;
 195+ array_push ( $a , "<a class=\"green\" href=\"".wikiLink("$t:$n")."\">$t</a>" ) ;
 196+ }
 197+ if ( $result != "" ) mysql_free_result ( $result ) ;
 198+ #mysql_close ( $connection ) ;
 199+ return $a ;
 200+ }
200201
201 - # This creates a new article if there is none with the same title yet
202 - function ensureExistence () {
203 - global $useCachedPages ;
204 - $this->makeSecureTitle () ;
205 - if ( $this->doesTopicExist() ) return ;
206 - global $wikiSQLServer ;
207 - $connection = getDBconnection () ;
208 - mysql_select_db ( $wikiSQLServer , $connection ) ;
209 - $sql = "INSERT INTO cur (cur_title) VALUES (\"$this->secureTitle\")" ;
210 - mysql_query ( $sql , $connection ) ;
211 - if ( $useCachedPages ) { # Flushing cache for all pages that linked to the empty topic
212 - $sql = "UPDATE cur SET cur_cache=\"\", cur_timestamp=cur_timestamp WHERE cur_linked_links LIKE \"%$this->secureTitle%\" OR cur_unlinked_links LIKE \"%$this->secureTitle%\"" ;
213 - mysql_query ( $sql , $connection ) ;
214 - }
215 - #mysql_close ( $connection ) ;
216 - }
 202+ # This creates a new article if there is none with the same title yet
 203+ function ensureExistence () {
 204+ global $useCachedPages ;
 205+ $this->makeSecureTitle () ;
 206+ if ( $this->doesTopicExist() ) return ;
 207+ global $wikiSQLServer ;
 208+ $connection = getDBconnection () ;
 209+ mysql_select_db ( $wikiSQLServer , $connection ) ;
 210+ $sql = "INSERT INTO cur (cur_title) VALUES (\"$this->secureTitle\")" ;
 211+ mysql_query ( $sql , $connection ) ;
 212+ if ( $useCachedPages ) { # Flushing cache for all pages that linked to the empty topic
 213+ $sql = "UPDATE cur SET cur_cache=\"\", cur_timestamp=cur_timestamp WHERE cur_linked_links LIKE \"%$this->secureTitle%\" OR cur_unlinked_links LIKE \"%$this->secureTitle%\"" ;
 214+ mysql_query ( $sql , $connection ) ;
 215+ }
 216+ #mysql_close ( $connection ) ;
 217+ }
217218
218 - # This function performs a backup from the "cur" to the "old" table, building a
219 - # single-linked chain with the cur_old_version/old_old_version entries
220 - # The target data set is defined by $this->secureTitle
221 - function backup () {
222 - $id = getMySQL ( "cur" , "cur_id" , "cur_title=\"$this->secureTitle\"" ) ;
223 - $oid = getMySQL ( "cur" , "cur_old_version" , "cur_id=$id" ) ;
 219+ # This function performs a backup from the "cur" to the "old" table, building a
 220+ # single-linked chain with the cur_old_version/old_old_version entries
 221+ # The target data set is defined by $this->secureTitle
 222+ function backup () {
 223+ $id = getMySQL ( "cur" , "cur_id" , "cur_title=\"$this->secureTitle\"" ) ;
 224+ $oid = getMySQL ( "cur" , "cur_old_version" , "cur_id=$id" ) ;
224225
225 - global $wikiSQLServer ;
226 - $connection = getDBconnection () ;
227 - mysql_select_db ( $wikiSQLServer , $connection ) ;
228 - $sql = "SELECT * FROM cur WHERE cur_id=$id" ;
229 - $result = mysql_query ( $sql , $connection ) ;
230 - $s = mysql_fetch_object ( $result ) ;
231 - mysql_free_result ( $result ) ;
 226+ global $wikiSQLServer ;
 227+ $connection = getDBconnection () ;
 228+ mysql_select_db ( $wikiSQLServer , $connection ) ;
 229+ $sql = "SELECT * FROM cur WHERE cur_id=$id" ;
 230+ $result = mysql_query ( $sql , $connection ) ;
 231+ $s = mysql_fetch_object ( $result ) ;
 232+ mysql_free_result ( $result ) ;
232233
233 - $s->cur_text = str_replace ( "\"" , "\\\"" , $s->cur_text ) ;
234 - $sql = "INSERT INTO old (old_title,old_old_version,old_text,old_comment,old_user,old_user_text,old_minor_edit)";
235 - $sql .= " VALUES (\"$this->secureTitle\",\"$oid\",\"".$s->cur_text."\",\"".$s->cur_comment."\",\"$s->cur_user\",\"$s->cur_user_text\",$s->cur_minor_edit)" ;
236 - mysql_query ( $sql , $connection ) ;
 234+ $s->cur_text = str_replace ( "\"" , "\\\"" , $s->cur_text ) ;
 235+ $sql = "INSERT INTO old (old_title,old_old_version,old_text,old_comment,old_user,old_user_text,old_minor_edit)";
 236+ $sql .= " VALUES (\"$this->secureTitle\",\"$oid\",\"".$s->cur_text."\",\"".$s->cur_comment."\",\"$s->cur_user\",\"$s->cur_user_text\",$s->cur_minor_edit)" ;
 237+ mysql_query ( $sql , $connection ) ;
237238
238 - $sql = "SELECT old_id FROM old WHERE old_old_version=\"$oid\" AND old_title=\"$this->secureTitle\"" ;
239 - $result = mysql_query ( $sql , $connection ) ;
240 - $s = mysql_fetch_object ( $result ) ;
241 - mysql_free_result ( $result ) ;
 239+ $sql = "SELECT old_id FROM old WHERE old_old_version=\"$oid\" AND old_title=\"$this->secureTitle\"" ;
 240+ $result = mysql_query ( $sql , $connection ) ;
 241+ $s = mysql_fetch_object ( $result ) ;
 242+ mysql_free_result ( $result ) ;
242243
243 - $oid = $s->old_id ;
244 - setMySQL ( "cur" , "cur_old_version" , $oid , "cur_id=$id" ) ;
245 - }
 244+ $oid = $s->old_id ;
 245+ setMySQL ( "cur" , "cur_old_version" , $oid , "cur_id=$id" ) ;
 246+ }
246247
247 - # This function stores the passed parameters into the database (the "cur" table)
248 - # The target data set is defined by $this->secureTitle
249 - function setEntry ( $text , $comment , $userID , $userName , $minorEdit , $addSQL = "" ) {
250 - global $useCachedPages ;
251 - $cond = "cur_title=\"$this->secureTitle\"" ;
 248+ # This function stores the passed parameters into the database (the "cur" table)
 249+ # The target data set is defined by $this->secureTitle
 250+ function setEntry ( $text , $comment , $userID , $userName , $minorEdit , $addSQL = "" ) {
 251+ global $useCachedPages ;
 252+ $cond = "cur_title=\"$this->secureTitle\"" ;
252253
253 - global $linkedLinks , $unlinkedLinks ;
254 - $this->parseContents ( $text , true ) ; # Calling with savingMode flag set, so only internal Links are parsed
255 - $ll = implode ( "\n" , array_keys ( $linkedLinks ) ) ;
256 - $ull = implode ( "\n" , array_keys ( $unlinkedLinks ) ) ;
257 - $pa = implode ( "\n" , $this->params ) ;
 254+ global $linkedLinks , $unlinkedLinks ;
 255+ $this->parseContents ( $text , true ) ; # Calling with savingMode flag set, so only internal Links are parsed
 256+ $ll = implode ( "\n" , array_keys ( $linkedLinks ) ) ;
 257+ $ull = implode ( "\n" , array_keys ( $unlinkedLinks ) ) ;
 258+ $pa = implode ( "\n" , $this->params ) ;
258259
259 - if ( $useCachedPages ) $addCache = "cur_cache=\"\"," ;
 260+ if ( $useCachedPages ) $addCache = "cur_cache=\"\"," ;
260261
261 - global $wikiSQLServer ;
262 - $connection = getDBconnection () ;
263 - mysql_select_db ( $wikiSQLServer , $connection ) ;
264 - $text = str_replace ( "\"" , "\\\"" , $text ) ;
265 -# $comment = str_replace ( "\"" , "\\\"" , $comment ) ;
266 - $userName = str_replace ( "\"" , "\\\"" , $userName ) ;
267 - $comment = htmlentities ( $comment ) ;
268 - $sql = "UPDATE cur SET cur_text=\"$text\",cur_comment=\"$comment\",cur_user=\"$userID\"," ;
269 - $sql .= "cur_user_text=\"$userName\",cur_minor_edit=\"$minorEdit\",";
270 - $sql .= "cur_linked_links=\"$ll\",cur_unlinked_links=\"$ull\",$addCache cur_params=\"$pa\"$addSQL WHERE $cond" ;
271 - $r = mysql_query ( $sql , $connection ) ;
272 - #mysql_close ( $connection ) ;
273 - }
 262+ global $wikiSQLServer ;
 263+ $connection = getDBconnection () ;
 264+ mysql_select_db ( $wikiSQLServer , $connection ) ;
 265+ $text = str_replace ( "\"" , "\\\"" , $text ) ;
 266+# $comment = str_replace ( "\"" , "\\\"" , $comment ) ;
 267+ $userName = str_replace ( "\"" , "\\\"" , $userName ) ;
 268+ $comment = htmlentities ( $comment ) ;
 269+ $sql = "UPDATE cur SET cur_text=\"$text\",cur_comment=\"$comment\",cur_user=\"$userID\"," ;
 270+ $sql .= "cur_user_text=\"$userName\",cur_minor_edit=\"$minorEdit\",";
 271+ $sql .= "cur_linked_links=\"$ll\",cur_unlinked_links=\"$ull\",$addCache cur_params=\"$pa\"$addSQL WHERE $cond" ;
 272+ $r = mysql_query ( $sql , $connection ) ;
 273+ #mysql_close ( $connection ) ;
 274+ }
274275
275276 #### Rendering functions
276 - # This function converts wiki-style internal links like [[Main Page]] with the appropriate HTML code
277 - # It has to handle namespaces, subpages, and alternate names (as in [[namespace:page/subpage name]])
278 - function replaceInternalLinks ( $s ) {
279 - global $wikiInterwiki , $action , $wikiOtherLanguages ;
280 - global $user , $unlinkedLinks , $linkedLinks , $wikiPrintLinksMarkup ;
281 - if ( !isset ( $this->knownLinkedLinks ) ) $this->knownLinkedLinks = array () ;
282 - if ( !isset ( $this->knownUnlinkedLinks ) ) $this->knownUnlinkedLinks = array () ;
283 - $abc = " abcdefghijklmnopqrstuvwxyz" ;
284 - $a = explode ( "[[" , " ".$s ) ;
285 - $s = array_shift ( $a ) ;
286 - $s = substr ( $s , 1 ) ;
287 - $connection = getDBconnection () ;
288 - $iws = array_keys ( $wikiInterwiki ) ;
289 - foreach ( $a as $t ) {
290 - $b = explode ( "]]" , $t , 2 ) ;
291 - if ( count($b) < 2 ) { # No matching ]]
292 - $s .= "[[".$b[0] ;
293 - } else {
294 - $c = explode ( "|" , $b[0] , 2 ) ;
295 - $link = $c[0] ;
 277+ # This function converts wiki-style internal links like [[Main Page]] with the appropriate HTML code
 278+ # It has to handle namespaces, subpages, and alternate names (as in [[namespace:page/subpage name]])
 279+ function replaceInternalLinks ( $s ) {
 280+ global $wikiInterwiki , $action , $wikiOtherLanguages ;
 281+ global $user , $unlinkedLinks , $linkedLinks , $wikiPrintLinksMarkup ;
 282+ if ( !isset ( $this->knownLinkedLinks ) ) $this->knownLinkedLinks = array () ;
 283+ if ( !isset ( $this->knownUnlinkedLinks ) ) $this->knownUnlinkedLinks = array () ;
 284+ $abc = " abcdefghijklmnopqrstuvwxyz" ;
 285+ $a = explode ( "[[" , " ".$s ) ;
 286+ $s = array_shift ( $a ) ;
 287+ $s = substr ( $s , 1 ) ;
 288+ $connection = getDBconnection () ;
 289+ $iws = array_keys ( $wikiInterwiki ) ;
 290+ foreach ( $a as $t ) {
 291+ $b = explode ( "]]" , $t , 2 ) ;
 292+ if ( count($b) < 2 ) { # No matching ]]
 293+ $s .= "[[".$b[0] ;
 294+ } else {
 295+ $c = explode ( "|" , $b[0] , 2 ) ;
 296+ $link = $c[0] ;
296297
297 - $topic = new WikiTitle ;
298 - $topic->setTitle ( $link ) ;
299 - $link = $this->getLinkTo ( $topic ) ;
300 - $topic->setTitle ( $link ) ;
 298+ $topic = new WikiTitle ;
 299+ $topic->setTitle ( $link ) ;
 300+ $link = $this->getLinkTo ( $topic ) ;
 301+ $topic->setTitle ( $link ) ;
301302
302 - if ( count ( $c ) == 1 ) array_push ( $c , $topic->getMainTitle() ) ;
303 - while ( $b[1] != "" and strpos ( $abc , substr ( $b[1] , 0 , 1 ) ) > 0 ) {
304 - $c[1] .= substr ( $b[1] , 0 , 1 ) ;
305 - $b[1] = substr ( $b[1] , 1 ) ;
306 - }
307 - $text = $c[1] ;
 303+ if ( count ( $c ) == 1 ) array_push ( $c , $topic->getMainTitle() ) ;
 304+ while ( $b[1] != "" and strpos ( $abc , substr ( $b[1] , 0 , 1 ) ) > 0 ) {
 305+ $c[1] .= substr ( $b[1] , 0 , 1 ) ;
 306+ $b[1] = substr ( $b[1] , 1 ) ;
 307+ }
 308+ $text = $c[1] ;
308309
309 - if ( in_array ( $topic->secureTitle , $this->knownLinkedLinks ) ) $doesItExist = true ;
310 - else $doesItExist = $topic->doesTopicExist( $connection ) ;
 310+ if ( in_array ( $topic->secureTitle , $this->knownLinkedLinks ) ) $doesItExist = true ;
 311+ else $doesItExist = $topic->doesTopicExist( $connection ) ;
311312
312 - # Check for interwiki links
313 - $iwl = "" ;
314 - foreach ( $iws as $ii )
315 - if ( strtolower ( $ii ) == strtolower ( $topic->namespace ) )
316 - $iwl = $wikiInterwiki[$ii] ;
317 - if ( $iwl != "" ) { # Interwiki Link
318 - $tt = ucfirst ( str_replace ( " " , "_" , $topic->mainTitle ) ) ;
319 - $iwl = str_replace ( "$1" , $tt , $iwl ) ;
320 - if ( $c[0] == $c[1] ) $text = $topic->getNiceTitle ( $topic->mainTitle ) ;
321 - #$linkStyle = "style=\"color:#3333BB;text-decoration:none\"" ;
322 - $linkStyle = "class=\"interwiki\"";
323 - $s .= "<a $linkStyle href=\"$iwl\">$text</a>" ;
324 - } else if ( in_array ( strtolower ( $topic->namespace ) , array_keys ( $wikiOtherLanguages ) ) ) {
325 - $tt = ucfirst ( str_replace ( " " , "_" , $topic->mainTitle ) ) ;
326 - $iwl = str_replace ( "$1" , $tt , $wikiOtherLanguages[strtolower($topic->namespace)] ) ;
327 - if ( $c[0] == $c[1] ) $text = $topic->getNiceTitle ( $topic->mainTitle ) ;
328 - #$linkStyle = "style=\"color:#3333BB;text-decoration:none\"" ;
329 - $linkStyle = "class=\"interwiki\"";
330 - $this->otherLanguages[$topic->namespace] = $iwl ;
331 - } else if ( $doesItExist ) {
332 - $linkedLinks[$topic->secureTitle]++ ;
333 - if ( $user->options["showHover"] == "yes" ) $hover = "title=\"" . htmlspecialchars ( $link ) . "\"" ;
334 - #if ( $user->options["underlineLinks"] == "no" ) $linkStyle = " style=\"color:blue;text-decoration:none\"" ;
335 - $ulink = nurlencode ( $link ) ;
336 - $s .= "<a href=\"".wikiLink($ulink)."\" $hover$linkStyle>$text</a>" ;
337 - } else {
338 - $unlinkedLinks[$link]++ ;
339 - #$text2 = $text ;
340 - #$style="" ;
341 - if ( $user->options["showHover"] == "yes" ) $hover = "title=\"Edit '" . htmlspecialchars ( $link ) . "'\"" ;
342 - #if ( substr_count ( $text2 , " " ) > 0 ) {
343 - # if ( $action == "print" ) $text2 = "<$wikiPrintLinksMarkup>$text2</$wikiPrintLinksMarkup>" ;
344 - # else $text2 = "[$text2]" ;
345 - # }
346 - #if ( $user->options["underlineLinks"] == "no" ) { $text = $text2 ; $style = ";text-decoration:none" ; }
347 - #$ulink = nurlencode ( $link ) ;
348 - #if ( $user->options["markupNewTopics"] == "red" )
349 - # $s .= "<a style=\"color:red$style\" href=\"".wikiLink("$ulink&action=edit")."\" $hover>$text</a>" ;
350 - #else if ( $user->options["markupNewTopics"] == "inverse" )
351 - # $s .= "<a style=\"color:white;background:blue$style\" href=\"".wikiLink("$ulink&action=edit")."\" $hover>$text</a>";
352 - #else $s .= "$text2<a href=\"".wikiLink("$ulink&action=edit")."\" $hover>?</a>" ;
353 - $ulink = wikilink( nurlencode ( $link ) . "&action=edit" ) ;
354 - if ( substr_count ( $text , " " ) > 0 ) {
355 - $s .= "<span class=\"newlinkedge\">[</span>";
356 - $bracket = "]";
357 - } else {
358 - $bracket = "";
359 - }
360 - $s .= "<a class=\"newlink\" href=\"$ulink\" $hover>$text</a>" ;
361 - $s .= "<span class=\"newlinkedge\">$bracket<a href=\"$ulink\" $hover>?</a></span>";
362 - }
363 - $s .= $b[1] ;
364 - }
365 - }
366 - #mysql_close ( $connection ) ;
367 - return $s ;
368 - }
 313+ # Check for interwiki links
 314+ $iwl = "" ;
 315+ foreach ( $iws as $ii )
 316+ if ( strtolower ( $ii ) == strtolower ( $topic->namespace ) )
 317+ $iwl = $wikiInterwiki[$ii] ;
 318+ if ( $iwl != "" ) { # Interwiki Link
 319+ $tt = ucfirst ( str_replace ( " " , "_" , $topic->mainTitle ) ) ;
 320+ $iwl = str_replace ( "$1" , $tt , $iwl ) ;
 321+ if ( $c[0] == $c[1] ) $text = $topic->getNiceTitle ( $topic->mainTitle ) ;
 322+ #$linkStyle = "style=\"color:#3333BB;text-decoration:none\"" ;
 323+ $linkStyle = "class=\"interwiki\"";
 324+ $s .= "<a $linkStyle href=\"$iwl\">$text</a>" ;
 325+ } else if ( in_array ( strtolower ( $topic->namespace ) , array_keys ( $wikiOtherLanguages ) ) ) {
 326+ $tt = ucfirst ( str_replace ( " " , "_" , $topic->mainTitle ) ) ;
 327+ $iwl = str_replace ( "$1" , $tt , $wikiOtherLanguages[strtolower($topic->namespace)] ) ;
 328+ if ( $c[0] == $c[1] ) $text = $topic->getNiceTitle ( $topic->mainTitle ) ;
 329+ #$linkStyle = "style=\"color:#3333BB;text-decoration:none\"" ;
 330+ $linkStyle = "class=\"interwiki\"";
 331+ $this->otherLanguages[$topic->namespace] = $iwl ;
 332+ } else if ( $doesItExist ) {
 333+ $linkedLinks[$topic->secureTitle]++ ;
 334+ if ( $user->options["showHover"] == "yes" ) $hover = "title=\"" . htmlspecialchars ( $link ) . "\"" ;
 335+ #if ( $user->options["underlineLinks"] == "no" ) $linkStyle = " style=\"color:blue;text-decoration:none\"" ;
 336+ $ulink = nurlencode ( $link ) ;
 337+ $s .= "<a href=\"".wikiLink($ulink)."\" $hover$linkStyle>$text</a>" ;
 338+ } else {
 339+ $unlinkedLinks[$link]++ ;
 340+ #$text2 = $text ;
 341+ #$style="" ;
 342+ if ( $user->options["showHover"] == "yes" ) $hover = "title=\"Edit '" . htmlspecialchars ( $link ) . "'\"" ;
 343+ #if ( substr_count ( $text2 , " " ) > 0 ) {
 344+ # if ( $action == "print" ) $text2 = "<$wikiPrintLinksMarkup>$text2</$wikiPrintLinksMarkup>" ;
 345+ # else $text2 = "[$text2]" ;
 346+ # }
 347+ #if ( $user->options["underlineLinks"] == "no" ) { $text = $text2 ; $style = ";text-decoration:none" ; }
 348+ #$ulink = nurlencode ( $link ) ;
 349+ #if ( $user->options["markupNewTopics"] == "red" )
 350+ # $s .= "<a style=\"color:red$style\" href=\"".wikiLink("$ulink&action=edit")."\" $hover>$text</a>" ;
 351+ #else if ( $user->options["markupNewTopics"] == "inverse" )
 352+ # $s .= "<a style=\"color:white;background:blue$style\" href=\"".wikiLink("$ulink&action=edit")."\" $hover>$text</a>";
 353+ #else $s .= "$text2<a href=\"".wikiLink("$ulink&action=edit")."\" $hover>?</a>" ;
 354+ $ulink = wikilink( nurlencode ( $link ) . "&action=edit" ) ;
 355+ if ( substr_count ( $text , " " ) > 0 ) {
 356+ $s .= "<span class=\"newlinkedge\">[</span>";
 357+ $bracket = "]";
 358+ } else {
 359+ $bracket = "";
 360+ }
 361+ $s .= "<a class=\"newlink\" href=\"$ulink\" $hover>$text</a>" ;
 362+ $s .= "<span class=\"newlinkedge\">$bracket<a href=\"$ulink\" $hover>?</a></span>";
 363+ }
 364+ $s .= $b[1] ;
 365+ }
 366+ }
 367+ #mysql_close ( $connection ) ;
 368+ return $s ;
 369+ }
369370
370 - # This function replaces wiki-style image links with the HTML code to display them
371 - function parseImages ( $s ) {
372 - $s = ereg_replace ( "([^[])http://([a-zA-Z0-9_/:.~\%\-]*)\.(png|jpg|jpeg|tif|tiff|gif)" , "\\1<img src=\"http://\\2.\\3\">" , $s ) ;
373 - return $s ;
374 - }
 371+ # This function replaces wiki-style image links with the HTML code to display them
 372+ function parseImages ( $s ) {
 373+ $s = ereg_replace ( "([^[])http://([a-zA-Z0-9_/:.~\%\-]*)\.(png|jpg|jpeg|tif|tiff|gif)" , "\\1<img src=\"http://\\2.\\3\">" , $s ) ;
 374+ return $s ;
 375+ }
375376
376 - # This function replaces wiki-style external links (both with and without []) with HTML links
377 - function replaceExternalLinks ( $s ) {
378 - global $user ;
379 - $cnt = 1 ;
380 - $a = explode ( "[http://" , " ".$s ) ;
381 - $s = array_shift ( $a ) ;
382 - $s = substr ( $s , 1 ) ;
383 - $image = "" ; # with an <img tag, this will be displayed before external links
384 - #$linkStyle = "style=\"color:#3333BB;text-decoration:none\"" ;
385 - $linkStyle = "class=\"external\"";
386 - foreach ( $a as $t ) {
387 - $b = spliti ( "]" , $t , 2 ) ;
388 - if ( count($b) < 2 ) $s .= "[Broken link : $b[0]]" ;
389 - else {
390 - $c = explode ( " " , $b[0] , 2 ) ;
391 - if ( count ( $c ) == 1 ) array_push ( $c , "" ) ;
392 - $link = $c[0] ;
393 - $text = trim ( $c[1] ) ;
394 - if ( $text == "" ) $text = "[".$cnt++."]" ;
395 - else {
396 - if ( substr_count ( $text , " " ) > 0 and $user->options["underlineLinks"] == "no" )
397 - $text = "[$text]" ;
398 - }
399 - if ( substr_count ( $b[1] , "<hr>" ) > 0 ) $cnt = 1 ;
400 - $link = "~http://".$link ;
401 - if ( $user->options["showHover"] == "yes" ) $hover = "title=\"$link\"" ;
402 - $theLink = "<a href=\"$link\" $linkStyle $hover>$image$text</a>" ;
403 - $s .= $theLink.$b[1] ;
404 - }
405 - }
 377+ # This function replaces wiki-style external links (both with and without []) with HTML links
 378+ function replaceExternalLinks ( $s ) {
 379+ global $user ;
 380+ $cnt = 1 ;
 381+ $a = explode ( "[http://" , " ".$s ) ;
 382+ $s = array_shift ( $a ) ;
 383+ $s = substr ( $s , 1 ) ;
 384+ $image = "" ; # with an <img tag, this will be displayed before external links
 385+ #$linkStyle = "style=\"color:#3333BB;text-decoration:none\"" ;
 386+ $linkStyle = "class=\"external\"";
 387+ foreach ( $a as $t ) {
 388+ $b = spliti ( "]" , $t , 2 ) ;
 389+ if ( count($b) < 2 ) $s .= "[Broken link : $b[0]]" ;
 390+ else {
 391+ $c = explode ( " " , $b[0] , 2 ) ;
 392+ if ( count ( $c ) == 1 ) array_push ( $c , "" ) ;
 393+ $link = $c[0] ;
 394+ $text = trim ( $c[1] ) ;
 395+ if ( $text == "" ) $text = "[".$cnt++."]" ;
 396+ else {
 397+ if ( substr_count ( $text , " " ) > 0 and $user->options["underlineLinks"] == "no" )
 398+ $text = "[$text]" ;
 399+ }
 400+ if ( substr_count ( $b[1] , "<hr>" ) > 0 ) $cnt = 1 ;
 401+ $link = "~http://".$link ;
 402+ if ( $user->options["showHover"] == "yes" ) $hover = "title=\"$link\"" ;
 403+ $theLink = "<a href=\"$link\" $linkStyle $hover>$image$text</a>" ;
 404+ $s .= $theLink.$b[1] ;
 405+ }
 406+ }
406407
407 - $o_no_dot = "A-Za-z0-9_~/=?\:\%\+\&\#\-" ;
408 - $o = "\.$o_no_dot" ;
409 - $s = eregi_replace ( "([^~\"])http://([$o]+[$o_no_dot])([^$o_no_dot])" , "\\1<a href=\"http://\\2\" $linkStyle>".$image."http://\\2</a>\\3" , $s ) ;
410 - $s = str_replace ( "~http://" , "http://" , $s ) ;
 408+ $o_no_dot = "A-Za-z0-9_~/=?\:\%\+\&\#\-" ;
 409+ $o = "\.$o_no_dot" ;
 410+ $s = eregi_replace ( "([^~\"])http://([$o]+[$o_no_dot])([^$o_no_dot])" , "\\1<a href=\"http://\\2\" $linkStyle>".$image."http://\\2</a>\\3" , $s ) ;
 411+ $s = str_replace ( "~http://" , "http://" , $s ) ;
411412
412 - return $s ;
413 - }
 413+ return $s ;
 414+ }
414415
415 - # This function replaces the newly introduced wiki variables with their values (for display only!)
416 - function replaceVariables ( $s ) {
417 - global $wikiDate ;
418 - $countvars = substr_count ( "{{" , $s ) ;
419 - $var=date("m"); $s = str_replace ( "{{CURRENTMONTH}}" , $var , $s ) ;
420 - $var=$wikiDate[strtolower(date("F"))]; $s = str_replace ( "{{CURRENTMONTHNAME}}" , $var , $s ) ;
421 - $var=date("j"); $s = str_replace ( "{{CURRENTDAY}}" , $var , $s ) ;
422 - $var=$wikiDate[strtolower(date("l"))]; $s = str_replace ( "{{CURRENTDAYNAME}}" , $var , $s ) ;
423 - $var=date("Y"); $s = str_replace ( "{{CURRENTYEAR}}" , $var , $s ) ;
424 - if ( strstr ( $s , "{{NUMBEROFARTICLES}}" ) ) { # This should count only "real" articles!
425 - global $wikiSQLServer ;
426 - $connection=getDBconnection() ;
427 - mysql_select_db ( $wikiSQLServer , $connection ) ;
428 - $sql="SELECT COUNT(*) as number FROM cur WHERE cur_title NOT LIKE \"%:%\" AND cur_title NOT LIKE \"%ikipedia%\" AND cur_text LIKE \"%,%\"";
429 - $result = mysql_query ( $sql , $connection ) ;
430 - $var = mysql_fetch_object ( $result ) ;
431 - $var = number_format ( $var->number , 0 ) ;
432 - mysql_free_result ( $result ) ;
433 - #mysql_close ( $connection ) ;
434 - $s = str_replace ( "{{NUMBEROFARTICLES}}" , $var , $s ) ;
435 - }
 416+ # This function replaces the newly introduced wiki variables with their values (for display only!)
 417+ function replaceVariables ( $s ) {
 418+ global $wikiDate ;
 419+ $countvars = substr_count ( "{{" , $s ) ;
 420+ $var=date("m"); $s = str_replace ( "{{CURRENTMONTH}}" , $var , $s ) ;
 421+ $var=$wikiDate[strtolower(date("F"))]; $s = str_replace ( "{{CURRENTMONTHNAME}}" , $var , $s ) ;
 422+ $var=date("j"); $s = str_replace ( "{{CURRENTDAY}}" , $var , $s ) ;
 423+ $var=$wikiDate[strtolower(date("l"))]; $s = str_replace ( "{{CURRENTDAYNAME}}" , $var , $s ) ;
 424+ $var=date("Y"); $s = str_replace ( "{{CURRENTYEAR}}" , $var , $s ) ;
 425+ if ( strstr ( $s , "{{NUMBEROFARTICLES}}" ) ) { # This should count only "real" articles!
 426+ global $wikiSQLServer ;
 427+ $connection=getDBconnection() ;
 428+ mysql_select_db ( $wikiSQLServer , $connection ) ;
 429+ $sql="SELECT COUNT(*) as number FROM cur WHERE cur_title NOT LIKE \"%:%\" AND cur_title NOT LIKE \"%ikipedia%\" AND cur_text LIKE \"%,%\"";
 430+ $result = mysql_query ( $sql , $connection ) ;
 431+ $var = mysql_fetch_object ( $result ) ;
 432+ $var = number_format ( $var->number , 0 ) ;
 433+ mysql_free_result ( $result ) ;
 434+ #mysql_close ( $connection ) ;
 435+ $s = str_replace ( "{{NUMBEROFARTICLES}}" , $var , $s ) ;
 436+ }
436437
437438 /*
438 - # Category functionality deactivated
439 - if ( strstr ( $s , "{{THISCATEGORY}}" ) ) {
440 - global $wikiSQLServer ;
441 - $connection=getDBconnection() ;
442 - mysql_select_db ( $wikiSQLServer , $connection ) ;
 439+ # Category functionality deactivated
 440+ if ( strstr ( $s , "{{THISCATEGORY}}" ) ) {
 441+ global $wikiSQLServer ;
 442+ $connection=getDBconnection() ;
 443+ mysql_select_db ( $wikiSQLServer , $connection ) ;
443444
444 - $comp = $this->getNiceTitle() ;
445 - $comp = "%\nCATEGORY $comp\n%" ;
446 - $sql = "SELECT cur_title FROM cur WHERE cur_params LIKE \"$comp\"" ;
 445+ $comp = $this->getNiceTitle() ;
 446+ $comp = "%\nCATEGORY $comp\n%" ;
 447+ $sql = "SELECT cur_title FROM cur WHERE cur_params LIKE \"$comp\"" ;
447448
448 - global $wikiThisCategory ;
449 - $result = mysql_query ( $sql , $connection ) ;
450 - $var = array () ;
451 - while ( $q = mysql_fetch_object ( $result ) ) array_push ( $var , $this->getNiceTitle ( $q->cur_title ) ) ;
452 - if ( count ( $var ) > 0 ) {
453 - $var = "[[".implode ( "]] -- [[" , $var )."]]\n" ;
454 - $var = "<table bgcolor=\"#CCCCCC\" width=\"100%\"><th>$wikiThisCategory</th><tr><td>$var</td></tr></table>" ;
455 - }
456 - else $var = "" ;
 449+ global $wikiThisCategory ;
 450+ $result = mysql_query ( $sql , $connection ) ;
 451+ $var = array () ;
 452+ while ( $q = mysql_fetch_object ( $result ) ) array_push ( $var , $this->getNiceTitle ( $q->cur_title ) ) ;
 453+ if ( count ( $var ) > 0 ) {
 454+ $var = "[[".implode ( "]] -- [[" , $var )."]]\n" ;
 455+ $var = "<table bgcolor=\"#CCCCCC\" width=\"100%\"><th>$wikiThisCategory</th><tr><td>$var</td></tr></table>" ;
 456+ }
 457+ else $var = "" ;
457458
458 - mysql_free_result ( $result ) ;
459 - #mysql_close ( $connection ) ;
460 - $s = str_replace ( "{{THISCATEGORY}}" , $var , $s ) ;
461 - }
 459+ mysql_free_result ( $result ) ;
 460+ #mysql_close ( $connection ) ;
 461+ $s = str_replace ( "{{THISCATEGORY}}" , $var , $s ) ;
 462+ }
462463 */
463464
464465 /*
465 - # Also deactivated
466 - # Hide the rest...
467 - $n = explode ( "{{" , $s ) ;
468 - $s = array_shift ( $n ) ;
469 - foreach ( $n as $x ) {
470 - $m = explode ( "}}" , $x , 2 ) ;
471 - if ( count ( $m ) == 1 ) $s .= "{{".$x ;
472 - else $s .= $m[1] ;
473 - }
 466+ # Also deactivated
 467+ # Hide the rest...
 468+ $n = explode ( "{{" , $s ) ;
 469+ $s = array_shift ( $n ) ;
 470+ foreach ( $n as $x ) {
 471+ $m = explode ( "}}" , $x , 2 ) ;
 472+ if ( count ( $m ) == 1 ) $s .= "{{".$x ;
 473+ else $s .= $m[1] ;
 474+ }
474475 */
475476
476 - if ( $countvars != substr_count ( "{{" , $s ) )
477 - $this->canBeCached = false ;
 477+ if ( $countvars != substr_count ( "{{" , $s ) )
 478+ $this->canBeCached = false ;
478479
479 - return $s ;
480 - }
 480+ return $s ;
 481+ }
481482
482 - # This function ensures all occurrences of $f are replaced with $r within $s
483 - function replaceAll ( $f , $r , &$s ) {
484 - $t = "" ;
485 - while ( $s != $t ) {
486 - $t = $s ;
487 - $s = str_replace ( $f , $r , $s ) ;
488 - }
489 - return $s ;
490 - }
 483+ # This function ensures all occurrences of $f are replaced with $r within $s
 484+ function replaceAll ( $f , $r , &$s ) {
 485+ $t = "" ;
 486+ while ( $s != $t ) {
 487+ $t = $s ;
 488+ $s = str_replace ( $f , $r , $s ) ;
 489+ }
 490+ return $s ;
 491+ }
491492
492 - # This function is called to replace wiki-style tags with HTML, e.g., the first occurrence of ''' with <b>, the second with </b>
493 - function pingPongReplace ( $f , $r1 , $r2 , $s , $startAtLine = false ) {
494 - $ret = "" ;
495 - $lines = explode ( "\n" , $s ) ;
496 - foreach ( $lines as $s ) {
497 - if ( $startAtLine == false or substr ( $s , 0 , strlen ( $f ) ) == $f ) {
498 - $a = explode ( $f , " ".$s ) ;
499 - $app = "" ;
500 - $s = substr ( array_shift ( $a ) , 1 ) ;
501 - $r = $r1 ;
502 - if ( count ( $a ) % 2 != 0 ) $app = $f.array_pop ( $a ) ;
503 - foreach ( $a as $t ) {
504 - $s .= $r.$t ;
505 - if ( $r == $r1 ) $r = $r2 ;
506 - else $r = $r1 ;
507 - }
508 - }
509 - if ( $ret != "" ) $ret .= "\n" ;
510 - $ret .= $s.$app ;
511 - }
512 - return $ret ;
513 - }
 493+ # This function is called to replace wiki-style tags with HTML, e.g., the first occurrence of ''' with <b>, the second with </b>
 494+ function pingPongReplace ( $f , $r1 , $r2 , $s , $startAtLine = false ) {
 495+ $ret = "" ;
 496+ $lines = explode ( "\n" , $s ) ;
 497+ foreach ( $lines as $s ) {
 498+ if ( $startAtLine == false or substr ( $s , 0 , strlen ( $f ) ) == $f ) {
 499+ $a = explode ( $f , " ".$s ) ;
 500+ $app = "" ;
 501+ $s = substr ( array_shift ( $a ) , 1 ) ;
 502+ $r = $r1 ;
 503+ if ( count ( $a ) % 2 != 0 ) $app = $f.array_pop ( $a ) ;
 504+ foreach ( $a as $t ) {
 505+ $s .= $r.$t ;
 506+ if ( $r == $r1 ) $r = $r2 ;
 507+ else $r = $r1 ;
 508+ }
 509+ }
 510+ if ( $ret != "" ) $ret .= "\n" ;
 511+ $ret .= $s.$app ;
 512+ }
 513+ return $ret ;
 514+ }
514515
515 - # Called from parseContents before saving
516 - function scanForParams ( $s ) {
517 - $this->params = array () ;
518 - return ;
 516+ # Called from parseContents before saving
 517+ function scanForParams ( $s ) {
 518+ $this->params = array () ;
 519+ return ;
519520 /*
520 - # Category functionality deactivated
521 - $this->params = array ( "" ) ;
522 - $a = explode ( "{{" , $s ) ;
523 - array_shift ( $a ) ;
524 - foreach ( $a as $x ) {
525 - $b = explode ( "}}" , $x , 2 ) ;
526 - if ( count ( $b ) > 1 ) {
527 - $before = $b[0] ;
528 - $after = $b[1] ;
529 - $c = explode ( " " , $before , 2 ) ;
530 - if ( count ( $c ) > 1 ) {
531 - $decl = strtolower ( trim ( $c[0] ) ) ;
532 - $vars = trim ( $c[1] ) ;
533 - $vars = str_replace ( "\"" , "" , $vars ) ;
534 - $vars = str_replace ( "\n" , "" , $vars ) ;
535 - $vars = explode ( "," , $vars ) ;
536 - foreach ( $vars as $y ) array_push ( $this->params , "$decl ".trim($y) ) ;
537 - }
538 - }
539 - }
540 - if ( count ( $this->params ) > 1 ) array_push ( $this->params , "" ) ;
541 - else $this->params = array () ;
 521+ # Category functionality deactivated
 522+ $this->params = array ( "" ) ;
 523+ $a = explode ( "{{" , $s ) ;
 524+ array_shift ( $a ) ;
 525+ foreach ( $a as $x ) {
 526+ $b = explode ( "}}" , $x , 2 ) ;
 527+ if ( count ( $b ) > 1 ) {
 528+ $before = $b[0] ;
 529+ $after = $b[1] ;
 530+ $c = explode ( " " , $before , 2 ) ;
 531+ if ( count ( $c ) > 1 ) {
 532+ $decl = strtolower ( trim ( $c[0] ) ) ;
 533+ $vars = trim ( $c[1] ) ;
 534+ $vars = str_replace ( "\"" , "" , $vars ) ;
 535+ $vars = str_replace ( "\n" , "" , $vars ) ;
 536+ $vars = explode ( "," , $vars ) ;
 537+ foreach ( $vars as $y ) array_push ( $this->params , "$decl ".trim($y) ) ;
 538+ }
 539+ }
 540+ }
 541+ if ( count ( $this->params ) > 1 ) array_push ( $this->params , "" ) ;
 542+ else $this->params = array () ;
542543 */
543 - }
 544+ }
544545
545 - # This function organizes the <nowiki> parts and calls subPageContents() for the wiki parts
546 - function parseContents ( $s , $savingMode = false ) {
547 - global $linkedLinks , $unlinkedLinks , $framed ;
548 - $linkedLinks = array () ;
549 - $unlinkedLinks = array () ;
550 - $this->otherLanguages = array () ;
551 - $s .= "\n" ;
 546+ # This function organizes the <nowiki> parts and calls subPageContents() for the wiki parts
 547+ function parseContents ( $s , $savingMode = false ) {
 548+ global $linkedLinks , $unlinkedLinks , $framed ;
 549+ $linkedLinks = array () ;
 550+ $unlinkedLinks = array () ;
 551+ $this->otherLanguages = array () ;
 552+ $s .= "\n" ;
552553
553 - # Parsing <pre> here
554 - $a = spliti ( "<pre>" , $s ) ;
555 - $s = array_shift ( $a ) ;
556 - foreach ( $a as $x ) {
557 - $b = spliti ( "</pre>" , $x , 2 ) ;
558 - if ( count ( $b ) == 1 ) $s .= "&lt;pre&gt;$x" ;
559 - else {
560 - $x = htmlentities ( $b[0] ) ;
561 - $s .= "<pre>$x</pre>$b[1]" ;
562 - }
563 - }
564 - $s = str_replace ( "<pre>" , "<pre><nowiki>" , $s ) ;
565 - $s = str_replace ( "</pre>" , "</nowiki></pre>" , $s ) ;
 554+ # Parsing <pre> here
 555+ $a = spliti ( "<pre>" , $s ) ;
 556+ $s = array_shift ( $a ) ;
 557+ foreach ( $a as $x ) {
 558+ $b = spliti ( "</pre>" , $x , 2 ) ;
 559+ if ( count ( $b ) == 1 ) $s .= "&lt;pre&gt;$x" ;
 560+ else {
 561+ $x = htmlentities ( $b[0] ) ;
 562+ $s .= "<pre>$x</pre>$b[1]" ;
 563+ }
 564+ }
 565+ $s = str_replace ( "<pre>" , "<pre><nowiki>" , $s ) ;
 566+ $s = str_replace ( "</pre>" , "</nowiki></pre>" , $s ) ;
566567
567 - $a = spliti ( "<nowiki>" , $s ) ;
 568+ $a = spliti ( "<nowiki>" , $s ) ;
568569
569 - # $d needs to contain a unique string - this can be altered at will, as long it stays unique!
570 - $d = "3iyZiyA7iMwg5rhxP0Dcc9oTnj8qD1jm1Sfv" ; #$d = "~~~~~~~~~~~~~~" ;
 570+ # $d needs to contain a unique string - this can be altered at will, as long it stays unique!
 571+ $d = "3iyZiyA7iMwg5rhxP0Dcc9oTnj8qD1jm1Sfv" ; #$d = "~~~~~~~~~~~~~~" ;
571572
572 - $b = array () ;
573 - $s = array_shift ( $a ) ;
574 - foreach ( $a as $x ) {
575 - $c = spliti ( "</nowiki>" , $x , 2 ) ;
576 - if ( count ( $c ) == 2 ) {
577 - array_push ( $b , $c[0] ) ;
578 - $s .= $d.$c[1] ;
579 - } else $s .= "<nowiki>".$x ;
580 - }
 573+ $b = array () ;
 574+ $s = array_shift ( $a ) ;
 575+ foreach ( $a as $x ) {
 576+ $c = spliti ( "</nowiki>" , $x , 2 ) ;
 577+ if ( count ( $c ) == 2 ) {
 578+ array_push ( $b , $c[0] ) ;
 579+ $s .= $d.$c[1] ;
 580+ } else $s .= "<nowiki>".$x ;
 581+ }
581582
582 - # If called from setEntry(), only parse internal links and return dummy entry
583 - if ( $savingMode ) {
584 - $this->scanForParams ( $s ) ;
585 - return $this->replaceInternalLinks ( $s ) ;
586 - }
 583+ # If called from setEntry(), only parse internal links and return dummy entry
 584+ if ( $savingMode ) {
 585+ $this->scanForParams ( $s ) ;
 586+ return $this->replaceInternalLinks ( $s ) ;
 587+ }
587588
588 - $k = explode ( "." , $s , 2 ) ;
589 - $k = explode ( "\n" , $k[0] , 2 ) ;
590 - $s = $this->subParseContents ( $s , $savingMode ) ;
 589+ $k = explode ( "." , $s , 2 ) ;
 590+ $k = explode ( "\n" , $k[0] , 2 ) ;
 591+ $s = $this->subParseContents ( $s , $savingMode ) ;
591592
592 - # Meta tags
593 - global $metaDescription , $metaKeywords , $wikiMetaDescription ;
594 - if ( $metaDescription == "" and $metaKeywords == "" ) {
595 - $k = str_replace ( "\"" , "" , $k[0] ) ;
596 - $k = str_replace ( "[" , "" , $k ) ;
597 - $k = str_replace ( "]" , "" , $k ) ;
598 - $k = str_replace ( "'" , "" , $k ) ;
599 - $k = ereg_replace ( "<[^>]*>" , "" , $k ) ;
600 - $metaDescription = str_replace ( "$1" , $k , $wikiMetaDescription ) ;
 593+ # Meta tags
 594+ global $metaDescription , $metaKeywords , $wikiMetaDescription ;
 595+ if ( $metaDescription == "" and $metaKeywords == "" ) {
 596+ $k = str_replace ( "\"" , "" , $k[0] ) ;
 597+ $k = str_replace ( "[" , "" , $k ) ;
 598+ $k = str_replace ( "]" , "" , $k ) ;
 599+ $k = str_replace ( "'" , "" , $k ) ;
 600+ $k = ereg_replace ( "<[^>]*>" , "" , $k ) ;
 601+ $metaDescription = str_replace ( "$1" , $k , $wikiMetaDescription ) ;
601602
602 - $k = array () ;
603 - array_push ( $k , "wikipedia" ) ;
604 - array_push ( $k , $this->title ) ;
605 - foreach ( $this->knownLinkedLinks as $x ) array_push ( $k , $x ) ;
606 - foreach ( $this->knownUnlinkedLinks as $x ) array_push ( $k , $x ) ;
607 - $k = implode ( "," , $k ) ;
608 - $k = str_replace ( "\"" , "" , $k ) ;
609 - $k = str_replace ( "_" , " " , $k ) ;
610 - $metaKeywords = $k ;
611 - }
 603+ $k = array () ;
 604+ array_push ( $k , "wikipedia" ) ;
 605+ array_push ( $k , $this->title ) ;
 606+ foreach ( $this->knownLinkedLinks as $x ) array_push ( $k , $x ) ;
 607+ foreach ( $this->knownUnlinkedLinks as $x ) array_push ( $k , $x ) ;
 608+ $k = implode ( "," , $k ) ;
 609+ $k = str_replace ( "\"" , "" , $k ) ;
 610+ $k = str_replace ( "_" , " " , $k ) ;
 611+ $metaKeywords = $k ;
 612+ }
612613
613 - # replacing $d with the actual nowiki contents
614 - $a = spliti ( $d , $s ) ;
615 - $s = array_shift ( $a ) ;
616 - foreach ( $a as $x ) {
617 - $nw = array_shift ( $b ) ;
618 - $s .= $nw . $x ;
619 - }
 614+ # replacing $d with the actual nowiki contents
 615+ $a = spliti ( $d , $s ) ;
 616+ $s = array_shift ( $a ) ;
 617+ foreach ( $a as $x ) {
 618+ $nw = array_shift ( $b ) ;
 619+ $s .= $nw . $x ;
 620+ }
620621
621 - return $s ;
622 - }
 622+ return $s ;
 623+ }
623624
624 - # This function removes "forbidden" HTML tags
625 - function removeHTMLtags ( $s ) {
626 - # Only allow known tags
627 - $htmlpairs = array( "b", "i", "u", "font", "big", "small", "sub", "sup", "h1", "h2", "h3", "h4", "h5", "h6",
628 - "cite", "code", "em", "s", "strike", "strong", "tt", "var", "div", "center", "blockquote", "ol",
629 - "ul", "dl", "table", "caption", "pre" );
630 - $htmlsingle = array( "br", "p", "hr", "li", "dt", "dd", "tr", "td", "th" );
631 - # Every single tag can also have a closing tag
632 - $htmlpairs = array_merge($htmlpairs, $htmlsingle);
 625+ # This function removes "forbidden" HTML tags
 626+ function removeHTMLtags ( $s ) {
 627+ # Only allow known tags
 628+ $htmlpairs = array( "b", "i", "u", "font", "big", "small", "sub", "sup", "h1", "h2", "h3", "h4", "h5", "h6",
 629+ "cite", "code", "em", "s", "strike", "strong", "tt", "var", "div", "center", "blockquote", "ol",
 630+ "ul", "dl", "table", "caption", "pre" );
 631+ $htmlsingle = array( "br", "p", "hr", "li", "dt", "dd", "tr", "td", "th" );
 632+ # Every single tag can also have a closing tag
 633+ $htmlpairs = array_merge($htmlpairs, $htmlsingle);
633634
634 - # FIXME Allowed elements -- we don't want scripting, etc
635 - #$htmlelements = array( "face", "color", "size", "border", "align", "valign", "alt" );
 635+ # FIXME Allowed elements -- we don't want scripting, etc
 636+ #$htmlelements = array( "face", "color", "size", "border", "align", "valign", "alt" );
636637
637 - # Unique placeholders for < and > so we don't interfere with &lt; and &gt;
638 - $lt = "t4hqKoeC0p2Os4nfUa"; $gt = "v06TEbpdpceupNHi13";
 638+ # Unique placeholders for < and > so we don't interfere with &lt; and &gt;
 639+ $lt = "t4hqKoeC0p2Os4nfUa"; $gt = "v06TEbpdpceupNHi13";
639640
640 - # Mark allowed tags
641 - foreach ($htmlpairs as $x) {
642 - $s = preg_replace("/<$x(\s[^<>]+?)?>(.*?)<\/$x>/is", "$lt$x$1$gt$2$lt/$x$gt", $s);
643 - }
644 - foreach ($htmlsingle as $x) {
645 - $s = preg_replace("/<$x(\s[^<>]+?)?>/i", "$lt$x$1$gt", $s);
646 - }
 641+ # Mark allowed tags
 642+ foreach ($htmlpairs as $x) {
 643+ $s = preg_replace("/<$x(\s[^<>]+?)?>(.*?)<\/$x>/is", "$lt$x$1$gt$2$lt/$x$gt", $s);
 644+ }
 645+ foreach ($htmlsingle as $x) {
 646+ $s = preg_replace("/<$x(\s[^<>]+?)?>/i", "$lt$x$1$gt", $s);
 647+ }
647648
648 - # Kill any other tags, and convert good ones back to correct form
649 - $s = str_replace(array("<", ">"), array("&lt;", "&gt;"), $s);
650 - $s = str_replace(array("$lt", "$gt"), array("<", ">"), $s);
651 - return $s ;
652 - }
 649+ # Kill any other tags, and convert good ones back to correct form
 650+ $s = str_replace(array("<", ">"), array("&lt;", "&gt;"), $s);
 651+ $s = str_replace(array("$lt", "$gt"), array("<", ">"), $s);
 652+ return $s ;
 653+ }
653654
654 - # This function will auto-number headings
655 - function autoNumberHeadings ( $s ) {
656 - if ( $this->isSpecialPage ) return $s ;
657 - $j = 0 ;
658 - $n = -1 ;
659 - for ( $i ; $i < 9 ; $i++ ) {
660 - if ( stristr ( $s , "<h$i>" ) != false ) {
661 - $j++ ;
662 - if ( $n == -1 ) $n = $i ;
663 - }
664 - }
665 - if ( $j < 2 ) return $s ;
666 - $i = $n ;
667 - $v = array ( 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ) ;
668 - $t = "" ;
669 - while ( count ( spliti ( "<h" , $s , 2 ) ) == 2 ) {
670 - $a = spliti ( "<h" , $s , 2 ) ;
671 - $j = substr ( $a[1] , 0 , 1 ) ;
672 - if ( strtolower ( $j ) != "r" ) {
673 - $t .= $a[0]."<h".$j.">" ;
674 - $v[$j]++ ;
675 - $b = array () ;
676 - for ( $k = $i ; $k <= $j ; $k++ ) array_push ( $b , $v[$k] ) ;
677 - for ( $k = $j+1 ; $k < 9 ; $k++ ) $v[$k] = 0 ;
678 - $t .= implode ( "." , $b ) . " " ;
679 - $s = substr ( $a[1] , 2 ) ;
680 - } else { # <HR> tag, not a heading!
681 - $t .= $a[0]."<hr>" ;
682 - $s = substr ( $a[1] , 2 ) ;
683 - }
684 - }
685 - return $t.$s ;
686 - }
 655+ # This function will auto-number headings
 656+ function autoNumberHeadings ( $s ) {
 657+ if ( $this->isSpecialPage ) return $s ;
 658+ $j = 0 ;
 659+ $n = -1 ;
 660+ for ( $i ; $i < 9 ; $i++ ) {
 661+ if ( stristr ( $s , "<h$i>" ) != false ) {
 662+ $j++ ;
 663+ if ( $n == -1 ) $n = $i ;
 664+ }
 665+ }
 666+ if ( $j < 2 ) return $s ;
 667+ $i = $n ;
 668+ $v = array ( 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ) ;
 669+ $t = "" ;
 670+ while ( count ( spliti ( "<h" , $s , 2 ) ) == 2 ) {
 671+ $a = spliti ( "<h" , $s , 2 ) ;
 672+ $j = substr ( $a[1] , 0 , 1 ) ;
 673+ if ( strtolower ( $j ) != "r" ) {
 674+ $t .= $a[0]."<h".$j.">" ;
 675+ $v[$j]++ ;
 676+ $b = array () ;
 677+ for ( $k = $i ; $k <= $j ; $k++ ) array_push ( $b , $v[$k] ) ;
 678+ for ( $k = $j+1 ; $k < 9 ; $k++ ) $v[$k] = 0 ;
 679+ $t .= implode ( "." , $b ) . " " ;
 680+ $s = substr ( $a[1] , 2 ) ;
 681+ } else { # <HR> tag, not a heading!
 682+ $t .= $a[0]."<hr>" ;
 683+ $s = substr ( $a[1] , 2 ) ;
 684+ }
 685+ }
 686+ return $t.$s ;
 687+ }
687688
688 - function ISBN ( $s ) {
689 - $a = split ( "ISBN " , " $s" ) ;
690 - $s = substr ( array_shift ( $a ) , 1 ) ;
691 - $valid = "0123456789-" ;
692 - foreach ( $a as $x ) {
693 - $isbn = "" ;
694 - $blank = "" ;
695 - while ( substr ( $x , 0 , 1 ) == " " ) {
696 - $blank .= " " ;
697 - $x = substr ( $x , 1 ) ;
698 - }
699 - while ( strstr ( $valid , substr ( $x , 0 , 1 ) ) != false ) {
700 - $isbn .= substr ( $x , 0 , 1 ) ;
701 - $x = substr ( $x , 1 ) ;
702 - }
703 - $num = str_replace ( "-" , "" , $isbn ) ;
704 - $num = str_replace ( " " , "" , $num ) ;
705 - if ( $num == "" ) {
706 - $s .= "ISBN $blank$x" ;
707 - } else { # Removed BarnesAndNoble and Amazon, left link to PriceScan
708 - $s .= "<a href=\"http://www.pricescan.com/books/bookDetail.asp?isbn=$num\">ISBN $isbn</a> " ;
709 -# $s .= "<a href=\"http://shop.barnesandnoble.com/bookSearch/isbnInquiry.asp?isbn=$num\">ISBN $isbn</a> " ;
710 -# $s .= "(<a href=\"http://www.amazon.com/exec/obidos/ISBN=$num\">Amazon</a>, " ;
711 -# $s .= "<a href=\"http://www.pricescan.com/books/bookDetail.asp?isbn=$num\">Pricescan</a>)" ;
712 - $s .= $x ;
713 - }
714 - }
715 - return $s ;
716 - }
 689+ function ISBN ( $s ) {
 690+ $a = split ( "ISBN " , " $s" ) ;
 691+ $s = substr ( array_shift ( $a ) , 1 ) ;
 692+ $valid = "0123456789-" ;
 693+ foreach ( $a as $x ) {
 694+ $isbn = "" ;
 695+ $blank = "" ;
 696+ while ( substr ( $x , 0 , 1 ) == " " ) {
 697+ $blank .= " " ;
 698+ $x = substr ( $x , 1 ) ;
 699+ }
 700+ while ( strstr ( $valid , substr ( $x , 0 , 1 ) ) != false ) {
 701+ $isbn .= substr ( $x , 0 , 1 ) ;
 702+ $x = substr ( $x , 1 ) ;
 703+ }
 704+ $num = str_replace ( "-" , "" , $isbn ) ;
 705+ $num = str_replace ( " " , "" , $num ) ;
 706+ if ( $num == "" ) {
 707+ $s .= "ISBN $blank$x" ;
 708+ } else { # Removed BarnesAndNoble and Amazon, left link to PriceScan
 709+ $s .= "<a href=\"http://www.pricescan.com/books/bookDetail.asp?isbn=$num\">ISBN $isbn</a> " ;
 710+# $s .= "<a href=\"http://shop.barnesandnoble.com/bookSearch/isbnInquiry.asp?isbn=$num\">ISBN $isbn</a> " ;
 711+# $s .= "(<a href=\"http://www.amazon.com/exec/obidos/ISBN=$num\">Amazon</a>, " ;
 712+# $s .= "<a href=\"http://www.pricescan.com/books/bookDetail.asp?isbn=$num\">Pricescan</a>)" ;
 713+ $s .= $x ;
 714+ }
 715+ }
 716+ return $s ;
 717+ }
717718
718 - # This function does the actual parsing of the wiki parts of the article, for regions NOT marked with <nowiki>
719 - function subParseContents ( $s ) {
720 - global $user ;
 719+ # This function does the actual parsing of the wiki parts of the article, for regions NOT marked with <nowiki>
 720+ function subParseContents ( $s ) {
 721+ global $user ;
721722 # Removed automatic links for CamelCase; wasn't working, anyway...
722 -# $s = ereg_replace ( "([\.|\n| )([a-z0-9]*[A-Z0-9]+[A-Za-z0-9]*)( |\n|\.)" , "\\1[[\\2]]\\3" , $s ) ;
723 - if ( ! $this->isSpecialPage )
724 - $s = $this->removeHTMLtags ( $s ) ; # Removing "forbidden" HTML tags
725 - #$s = ereg_replace ( "&amp;([a-zA-Z0-9#]+);" , "&\\1;" , $s ) ; # That's a long story... FIXME: What is this for? It mostly seems to make it very hard to write the code for an entity instead of the entity itself.
 723+# $s = ereg_replace ( "([\.|\n| )([a-z0-9]*[A-Z0-9]+[A-Za-z0-9]*)( |\n|\.)" , "\\1[[\\2]]\\3" , $s ) ;
 724+ if ( ! $this->isSpecialPage )
 725+ $s = $this->removeHTMLtags ( $s ) ; # Removing "forbidden" HTML tags
 726+ #$s = ereg_replace ( "&amp;([a-zA-Z0-9#]+);" , "&\\1;" , $s ) ; # That's a long story... FIXME: What is this for? It mostly seems to make it very hard to write the code for an entity instead of the entity itself.
726727
727 - # Now some repalcements wiki->HTML
728 - $s = ereg_replace ( "(^|\n)-----*" , "\\1<hr>" , $s ) ;
729 - $s = str_replace ( "<HR>" , "<hr>" , $s ) ;
730 - $s = $this->replaceVariables ( $s ) ;
731 - $s = $this->pingPongReplace ( "'''''" , "<i><b>" , "</b></i>" , $s ) ;
732 - $s = $this->pingPongReplace ( "'''" , "<b>" , "</b>" , $s ) ;
733 - $s = $this->pingPongReplace ( "''" , "<i>" , "</i>" , $s ) ;
 728+ # Now some repalcements wiki->HTML
 729+ $s = ereg_replace ( "(^|\n)-----*" , "\\1<hr>" , $s ) ;
 730+ $s = str_replace ( "<HR>" , "<hr>" , $s ) ;
 731+ $s = $this->replaceVariables ( $s ) ;
 732+ $s = $this->pingPongReplace ( "'''''" , "<i><b>" , "</b></i>" , $s ) ;
 733+ $s = $this->pingPongReplace ( "'''" , "<b>" , "</b>" , $s ) ;
 734+ $s = $this->pingPongReplace ( "''" , "<i>" , "</i>" , $s ) ;
734735
735 - $s = preg_replace ( "/(^|\\n)==== ([^\\n]*) ====\s*(\\r|$)/" , "\\1<h4>\\2</h4>\\3" , $s ) ;
736 - $s = preg_replace ( "/(^|\\n)=== ([^\\n]*) ===\s*(\\r|$)/" , "\\1<h3>\\2</h3>\\3" , $s ) ;
737 - $s = preg_replace ( "/(^|\\n)== ([^\\n]*) ==\s*(\\r|$)/" , "\\1<h2>\\2</h2>\\3" , $s ) ;
738 - $s = preg_replace ( "/(^|\\n)= ([^\\n]*) =\s*(\\r|$)/" , "\\1<h1>\\2</h1>\\3" , $s ) ;
 736+ $s = preg_replace ( "/(^|\\n)==== ([^\\n]*) ====\s*(\\r|$)/" , "\\1<h4>\\2</h4>\\3" , $s ) ;
 737+ $s = preg_replace ( "/(^|\\n)=== ([^\\n]*) ===\s*(\\r|$)/" , "\\1<h3>\\2</h3>\\3" , $s ) ;
 738+ $s = preg_replace ( "/(^|\\n)== ([^\\n]*) ==\s*(\\r|$)/" , "\\1<h2>\\2</h2>\\3" , $s ) ;
 739+ $s = preg_replace ( "/(^|\\n)= ([^\\n]*) =\s*(\\r|$)/" , "\\1<h1>\\2</h1>\\3" , $s ) ;
739740
740 - $s = ereg_replace ( "\n====*" , "<hr>" , $s ) ;
 741+ $s = ereg_replace ( "\n====*" , "<hr>" , $s ) ;
741742
742 - # Automatic links to subpages (e.g., /Talk -> [[/Talk]] #DEACTIVATED
743 -# $s = ereg_replace ( "([\n ])/([a-zA-Z0-9]+)" , "\\1[[/\\2|/\\2]]" , $s ) ;
 743+ # Automatic links to subpages (e.g., /Talk -> [[/Talk]] #DEACTIVATED
 744+# $s = ereg_replace ( "([\n ])/([a-zA-Z0-9]+)" , "\\1[[/\\2|/\\2]]" , $s ) ;
744745
745 - # Parsing through the text line by line
746 - # The main thing happening here is handling of lines starting with * # : etc.
747 - $justify = " class=\"bodytext\"" ; # Justification is handled in the style sheet
748 - #if ( $user->options["justify"] == "yes" ) $justify = " align=justify" ;
749 - $a = explode ( "\n" , $s ) ;
750 - $s = "<p$justify>" ;
751 - $obegin = "" ;
752 - foreach ( $a as $t ) {
753 - $pre = "" ;
754 - $post = "" ;
755 - $ppre = "" ;
756 - $ppost = "" ;
757 - if ( trim ( $t ) == "" ) $post .= "</p><p$justify>" ;
 746+ # Parsing through the text line by line
 747+ # The main thing happening here is handling of lines starting with * # : etc.
 748+ $justify = " class=\"bodytext\"" ; # Justification is handled in the style sheet
 749+ #if ( $user->options["justify"] == "yes" ) $justify = " align=justify" ;
 750+ $a = explode ( "\n" , $s ) ;
 751+ $s = "<p$justify>" ;
 752+ $obegin = "" ;
 753+ foreach ( $a as $t ) {
 754+ $pre = "" ;
 755+ $post = "" ;
 756+ $ppre = "" ;
 757+ $ppost = "" ;
 758+ if ( trim ( $t ) == "" ) $post .= "</p><p$justify>" ;
758759
759 - if ( substr($t,0,1) == " " ) { $ppre = "<pre>\n " ; $ppost = "</pre>".$ppost ; $t = substr ( $t , 1 ) ; }
760 - if ( substr($t,0,1) == "*" ) { $ppre .= "<li>" ; $ppost .= "</li>" ; }
761 - if ( substr($t,0,1) == "#" ) { $ppre .= "<li>" ; $ppost .= "</li>" ; }
762 - if ( substr($t,0,1) == ":" ) { $ppre .= "<dt><dd>" ; }
763 - if ( substr($t,0,1) == ";" ) {
764 - $ppre = "<DL>\n<dt> " ;
765 - $t = str_replace ( ":" , "<dd>" , $t ) ;
766 - $ppost = "</DL>".$ppost ;
767 - $t = substr ( $t , 1 ) ;
768 - }
 760+ if ( substr($t,0,1) == " " ) { $ppre = "<pre>\n " ; $ppost = "</pre>".$ppost ; $t = substr ( $t , 1 ) ; }
 761+ if ( substr($t,0,1) == "*" ) { $ppre .= "<li>" ; $ppost .= "</li>" ; }
 762+ if ( substr($t,0,1) == "#" ) { $ppre .= "<li>" ; $ppost .= "</li>" ; }
 763+ if ( substr($t,0,1) == ":" ) { $ppre .= "<dt><dd>" ; }
 764+ if ( substr($t,0,1) == ";" ) {
 765+ $ppre = "<DL>\n<dt> " ;
 766+ $t = str_replace ( ":" , "<dd>" , $t ) ;
 767+ $ppost = "</DL>".$ppost ;
 768+ $t = substr ( $t , 1 ) ;
 769+ }
769770
770 - $nbegin = "" ;
771 - while ( $t != "" and $obegin != "" and substr($obegin,0,1)==substr($t,0,1) ) {
772 - $nbegin .= substr($obegin,0,1) ;
773 - $t = substr ( $t , 1 ) ;
774 - $obegin = substr ( $obegin , 1 ) ;
775 - }
776 -
777 - $obegin = str_replace ( "*" , "</ul>" , $obegin ) ;
778 - $obegin = str_replace ( "#" , "</ol>" , $obegin ) ;
779 - $obegin = str_replace ( ":" , "</DL>" , $obegin ) ;
780 - $pre .= $obegin ;
781 - $obegin = $nbegin ;
 771+ $nbegin = "" ;
 772+ while ( $t != "" and $obegin != "" and substr($obegin,0,1)==substr($t,0,1) ) {
 773+ $nbegin .= substr($obegin,0,1) ;
 774+ $t = substr ( $t , 1 ) ;
 775+ $obegin = substr ( $obegin , 1 ) ;
 776+ }
 777+
 778+ $obegin = str_replace ( "*" , "</ul>" , $obegin ) ;
 779+ $obegin = str_replace ( "#" , "</ol>" , $obegin ) ;
 780+ $obegin = str_replace ( ":" , "</DL>" , $obegin ) ;
 781+ $pre .= $obegin ;
 782+ $obegin = $nbegin ;
782783
783 - while ( substr ( $t , 0 , 1 ) == "*" ) {
784 - $pre .= "<ul>" ;
785 - $t = substr ( $t , 1 ) ;
786 - $obegin .= "*" ;
787 - }
 784+ while ( substr ( $t , 0 , 1 ) == "*" ) {
 785+ $pre .= "<ul>" ;
 786+ $t = substr ( $t , 1 ) ;
 787+ $obegin .= "*" ;
 788+ }
788789
789 - while ( substr ( $t , 0 , 1 ) == "#" ) {
790 - $pre .= "<ol>" ;
791 - $t = substr ( $t , 1 ) ;
792 - $obegin .= "#" ;
793 - }
 790+ while ( substr ( $t , 0 , 1 ) == "#" ) {
 791+ $pre .= "<ol>" ;
 792+ $t = substr ( $t , 1 ) ;
 793+ $obegin .= "#" ;
 794+ }
794795
795 - while ( substr ( $t , 0 , 1 ) == ":" ) {
796 - $pre .= "<DL>" ;
797 - $t = substr ( $t , 1 ) ;
798 - $obegin .= ":" ;
799 - }
 796+ while ( substr ( $t , 0 , 1 ) == ":" ) {
 797+ $pre .= "<DL>" ;
 798+ $t = substr ( $t , 1 ) ;
 799+ $obegin .= ":" ;
 800+ }
800801
801 - $t = str_replace ( " " , "&nbsp; " , $t ) ;
 802+ $t = str_replace ( " " , "&nbsp; " , $t ) ;
802803
803 - $t = $pre.$ppre.$t.$ppost.$post ;
804 - $s .= $t."\n" ;
805 - }
806 - $s .= "</p>" ;
 804+ $t = $pre.$ppre.$t.$ppost.$post ;
 805+ $s .= $t."\n" ;
 806+ }
 807+ $s .= "</p>" ;
807808
808 - $s = str_replace ( "</li>\n&nbsp;<li>" , "</li>\n<li>" , $s ) ;
809 - $s = str_replace ( "</pre>\n<pre>" , "" , $s ) ;
810 - $s = str_replace ( "</dl>\n<dl>" , "" , $s ) ;
 809+ $s = str_replace ( "</li>\n&nbsp;<li>" , "</li>\n<li>" , $s ) ;
 810+ $s = str_replace ( "</pre>\n<pre>" , "" , $s ) ;
 811+ $s = str_replace ( "</dl>\n<dl>" , "" , $s ) ;
811812
812 - # Removing artefact empty paragraphs like <p></p>
813 - $this->replaceAll ( "<p$justify>\n</p>" , "<p$justify></p>" , $s ) ;
814 - $this->replaceAll ( "<p$justify></p>" , "" , $s ) ;
815 - $this->replaceAll ( "</p><p$justify>" , "<p$justify>" , $s ) ;
 813+ # Removing artefact empty paragraphs like <p></p>
 814+ $this->replaceAll ( "<p$justify>\n</p>" , "<p$justify></p>" , $s ) ;
 815+ $this->replaceAll ( "<p$justify></p>" , "" , $s ) ;
 816+ $this->replaceAll ( "</p><p$justify>" , "<p$justify>" , $s ) ;
816817
817 - # Stuff for the skins
818 - if ( $user->options["textTableBackground"] != "" ) {
819 - $s = str_replace ( "<table" , "<table".$user->options["textTableBackground"] , $s ) ;
820 - }
 818+ # Stuff for the skins
 819+ if ( $user->options["textTableBackground"] != "" ) {
 820+ $s = str_replace ( "<table" , "<table".$user->options["textTableBackground"] , $s ) ;
 821+ }
821822
822 - # And now, for the final...
823 - $s = $this->parseImages ( $s ) ;
824 - $s = $this->replaceExternalLinks ( $s ) ;
825 - $s = $this->replaceInternalLinks ( $s ) ;
826 - $s = $this->ISBN ( $s ) ;
827 - if ( $user->options["numberHeadings"] == "yes" ) $s = $this->autoNumberHeadings ( $s ) ;
828 - return $s ;
829 - }
 823+ # And now, for the final...
 824+ $s = $this->parseImages ( $s ) ;
 825+ $s = $this->replaceExternalLinks ( $s ) ;
 826+ $s = $this->replaceInternalLinks ( $s ) ;
 827+ $s = $this->ISBN ( $s ) ;
 828+ if ( $user->options["numberHeadings"] == "yes" ) $s = $this->autoNumberHeadings ( $s ) ;
 829+ return $s ;
 830+ }
830831
831832 #### Header and footer section
832833
833 - # This generates the bar at the top and bottom of each page
834 - # Used by getHeader() and getFooter()
835 - function getLinkBar () {
836 - global $wikiMainPage ;
837 - global $user , $oldID , $version ;
838 - $editOldVersion = "" ;
839 - if ( $oldID != "" ) $editOldVersion="&oldID=$oldID&version=$version" ;
840 - $ret = "<a href=\"".wikiLink($wikiMainPage)."\">$wikiMainPage</a>" ;
 834+ # This generates the bar at the top and bottom of each page
 835+ # Used by getHeader() and getFooter()
 836+ function getLinkBar () {
 837+ global $wikiMainPage ;
 838+ global $user , $oldID , $version ;
 839+ $editOldVersion = "" ;
 840+ if ( $oldID != "" ) $editOldVersion="&oldID=$oldID&version=$version" ;
 841+ $ret = "<a href=\"".wikiLink($wikiMainPage)."\">$wikiMainPage</a>" ;
841842
842 - $spl = $this->getSubpageList () ;
843 - if ( count ( $spl ) > 0 and $this->subpageTitle != "" and $user->options["showStructure"] == "yes" ) {
844 - $zz = trim ( $this->parseContents ( $spl[0] ) ) ;
845 - $zz = strstr ( $zz , "<a" ) ;
846 - $zz = str_replace ( "</p>" , "" , $zz ) ;
847 - $zz = $this->getNiceTitle ( $zz ) ;
848 - $ret .= " | ".$zz ;
849 - }
 843+ $spl = $this->getSubpageList () ;
 844+ if ( count ( $spl ) > 0 and $this->subpageTitle != "" and $user->options["showStructure"] == "yes" ) {
 845+ $zz = trim ( $this->parseContents ( $spl[0] ) ) ;
 846+ $zz = strstr ( $zz , "<a" ) ;
 847+ $zz = str_replace ( "</p>" , "" , $zz ) ;
 848+ $zz = $this->getNiceTitle ( $zz ) ;
 849+ $ret .= " | ".$zz ;
 850+ }
850851
851 - global $wikiRecentChanges , $wikiRecentChangesLink , $wikiEditThisPage , $wikiHistory , $wikiRandomPage , $wikiSpecialPages ;
852 - global $wikiSpecialPagesLink ;
853 - $ret .= " | <a href=\"".wikiLink("special:$wikiRecentChangesLink")."\">$wikiRecentChanges</a>" ;
854 - if ( $this->canEdit() ) $ret .= " | <a href=\"".wikiLink(urldecode($this->url)."$editOldVersion&action=edit")."\">$wikiEditThisPage</a>" ;
855 - else if ( !$this->isSpecialPage ) $ret .= " | Protected page" ;
856 - if ( !$this->isSpecialPage ) $ret .= " | <a href=\"".wikiLink(urldecode($this->url)."&action=history")."\">$wikiHistory</a>\n" ;
857 - $ret .= " | <a href=\"".wikiLink("special:RandomPage")."\">$wikiRandomPage</a>" ;
858 - $ret .= " | <a href=\"".wikiLink("special:$wikiSpecialPagesLink")."\">$wikiSpecialPages</a>" ;
859 - return $ret ;
860 - }
 852+ global $wikiRecentChanges , $wikiRecentChangesLink , $wikiEditThisPage , $wikiHistory , $wikiRandomPage , $wikiSpecialPages ;
 853+ global $wikiSpecialPagesLink ;
 854+ $ret .= " | <a href=\"".wikiLink("special:$wikiRecentChangesLink")."\">$wikiRecentChanges</a>" ;
 855+ if ( $this->canEdit() ) $ret .= " | <a href=\"".wikiLink(urldecode($this->url)."$editOldVersion&action=edit")."\">$wikiEditThisPage</a>" ;
 856+ else if ( !$this->isSpecialPage ) $ret .= " | Protected page" ;
 857+ if ( !$this->isSpecialPage ) $ret .= " | <a href=\"".wikiLink(urldecode($this->url)."&action=history")."\">$wikiHistory</a>\n" ;
 858+ $ret .= " | <a href=\"".wikiLink("special:RandomPage")."\">$wikiRandomPage</a>" ;
 859+ $ret .= " | <a href=\"".wikiLink("special:$wikiSpecialPagesLink")."\">$wikiSpecialPages</a>" ;
 860+ return $ret ;
 861+ }
861862
862 - # This generates the header with title, user name and functions, wikipedia logo, search box etc.
863 - function getHeader () {
864 - global $wikiMainPageTitle , $wikiArticleSubtitle , $wikiPrintable , $wikiWatch , $wikiMainPage ;
865 - global $user , $action , $wikiNoWatch , $wikiLogIn , $wikiLogOut , $wikiSearch ;
866 - global $wikiHelp , $wikiHelpLink , $wikiPreferences , $wikiLanguageNames , $wikiWhatLinksHere ;
867 - global $wikiCharset , $wikiEncodingCharsets , $wikiEncodingNames , $wikiLogoFile , $wikiEditHelp ;
868 - global $framed ; if ( isset ( $framed ) and $framed != "top" ) return "" ;
869 - $t = $this->getNiceTitle ( $this->title ) ;
870 - if ( substr_count ( $t , ":" ) > 0 ) $t = ucfirst ( $t ) ;
871 - $ret = "<table ".$user->options["quickBarBackground"]. "width=\"100%\" class=\"topbar\" cellspacing=0>\n<tr>" ;
872 - if ( $user->options["leftImage"] != "" )
873 - $ret .= "<td width=\"1%\" rowspan=2 bgcolor=\"#000000\"><img src=\"".$user->options["leftImage"]."\"></td>" ;
874 - $ret .= "<td valign=top height=1>" ;
875 - if ( $this->isSpecialPage ) {
876 - $ret .= "<font size=\"+3\">".$t."</font>" ;
877 - if ( $action == "" ) {
878 - $ret .= "<br>\n<br>\n<a href=\"".wikiLink("special:whatlinkshere&target=$this->url")."\">$wikiWhatLinksHere</a>" ;
879 - $ret .= " | <a href=\"".wikiLink("wikipedia:How does one edit a page")."\">$wikiEditHelp</a>" ;
880 - }
881 - } else {
882 - $ret .= "<font size=\"+3\"><b><u>" ;
883 - if ( $this->secureTitle == $wikiMainPage and $action == "view" ) $ret .= $wikiMainPageTitle.$this->thisVersion ;
884 - else $ret .= $this->getNiceTitle($t).$this->thisVersion ;
885 -# if ( $this->secureTitle == "Main_Page" and $action == "view" ) $ret .= "<font color=blue>$wikiMainPageTitle</font>$this->thisVersion" ;
886 -# else $ret .= "<a href=\"".wikiLink("&search=$this->title")."\">".$this->getNiceTitle($t)."</a>$this->thisVersion" ;
887 - $ret .= "</u></b></font>" ;
888 - $subText = array () ;
889 - if ( $action == "view" and !$this->isSpecialPage ) $ret .= "<br>$wikiArticleSubtitle\n" ;
890 - if ( $user->isLoggedIn ) {
891 - if ( $user->doWatch($this->title) )
892 - array_push($subText,"<a href=\"".wikiLink("$this->url&action=watch&mode=no")."\">$wikiNoWatch</a>");
893 - else array_push($subText,"<a href=\"".wikiLink("$this->url&action=watch&mode=yes")."\">$wikiWatch</a>") ;
894 - }
895 - if ( $action == "view" and !$this->isSpecialPage ) array_push ( $subText , "<a href=\"".wikiLink("$this->url&action=print")."\">$wikiPrintable</a>" ) ;
896 - if ( $action == "view" and !$this->isSpecialPage ) array_push ( $subText , "<a href=\"".wikiLink("special:whatlinkshere&target=$this->url")."\">$wikiWhatLinksHere</a>" ) ;
897 - if ( $this->backLink != "" ) array_push ( $subText , $this->backLink ) ;
898 - if ( $this->namespace == "user" and $this->subpageTitle == "" )
899 - array_push ( $subText , "<a href=\"".wikiLink("special:contributions&theuser=$this->mainTitle")."\">This user's contributions</a>");
900 - $ret .= "<br>".implode ( " | " , $subText ) ;
901 - if ( count ( $this->otherLanguages ) > 0 ) {
902 - global $wikiOtherLanguagesText ;
903 - $subText = array () ;
904 - $olk = array_keys ( $this->otherLanguages ) ;
905 - foreach ( $olk as $x )
906 - array_push ( $subText , "<a href=\"".$this->otherLanguages[$x]."\">".$wikiLanguageNames[$x]."</a>" ) ;
907 - $subText = implode ( ", " , $subText ) ;
908 - $ret .= "<br>".str_replace ( "$1" , $subText , $wikiOtherLanguagesText ) ;
909 - }
910 - }
911 - $ret .= "</td>\n<td valign=top width=200 rowspan=2 nowrap>".$user->getLink()."<br>" ;
912 - if ( $user->isLoggedIn ) $ret .= "<a href=\"".wikiLink("special:userLogout")."\">$wikiLogOut</a> | <a href=\"".wikiLink("special:editUserSettings")."\">$wikiPreferences</a>" ;
913 - else $ret .= "<a href=\"".wikiLink("special:userLogin")."\">$wikiLogIn</a>" ;
914 - $ret .= " | <a href=\"".wikiLink("wikipedia:$wikiHelpLink")."\">$wikiHelp</a><br>\n" ;
 863+ # This generates the header with title, user name and functions, wikipedia logo, search box etc.
 864+ function getHeader () {
 865+ global $wikiMainPageTitle , $wikiArticleSubtitle , $wikiPrintable , $wikiWatch , $wikiMainPage ;
 866+ global $user , $action , $wikiNoWatch , $wikiLogIn , $wikiLogOut , $wikiSearch ;
 867+ global $wikiHelp , $wikiHelpLink , $wikiPreferences , $wikiLanguageNames , $wikiWhatLinksHere ;
 868+ global $wikiCharset , $wikiEncodingCharsets , $wikiEncodingNames , $wikiLogoFile , $wikiEditHelp ;
 869+ global $framed ; if ( isset ( $framed ) and $framed != "top" ) return "" ;
 870+ $t = $this->getNiceTitle ( $this->title ) ;
 871+ if ( substr_count ( $t , ":" ) > 0 ) $t = ucfirst ( $t ) ;
 872+ $ret = "<table ".$user->options["quickBarBackground"]. "width=\"100%\" class=\"topbar\" cellspacing=0>\n<tr>" ;
 873+ if ( $user->options["leftImage"] != "" )
 874+ $ret .= "<td width=\"1%\" rowspan=2 bgcolor=\"#000000\"><img src=\"".$user->options["leftImage"]."\"></td>" ;
 875+ $ret .= "<td valign=top height=1>" ;
 876+ if ( $this->isSpecialPage ) {
 877+ $ret .= "<font size=\"+3\">".$t."</font>" ;
 878+ if ( $action == "" ) {
 879+ $ret .= "<br>\n<br>\n<a href=\"".wikiLink("special:whatlinkshere&target=$this->url")."\">$wikiWhatLinksHere</a>" ;
 880+ $ret .= " | <a href=\"".wikiLink("wikipedia:How does one edit a page")."\">$wikiEditHelp</a>" ;
 881+ }
 882+ } else {
 883+ $ret .= "<font size=\"+3\"><b><u>" ;
 884+ if ( $this->secureTitle == $wikiMainPage and $action == "view" ) $ret .= $wikiMainPageTitle.$this->thisVersion ;
 885+ else $ret .= $this->getNiceTitle($t).$this->thisVersion ;
 886+# if ( $this->secureTitle == "Main_Page" and $action == "view" ) $ret .= "<font color=blue>$wikiMainPageTitle</font>$this->thisVersion" ;
 887+# else $ret .= "<a href=\"".wikiLink("&search=$this->title")."\">".$this->getNiceTitle($t)."</a>$this->thisVersion" ;
 888+ $ret .= "</u></b></font>" ;
 889+ $subText = array () ;
 890+ if ( $action == "view" and !$this->isSpecialPage ) $ret .= "<br>$wikiArticleSubtitle\n" ;
 891+ if ( $user->isLoggedIn ) {
 892+ if ( $user->doWatch($this->title) )
 893+ array_push($subText,"<a href=\"".wikiLink("$this->url&action=watch&mode=no")."\">$wikiNoWatch</a>");
 894+ else array_push($subText,"<a href=\"".wikiLink("$this->url&action=watch&mode=yes")."\">$wikiWatch</a>") ;
 895+ }
 896+ if ( $action == "view" and !$this->isSpecialPage ) array_push ( $subText , "<a href=\"".wikiLink("$this->url&action=print")."\">$wikiPrintable</a>" ) ;
 897+ if ( $action == "view" and !$this->isSpecialPage ) array_push ( $subText , "<a href=\"".wikiLink("special:whatlinkshere&target=$this->url")."\">$wikiWhatLinksHere</a>" ) ;
 898+ if ( $this->backLink != "" ) array_push ( $subText , $this->backLink ) ;
 899+ if ( $this->namespace == "user" and $this->subpageTitle == "" )
 900+ array_push ( $subText , "<a href=\"".wikiLink("special:contributions&theuser=$this->mainTitle")."\">This user's contributions</a>");
 901+ $ret .= "<br>".implode ( " | " , $subText ) ;
 902+ if ( count ( $this->otherLanguages ) > 0 ) {
 903+ global $wikiOtherLanguagesText ;
 904+ $subText = array () ;
 905+ $olk = array_keys ( $this->otherLanguages ) ;
 906+ foreach ( $olk as $x )
 907+ array_push ( $subText , "<a href=\"".$this->otherLanguages[$x]."\">".$wikiLanguageNames[$x]."</a>" ) ;
 908+ $subText = implode ( ", " , $subText ) ;
 909+ $ret .= "<br>".str_replace ( "$1" , $subText , $wikiOtherLanguagesText ) ;
 910+ }
 911+ }
 912+ $ret .= "</td>\n<td valign=top width=200 rowspan=2 nowrap>".$user->getLink()."<br>" ;
 913+ if ( $user->isLoggedIn ) $ret .= "<a href=\"".wikiLink("special:userLogout")."\">$wikiLogOut</a> | <a href=\"".wikiLink("special:editUserSettings")."\">$wikiPreferences</a>" ;
 914+ else $ret .= "<a href=\"".wikiLink("special:userLogin")."\">$wikiLogIn</a>" ;
 915+ $ret .= " | <a href=\"".wikiLink("wikipedia:$wikiHelpLink")."\">$wikiHelp</a><br>\n" ;
915916
916 - # Text encoding
917 - if(count($wikiEncodingNames) > 1) { # Shortcut for switching character encodings
918 - global $THESCRIPT;
919 - $u = $THESCRIPT . "?" . getenv("QUERY_STRING");
920 - $u = preg_replace("/[\?\&]encoding=[0-9]+/", "", $u);
921 - $u .= (strchr($u, "?") ? "&" : "?");
922 - foreach ( $wikiEncodingNames as $i => $enc ) {
923 - if($i > 0) $ret .= " | ";
924 - if($i == $user->options["encoding"]) $ret .= "<b>";
925 - $ret .= "<a href=\"" . $u . "encoding=$i\">$enc</a>";
926 - if($i == $user->options["encoding"]) $ret .= "</b>";
927 - }
928 - }
 917+ # Text encoding
 918+ if(count($wikiEncodingNames) > 1) { # Shortcut for switching character encodings
 919+ global $THESCRIPT;
 920+ $u = $THESCRIPT . "?" . getenv("QUERY_STRING");
 921+ $u = preg_replace("/[\?\&]encoding=[0-9]+/", "", $u);
 922+ $u .= (strchr($u, "?") ? "&" : "?");
 923+ foreach ( $wikiEncodingNames as $i => $enc ) {
 924+ if($i > 0) $ret .= " | ";
 925+ if($i == $user->options["encoding"]) $ret .= "<b>";
 926+ $ret .= "<a href=\"" . $u . "encoding=$i\">$enc</a>";
 927+ if($i == $user->options["encoding"]) $ret .= "</b>";
 928+ }
 929+ }
929930
930 - $ret .= "<FORM method=post action=\"".wikiLink("")."\"><INPUT TYPE=text NAME=search SIZE=16><INPUT TYPE=submit value=\"$wikiSearch\"></FORM>" ;
931 - $ret .= "</td>\n<td rowspan=2 width=1><a href=\"".wikiLink("")."\"><img border=0 src=\"$wikiLogoFile\" alt=\"[$wikiMainPage]\"></a></td></tr>\n" ;
932 - $ret .= "<tr><td valign=bottom>".$this->getLinkBar()."</td></tr></table>" ;
933 - return $ret ;
934 - }
 931+ $ret .= "<FORM method=post action=\"".wikiLink("")."\"><INPUT TYPE=text NAME=search SIZE=16><INPUT TYPE=submit value=\"$wikiSearch\"></FORM>" ;
 932+ $ret .= "</td>\n<td rowspan=2 width=1><a href=\"".wikiLink("")."\"><img border=0 src=\"$wikiLogoFile\" alt=\"[$wikiMainPage]\"></a></td></tr>\n" ;
 933+ $ret .= "<tr><td valign=bottom>".$this->getLinkBar()."</td></tr></table>" ;
 934+ return $ret ;
 935+ }
935936
936 - # This generates the QuickBar (also used by the list of special pages function)
937 - function getQuickBar () {
938 - global $wikiMainPage , $wikiRecentChanges , $wikiRecentChangesLink , $wikiUpload , $wikiPopularPages , $wikiLongPages;
939 - global $user , $oldID , $version , $wikiEditThisPage , $wikiDeleteThisPage , $wikiHistory , $wikiMyWatchlist ;
940 - global $wikiStatistics , $wikiNewPages , $wikiOrphans , $wikiMostWanted , $wikiAllPages , $wikiRandomPage , $wikiStubs , $wikiListUsers ;
941 - $editOldVersion = "" ;
942 - if ( $oldID != "" ) $editOldVersion="&oldID=$oldID&version=$version" ;
943 - $column = "" ;
944 - $column .= "<a href=\"".wikiLink("")."\">$wikiMainPage</a>\n" ;
945 - $column .= "<br><a href=\"".wikiLink("special:$wikiRecentChangesLink")."\">$wikiRecentChanges</a>\n" ;
946 - if ( $this->canEdit() ) $column .= "<br><a href=\"".wikiLink(urldecode($this->url)."$editOldVersion&action=edit")."\">$wikiEditThisPage</a>\n" ;
947 - else if ( !$this->isSpecialPage ) $column .= "<br>Protected page\n" ;
948 - if ( $this->canDelete() ) $column .= "<br><a href=\"".wikiLink("special:deletepage&target=".urldecode($this->url))."\">$wikiDeleteThisPage</a>\n" ;
949 - if ( $this->canProtect() ) $column .= "<br><a href=\"".wikiLink("special:protectpage&target=".urldecode($this->url))."\">Protect this page</a>\n" ;
 937+ # This generates the QuickBar (also used by the list of special pages function)
 938+ function getQuickBar () {
 939+ global $wikiMainPage , $wikiRecentChanges , $wikiRecentChangesLink , $wikiUpload , $wikiPopularPages , $wikiLongPages;
 940+ global $user , $oldID , $version , $wikiEditThisPage , $wikiDeleteThisPage , $wikiHistory , $wikiMyWatchlist ;
 941+ global $wikiStatistics , $wikiNewPages , $wikiOrphans , $wikiMostWanted , $wikiAllPages , $wikiRandomPage , $wikiStubs , $wikiListUsers ;
 942+ $editOldVersion = "" ;
 943+ if ( $oldID != "" ) $editOldVersion="&oldID=$oldID&version=$version" ;
 944+ $column = "" ;
 945+ $column .= "<a href=\"".wikiLink("")."\">$wikiMainPage</a>\n" ;
 946+ $column .= "<br><a href=\"".wikiLink("special:$wikiRecentChangesLink")."\">$wikiRecentChanges</a>\n" ;
 947+ if ( $this->canEdit() ) $column .= "<br><a href=\"".wikiLink(urldecode($this->url)."$editOldVersion&action=edit")."\">$wikiEditThisPage</a>\n" ;
 948+ else if ( !$this->isSpecialPage ) $column .= "<br>Protected page\n" ;
 949+ if ( $this->canDelete() ) $column .= "<br><a href=\"".wikiLink("special:deletepage&target=".urldecode($this->url))."\">$wikiDeleteThisPage</a>\n" ;
 950+ if ( $this->canProtect() ) $column .= "<br><a href=\"".wikiLink("special:protectpage&target=".urldecode($this->url))."\">Protect this page</a>\n" ;
950951 # To be implemented later
951 -# if ( $this->canAdvance() ) $column .= "<br><a href=\"".wikiLink("special:Advance&topic=$this->safeTitle")."\">Advance</a>\n" ;
 952+# if ( $this->canAdvance() ) $column .= "<br><a href=\"".wikiLink("special:Advance&topic=$this->safeTitle")."\">Advance</a>\n" ;
952953
953 - if ( !$this->isSpecialPage ) $column .= "<br><a href=\"".wikiLink(urldecode($this->url)."&action=history")."\">$wikiHistory</a>\n" ;
954 - $column .= "<br><a href=\"".wikiLink("special:Upload")."\">$wikiUpload</a>\n" ;
955 - $column .= "<hr>" ;
956 - $column .= "<a href=\"".wikiLink("special:Statistics")."\">$wikiStatistics</a>" ;
957 - $column .= "<br>\n<a href=\"".wikiLink("special:NewPages")."\">$wikiNewPages</a>" ;
958 - $column .= "<br>\n<a href=\"".wikiLink("special:LonelyPages")."\">$wikiOrphans</a>" ;
959 - $column .= "<br>\n<a href=\"".wikiLink("special:WantedPages")."\">$wikiMostWanted</a>" ;
960 - $column .= "<br>\n<a href=\"".wikiLink("special:PopularPages")."\">$wikiPopularPages</a>" ;
961 - $column .= "<br>\n<a href=\"".wikiLink("special:AllPages")."\">$wikiAllPages</a>" ;
962 - $column .= "<br>\n<a href=\"".wikiLink("special:RandomPage")."\">$wikiRandomPage</a>" ;
963 - $column .= "<br>\n<a href=\"".wikiLink("special:ShortPages")."\">$wikiStubs</a>" ;
964 - $column .= "<br>\n<a href=\"".wikiLink("special:LongPages")."\">$wikiLongPages</a>" ;
965 - $column .= "<br>\n<a href=\"".wikiLink("special:ListUsers")."\">$wikiListUsers</a>" ;
966 - if ( $user->isLoggedIn ) {
967 - $column .= "<br>\n<a href=\"".wikiLink("special:WatchList")."\">$wikiMyWatchlist</a>" ;
968 - }
969 - $a = $this->getOtherNamespaces () ;
970 - if ( count ( $a ) > 0 ) $column .= "<hr>".implode ( "<br>\n" , $a ) ;
 954+ if ( !$this->isSpecialPage ) $column .= "<br><a href=\"".wikiLink(urldecode($this->url)."&action=history")."\">$wikiHistory</a>\n" ;
 955+ $column .= "<br><a href=\"".wikiLink("special:Upload")."\">$wikiUpload</a>\n" ;
 956+ $column .= "<hr>" ;
 957+ $column .= "<a href=\"".wikiLink("special:Statistics")."\">$wikiStatistics</a>" ;
 958+ $column .= "<br>\n<a href=\"".wikiLink("special:NewPages")."\">$wikiNewPages</a>" ;
 959+ $column .= "<br>\n<a href=\"".wikiLink("special:LonelyPages")."\">$wikiOrphans</a>" ;
 960+ $column .= "<br>\n<a href=\"".wikiLink("special:WantedPages")."\">$wikiMostWanted</a>" ;
 961+ $column .= "<br>\n<a href=\"".wikiLink("special:PopularPages")."\">$wikiPopularPages</a>" ;
 962+ $column .= "<br>\n<a href=\"".wikiLink("special:AllPages")."\">$wikiAllPages</a>" ;
 963+ $column .= "<br>\n<a href=\"".wikiLink("special:RandomPage")."\">$wikiRandomPage</a>" ;
 964+ $column .= "<br>\n<a href=\"".wikiLink("special:ShortPages")."\">$wikiStubs</a>" ;
 965+ $column .= "<br>\n<a href=\"".wikiLink("special:LongPages")."\">$wikiLongPages</a>" ;
 966+ $column .= "<br>\n<a href=\"".wikiLink("special:ListUsers")."\">$wikiListUsers</a>" ;
 967+ if ( $user->isLoggedIn ) {
 968+ $column .= "<br>\n<a href=\"".wikiLink("special:WatchList")."\">$wikiMyWatchlist</a>" ;
 969+ }
 970+ $a = $this->getOtherNamespaces () ;
 971+ if ( count ( $a ) > 0 ) $column .= "<hr>".implode ( "<br>\n" , $a ) ;
971972
972973 /*
973 - # Category functionality deactivated
974 - $cat = $this->getParam ( "CATEGORY" ) ;
975 - if ( count ( $cat ) > 0 ) {
976 - $column .= "<hr>" ;
977 - $t = new wikiTitle ;
978 - foreach ( $cat as $x ) {
979 - $t->setTitle ( $x ) ;
980 - $column .= "<a href=\"".wikiLink($t->url")."\">".$this->getNiceTitle($x)."</a><br>\n" ;
981 - }
982 - }
 974+ # Category functionality deactivated
 975+ $cat = $this->getParam ( "CATEGORY" ) ;
 976+ if ( count ( $cat ) > 0 ) {
 977+ $column .= "<hr>" ;
 978+ $t = new wikiTitle ;
 979+ foreach ( $cat as $x ) {
 980+ $t->setTitle ( $x ) ;
 981+ $column .= "<a href=\"".wikiLink($t->url")."\">".$this->getNiceTitle($x)."</a><br>\n" ;
 982+ }
 983+ }
983984 */
984985
985 - return $column ;
986 - }
 986+ return $column ;
 987+ }
987988
988 - # This calls the parser and eventually adds the QuickBar. Used for display of normal article pages
989 - # Some special pages have their own rendering function
990 - function getMiddle ( $ret ) {
991 - global $user , $action ;
992 - if ( $action == "print" ) return $ret ;
993 - $oaction = $action ;
994 - if ( $action == "edit" ) $action = "" ;
995 - if ( $user->options["quickBar"] == "right" or $user->options["quickBar"] == "left" or $user->options["forceQuickBar"] != "" ) {
996 - $column = $this->getQuickBar();
997 - $spl = $this->getSubpageList () ;
998 - if ( !$this->isSpecialPage and $user->options["showStructure"]=="yes" and count ( $spl ) > 0 )
999 - $column .= "<font size=-1>".$this->parseContents ( "<hr>".implode ( "<br>\n" , $spl ) )."</font>" ;
 989+ # This calls the parser and eventually adds the QuickBar. Used for display of normal article pages
 990+ # Some special pages have their own rendering function
 991+ function getMiddle ( $ret ) {
 992+ global $user , $action ;
 993+ if ( $action == "print" ) return $ret ;
 994+ $oaction = $action ;
 995+ if ( $action == "edit" ) $action = "" ;
 996+ if ( $user->options["quickBar"] == "right" or $user->options["quickBar"] == "left" or $user->options["forceQuickBar"] != "" ) {
 997+ $column = $this->getQuickBar();
 998+ $spl = $this->getSubpageList () ;
 999+ if ( !$this->isSpecialPage and $user->options["showStructure"]=="yes" and count ( $spl ) > 0 )
 1000+ $column .= "<font size=-1>".$this->parseContents ( "<hr>".implode ( "<br>\n" , $spl ) )."</font>" ;
10001001
1001 - $column = "<td class=\"quickbar\" ".$user->options["quickBarBackground"]." width=110 valign=top nowrap>".$column."</td>" ;
1002 - $ret = "<td valign=top>".$ret."</td>" ;
 1002+ $column = "<td class=\"quickbar\" ".$user->options["quickBarBackground"]." width=110 valign=top nowrap>".$column."</td>" ;
 1003+ $ret = "<td valign=top>".$ret."</td>" ;
10031004
1004 - $table = "<table width=\"100%\" class=\"middle\" cellpadding=2 cellspacing=0><tr>" ;
1005 - $qb = $user->options["quickBar"] ;
1006 - if ( $user->options["forceQuickBar"] != "" ) $qb = $user->options["forceQuickBar"] ;
 1005+ $table = "<table width=\"100%\" class=\"middle\" cellpadding=2 cellspacing=0><tr>" ;
 1006+ $qb = $user->options["quickBar"] ;
 1007+ if ( $user->options["forceQuickBar"] != "" ) $qb = $user->options["forceQuickBar"] ;
10071008
1008 - global $framed ;
1009 - if ( isset ( $framed ) ) {
1010 - if ( $framed == "bar" ) $ret = $column ;
1011 - else if ( $framed == "main" ) $ret = $ret ;
1012 - else $ret = "" ;
1013 - } else {
1014 - if ( $qb == "left" ) $ret = $table.$column.$ret."</tr></table>" ;
1015 - else if ( $qb == "right" ) $ret = $table.$ret.$column."</tr></table>" ;
1016 - }
1017 - }
1018 - $action = $oaction ;
1019 - return $ret ;
1020 - }
 1009+ global $framed ;
 1010+ if ( isset ( $framed ) ) {
 1011+ if ( $framed == "bar" ) $ret = $column ;
 1012+ else if ( $framed == "main" ) $ret = $ret ;
 1013+ else $ret = "" ;
 1014+ } else {
 1015+ if ( $qb == "left" ) $ret = $table.$column.$ret."</tr></table>" ;
 1016+ else if ( $qb == "right" ) $ret = $table.$ret.$column."</tr></table>" ;
 1017+ }
 1018+ }
 1019+ $action = $oaction ;
 1020+ return $ret ;
 1021+ }
10211022
1022 - # This generates the footer with link bar, search box, etc.
1023 - function getFooter () {
1024 - global $wikiSearch , $wikiCategories , $wikiOtherNamespaces , $wikiCounter , $wikiLastChange ;
1025 - global $wikiGetDate , $framed ; if ( isset ( $framed ) ) return "" ;
1026 - $ret = $this->getLinkBar() ;
1027 - $ret = "<table width=\"100%\" $border class=\"footer\" cellspacing=0><tr><td>$ret</td></tr></table>" ;
 1023+ # This generates the footer with link bar, search box, etc.
 1024+ function getFooter () {
 1025+ global $wikiSearch , $wikiCategories , $wikiOtherNamespaces , $wikiCounter , $wikiLastChange ;
 1026+ global $wikiGetDate , $framed ; if ( isset ( $framed ) ) return "" ;
 1027+ $ret = $this->getLinkBar() ;
 1028+ $ret = "<table width=\"100%\" $border class=\"footer\" cellspacing=0><tr><td>$ret</td></tr></table>" ;
10281029
1029 - # Page counter
1030 - if ( !$this->isSpecialPage )
1031 - $ret .= str_replace ( "$1" , $this->counter , $wikiCounter ) ;
 1030+ # Page counter
 1031+ if ( !$this->isSpecialPage )
 1032+ $ret .= str_replace ( "$1" , $this->counter , $wikiCounter ) ;
10321033
1033 - # Other namespaces
1034 - $a = $this->getOtherNamespaces () ;
1035 - if ( count ( $a ) > 0 ) $ret .= " ".$wikiOtherNamespaces.implode ( " | " , $a )." " ;
 1034+ # Other namespaces
 1035+ $a = $this->getOtherNamespaces () ;
 1036+ if ( count ( $a ) > 0 ) $ret .= " ".$wikiOtherNamespaces.implode ( " | " , $a )." " ;
10361037
1037 - # Last change / Diff
1038 - if ( !$this->isSpecialPage ) {
1039 - $lc = $wikiGetDate ( tsc ( $this->timestamp ) ) ;
1040 - $lc .= ", ".substr ( $this->timestamp , 8 , 2 ) ;
1041 - $lc .= ":".substr ( $this->timestamp , 10 , 2 ) ;
1042 - $ret .= "<br>\n" ;
1043 - $ret .= str_replace ( "$1" , $lc , $wikiLastChange ) ;
1044 - $ret .= " <a href=\"".wikiLink("$this->url&diff=yes")."\">(diff)</a> " ;
1045 - }
 1038+ # Last change / Diff
 1039+ if ( !$this->isSpecialPage ) {
 1040+ $lc = $wikiGetDate ( tsc ( $this->timestamp ) ) ;
 1041+ $lc .= ", ".substr ( $this->timestamp , 8 , 2 ) ;
 1042+ $lc .= ":".substr ( $this->timestamp , 10 , 2 ) ;
 1043+ $ret .= "<br>\n" ;
 1044+ $ret .= str_replace ( "$1" , $lc , $wikiLastChange ) ;
 1045+ $ret .= " <a href=\"".wikiLink("$this->url&diff=yes")."\">(diff)</a> " ;
 1046+ }
10461047
10471048 /*
1048 - # Category functionality deactivated
1049 - $cat = $this->getParam ( "CATEGORY" ) ;
1050 - if ( count ( $cat ) > 0 ) {
1051 - $ret .= $wikiCategories ;
1052 - $t = new wikiTitle ;
1053 - $m = "" ;
1054 - foreach ( $cat as $x ) {
1055 - $t->setTitle ( $x ) ;
1056 - $ret .= "$m<a href=\"".wikiLink($t->url)."\">".$this->getNiceTitle($x)."</a>" ;
1057 - if ( $m == "" ) $m = " | " ;
1058 - }
1059 - }
 1049+ # Category functionality deactivated
 1050+ $cat = $this->getParam ( "CATEGORY" ) ;
 1051+ if ( count ( $cat ) > 0 ) {
 1052+ $ret .= $wikiCategories ;
 1053+ $t = new wikiTitle ;
 1054+ $m = "" ;
 1055+ foreach ( $cat as $x ) {
 1056+ $t->setTitle ( $x ) ;
 1057+ $ret .= "$m<a href=\"".wikiLink($t->url)."\">".$this->getNiceTitle($x)."</a>" ;
 1058+ if ( $m == "" ) $m = " | " ;
 1059+ }
 1060+ }
10601061 */
10611062
1062 - $ret .= "<FORM method=post action=\"".wikiLink("")."\"><INPUT TYPE=text NAME=search SIZE=16><INPUT TYPE=submit value=\"$wikiSearch\">" ;
1063 - $ret .= " &nbsp; &nbsp; <a href=\"http://validator.w3.org/check/referer\" target=blank>Validate this page</a>" ;
1064 - $ret .= "</FORM>" ;
 1063+ $ret .= "<FORM method=post action=\"".wikiLink("")."\"><INPUT TYPE=text NAME=search SIZE=16><INPUT TYPE=submit value=\"$wikiSearch\">" ;
 1064+ $ret .= " &nbsp; &nbsp; <a href=\"http://validator.w3.org/check/referer\" target=blank>Validate this page</a>" ;
 1065+ $ret .= "</FORM>" ;
10651066
1066 - return $ret ;
1067 - }
 1067+ return $ret ;
 1068+ }
10681069
1069 - # This generates header, diff (if wanted), article body (with QuickBar), and footer
1070 - # The whole page (for normal pages) is generated here
1071 - function renderPage ( $doPrint = false ) {
1072 - global $pageTitle , $diff , $wikiArticleSource , $wikiCurrentServer , $wikiPrintLinksMarkup , $useCachedPages ;
1073 - $pageTitle = $this->title ;
1074 - if ( isset ( $diff ) ) {
1075 - $this->canBeCached = false; # A little crude, but effective
1076 - $middle = $this->doDiff().$this->contents ;
1077 - }
1078 - else $middle = $this->contents ;
1079 - if ( $useCachedPages and !$this->isSpecialPage and $this->canBeCached) {
1080 - if ( $this->cache != "" ) { # Using cache
1081 - $middle = $this->cache ;
1082 - #$middle = "<p>(cached)</p>" . $this->cache ; #FIXME
1083 - } else {
1084 - $middle = $this->parseContents($middle) ;
1085 - if ( $this->canBeCached ) { # Generating cache
 1070+ # This generates header, diff (if wanted), article body (with QuickBar), and footer
 1071+ # The whole page (for normal pages) is generated here
 1072+ function renderPage ( $doPrint = false ) {
 1073+ global $pageTitle , $diff , $wikiArticleSource , $wikiCurrentServer , $wikiPrintLinksMarkup , $useCachedPages ;
 1074+ $pageTitle = $this->title ;
 1075+ if ( isset ( $diff ) ) {
 1076+ $this->canBeCached = false; # A little crude, but effective
 1077+ $middle = $this->doDiff().$this->contents ;
 1078+ }
 1079+ else $middle = $this->contents ;
 1080+ if ( $useCachedPages and !$this->isSpecialPage and $this->canBeCached) {
 1081+ if ( $this->cache != "" ) { # Using cache
 1082+ $middle = $this->cache ;
 1083+ #$middle = "<p>(cached)</p>" . $this->cache ; #FIXME
 1084+ } else {
 1085+ $middle = $this->parseContents($middle) ;
 1086+ if ( $this->canBeCached ) { # Generating cache
10861087
1087 - $this->cache = str_replace ( "\"" , "\\\"" , $middle ) ;
1088 - $connection = getDBconnection () ;
1089 - mysql_select_db ( $wikiSQLServer , $connection ) ;
1090 - $sql = "UPDATE cur SET cur_cache=\"$this->cache\", cur_timestamp=cur_timestamp WHERE cur_title=\"$this->secureTitle\"" ;
1091 - mysql_query ( $sql , $connection ) ;
1092 - $sql = "UPDATE cur SET cur_text=\"\", cur_timestamp=cur_timestamp WHERE cur_title=\"Log:RecentChanges\"" ;
1093 - mysql_query ( $sql , $connection ) ;
1094 - #mysql_close ( $connection ) ;
 1088+ $this->cache = str_replace ( "\"" , "\\\"" , $middle ) ;
 1089+ $connection = getDBconnection () ;
 1090+ mysql_select_db ( $wikiSQLServer , $connection ) ;
 1091+ $sql = "UPDATE cur SET cur_cache=\"$this->cache\", cur_timestamp=cur_timestamp WHERE cur_title=\"$this->secureTitle\"" ;
 1092+ mysql_query ( $sql , $connection ) ;
 1093+ $sql = "UPDATE cur SET cur_text=\"\", cur_timestamp=cur_timestamp WHERE cur_title=\"Log:RecentChanges\"" ;
 1094+ mysql_query ( $sql , $connection ) ;
 1095+ #mysql_close ( $connection ) ;
10951096
1096 -
1097 - }
1098 - }
1099 - } else {
1100 - $middle = $this->parseContents($middle) ;
1101 - }
1102 - $middle = $this->getMiddle($middle) ;
1103 - if ( $doPrint ) {
1104 - $header = "<h1>".$this->getNiceTitle($pageTitle)."</h1>\n" ;
1105 - $link = str_replace ( "$1" , $this->url , $wikiArticleSource ) ;
1106 - $footer = "<hr>This article is from <b>Wikipedia</b> (<a href=\"$wikiCurrentServer\">$wikiCurrentServer</a>), " ;
1107 - $footer .= "the free online encyclopedia. You can find this article at <a href=\"$link\">$link</a>" ;
1108 - $ret = $header.$middle ;
1109 - $ret = eregi_replace ( "<a[^>]*>\\?</a>" , "" , $ret ) ;
1110 - $ret = eregi_replace ( "<a[^>]*>\\[" , "<a>" , $ret ) ;
1111 - $ret = eregi_replace ( "\\]</a>" , "</a>" , $ret ) ;
1112 - $ret = eregi_replace ( "<a[^>]*>([^<]*)</a>" , "<$wikiPrintLinksMarkup>\\1</$wikiPrintLinksMarkup>" , $ret ) ;
1113 - return $ret.$footer ;
1114 - } else {
1115 - return $this->getHeader().$middle.$this->getFooter() ;
1116 - }
1117 - }
 1097+
 1098+ }
 1099+ }
 1100+ } else {
 1101+ $middle = $this->parseContents($middle) ;
 1102+ }
 1103+ $middle = $this->getMiddle($middle) ;
 1104+ if ( $doPrint ) {
 1105+ $header = "<h1>".$this->getNiceTitle($pageTitle)."</h1>\n" ;
 1106+ $link = str_replace ( "$1" , $this->url , $wikiArticleSource ) ;
 1107+ $footer = "<hr>This article is from <b>Wikipedia</b> (<a href=\"$wikiCurrentServer\">$wikiCurrentServer</a>), " ;
 1108+ $footer .= "the free online encyclopedia. You can find this article at <a href=\"$link\">$link</a>" ;
 1109+ $ret = $header.$middle ;
 1110+ $ret = eregi_replace ( "<a[^>]*>\\?</a>" , "" , $ret ) ;
 1111+ $ret = eregi_replace ( "<a[^>]*>\\[" , "<a>" , $ret ) ;
 1112+ $ret = eregi_replace ( "\\]</a>" , "</a>" , $ret ) ;
 1113+ $ret = eregi_replace ( "<a[^>]*>([^<]*)</a>" , "<$wikiPrintLinksMarkup>\\1</$wikiPrintLinksMarkup>" , $ret ) ;
 1114+ return $ret.$footer ;
 1115+ } else {
 1116+ return $this->getHeader().$middle.$this->getFooter() ;
 1117+ }
 1118+ }
11181119
1119 - # This displays the diff. Currently, only diff with the last edit!
1120 - function doDiff () {
1121 - global $oldID , $version , $user ;
1122 - global $wikiBeginDiff , $wikiEndDiff , $wikiDiffLegend , $wikiDiffFirstVersion , $wikiDiffImpossible ;
1123 - $ret = "<nowiki><font color=red><b>$wikiBeginDiff</b></font><br>\n\n" ;
1124 - global $wikiSQLServer ;
1125 - $connection = getDBconnection () ;
1126 - mysql_select_db ( $wikiSQLServer , $connection ) ;
 1120+ # This displays the diff. Currently, only diff with the last edit!
 1121+ function doDiff () {
 1122+ global $oldID , $version , $user ;
 1123+ global $wikiBeginDiff , $wikiEndDiff , $wikiDiffLegend , $wikiDiffFirstVersion , $wikiDiffImpossible ;
 1124+ $ret = "<nowiki><font color=red><b>$wikiBeginDiff</b></font><br>\n\n" ;
 1125+ global $wikiSQLServer ;
 1126+ $connection = getDBconnection () ;
 1127+ mysql_select_db ( $wikiSQLServer , $connection ) ;
11271128
1128 - if ( isset ( $oldID ) ) { # Diff between old versions
1129 - $sql = "SELECT old_old_version FROM old WHERE old_id=$oldID" ;
1130 - $result = mysql_query ( $sql , $connection ) ;
1131 - $s = mysql_fetch_object ( $result ) ;
1132 - $sql = "SELECT * FROM old WHERE old_id=$s->old_old_version" ;
1133 - } else { # Diff between old and new version
1134 - $sql = "SELECT cur_old_version FROM cur WHERE cur_title=\"$this->secureTitle\"" ;
1135 - $result = mysql_query ( $sql , $connection ) ;
1136 - $s = mysql_fetch_object ( $result ) ;
1137 - $sql = "SELECT * FROM old WHERE old_id=$s->cur_old_version" ;
1138 - $s->old_old_version = $s->cur_old_version ;
1139 - }
 1129+ if ( isset ( $oldID ) ) { # Diff between old versions
 1130+ $sql = "SELECT old_old_version FROM old WHERE old_id=$oldID" ;
 1131+ $result = mysql_query ( $sql , $connection ) ;
 1132+ $s = mysql_fetch_object ( $result ) ;
 1133+ $sql = "SELECT * FROM old WHERE old_id=$s->old_old_version" ;
 1134+ } else { # Diff between old and new version
 1135+ $sql = "SELECT cur_old_version FROM cur WHERE cur_title=\"$this->secureTitle\"" ;
 1136+ $result = mysql_query ( $sql , $connection ) ;
 1137+ $s = mysql_fetch_object ( $result ) ;
 1138+ $sql = "SELECT * FROM old WHERE old_id=$s->cur_old_version" ;
 1139+ $s->old_old_version = $s->cur_old_version ;
 1140+ }
11401141
1141 - $fc = $user->options["background"] ;
1142 - if ( $fc == "" ) $fc = "=black" ;
1143 - $fc = substr ( $fc , strpos("=",$fc)+1 ) ;
1144 - $bc = " bordercolor=white" ;
1145 - $fc = "black" ; # HOTFIX
1146 - $fc = " color=".$fc ;
1147 - $result = mysql_query ( $sql , $connection ) ;
1148 - if ( $result != "" and $s->old_old_version != 0 ) {
1149 - $s = mysql_fetch_object ( $result ) ;
1150 - mysql_free_result ( $result ) ;
1151 - $a1 = explode ( "\n" , $this->contents ) ;
1152 - $a2 = explode ( "\n" , $s->old_text ) ;
1153 - $nl = array () ;
1154 - $dl = array () ;
1155 - foreach ( $a1 as $x ) if ( !in_array ( $x , $a2 ) ) array_push ( $nl , htmlentities ( $x ) ) ;
1156 - foreach ( $a2 as $x ) if ( !in_array ( $x , $a1 ) ) array_push ( $dl , htmlentities ( $x ) ) ;
1157 - # Output
1158 - $ret .= $wikiDiffLegend ;
1159 - $ret .= "<table width=\"100%\" border=1$bc cellspacing=0 cellpadding=2>\n" ;
1160 - foreach ( $nl as $x ) $ret .= "<tr><td bgcolor=\"#CFFFCF\"><font$fc>$x</font></td></tr>\n" ;
1161 - foreach ( $dl as $x ) $ret .= "<tr><td bgcolor=\"#FFFFAF\"><font$fc>$x</font></td></tr>\n" ;
1162 - $ret .= "</table>\n" ;
1163 - } else if ( isset ( $oldID ) and $s->old_old_version == 0 ) $ret .= $wikiDiffFirstVersion ;
1164 - else if ( !isset ( $oldID ) ) $ret .= $wikiDiffImpossible ;
1165 - #mysql_close ( $connection ) ;
1166 -
1167 - $ret .= "<font color=red><b>$wikiEndDiff</b></font><hr></nowiki>\n" ;
1168 - return $ret ;
1169 - }
1170 - }
 1142+ $fc = $user->options["background"] ;
 1143+ if ( $fc == "" ) $fc = "=black" ;
 1144+ $fc = substr ( $fc , strpos("=",$fc)+1 ) ;
 1145+ $bc = " bordercolor=white" ;
 1146+ $fc = "black" ; # HOTFIX
 1147+ $fc = " color=".$fc ;
 1148+ $result = mysql_query ( $sql , $connection ) ;
 1149+ if ( $result != "" and $s->old_old_version != 0 ) {
 1150+ $s = mysql_fetch_object ( $result ) ;
 1151+ mysql_free_result ( $result ) ;
 1152+ $a1 = explode ( "\n" , $this->contents ) ;
 1153+ $a2 = explode ( "\n" , $s->old_text ) ;
 1154+ $nl = array () ;
 1155+ $dl = array () ;
 1156+ foreach ( $a1 as $x ) if ( !in_array ( $x , $a2 ) ) array_push ( $nl , htmlentities ( $x ) ) ;
 1157+ foreach ( $a2 as $x ) if ( !in_array ( $x , $a1 ) ) array_push ( $dl , htmlentities ( $x ) ) ;
 1158+ # Output
 1159+ $ret .= $wikiDiffLegend ;
 1160+ $ret .= "<table width=\"100%\" border=1$bc cellspacing=0 cellpadding=2>\n" ;
 1161+ foreach ( $nl as $x ) $ret .= "<tr><td bgcolor=\"#CFFFCF\"><font$fc>$x</font></td></tr>\n" ;
 1162+ foreach ( $dl as $x ) $ret .= "<tr><td bgcolor=\"#FFFFAF\"><font$fc>$x</font></td></tr>\n" ;
 1163+ $ret .= "</table>\n" ;
 1164+ } else if ( isset ( $oldID ) and $s->old_old_version == 0 ) $ret .= $wikiDiffFirstVersion ;
 1165+ else if ( !isset ( $oldID ) ) $ret .= $wikiDiffImpossible ;
 1166+ #mysql_close ( $connection ) ;
 1167+
 1168+ $ret .= "<font color=red><b>$wikiEndDiff</b></font><hr></nowiki>\n" ;
 1169+ return $ret ;
 1170+ }
 1171+ }
11711172 ?>

Status & tagging log