2011-03-28 14:21:28 +00:00
|
|
|
<?
|
|
|
|
/*########################################################################
|
2012-10-09 08:00:17 +00:00
|
|
|
## Wiki class ##
|
2011-03-28 14:21:28 +00:00
|
|
|
##########################################################################
|
|
|
|
|
|
|
|
Seeing as each page has to manage its wiki separately (for performance
|
|
|
|
reasons - JOINs instead of multiple queries), this class is rather bare.
|
|
|
|
|
|
|
|
The only useful function in here is revision_history(). It creates a
|
|
|
|
table with the revision history for that particular wiki page.
|
|
|
|
|
|
|
|
|
|
|
|
class_wiki depends on your wiki table being structured like this:
|
|
|
|
|
2012-10-09 08:00:17 +00:00
|
|
|
+------------+--------------+------+-----+----------------------+-------+
|
|
|
|
| Field | Type | Null | Key | Default | Extra |
|
|
|
|
+------------+--------------+------+-----+----------------------+-------+
|
|
|
|
| RevisionID | int(12) | NO | PRI | 0 | |
|
|
|
|
| PageID | int(10) | NO | MUL | 0 | |
|
|
|
|
| Body | text | YES | | NULL | |
|
|
|
|
| UserID | int(10) | NO | MUL | 0 | |
|
|
|
|
| Summary | varchar(100) | YES | | NULL | |
|
|
|
|
| Time | datetime | NO | MUL | 0000-00-00 00:00:00 | |
|
|
|
|
+------------+--------------+------+-----+----------------------+-------+
|
2011-03-28 14:21:28 +00:00
|
|
|
|
|
|
|
It is also recommended that you have a field in the main table for
|
2012-10-09 08:00:17 +00:00
|
|
|
whatever the page is (e.g. details.php main table = torrents), so you can
|
2011-03-28 14:21:28 +00:00
|
|
|
do a JOIN.
|
|
|
|
|
|
|
|
|
|
|
|
########################################################################*/
|
|
|
|
|
|
|
|
class WIKI {
|
|
|
|
var $Table = '';
|
|
|
|
var $PageID = 0;
|
|
|
|
var $BaseURL = '';
|
|
|
|
function WIKI($Table, $PageID, $BaseURL = ''){
|
|
|
|
$this->Table = $Table;
|
|
|
|
$this->PageID = $PageID;
|
|
|
|
$this->BaseURL = $BaseURL;
|
|
|
|
}
|
|
|
|
|
|
|
|
function revision_history(){
|
|
|
|
global $DB;
|
|
|
|
|
|
|
|
$BaseURL = $this->BaseURL;
|
|
|
|
$DB->query("SELECT
|
|
|
|
RevisionID,
|
|
|
|
Summary,
|
|
|
|
Time,
|
2013-02-17 08:00:08 +00:00
|
|
|
UserID
|
2011-03-28 14:21:28 +00:00
|
|
|
FROM ".$this->Table." AS wiki
|
|
|
|
WHERE wiki.PageID = ".$this->PageID."
|
|
|
|
ORDER BY RevisionID DESC");
|
|
|
|
//----------------------------------------------- ?>
|
2012-10-09 08:00:17 +00:00
|
|
|
<table cellpadding="6" cellspacing="1" border="0" width="100%" class="border">
|
2011-03-28 14:21:28 +00:00
|
|
|
<tr class="colhead">
|
|
|
|
<td>Revision</td>
|
2013-02-17 08:00:08 +00:00
|
|
|
<td>Date</td>
|
|
|
|
<td>User</td>
|
2011-03-28 14:21:28 +00:00
|
|
|
<td>Summary</td>
|
|
|
|
</tr>
|
|
|
|
<? //-----------------------------------------
|
|
|
|
$Row = 'a';
|
|
|
|
while(list($RevisionID, $Summary, $Time, $UserID, $Username) = $DB->next_record()){
|
|
|
|
$Row = ($Row == 'a') ? 'b' : 'a';
|
|
|
|
//------------------------------------------------------ ?>
|
|
|
|
<tr class="row<?=$Row?>">
|
|
|
|
<td>
|
|
|
|
<?= "<a href='$BaseURL&revisionid=$RevisionID'>#$RevisionID</a>" ?>
|
|
|
|
</td>
|
|
|
|
<td>
|
2013-02-17 08:00:08 +00:00
|
|
|
<?=$Time?>
|
|
|
|
</td>
|
|
|
|
<td>
|
|
|
|
<?=Users::format_username($UserID, false, false, false)?>
|
|
|
|
</td>
|
|
|
|
<td>
|
|
|
|
<?=($Summary ? $Summary : '(empty)')?>
|
2011-03-28 14:21:28 +00:00
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
<? //---------------------------------------------------
|
|
|
|
}
|
|
|
|
//-------------------------------------------- ?>
|
|
|
|
</table>
|
|
|
|
<?
|
|
|
|
|
|
|
|
}
|
|
|
|
} // class
|
2012-10-09 08:00:17 +00:00
|
|
|
?>
|