]> CyberLeo.Net >> Repos - SourceForge/phpwiki.git/blob - lib/pageinfo.php
Jeff's hacks II.
[SourceForge/phpwiki.git] / lib / pageinfo.php
1 <?php
2 rcs_id('$Id: pageinfo.php,v 1.11 2001-09-18 19:16:23 dairiki Exp $');
3 require_once('lib/Template.php');
4
5 global $datetimeformat;
6
7 // Display the internal structure of a page.
8 $pagename = $request->getArg('pagename');
9 $page = $dbi->getPage($pagename);
10
11 $rows[] = Element('tr',
12                   "\n"
13                   . Element('th', 'Version') . "\n"
14                   . Element('th', 'Newer') . "\n"
15                   . Element('th', 'Older') . "\n"
16                   . Element('th', 'Created') . "\n"
17                   . Element('th', 'Summary') . "\n"
18                   . Element('th', 'Author') . "\n"
19                   );
20
21 // Get all versions of a page, then iterate over them to make version list
22 $iter = $page->getAllRevisions();
23 $i = 0;
24 $last_author_id = false;
25
26 function bold_if($cond, $text) {
27     return (bool)$cond ? QElement('b', $text) : htmlspecialchars($text);
28 }
29
30
31 while ($rev = $iter->next()) {
32     $version = $rev->getVersion();
33     $cols = array();
34     $is_major_edit = ! $rev->get('is_minor_edit');
35     
36     $cols[] = Element('td', array('align' => 'right'),
37                       Element('a', array('href'
38                                           => WikiURL($pagename,
39                                                      array('version' => $version))),
40                               bold_if($is_major_edit, $version)));
41     
42
43     $cols[] = Element('td', array('align' => 'center'),
44                       QElement('input', array('type' => 'radio',
45                                               'name' => 'version',
46                                               'value' => $version,
47                                               'checked' => $i == 0)));
48     
49     $cols[] = Element('td', array('align' => 'center'),
50                       QElement('input', array('type' => 'radio',
51                                               'name' => 'previous',
52                                               'value' => $version,
53                                               'checked' => $i++ == 1)));
54     
55     $cols[] = QElement('td', array('align' => 'right'),
56                        strftime($datetimeformat, $rev->get('mtime'))
57                        . "\xa0");
58
59     
60     $cols[] = Element('td', bold_if($is_major_edit, $rev->get('summary')));
61     
62     $author_id = $rev->get('author_id');
63     $cols[] = Element('td', bold_if($author_id !== $last_author_id,
64                                     $rev->get('author')));
65     $last_author_id = $author_id;
66     $rows[] = Element('tr', "\n" . join("\n", $cols) . "\n");
67 }
68
69 $table = ("\n"
70          . Element('table', join("\n", $rows)) . "\n"
71          . Element('input', array('type' => 'hidden',
72                                   'name' => 'action',
73                                   'value' => 'diff')) . "\n"
74          . Element('input', array('type' => 'submit', 'value' => 'Run Diff')) . "\n");
75
76 $formargs['action'] = USE_PATH_INFO ? WikiURL($pagename) : SCRIPT_NAME;
77 $formargs['method'] = 'post';
78
79 $html = Element('p',
80                 htmlspecialchars(gettext("Currently archived versions of"))
81                 . " "
82                 . LinkExistingWikiWord($pagename));
83 $html .= Element('form', $formargs, $table);
84
85 echo GeneratePage('MESSAGE', $html, gettext("Revision History: ") . $pagename);
86
87
88 // Local Variables:
89 // mode: php
90 // tab-width: 8
91 // c-basic-offset: 4
92 // c-hanging-comment-ender-p: nil
93 // indent-tabs-mode: nil
94 // End:   
95 ?>