Index: trunk/phpwiki/fpw/special_recentchanges.php |
— | — | @@ -2,120 +2,172 @@ |
3 | 3 | include_once ( "special_recentchangeslayout.php" ) ; |
4 | 4 | |
5 | 5 | function recentchanges () { |
6 | | - global $THESCRIPT , $user , $useCachedPages ; |
7 | | - global $vpage , $maxcnt , $daysAgo , $from , $wikiRecentChangesText , $wikiRecentChangesTitle ; |
8 | | - global $wikiRecentChangesLastDays , $wikiRecentChangesSince , $wikiViewLastDays , $wikiViewMaxNum , $wikiListOnlyNewChanges ; |
9 | | - $vpage->special ( $wikiRecentChangesTitle ) ; |
10 | | - $vpage->makeSecureTitle() ; |
11 | | - if ( !isset ( $maxcnt ) ) $maxcnt = 50 ; |
12 | | - if ( !isset ( $daysAgo ) ) $daysAgo = 3 ; |
13 | | - |
14 | | - if ( $maxcnt == 50 and $daysAgo == 3 and !isset($from) |
15 | | - and $user->options["hideMinor"] == "no" and $user->options["changesLayout"] == "classic" |
16 | | - and $useCachedPages) { |
17 | | - # If all default settings are in use, we can show a cached version of the page if available |
18 | | - #echo "(caching)"; #FIXME |
19 | | - $canBeCached = true; |
20 | | - $cache = getMySQL ( "cur" , "cur_text" , "cur_title=\"Log:RecentChanges\"" ) ; |
21 | | - |
22 | | - if ( $cache != "" ) |
23 | | - return $cache; |
24 | | - #echo "(reforming)"; #FIXME |
25 | | - } else { |
26 | | - #echo "(not caching)"; #FIXME |
27 | | - $canBeCached = false; |
28 | | - } |
| 6 | + global $THESCRIPT , $user , $useCachedPages ; |
| 7 | + global $vpage , $maxcnt , $daysAgo , $from , $wikiRecentChangesText , $wikiRecentChangesTitle ; |
| 8 | + global $wikiRecentChangesLastDays , $wikiRecentChangesSince , $wikiViewLastDays , $wikiViewMaxNum , $wikiListOnlyNewChanges ; |
| 9 | + $vpage->special ( $wikiRecentChangesTitle ) ; |
| 10 | + $vpage->makeSecureTitle() ; |
| 11 | + if ( !isset ( $maxcnt ) ) $maxcnt = 50 ; |
| 12 | + if ( !isset ( $daysAgo ) ) $daysAgo = 3 ; |
| 13 | + |
| 14 | + $from2 = substr ( $from , 0 , 4 ) . "-" . substr ( $from , 4 , 2 ) . "-" . substr ( $from , 6 , 2 ) ; |
| 15 | + $from2 .= " " . substr ( $from , 8 , 2 ) . ":" . substr ( $from , 10 , 2 ) . ":" . substr ( $from , 12 , 2 ) ; |
29 | 16 | |
30 | | - $from2 = substr ( $from , 0 , 4 ) . "-" . substr ( $from , 4 , 2 ) . "-" . substr ( $from , 6 , 2 ) ; |
31 | | - $from2 .= " " . substr ( $from , 8 , 2 ) . ":" . substr ( $from , 10 , 2 ) . ":" . substr ( $from , 12 , 2 ) ; |
| 17 | + $ret = "" ; |
| 18 | + if ( $wikiRecentChangesText != "" ) $ret .= "$wikiRecentChangesText<br><br>" ; |
32 | 19 | |
33 | | - $ret = "" ; |
34 | | - if ( $wikiRecentChangesText != "" ) $ret .= "$wikiRecentChangesText<br><br>" ; |
| 20 | + $ret .= "<nowiki>" ; |
| 21 | + if ( !isset($from) ) $ret .= str_replace ( "$1" , $maxcnt , str_replace ( "$2" , $daysAgo , $wikiRecentChangesLastDays ) ) ; |
| 22 | + else $ret .= str_replace ( "$1" , $maxcnt , str_replace ( "$2" , $from2 , $wikiRecentChangesSince ) ) ; |
35 | 23 | |
36 | | - $ret .= "<nowiki>" ; |
37 | | - if ( !isset($from) ) $ret .= str_replace ( "$1" , $maxcnt , str_replace ( "$2" , $daysAgo , $wikiRecentChangesLastDays ) ) ; |
38 | | - else $ret .= str_replace ( "$1" , $maxcnt , str_replace ( "$2" , $from2 , $wikiRecentChangesSince ) ) ; |
| 24 | + $ret .= "<br>\n" ; |
| 25 | + $n = explode ( "$1" , $wikiViewMaxNum ) ; |
| 26 | + $ret .= $n[0] ; |
| 27 | + $ret .= "<a href=\"".wikiLink("special:RecentChanges&daysAgo=$daysAgo&maxcnt=50")."\">50</a> | " ; |
| 28 | + $ret .= "<a href=\"".wikiLink("special:RecentChanges&daysAgo=$daysAgo&maxcnt=100")."\">100</a> | " ; |
| 29 | + $ret .= "<a href=\"".wikiLink("special:RecentChanges&daysAgo=$daysAgo&maxcnt=250")."\">250</a> | " ; |
| 30 | + $ret .= "<a href=\"".wikiLink("special:RecentChanges&daysAgo=$daysAgo&maxcnt=500")."\">500</a> | " ; |
| 31 | + $ret .= "<a href=\"".wikiLink("special:RecentChanges&daysAgo=$daysAgo&maxcnt=1000")."\">1000</a> | " ; |
| 32 | + $ret .= "<a href=\"".wikiLink("special:RecentChanges&daysAgo=$daysAgo&maxcnt=2500")."\">2500</a> | " ; |
| 33 | + $ret .= "<a href=\"".wikiLink("special:RecentChanges&daysAgo=$daysAgo&maxcnt=5000")."\">5000</a> " ; |
| 34 | + $ret .= $n[1]."; \n" ; |
| 35 | + $n = explode ( "$1" , $wikiViewLastDays ) ; |
| 36 | + $ret .= $n[0] ; |
| 37 | + $ret .= "<a href=\"".wikiLink("special:RecentChanges&maxcnt=$maxcnt&daysAgo=1")."\">1 </a> | " ; |
| 38 | + $ret .= "<a href=\"".wikiLink("special:RecentChanges&maxcnt=$maxcnt&daysAgo=2")."\">2 </a> | " ; |
| 39 | + $ret .= "<a href=\"".wikiLink("special:RecentChanges&maxcnt=$maxcnt&daysAgo=3")."\">3 </a> | " ; |
| 40 | + $ret .= "<a href=\"".wikiLink("special:RecentChanges&maxcnt=$maxcnt&daysAgo=5")."\">5 </a> | " ; |
| 41 | + $ret .= "<a href=\"".wikiLink("special:RecentChanges&maxcnt=$maxcnt&daysAgo=7")."\">7 </a> | " ; |
| 42 | + $ret .= "<a href=\"".wikiLink("special:RecentChanges&maxcnt=$maxcnt&daysAgo=14")."\">14 </a> ".$n[1]."; \n" ; |
39 | 43 | |
40 | | - $ret .= "<br>\n" ; |
41 | | - $n = explode ( "$1" , $wikiViewMaxNum ) ; |
42 | | - $ret .= $n[0] ; |
43 | | - $ret .= "<a href=\"".wikiLink("special:RecentChanges&daysAgo=$daysAgo&maxcnt=50")."\">50</a> | " ; |
44 | | - $ret .= "<a href=\"".wikiLink("special:RecentChanges&daysAgo=$daysAgo&maxcnt=100")."\">100</a> | " ; |
45 | | - $ret .= "<a href=\"".wikiLink("special:RecentChanges&daysAgo=$daysAgo&maxcnt=250")."\">250</a> | " ; |
46 | | - $ret .= "<a href=\"".wikiLink("special:RecentChanges&daysAgo=$daysAgo&maxcnt=500")."\">500</a> | " ; |
47 | | - $ret .= "<a href=\"".wikiLink("special:RecentChanges&daysAgo=$daysAgo&maxcnt=1000")."\">1000</a> | " ; |
48 | | - $ret .= "<a href=\"".wikiLink("special:RecentChanges&daysAgo=$daysAgo&maxcnt=2500")."\">2500</a> | " ; |
49 | | - $ret .= "<a href=\"".wikiLink("special:RecentChanges&daysAgo=$daysAgo&maxcnt=5000")."\">5000</a> " ; |
50 | | - $ret .= $n[1]."; \n" ; |
51 | | - $n = explode ( "$1" , $wikiViewLastDays ) ; |
52 | | - $ret .= $n[0] ; |
53 | | - $ret .= "<a href=\"".wikiLink("special:RecentChanges&maxcnt=$maxcnt&daysAgo=1")."\">1 </a> | " ; |
54 | | - $ret .= "<a href=\"".wikiLink("special:RecentChanges&maxcnt=$maxcnt&daysAgo=2")."\">2 </a> | " ; |
55 | | - $ret .= "<a href=\"".wikiLink("special:RecentChanges&maxcnt=$maxcnt&daysAgo=3")."\">3 </a> | " ; |
56 | | - $ret .= "<a href=\"".wikiLink("special:RecentChanges&maxcnt=$maxcnt&daysAgo=5")."\">5 </a> | " ; |
57 | | - $ret .= "<a href=\"".wikiLink("special:RecentChanges&maxcnt=$maxcnt&daysAgo=7")."\">7 </a> | " ; |
58 | | - $ret .= "<a href=\"".wikiLink("special:RecentChanges&maxcnt=$maxcnt&daysAgo=14")."\">14 </a> ".$n[1]."; \n" ; |
| 44 | + $mindate = date ( "Ymd000000" , time () - $daysAgo*24*60*60 ) ; |
| 45 | + $mindate = timestampAddHour ( $mindate , $user->options["hourDiff"] ) ; |
59 | 46 | |
60 | | - $mindate = date ( "Ymd000000" , time () - $daysAgo*24*60*60 ) ; |
61 | | - $mindate = timestampAddHour ( $mindate , $user->options["hourDiff"] ) ; |
| 47 | + $now = date ( "YmdHis" , time() ) ; |
| 48 | + $now = timestampAddHour ( $now , $user->options["hourDiff"] ) ; |
62 | 49 | |
63 | | - $now = date ( "YmdHis" , time() ) ; |
64 | | - $now = timestampAddHour ( $now , $user->options["hourDiff"] ) ; |
| 50 | + $ret .= "<a href=\"".wikiLink("special:RecentChanges&from=$now")."\">$wikiListOnlyNewChanges</a>" ; |
| 51 | + $ret .= "</nowiki>" ; |
| 52 | + $ret .= "\n----\n" ; |
| 53 | + $arr = array () ; |
65 | 54 | |
66 | | - $ret .= "<a href=\"".wikiLink("special:RecentChanges&from=$now")."\">$wikiListOnlyNewChanges</a>" ; |
67 | | - $ret .= "</nowiki>" ; |
68 | | - $ret .= "\n----\n" ; |
69 | | - $arr = array () ; |
| 55 | + global $wikiSQLServer ; |
| 56 | + $connection=getDBconnection() ; |
| 57 | + mysql_select_db ( $wikiSQLServer , $connection ) ; |
70 | 58 | |
71 | | - if ( $from != "" ) $mindate = $from ; |
| 59 | + if ( $user->options["hideMinor"] != "yes" ) { |
| 60 | + |
| 61 | + # here starts the code for retrieving the recent changes information |
| 62 | + # for the major _and_ the minor edits |
72 | 63 | |
73 | | - global $wikiSQLServer ; |
74 | | - $connection=getDBconnection() ; |
75 | | - mysql_select_db ( $wikiSQLServer , $connection ) ; |
76 | | - $sql = "SELECT cur_timestamp,cur_title,cur_comment,cur_user,cur_user_text,cur_minor_edit FROM cur WHERE cur_timestamp>$mindate ORDER BY cur_timestamp DESC LIMIT $maxcnt" ; |
77 | | - $result = mysql_query ( $sql , $connection ) ; |
78 | | - while ( $s = mysql_fetch_object ( $result ) ) array_push ( $arr , $s ) ; |
79 | | - mysql_free_result ( $result ) ; |
| 64 | + # optional parts of the query |
| 65 | + $fromCondOld = ( isset($from) ) ? "AND old_timestamp > $from" : ""; |
| 66 | + $fromCondCur = ( isset($from) ) ? "AND cur_timestamp > $from" : ""; |
| 67 | + |
| 68 | + # the SQL query that retrieves all information |
| 69 | + $sql = "SELECT cur_timestamp, cur_title, cur_comment, cur_user, |
| 70 | + cur_user_text, cur_minor_edit, |
| 71 | + COUNT(old_id) + (IF(cur_old_version = 0,0,1)) AS changes |
| 72 | + FROM cur LEFT OUTER JOIN old ON cur_title = old_title |
| 73 | + AND old_timestamp > SUBDATE(CURRENT_TIMESTAMP, INTERVAL $daysAgo DAY) |
| 74 | + AND old_old_version <> 0 |
| 75 | + $fromCondOld |
| 76 | + WHERE cur_timestamp > SUBDATE(CURRENT_TIMESTAMP, INTERVAL $daysAgo DAY) |
| 77 | + $fromCondCur |
| 78 | + GROUP BY cur_title |
| 79 | + ORDER BY cur_timestamp DESC |
| 80 | + LIMIT $maxcnt" ; |
80 | 81 | |
81 | | - $minoredits = ( $user->options["hideMinor"] == "yes" ) ? "AND old_minor_edit<>1" : "" ; |
82 | | - $d = array () ; |
83 | | - foreach ( $arr as $s ) { |
84 | | - $addoriginal = 1 ; |
85 | | - if ( $minoredits != "" and $s->cur_minor_edit == 1 ) $addoriginal = 0 ; |
86 | | - $i = 0 ; |
87 | | - $j = tsc ( $s->cur_timestamp ) ; |
88 | | - $ja = date ( "Ymd000000" , $j ) ; |
89 | | - $jb = date ( "Ymd000000" , $j + 24*60*60 ) ; |
90 | | - $sql = "SELECT count(old_id) AS cnt FROM old WHERE old_title=\"".$s->cur_title."\" AND old_timestamp>=$ja AND old_timestamp<=$jb $minoredits" ; |
91 | | - $result = mysql_query ( $sql , $connection ) ; |
92 | | - if ( $result != "" ) { |
93 | | - $t = mysql_fetch_object ( $result ) ; |
94 | | - if ( $t != "" ) $i = $t->cnt + $addoriginal ; |
95 | | - mysql_free_result ( $result ) ; |
96 | | - } |
97 | | - if ( $i < 2 ) $i = "" ; |
98 | | - $s->changes = $i ; |
99 | | - if ( $s->cur_minor_edit != 1 OR $i > 1 OR $minoredits == "" ) { |
100 | | - if ( $minoredits != "" ) $s->cur_minor_edit = 0 ; |
101 | | - array_push ( $d , $s ) ; |
102 | | - } |
103 | | - } |
104 | | - $arr = $d ; |
105 | | - $d = array () ; |
| 82 | + # store result in $arr |
| 83 | + $result = mysql_query ( $sql , $connection ) ; |
| 84 | + while ( $s = mysql_fetch_object ( $result ) ) array_push ( $arr , $s ) ; |
| 85 | + mysql_free_result ( $result ) ; |
| 86 | + |
| 87 | + } else { |
106 | 88 | |
107 | | - #mysql_close ( $connection ) ; |
108 | | - $ret .= recentChangesLayout($arr) ; |
109 | | - |
110 | | - if ( $canBeCached ) { |
111 | | - # Store the cached version |
112 | | - #echo "(saving)"; #FIXME |
113 | | - $p = new wikiPage ; |
114 | | - $p->setTitle ( "log:RecentChanges" ) ; |
115 | | - $p->ensureExistence () ; |
116 | | - $p->setEntry ( $ret , "Refresh" , 0 , "System" , 1, ",cur_timestamp=0" ) ; |
117 | | - } |
118 | | - |
119 | | - return $ret ; |
120 | | - } |
| 89 | + # here starts the code for retreiving the recent changes information |
| 90 | + # without the minor edits |
121 | 91 | |
| 92 | + # optional parts of the query |
| 93 | + $fromCondCur = ( isset($from) ) ? "AND cur_timestamp > $from" : ""; |
| 94 | + |
| 95 | + # the SQL query that retrieves the current pages that are not the result of a minor edit |
| 96 | + $sql1 = "SELECT cur_timestamp, cur_title, cur_comment, cur_user, |
| 97 | + cur_user_text, cur_minor_edit |
| 98 | + FROM cur |
| 99 | + WHERE cur_timestamp > SUBDATE(CURRENT_TIMESTAMP, INTERVAL $daysAgo DAY) |
| 100 | + AND cur_minor_edit != 1 |
| 101 | + $fromCondCur |
| 102 | + ORDER BY cur_title |
| 103 | + LIMIT $maxcnt" ; |
| 104 | + |
| 105 | + # store result in $arr1 |
| 106 | + $arr1 = array () ; |
| 107 | + $result = mysql_query ( $sql1 , $connection ) ; |
| 108 | + while ( $s = mysql_fetch_object ( $result ) ) array_push ( $arr1 , $s ) ; |
| 109 | + mysql_free_result ( $result ) ; |
| 110 | + |
| 111 | + # optional parts of the query |
| 112 | + $fromCondOld1 = ( isset($from) ) ? "AND o1.old_timestamp > $from" : ""; |
| 113 | + $fromCondOld2 = ( isset($from) ) ? "AND o2.old_timestamp > $from" : ""; |
| 114 | + |
| 115 | + # the SQL query that retrieves the old pages that are not the result of a minor edit |
| 116 | + # and groups them |
| 117 | + $sql2 = "SELECT o1.old_timestamp AS cur_timestamp, o1.old_title AS cur_title, |
| 118 | + o1.old_comment AS cur_comment, o1.old_user AS cur_user, |
| 119 | + o1.old_user_text AS cur_user_text, o1.old_minor_edit, |
| 120 | + COUNT(DISTINCT o2.old_id ) AS changes |
| 121 | + FROM old AS o1 LEFT OUTER JOIN old AS o2 |
| 122 | + ON o1.old_title = o2.old_title |
| 123 | + AND o2.old_timestamp > SUBDATE(CURRENT_TIMESTAMP, INTERVAL 3 DAY) |
| 124 | + AND o2.old_old_version <> 0 AND o2.old_minor_edit != 1 |
| 125 | + $fromCondOld2 |
| 126 | + WHERE o1.old_timestamp > SUBDATE(CURRENT_TIMESTAMP, INTERVAL 3 DAY) |
| 127 | + AND o1.old_minor_edit != 1 |
| 128 | + $fromCondOld1 |
| 129 | + GROUP BY o1.old_title, o1.old_timestamp |
| 130 | + HAVING cur_timestamp = MAX(o2.old_timestamp) |
| 131 | + ORDER BY o1.old_title |
| 132 | + LIMIT $maxcnt"; |
| 133 | + |
| 134 | + # store result in $arr2 |
| 135 | + $arr2 = array () ; |
| 136 | + $result = mysql_query ( $sql2 , $connection ) ; |
| 137 | + while ( $s = mysql_fetch_object ( $result ) ) array_push ( $arr2 , $s ) ; |
| 138 | + mysql_free_result ( $result ) ; |
| 139 | + |
| 140 | + # Now we merge the two results. |
| 141 | + # Evidently this is better done by the database, |
| 142 | + # but MySQL doesn't implement enough SQL for that. |
| 143 | + foreach ( $arr1 as $row1 ) { |
| 144 | + while ( $arr2 and ( $arr2[0]->cur_title < $row1->cur_title ) ) |
| 145 | + array_push ( $arr, array_shift ( $arr2 ) ); |
| 146 | + $extra = ($row1->cur_minor_edit == 2) ? 0 : 1; |
| 147 | + if ( $arr2 and ( $arr2[0]->cur_title == $row1->cur_title ) ) { |
| 148 | + $arr2[0]->changes += $extra; |
| 149 | + array_push ( $arr, array_shift ( $arr2 ) ); |
| 150 | + } else { |
| 151 | + $row1->changes = $extra; |
| 152 | + array_push ( $arr, $row1 ); |
| 153 | + } |
| 154 | + } |
| 155 | + $arr = array_merge ($arr, $arr2); |
| 156 | + |
| 157 | + # Now we sort the result on the timestamp |
| 158 | + function cmp ($a, $b) { |
| 159 | + $x = $a->cur_timestamp; |
| 160 | + $y = $b->cur_timestamp; |
| 161 | + if ( $x == $y ) return 0; |
| 162 | + return ($x > $y) ? -1 : 1; |
| 163 | + } |
| 164 | + |
| 165 | + usort ($arr, "cmp"); |
| 166 | + } |
| 167 | + |
| 168 | + #mysql_close ( $connection ) ; |
| 169 | + $ret .= recentChangesLayout($arr) ; |
| 170 | + |
| 171 | + return $ret ; |
| 172 | + } |
| 173 | + |
122 | 174 | ?> |
Index: trunk/phpwiki/fpw/wikipedia.sql |
— | — | @@ -1,8 +1,8 @@ |
2 | | -# MySQL dump 8.14 |
| 2 | +# MySQL dump 8.16 |
3 | 3 | # |
4 | 4 | # Host: localhost Database: wikipedia |
5 | 5 | #-------------------------------------------------------- |
6 | | -# Server version 3.23.41 |
| 6 | +# Server version 3.23.47 |
7 | 7 | |
8 | 8 | # |
9 | 9 | # Table structure for table 'cur' |
— | — | @@ -10,7 +10,7 @@ |
11 | 11 | |
12 | 12 | CREATE TABLE cur ( |
13 | 13 | cur_id mediumint(8) unsigned NOT NULL auto_increment, |
14 | | - cur_title varchar(255) binary NOT NULL, |
| 14 | + cur_title varchar(255) binary NOT NULL default '', |
15 | 15 | cur_text mediumtext, |
16 | 16 | cur_comment tinyblob, |
17 | 17 | cur_user mediumint(8) unsigned default '0', |
— | — | @@ -24,10 +24,11 @@ |
25 | 25 | cur_unlinked_links mediumtext, |
26 | 26 | cur_counter bigint(20) unsigned default '0', |
27 | 27 | cur_cache mediumtext, |
| 28 | + UNIQUE KEY cur_id (cur_id), |
28 | 29 | UNIQUE KEY cur_title (cur_title), |
29 | | - UNIQUE KEY cur_id (cur_id), |
30 | | - KEY cur_id_2 (cur_id) |
31 | | -) TYPE=MyISAM; |
| 30 | + KEY cur_id_2 (cur_id), |
| 31 | + KEY timeind (cur_timestamp) |
| 32 | +) TYPE=ISAM PACK_KEYS=1; |
32 | 33 | |
33 | 34 | # |
34 | 35 | # Table structure for table 'old' |
— | — | @@ -45,8 +46,9 @@ |
46 | 47 | old_minor_edit tinyint(1) default '0', |
47 | 48 | PRIMARY KEY (old_id), |
48 | 49 | UNIQUE KEY old_id (old_id), |
49 | | - KEY old_id_2 (old_id) |
50 | | -) TYPE=MyISAM; |
| 50 | + KEY old_id_2 (old_id), |
| 51 | + KEY timeind (old_timestamp) |
| 52 | +) TYPE=ISAM PACK_KEYS=1; |
51 | 53 | |
52 | 54 | # |
53 | 55 | # Table structure for table 'user' |
— | — | @@ -63,4 +65,5 @@ |
64 | 66 | PRIMARY KEY (user_id), |
65 | 67 | UNIQUE KEY user_id (user_id), |
66 | 68 | KEY user_id_2 (user_id) |
67 | | -) TYPE=MyISAM; |
| 69 | +) TYPE=ISAM PACK_KEYS=1; |
| 70 | + |
Index: trunk/phpwiki/fpw/special_recentchangeslayout.php |
— | — | @@ -1,121 +1,129 @@ |
2 | 2 | <? |
3 | 3 | # Changes the date in recentChangesLayout() according to user setting; can be used similar elsewhere |
4 | 4 | function timestampAddHour ( $x , $d ) { |
5 | | - $x = tsc ( $x ) ; |
6 | | - $x += $d * 3600 ; |
7 | | - $x = date ( "YmdHis" , $x ) ; |
8 | | - return $x ; |
9 | | - } |
| 5 | + $x = tsc ( $x ) ; |
| 6 | + $x += $d * 3600 ; |
| 7 | + $x = date ( "YmdHis" , $x ) ; |
| 8 | + return $x ; |
| 9 | + } |
10 | 10 | |
11 | 11 | function recentChangesLayout ( &$arr ) { |
12 | | - if ( count ( $arr ) == 0 ) return "" ; |
13 | | - global $THESCRIPT , $user , $wikiDiff , $wikiGetDate , $wikiUser ; |
14 | | - $lastDay = "" ; |
15 | | - $color1 = $user->options["tabLine1"] ; |
16 | | - $color2 = $user->options["tabLine2"] ; |
| 12 | + if ( count ( $arr ) == 0 ) return "" ; |
| 13 | + global $THESCRIPT , $user , $wikiDiff , $wikiGetDate , $wikiUser ; |
| 14 | + $lastDay = "" ; |
| 15 | + $color1 = $user->options["tabLine1"] ; |
| 16 | + $color2 = $user->options["tabLine2"] ; |
17 | 17 | |
18 | | - # Correcting time difference |
19 | | - $arr2 = array () ; |
20 | | - foreach ( $arr as $y ) { |
21 | | - $y->cur_timestamp = timestampAddHour ( $y->cur_timestamp , $user->options["hourDiff"] ) ; |
22 | | - array_push ( $arr2 , $y ) ; |
23 | | - } |
24 | | - $arr = $arr2 ; |
25 | | - $arr2 = array () ; |
| 18 | + # Correcting time difference |
| 19 | + $arr2 = array () ; |
| 20 | + foreach ( $arr as $y ) { |
| 21 | + $y->cur_timestamp = timestampAddHour ( $y->cur_timestamp , $user->options["hourDiff"] ); |
| 22 | + array_push ( $arr2 , $y ) ; |
| 23 | + } |
| 24 | + $arr = $arr2 ; |
| 25 | + $arr2 = array () ; |
26 | 26 | |
27 | | - global $wikiRCLegend ; |
| 27 | + global $wikiRCLegend ; |
28 | 28 | |
29 | | - if ( in_array ( "is_sysop" , $user->rights ) ) $isSysop = true ; |
30 | | - else $isSysop = false ; |
| 29 | + if ( in_array ( "is_sysop" , $user->rights ) ) $isSysop = true ; |
| 30 | + else $isSysop = false ; |
31 | 31 | |
32 | | - $xyz = new WikiTitle ; |
33 | | - $editTypes = array ( "0"=>"" , "1"=>"<font color=cyan>M</font>" , "2"=>"<font color=green>N</font>" ) ; |
34 | | - $ret = str_replace ( "$1" , $editTypes["1"] , str_replace ( "$2" , $editTypes["2"] , $wikiRCLegend ) ) ; |
35 | | - if ( $user->options["changesLayout"] == "table" ) $ret .= "<table width=\"100%\" border=0 cellpadding=2 cellspacing=0>\n" ; |
36 | | - else $ret .= "<ul>\n" ; |
37 | | - $dummy = wikiLink("x=y") ; |
38 | | - foreach ( $arr as $s ) { |
39 | | - $nt = $xyz->getNiceTitle ( $s->cur_title ) ; |
40 | | - $url = nurlencode ( $s->cur_title ) ; |
41 | | - $day = date ( "l, F d, Y" , tsc ( $s->cur_timestamp ) ) ; |
42 | | - $time = date ( "H:i" , tsc ( $s->cur_timestamp ) ) ; |
43 | | - if ( $day != $lastDay ) { |
44 | | - $lastDay = $day ; |
45 | | - $tday = $wikiGetDate ( tsc ( $s->cur_timestamp ) ) ; |
46 | | - if ( $user->options["changesLayout"] == "table" ) $ret.="<tr><td width=\"100%\" colspan=7".$user->options["tabLine0"]."><b>$tday</b></td></tr>"; |
47 | | - else $ret .= "</ul><b>$tday</b><ul>\n" ; |
48 | | - $color = $color1 ; |
49 | | - } |
50 | | - $u = $s->cur_user_text ; |
51 | | - if ( $s->cur_user != 0 ) { |
52 | | - $xyz->SetTitle ( $u ) ; |
53 | | - $u = "<a href=\"".wikiLink("$wikiUser:$xyz->url")."\">$u</a>" ; |
54 | | - } elseif ( !$isSysop ) { |
55 | | - $u = explode ( "." , $u ) ; |
56 | | - $u = $u[0].".".$u[1].".".$u[2].".xxx" ; |
57 | | -# $u = "<font color=red>$u</font>" ; # IPs in red, deactivated |
58 | | - } |
59 | | - $comment = trim($s->cur_comment) ; |
60 | | - if ( $comment == "*" ) $comment = "" ; |
61 | | - $o_comment = $comment ; |
62 | | - if ( $s->cur_minor_edit == 1 ) $comment = "<font size=-1><i>$comment</i></font>" ; |
63 | | - $minor = $editTypes[$s->cur_minor_edit] ; |
| 32 | + $xyz = new WikiTitle ; |
| 33 | + $editTypes = array ( "0"=>"" , "1"=>"<font color=cyan>M</font>" , "2"=>"<font color=green>N</font>" ) ; |
| 34 | + $ret = str_replace ( "$1" , $editTypes["1"] , str_replace ( "$2" , $editTypes["2"] , $wikiRCLegend ) ) ; |
| 35 | + if ( $user->options["changesLayout"] == "table" ) |
| 36 | + $ret .= "<table width=\"100%\" border=0 cellpadding=2 cellspacing=0>\n" ; |
| 37 | + else $ret .= "<ul>\n" ; |
| 38 | + $dummy = wikiLink("x=y") ; |
| 39 | + foreach ( $arr as $s ) { |
| 40 | + $nt = $xyz->getNiceTitle ( $s->cur_title ) ; |
| 41 | + $url = nurlencode ( $s->cur_title ) ; |
| 42 | + $day = date ( "l, F d, Y" , tsc ( $s->cur_timestamp ) ) ; |
| 43 | + $time = date ( "H:i" , tsc ( $s->cur_timestamp ) ) ; |
| 44 | + if ( $day != $lastDay ) { |
| 45 | + $lastDay = $day ; |
| 46 | + $tday = $wikiGetDate ( tsc ( $s->cur_timestamp ) ) ; |
| 47 | + if ( $user->options["changesLayout"] == "table" ) |
| 48 | + $ret.="<tr><td width=\"100%\" colspan=7".$user->options["tabLine0"]."><b>$tday</b></td></tr>"; |
| 49 | + else $ret .= "</ul><b>$tday</b><ul>\n" ; |
| 50 | + $color = $color1 ; |
| 51 | + } |
| 52 | + $u = $s->cur_user_text ; |
| 53 | + if ( $s->cur_user != 0 ) { |
| 54 | + $xyz->SetTitle ( $u ) ; |
| 55 | + $u = "<a href=\"".wikiLink("$wikiUser:$xyz->url")."\">$u</a>" ; |
| 56 | + } elseif ( !$isSysop ) { |
| 57 | + $u = explode ( "." , $u ) ; |
| 58 | + $u = $u[0].".".$u[1].".".$u[2].".xxx" ; |
| 59 | +# $u = "<font color=red>$u</font>" ; # IPs in red, deactivated |
| 60 | + } |
| 61 | + $comment = trim($s->cur_comment) ; |
| 62 | + if ( $comment == "*" ) $comment = "" ; |
| 63 | + $o_comment = $comment ; |
| 64 | + if ( $s->cur_minor_edit == 1 ) $comment = "<font size=-1><i>$comment</i></font>" ; |
| 65 | + $minor = $editTypes[$s->cur_minor_edit] ; |
64 | 66 | |
65 | | - if ( $user->options["changesLayout"] == "table" ) $t = "<tr><td$color valign=top width=0%>" ; |
66 | | - else $t = "<li>" ; |
| 67 | + if ( $user->options["changesLayout"] == "table" ) $t = "<tr><td$color valign=top width=0%>" ; |
| 68 | + else $t = "<li>" ; |
67 | 69 | |
68 | | - if ( $s->version == "current" ) $t .= "<a href=\"".wikiLink("$url&diff=yes")."\">$wikiDiff</a> " ; |
69 | | - else if ( $s->version != "" ) $t .= "<a href=\"".wikiLink("$url&oldID=$s->old_id&version=$s->version&diff=yes")."\">$wikiDiff</a> "; |
70 | | - else $t .= "<a href=\"".wikiLink("$url&diff=yes")."\">$wikiDiff</a>" ; |
| 70 | + if ( $s->version == "current" ) $t .= "<a href=\"".wikiLink("$url&diff=yes")."\">$wikiDiff</a> " ; |
| 71 | + else if ( $s->version != "" ) $t .= "<a href=\"".wikiLink("$url&oldID=".$s->old_id."&version=".$s->version."&diff=yes")."\">$wikiDiff</a> "; |
| 72 | + else $t .= "<a href=\"".wikiLink("$url&diff=yes")."\">$wikiDiff</a>" ; |
71 | 73 | |
72 | | - if ( $user->options["changesLayout"] == "table" ) $t .= "</td><td$color valign=top>" ; |
73 | | - else $t .= " " ; |
| 74 | + if ( $user->options["changesLayout"] == "table" ) $t .= "</td><td$color valign=top>" ; |
| 75 | + else $t .= " " ; |
74 | 76 | |
75 | | - if ( $s->version == "current" ) $t .= "<a href=\"".wikiLink("$url")."\">$nt</a></td>" ; |
76 | | - else if ( $s->version != "" ) $t .= "<a href=\"".wikiLink("$url&oldID=$s->old_id&version=$s->version")."\">$nt ($s->version)</a></td>" ; |
77 | | - else $t .= "<a href=\"".wikiLink("$url")."\">$nt</a>" ; |
| 77 | + if ( $s->version == "current" ) $t .= "<a href=\"".wikiLink("$url")."\">$nt</a></td>" ; |
| 78 | + else if ( $s->version != "" ) $t .= "<a href=\"".wikiLink("$url&oldID=".$s->old_id."&version=".$s->version)."\">$nt (".$s->version.")</a></td>" ; |
| 79 | + else $t .= "<a href=\"".wikiLink("$url")."\">$nt</a></td>" ; |
78 | 80 | |
79 | | - if ( $user->options["changesLayout"] == "table" ) $t .= "<td$color valign=top width=0% nowrap>$time</td>" ; |
80 | | - else $t = str_replace ( "</td>" , "; " , $t ) . " $time" ; |
| 81 | + if ( $user->options["changesLayout"] == "table" ) $t .= "<td$color valign=top width=0% nowrap>$time</td>" ; |
| 82 | + else $t = str_replace ( "</td>" , "; " , $t ) . " $time" ; |
81 | 83 | |
82 | | - $noc = $s->changes ; |
83 | | - if ( $noc > 1 ) $noc = "$noc <a href=\"".wikiLink("$url&action=history")."\">changes</a>" ; |
84 | | - if ( $user->options["changesLayout"] == "table" ) $t .= "<td$color valign=top width=0% nowrap>$noc</td>" ; |
85 | | - else { |
86 | | - if ( $noc != "" ) $t .= " ($noc)" ; |
87 | | - $t .= " . . . " ; |
88 | | - } |
| 84 | + $noc = $s->changes ; |
| 85 | + $changes = ( $noc > 1 ) ? "changes" : "change"; |
| 86 | + if ( $noc > 0 ) |
| 87 | + $noc = "$noc <a href=\"".wikiLink("$url&action=history")."\">$changes</a>" ; |
| 88 | + else |
| 89 | + $noc = ""; |
| 90 | + |
| 91 | + if ( $user->options["changesLayout"] == "table" ) |
| 92 | + $t .= "<td$color valign=top width=0% nowrap>$noc</td>" ; |
| 93 | + else { |
| 94 | + if ( $noc != "" ) $t .= " ($noc)" ; |
| 95 | + $t .= " . . . " ; |
| 96 | + } |
89 | 97 | |
90 | 98 | |
91 | | - if ( $s->version != "" ) { |
92 | | - $v = new wikiTitle ; |
93 | | - $v->SetTitle ( $s->cur_user_text ) ; |
94 | | - if ( $user->options["changesLayout"] == "table" ) $t .= "<td$color valign=top nowrap>" ; |
95 | | - if ( $s->cur_user == 0 ) $t .= "$s->cur_user_text</td>" ; |
96 | | - else $t .= "<a href=\"".wikiLink("$wikiUser:$v->url")."\">$s->cur_user_text</a></td>" ; |
97 | | - if ( $user->options["changesLayout"] == "table" ) $t .= "</td>" ; |
98 | | - else $t .= "; " ; |
99 | | - } |
100 | | - else { |
101 | | - if ( $user->options["changesLayout"] == "table" ) $t .= "<td$color valign=top nowrap>$u</td>" ; |
102 | | - else $t .= $u ; |
103 | | - } |
104 | | - if ( $user->options["changesLayout"] == "table" ) $t .= "<td$color valign=top>$minor</td>" ; |
105 | | - else $t .= " $minor" ; |
106 | | - if ( $user->options["changesLayout"] == "table" ) $t .= "<td$color >$comment</td>" ; |
107 | | - else if ( $o_comment != "" ) $t .= " <b>[$comment]</b>" ; |
108 | | - if ( $user->options["changesLayout"] == "table" ) $t .= "</tr>\n" ; |
109 | | - else $t .= "</li>\n" ; |
110 | | - $ret .= $t ; |
111 | | - if ( $color == $color1 ) $color = $color2 ; |
112 | | - else $color = $color1 ; |
113 | | - } |
114 | | - if ( $user->options["changesLayout"] == "table" ) $ret .= "</table>" ; |
115 | | - else { |
116 | | - $ret = "$ret</ul>\n" ; |
117 | | - $ret = str_replace ( "</td>" , "" , $ret ) ; |
118 | | - } |
119 | | - return "<nowiki>$ret</nowiki>" ; |
120 | | - } |
| 99 | + if ( $s->version != "" ) { |
| 100 | + $v = new wikiTitle ; |
| 101 | + $v->SetTitle ( $s->cur_user_text ) ; |
| 102 | + if ( $user->options["changesLayout"] == "table" ) $t .= "<td$color valign=top nowrap>" ; |
| 103 | + if ( $s->cur_user == 0 ) $t .= $s->cur_user_text."</td>" ; |
| 104 | + else $t .= "<a href=\"".wikiLink("$wikiUser:$v->url")."\">".$s->cur_user_text."</a></td>" ; |
| 105 | + if ( $user->options["changesLayout"] == "table" ) $t .= "</td>" ; |
| 106 | + else $t .= "; " ; |
| 107 | + } |
| 108 | + else { |
| 109 | + if ( $user->options["changesLayout"] == "table" ) $t .= "<td$color valign=top nowrap>$u</td>" ; |
| 110 | + else $t .= $u ; |
| 111 | + } |
| 112 | + if ( $user->options["changesLayout"] == "table" ) $t .= "<td$color valign=top>$minor</td>" ; |
| 113 | + else $t .= " $minor" ; |
| 114 | + if ( $user->options["changesLayout"] == "table" ) $t .= "<td$color >$comment</td>" ; |
| 115 | + else if ( $o_comment != "" ) $t .= " <b>[$comment]</b>" ; |
| 116 | + if ( $user->options["changesLayout"] == "table" ) $t .= "</tr>\n" ; |
| 117 | + else $t .= "</li>\n" ; |
| 118 | + $ret .= $t ; |
| 119 | + if ( $color == $color1 ) $color = $color2 ; |
| 120 | + else $color = $color1 ; |
| 121 | + } |
| 122 | + if ( $user->options["changesLayout"] == "table" ) $ret .= "</table>" ; |
| 123 | + else { |
| 124 | + $ret = "$ret</ul>\n" ; |
| 125 | + $ret = str_replace ( "</td>" , "" , $ret ) ; |
| 126 | + } |
| 127 | + return "<nowiki>$ret</nowiki>" ; |
| 128 | + } |
121 | 129 | |
122 | 130 | ?> |
Index: trunk/phpwiki/fpw/updSchema.sql |
— | — | @@ -0,0 +1,6 @@ |
| 2 | +# This code adapts older versions of the database. |
| 3 | +# It adapts the table definitions adds indexes and, if necessary, |
| 4 | +# fills new columns with appropriate values. |
| 5 | + |
| 6 | +ALTER TABLE cur ADD INDEX timeind (cur_timestamp); |
| 7 | +ALTER TABLE old ADD INDEX timeind (cur_timestamp); |
Property changes on: trunk/phpwiki/fpw/updSchema.sql |
___________________________________________________________________ |
Name: svn:eol-style |
1 | 8 | + native |
Name: svn:keywords |
2 | 9 | + Author Date Id Revision |
Index: trunk/phpwiki/fpw/special_dohistory.php |
— | — | @@ -2,55 +2,55 @@ |
3 | 3 | include_once ( "special_recentchangeslayout.php" ) ; |
4 | 4 | |
5 | 5 | function doHistory ( $title ) { |
6 | | - global $THESCRIPT , $vpage , $wikiSQLServer , $wikiHistoryTitle , $wikiCurrentVersion , $wikiHistoryHeader ; |
7 | | - $vpage = new WikiPage ; |
8 | | - $vpage->SetTitle ( $title ) ; |
9 | | - $ti = $vpage->secureTitle ; |
10 | | - $url = $vpage->url; |
11 | | - $vpage->special ( str_replace ( "$1" , $title , $wikiHistoryTitle ) ) ; |
12 | | - $vpage->makeSecureTitle () ; |
| 6 | + global $THESCRIPT , $vpage , $wikiSQLServer , $wikiHistoryTitle , $wikiCurrentVersion , $wikiHistoryHeader ; |
| 7 | + $vpage = new WikiPage ; |
| 8 | + $vpage->SetTitle ( $title ) ; |
| 9 | + $ti = $vpage->secureTitle ; |
| 10 | + $url = $vpage->url; |
| 11 | + $vpage->special ( str_replace ( "$1" , $title , $wikiHistoryTitle ) ) ; |
| 12 | + $vpage->makeSecureTitle () ; |
13 | 13 | |
14 | | - $a = array () ; |
15 | | - $connection = getDBconnection () ; |
16 | | - mysql_select_db ( $wikiSQLServer , $connection ) ; |
17 | | - $sql = "SELECT * FROM cur WHERE cur_title=\"$ti\"" ; |
18 | | - $result = mysql_query ( $sql , $connection ) ; |
19 | | - $s = mysql_fetch_object ( $result ) ; |
20 | | - array_push ( $a , $s ) ; |
21 | | - mysql_free_result ( $result ) ; |
22 | | - $o = $s->cur_old_version ; |
23 | | - while ( $o != 0 ) { |
24 | | - $sql = "SELECT * FROM old WHERE old_id=$o" ; |
25 | | - $result = mysql_query ( $sql , $connection ) ; |
26 | | - $s = mysql_fetch_object ( $result ) ; |
27 | | -# print "<font color=red>$s->old_timestamp:</font> ".$s->old_text."<br>" ; |
28 | | - $s->cur_timestamp = $s->old_timestamp ; |
29 | | - $s->cur_title = $s->old_title ; |
30 | | - $s->cur_user = $s->old_user ; |
31 | | - $s->cur_comment = $s->old_comment ; |
32 | | - $s->cur_user_text = $s->old_user_text ; |
33 | | - $s->cur_minor_edit = $s->old_minor_edit ; |
34 | | - array_push ( $a , $s ) ; |
35 | | - $o = $s->old_old_version ; |
36 | | - mysql_free_result ( $result ) ; |
37 | | - } |
38 | | - #mysql_close ( $connection ) ; |
| 14 | + $a = array () ; |
| 15 | + $connection = getDBconnection () ; |
| 16 | + mysql_select_db ( $wikiSQLServer , $connection ) ; |
| 17 | + |
| 18 | + # first we get the current record |
| 19 | + $sql1 = "SELECT cur_timestamp, cur_title, cur_comment, cur_user, |
| 20 | + cur_user_text, cur_minor_edit |
| 21 | + FROM cur |
| 22 | + WHERE cur_title=\"$ti\"" ; |
| 23 | + $result = mysql_query ( $sql1 , $connection ) ; |
| 24 | + $s = mysql_fetch_object ( $result ) ; |
| 25 | + array_push ( $a , $s ) ; |
| 26 | + mysql_free_result ( $result ) ; |
| 27 | + |
| 28 | + # then we get the old records |
| 29 | + $sql2 = "SELECT old_timestamp AS cur_timestamp, old_title AS cur_title, old_comment AS cur_comment, |
| 30 | + old_user AS cur_user, old_user_text AS cur_user_text, old_minor_edit AS cur_minor_edit, |
| 31 | + old_id |
| 32 | + FROM old |
| 33 | + WHERE old_title=\"$ti\" |
| 34 | + ORDER BY cur_timestamp DESC" ; |
| 35 | + $result = mysql_query ( $sql2 , $connection ) ; |
| 36 | + while ( $s = mysql_fetch_object ( $result ) ) array_push ( $a , $s ) ; |
| 37 | + mysql_free_result ( $result ) ; |
39 | 38 | |
40 | | - $i = count ( $a ) ; |
41 | | - $k = array_keys ( $a ) ; |
42 | | - foreach ( $k as $x ) { |
43 | | - if ( $i != count ( $a ) ) $a[$x]->version = $i ; |
44 | | - else $a[$x]->version = $wikiCurrentVersion ; |
45 | | - $i-- ; |
46 | | - } |
| 39 | + # now we number the versions |
| 40 | + $version = 0; |
| 41 | + foreach ( array_keys ( $a ) as $i ) { |
| 42 | + if ( $version > 0 ) $a[$i]->version = $version; |
| 43 | + $version++; |
| 44 | + } |
47 | 45 | |
48 | | - $t = recentChangesLayout ( $a ) ; |
49 | | - $t = "<b>".str_replace(array("$1","$2"),array($url,$title),$wikiHistoryHeader)."</b>".$t ; |
| 46 | + #mysql_close ( $connection ) ; |
50 | 47 | |
51 | | - $ret = $vpage->getHeader() ; |
52 | | - $ret .= $vpage->getMiddle($t) ; |
53 | | - $ret .= $vpage->getFooter() ; |
54 | | - return $ret ; |
55 | | - } |
| 48 | + $t = recentChangesLayout ( $a ) ; |
| 49 | + $t = "<b>".str_replace(array("$1","$2"),array($url,$title),$wikiHistoryHeader)."</b>".$t ; |
56 | 50 | |
57 | | -?> |
\ No newline at end of file |
| 51 | + $ret = $vpage->getHeader() ; |
| 52 | + $ret .= $vpage->getMiddle($t) ; |
| 53 | + $ret .= $vpage->getFooter() ; |
| 54 | + return $ret ; |
| 55 | + } |
| 56 | + |
| 57 | +?> |