]> CyberLeo.Net >> Repos - SourceForge/phpwiki.git/blob - lib/pageinfo.php
New file.
[SourceForge/phpwiki.git] / lib / pageinfo.php
1 <?php
2 rcs_id('$Id: pageinfo.php,v 1.12 2001-10-29 18:24:26 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' => 'hidden',
75                                    'name' => 'pagename',
76                                    'value' => $pagename)) . "\n"
77           . Element('input', array('type' => 'submit', 'value' => 'Run Diff')) . "\n");
78
79 $formargs['action'] = USE_PATH_INFO ? WikiURL($pagename) : SCRIPT_NAME;
80 $formargs['method'] = 'post';
81
82 $html = Element('p',
83                 htmlspecialchars(gettext("Currently archived versions of"))
84                 . " "
85                 . LinkExistingWikiWord($pagename));
86 $html .= Element('form', $formargs, $table);
87
88 echo GeneratePage('MESSAGE', $html, gettext("Revision History: ") . $pagename);
89
90
91 // Local Variables:
92 // mode: php
93 // tab-width: 8
94 // c-basic-offset: 4
95 // c-hanging-comment-ender-p: nil
96 // indent-tabs-mode: nil
97 // End:   
98 ?>