wiki.pl: Port some fixes from upstream
[Orgmuse.git] / modules / plainsite.pl
blob48ab847c24255441b7e92bae6faf15b877ac1012
1 # Copyright (C) 2005-2007 Fletcher T. Penney <fletcher@freeshell.org>
3 # This program is free software; you can redistribute it and/or modify
4 # it under the terms of the GNU General Public License as published by
5 # the Free Software Foundation; either version 2 of the License, or
6 # (at your option) any later version.
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License for more details.
13 # You should have received a copy of the GNU General Public License
14 # along with this program; if not, write to the
15 # Free Software Foundation, Inc.
16 # 59 Temple Place, Suite 330
17 # Boston, MA 02111-1307 USA
19 $ModulesDescription .= '<p><a href="http://git.savannah.gnu.org/cgit/oddmuse.git/tree/modules/plainsite.pl">plainsite.pl</a>, see <a href="http://www.oddmuse.org/cgi-bin/oddmuse/PlainSite_Module">PlainSite Module</a></p>';
21 use vars qw($PlainSiteAllowCommentLink);
23 *OldGetFooterLinks = *GetFooterLinks;
24 *GetFooterLinks = *PlainSiteGetFooterLinks;
26 sub PlainSiteGetFooterLinks {
27 return if (GetParam('action','') eq 'static');
28 if (UserIsAdmin() or UserIsEditor()) {
29 return OldGetFooterLinks(@_);
30 } else {
31 if ($PlainSiteAllowCommentLink) {
32 return CommentFooterLink(@_);
33 } else {
34 return;
39 sub CommentFooterLink {
40 my ($id, $rev) = @_;
41 my @elements;
42 if ($id and $rev ne 'history' and $rev ne 'edit') {
43 if ($CommentsPrefix) {
44 if ($OpenPageName =~ /^$CommentsPrefix(.*)/o) {
45 push(@elements, GetPageLink($1, undef, 'original'));
46 } else {
47 push(@elements, GetPageLink($CommentsPrefix . $OpenPageName, undef, 'comment'));
51 return @elements ? $q->span({-class=>'edit bar'}, $q->br(), @elements) : '';
54 *OldGetFooterTimestamp = *GetFooterTimestamp;
55 *GetFooterTimestamp = *PlainSiteGetFooterTimestamp;
57 sub PlainSiteGetFooterTimestamp {
58 return if (GetParam('action','') eq 'static');
59 if (UserIsAdmin() or UserIsEditor()) {
60 return OldGetFooterTimestamp(@_);
61 } else {
62 return;
66 *OldGetRcRss = *GetRcRss;
67 *GetRcRss = *PlainSiteGetRcRss;
69 sub PlainSiteGetRcRss {
70 # Have Rss point to HomePage rather than RecentChanges, since we want
71 # to avoid drawing visitors to RecentChanges
72 $RCName = $HomePage;
73 OldGetRcRss(@_);
76 *GetNearLinksUsed = *PlainSiteGetNearLinksUsed;
78 sub PlainSiteGetNearLinksUsed {
79 return;
83 # Disable the Recent Change function on cluster pages
84 # Must load before clustermap module if that module is used
87 *OldPrintRc = *PrintRc;
88 *PrintRc = *PlainSitePrintRc;
90 sub PlainSitePrintRc{
91 my ($id, $standalone) = @_;
92 if (!(UserIsAdmin() or UserIsEditor())) {
93 DoRc(\&PlainSiteRcHtml);
94 } else {
95 return OldPrintRc($id, $standalone);
99 sub PlainSiteRcHtml {
100 my ($html, $inlist) = ('', 0);
101 if (!(UserIsAdmin() or UserIsEditor())) {
102 return;
103 } else {
104 *GetRcHtml = *OldGetRcHtml;
105 return OldGetRcHtml();