Gazelle/classes/wiki.class.php

81 lines
2.3 KiB
PHP
Raw Normal View History

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
##########################################################################
2013-02-22 08:00:24 +00:00
Seeing as each page has to manage its wiki separately (for performance
2011-03-28 14:21:28 +00:00
reasons - JOINs instead of multiple queries), this class is rather bare.
2013-02-22 08:00:24 +00:00
The only useful function in here is revision_history(). It creates a
table with the revision history for that particular wiki page.
2011-03-28 14:21:28 +00:00
2013-05-27 08:00:58 +00:00
wiki.class depends on your wiki table being structured like this:
2011-03-28 14:21:28 +00:00
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
2013-02-22 08:00:24 +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
2013-02-22 08:00:24 +00:00
do a JOIN.
2011-03-28 14:21:28 +00:00
########################################################################*/
2013-06-20 08:01:00 +00:00
class Wiki {
2013-02-22 08:00:24 +00:00
2013-06-20 08:01:00 +00:00
public static function revision_history($Table = '', $PageID = 0, $BaseURL = '') {
2013-08-28 23:08:41 +00:00
$QueryID = G::$DB->get_query_id();
2013-02-22 08:00:24 +00:00
2013-08-28 23:08:41 +00:00
G::$DB->query("
2013-05-21 08:01:09 +00:00
SELECT
2013-02-22 08:00:24 +00:00
RevisionID,
2011-03-28 14:21:28 +00:00
Summary,
Time,
2013-02-17 08:00:08 +00:00
UserID
2013-06-20 08:01:00 +00:00
FROM $Table AS wiki
WHERE wiki.PageID = $PageID
2013-05-21 08:01:09 +00:00
ORDER BY RevisionID DESC");
2013-06-20 08:01:00 +00:00
?>
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>
2013-06-20 08:01:00 +00:00
<?
2011-03-28 14:21:28 +00:00
$Row = 'a';
2013-08-28 23:08:41 +00:00
while (list($RevisionID, $Summary, $Time, $UserID, $Username) = G::$DB->next_record()) {
2013-05-21 08:01:09 +00:00
$Row = (($Row == 'a') ? 'b' : 'a');
2013-06-20 08:01:00 +00:00
?>
2011-03-28 14:21:28 +00:00
<tr class="row<?=$Row?>">
<td>
2013-05-21 08:01:09 +00:00
<?= "<a href=\"$BaseURL&amp;revisionid=$RevisionID\">#$RevisionID</a>" ?>
2011-03-28 14:21:28 +00:00
</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>
2013-06-20 08:01:00 +00:00
<? } // while ?>
2011-03-28 14:21:28 +00:00
</table>
<?
2013-08-28 23:08:41 +00:00
G::$DB->set_query_id($QueryID);
2013-06-20 08:01:00 +00:00
} // function
2011-03-28 14:21:28 +00:00
} // class
2012-10-09 08:00:17 +00:00
?>