very close now
This commit is contained in:
parent
737cbf0fef
commit
5800dc1596
12 changed files with 228 additions and 216 deletions
|
|
@ -15,13 +15,13 @@
|
|||
|
||||
<div style="float: left; width: 50%;">
|
||||
<h3><a href="<tmpl_var recentChangesUrl>"><tmpl_var recentChangesLabel></a></h3>
|
||||
<ul><tmpl_loop recentChangesLoop>
|
||||
<ul><tmpl_loop recentChanges>
|
||||
<li><a href="<tmpl_var url>"><tmpl_var title></a></li>
|
||||
</tmpl_loop></ul>
|
||||
</div>
|
||||
<div style="float: left;">
|
||||
<h3><a href="<tmpl_var mostPopularUrl>"><tmpl_var mostPopularLabel></a></h3>
|
||||
<ul><tmpl_loop mostPopularLoop>
|
||||
<ul><tmpl_loop mostPopular>
|
||||
<li><a href="<tmpl_var url>"><tmpl_var title></a></li>
|
||||
</tmpl_loop></ul>
|
||||
|
||||
|
|
|
|||
14
docs/upgrades/templates-7.3.0/default-wiki-most-popular.tmpl
Normal file
14
docs/upgrades/templates-7.3.0/default-wiki-most-popular.tmpl
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
#WikiMPTmpl000000000001
|
||||
#create
|
||||
#namespace:WikiMaster_mostPopular
|
||||
#url:default-wiki-most-popular
|
||||
#title:Default Most Popular
|
||||
#menuTitle:Default Most Popular
|
||||
<h2><tmpl_var title></h2>
|
||||
|
||||
<ol><tmpl_loop mostPopular>
|
||||
<li><a href="<tmpl_var url>"><tmpl_var title></a></li>
|
||||
</tmpl_loop></ol>
|
||||
|
||||
<div style="padding: 8px;"><a href="<tmpl_var searchUrl>"><tmpl_var searchLabel></a> | <a href="<tmpl_var recentChangesUrl>"><tmpl_var recentChangesLabel></a> | <a href="<tmpl_var wikiHomeUrl>"><tmpl_var wikiHomeLabel></a></div>
|
||||
|
||||
|
|
@ -9,6 +9,9 @@
|
|||
<tbody>
|
||||
<tr><td><label for="title"><tmpl_var titleLabel></label></td><td><tmpl_var formTitle></td></tr>
|
||||
<tr><td><label for="content"><tmpl_var contentLabel></label></td><td><tmpl_var formContent></td></tr>
|
||||
<tmpl_if canAdminister>
|
||||
<tr><td><label for="isProtected"><tmpl_var protectQuestionLabel></label></td><td><tmpl_var formProtect></td></tr>
|
||||
</tmpl_if>
|
||||
<tmpl_if allowsAttachments>
|
||||
<tr><td><label for="storageId"><tmpl_var attachmentLabel></label></td><td><tmpl_var formAttachment></td></tr>
|
||||
</tmpl_if>
|
||||
|
|
@ -20,17 +23,7 @@
|
|||
<tmpl_if canAdminister><tmpl_unless isNew>
|
||||
<ul>
|
||||
<li><a href="<tmpl_var deleteUrl>"><tmpl_var deleteLabel></a></li>
|
||||
<li id="wikiPageProtect"><a href="javascript:wikiPageCall('<tmpl_var protectUrl>');"><tmpl_var protectLabel></a></li>
|
||||
<li id="wikiPageUnprotect"><a href="javascript:wikiPageCall('<tmpl_var unprotectUrl>');"><tmpl_var unprotectLabel></a></li>
|
||||
</ul>
|
||||
</tmpl_unless></tmpl_if>
|
||||
|
||||
<script type="text/javascript">
|
||||
var wikiPageIsProtected = <tmpl_var isProtected>;
|
||||
function wikiPageCall (url) {
|
||||
var request = YAHOO.util.Connect.asyncRequest('GET', url, { success:wikiPageCallSuccess, failure:wikiPageCallFail });
|
||||
}
|
||||
function wikiPageCallSuccess ( response ) {
|
||||
}
|
||||
</script>
|
||||
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
#title:Default Wiki Page
|
||||
#menuTitle:Default Wiki Page
|
||||
<tmpl_if session.var.adminOn><p><tmpl_var controls></p></tmpl_if>
|
||||
<tmpl_if displayTitle><h2><tmpl_var title></h2></tmpl_if>
|
||||
<h2><tmpl_var title></h2>
|
||||
|
||||
<div id="wikipage" class="yui-navset">
|
||||
<ul class="yui-nav">
|
||||
|
|
@ -34,7 +34,7 @@ initWikiTabs = function() {
|
|||
};
|
||||
initWikiTabs();
|
||||
</script>
|
||||
<div style="padding: 8px;"><a href="<tmpl_var searchUrl>"><tmpl_var searchLabel></a> | <a href="<tmpl_var recentChangesUrl>"><tmpl_var recentChangesLabel></a> | <a href="<tmpl_var wikiHomeUrl>"><tmpl_var wikiHomeLabel></a></div>
|
||||
<div style="padding: 8px;"><a href="<tmpl_var searchUrl>"><tmpl_var searchLabel></a> | <a href="<tmpl_var mostPopularUrl>"><tmpl_var mostPopularLabel></a> | <a href="<tmpl_var recentChangesUrl>"><tmpl_var recentChangesLabel></a> | <a href="<tmpl_var wikiHomeUrl>"><tmpl_var wikiHomeLabel></a></div>
|
||||
|
||||
~~~
|
||||
|
||||
|
|
|
|||
|
|
@ -4,16 +4,11 @@
|
|||
#url:default-wiki-recent-changes
|
||||
#title:Default Recent Changes
|
||||
#menuTitle:Default Recent Changes
|
||||
<tmpl_if session.var.adminOn><p><tmpl_var controls></p></tmpl_if>
|
||||
<tmpl_if displayTitle><h2><tmpl_var title></h2></tmpl_if>
|
||||
<h2><tmpl_var title></h2>
|
||||
|
||||
|
||||
<tmpl_loop rcDays>
|
||||
<h3><tmpl_var dayDate></h3>
|
||||
<ul><tmpl_loop dayEntries>
|
||||
<li><tmpl_var date> <tmpl_var time>: <a href="<tmpl_var viewLatest>"><tmpl_var title></a>
|
||||
<tmpl_var actionTakenLowerCase> by <tmpl_var username></li>
|
||||
<ul><tmpl_loop recentChanges>
|
||||
<li><a href="<tmpl_var url>"><tmpl_var title></a> <tmpl_var actionTaken> on <tmpl_var date> by <tmpl_var username></li>
|
||||
</tmpl_loop></ul>
|
||||
</tmpl_loop>
|
||||
<div style="padding: 8px;"><a href="<tmpl_var searchUrl>"><tmpl_var searchLabel></a> | <a href="<tmpl_var recentChangesUrl>"><tmpl_var recentChangesLabel></a> | <a href="<tmpl_var wikiHomeUrl>"><tmpl_var wikiHomeLabel></a></div>
|
||||
|
||||
<div style="padding: 8px;"><a href="<tmpl_var searchUrl>"><tmpl_var searchLabel></a> | <a href="<tmpl_var mostPopularUrl>"><tmpl_var mostPopularLabel></a> | <a href="<tmpl_var wikiHomeUrl>"><tmpl_var wikiHomeLabel></a></div>
|
||||
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@
|
|||
</tmpl_if>
|
||||
</tmpl_if>
|
||||
<div id="addFormGoesHere" style="display: none;"></div>
|
||||
<div style="padding: 8px;"><a href="<tmpl_var recentChangesUrl>"><tmpl_var recentChangesLabel></a> | <a href="<tmpl_var wikiHomeUrl>"><tmpl_var wikiHomeLabel></a></div>
|
||||
<div style="padding: 8px;"><a href="<tmpl_var mostPopularUrl>"><tmpl_var mostPopularLabel></a> | <a href="<tmpl_var recentChangesUrl>"><tmpl_var recentChangesLabel></a> | <a href="<tmpl_var wikiHomeUrl>"><tmpl_var wikiHomeLabel></a></div>
|
||||
|
||||
~~~
|
||||
<script type="text/javascript" src="^Extras(yui/build/yahoo/yahoo-min.js);"></script>
|
||||
|
|
|
|||
|
|
@ -64,14 +64,16 @@ sub addWikiAssets {
|
|||
default 'WikiPageTmpl0000000001',
|
||||
`pageEditTemplateId` varchar(22) character set utf8 collate utf8_bin NOT NULL
|
||||
default 'WikiPageEditTmpl000001',
|
||||
`recentChangesTemplateId` varchar(22) character set utf8 collate utf8_bin NOT NULL
|
||||
default 'WikiRCTmpl000000000001',
|
||||
`recentChangesTemplateId` varchar(22) character set utf8 collate utf8_bin NOT NULL default 'WikiRCTmpl000000000001',
|
||||
`mostPopularTemplateId` varchar(22) character set utf8 collate utf8_bin NOT NULL default 'WikiMPTmpl000000000001',
|
||||
`pageHistoryTemplateId` varchar(22) character set utf8 collate utf8_bin NOT NULL
|
||||
default 'WikiPHTmpl000000000001',
|
||||
`searchTemplateId` varchar(22) character set utf8 collate utf8_bin NOT NULL
|
||||
default 'WikiSearchTmpl00000001',
|
||||
`recentChangesCount` int(11) NOT NULL default 50,
|
||||
`recentChangesCountFront` int(11) NOT NULL default 10,
|
||||
`mostPopularCount` int(11) NOT NULL default 50,
|
||||
`mostPopularCountFront` int(11) NOT NULL default 10,
|
||||
`thumbnailSize` int(11) NOT NULL default 0,
|
||||
`maxImageSize` int(11) NOT NULL default 0,
|
||||
`approvalWorkflow` varchar(22) binary not null default 'pbworkflow000000000003',
|
||||
|
|
@ -85,6 +87,9 @@ EOT
|
|||
`content` mediumtext,
|
||||
`storageId` varchar(22) character set utf8 collate utf8_bin NULL,
|
||||
`views` bigint(20) NOT NULL default 0,
|
||||
isProtected int not null default 0,
|
||||
actionTaken varchar(35) not null,
|
||||
actionTakenBy varchar(22) binary not null,
|
||||
PRIMARY KEY (`assetId`, `revisionDate`)
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
|
||||
EOT
|
||||
|
|
@ -95,24 +100,6 @@ EOT
|
|||
`title` varchar(255) NOT NULL,
|
||||
PRIMARY KEY (`assetId`, `pageId`)
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
|
||||
EOT
|
||||
# Don't want protection to be versioned, so put it in a
|
||||
# separate table.
|
||||
<<'EOT',
|
||||
CREATE TABLE `WikiPage_protected` (
|
||||
`assetId` varchar(22) character set utf8 collate utf8_bin NOT NULL,
|
||||
PRIMARY KEY (`assetId`)
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
|
||||
EOT
|
||||
<<'EOT',
|
||||
CREATE TABLE `WikiPage_extraHistory` (
|
||||
`assetId` varchar(22) character set utf8 collate utf8_bin NOT NULL,
|
||||
`userId` varchar(22) character set utf8 collate utf8_bin NOT NULL,
|
||||
`dateStamp` bigint(20) NOT NULL,
|
||||
`actionTaken` varchar(255) NOT NULL,
|
||||
`url` varchar(255) NOT NULL,
|
||||
`title` varchar(255) NOT NULL
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
|
||||
EOT
|
||||
);
|
||||
|
||||
|
|
|
|||
|
|
@ -17,29 +17,6 @@ use WebGUI::International;
|
|||
use WebGUI::Storage::Image;
|
||||
use WebGUI::Utility;
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
# Buggo, semi-duplication with WikiMaster; move this into a common utility routine somewhere
|
||||
sub _appendFuncTemplateVars {
|
||||
my $self = shift;
|
||||
my $var = shift;
|
||||
my @funcs = @_;
|
||||
my $i18n = WebGUI::International->new($self->session, 'Asset_WikiPage');
|
||||
my %specialFuncs = ();
|
||||
my $revision = $self->session->form->process('revision');
|
||||
my $revisionSuffix = defined($revision)? ";revision=$revision" : '';
|
||||
@funcs = (qw/view edit pageHistory protect unprotect delete wikiPurgeRevision/) unless @funcs;
|
||||
|
||||
foreach my $func (@funcs) {
|
||||
$var->{$func.'Url'} = $self->getUrl($specialFuncs{$func}
|
||||
|| "func=$func$revisionSuffix");
|
||||
$var->{$func.'Label'} = $i18n->get("func $func link text");
|
||||
my $confirmation = $i18n->get("func $func link confirm");
|
||||
if (length $confirmation) {
|
||||
$confirmation =~ s/\'/\\\'/g;
|
||||
$var->{$func.'Confirm'} = "return confirm('$confirmation')";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
|
|
@ -128,6 +105,26 @@ sub definition {
|
|||
defaultValue => undef },
|
||||
content => { fieldType => "HTMLArea",
|
||||
defaultValue => undef },
|
||||
views => {
|
||||
fieldType => "integer",
|
||||
defaultValue => 0,
|
||||
noFormPost => 1
|
||||
},
|
||||
isProtected => {
|
||||
fieldType => "yesNo",
|
||||
defaultValue => 0,
|
||||
noFormPost => 1
|
||||
},
|
||||
actionTaken => {
|
||||
fieldType => "text",
|
||||
defaultValue => undef,
|
||||
noFormPost => 1
|
||||
},
|
||||
actionTakenBy => {
|
||||
fieldType => "user",
|
||||
defaultValue => undef,
|
||||
noFormPost => 1
|
||||
},
|
||||
);
|
||||
|
||||
push @$definition,
|
||||
|
|
@ -161,33 +158,33 @@ sub getEditForm {
|
|||
my $i18n = WebGUI::International->new($session, "Asset_WikiPage");
|
||||
my $newPage = 0;
|
||||
my $wiki = $self->getWiki;
|
||||
my $url = ($self->getId eq "new") ? $wiki->getUrl : $self->getUrl;
|
||||
my $var = {
|
||||
title=> $i18n->get("editing")." ".(defined($self->get('title'))? $self->get('title') : $i18n->get("assetName")),
|
||||
formHeader => WebGUI::Form::formHeader($session, { action => $wiki->getUrl })
|
||||
formHeader => WebGUI::Form::formHeader($session, { action => $url})
|
||||
.WebGUI::Form::hidden($session, { name => 'func', value => 'editSave' })
|
||||
.WebGUI::Form::hidden($session, { name=>"proceed", value=>$form->process("proceed") }),
|
||||
formTitle => WebGUI::Form::text($session, { name => 'title', maxlength => 255, size => 40, value => $self->get('title') }),
|
||||
formContent => WebGUI::Form::HTMLArea($session, { name => 'content', richEditId => $wiki->get('richEditor'), value => $self->get('content') }),
|
||||
formSubmit => WebGUI::Form::submit($session, { value => 'Save' }),
|
||||
formProtect => WebGUI::Form::yesNo($session, { name => "isProtected", value=>$self->getValue("isProtected")}),
|
||||
formAttachment => '',
|
||||
allowsAttachments => $wiki->get("maxAttachments"),
|
||||
formFooter => WebGUI::Form::formFooter($session),
|
||||
isNew => ($self->getId eq "new"),
|
||||
canAdminister => $wiki->canAdminister,
|
||||
deleteLabel => $i18n->get("deleteLabel"),
|
||||
deleteUrl => $self->getUrl("func=delete"),
|
||||
titleLabel => $i18n->get("titleLabel"),
|
||||
contentLabel => $i18n->get("contentLabel"),
|
||||
protectLabel => $i18n->get("attachmentLabel"),
|
||||
attachmentLabel => $i18n->get("attachmentLabel"),
|
||||
unprotectLabel => $i18n->get("attachmentLabel"),
|
||||
protectUrl => $self->get("func=protect"),
|
||||
unprotectUrl => $self->get("func=unprotect"),
|
||||
protectQuestionLabel => $i18n->get("protectQuestionLabel"),
|
||||
isProtected => $self->isProtected
|
||||
};
|
||||
if ($self->getId eq "new") {
|
||||
$var->{formHeader} .= WebGUI::Form::hidden($session, { name=>"assetId", value=>"new" })
|
||||
.WebGUI::Form::hidden($session, { name=>"class", value=>$form->process("class","className") });
|
||||
}
|
||||
$self->_appendFuncTemplateVars($var);
|
||||
return $self->processTemplate($var, $wiki->getValue('pageEditTemplateId'));
|
||||
}
|
||||
|
||||
|
|
@ -224,9 +221,7 @@ sub indexContent {
|
|||
#-------------------------------------------------------------------
|
||||
sub isProtected {
|
||||
my $self = shift;
|
||||
return $self->{_isProtected} if exists $self->{_isProtected};
|
||||
($self->{_isProtected}) = $self->session->db->quickArray("SELECT COUNT(assetId) FROM WikiPage_protected WHERE assetId = ?", [$self->getId]);
|
||||
return $self->{_isProtected};
|
||||
return $self->get("isProtected");
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
|
@ -246,35 +241,20 @@ sub prepareView {
|
|||
$self->preparePageTemplate;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub processPageTemplate {
|
||||
my $self = shift;
|
||||
my $content = shift;
|
||||
my $func = shift || $self->session->form->process('func');
|
||||
my $var = {};
|
||||
my $template = $self->preparePageTemplate;
|
||||
|
||||
$var->{content} = $content;
|
||||
$var->{canEdit} = $self->canEdit;
|
||||
$var->{couldEdit} = $self->couldEdit;
|
||||
$var->{canProtect} = $self->canProtect;
|
||||
$var->{canDelete} = $self->canDelete;
|
||||
$var->{isProtected} = $self->isProtected;
|
||||
$var->{inEdit} = isIn($func, qw/edit add/);
|
||||
$var->{inView} = isIn($func, qw/view/) || !defined $func;
|
||||
$var->{inHistory} = isIn($func, qw/pageHistory/);
|
||||
$self->_appendFuncTemplateVars($var);
|
||||
|
||||
return $self->processTemplate($var, undef, $template);
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub processPropertiesFromFormPost {
|
||||
my $self = shift;
|
||||
$self->SUPER::processPropertiesFromFormPost(@_);
|
||||
my $actionTaken = ($self->session->form->process("assetId") eq "new") ? "Created" : "Edited";
|
||||
$self->update({ groupIdView => $self->getWiki->get('groupIdView'),
|
||||
groupIdEdit => $self->getWiki->get('groupToAdminister'),
|
||||
isHidden => 1});
|
||||
isHidden => 1,
|
||||
actionTakenBy => $self->session->user->userId,
|
||||
actionTaken => $actionTaken});
|
||||
if ($self->canAdminister) {
|
||||
$self->update({isProtected => $self->session->form("isProtected")});
|
||||
}
|
||||
$self->getWiki->updateTitleIndex([$self], from => 'edit');
|
||||
delete $self->{_storageLocation};
|
||||
my $size = 0;
|
||||
|
|
@ -323,14 +303,6 @@ sub purgeRevision {
|
|||
return $self->SUPER::purgeRevision;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub updateWikiHistory {
|
||||
my $self = shift;
|
||||
my $action = shift;
|
||||
my $userId = shift || $self->session->user->userId;
|
||||
$self->session->db->write("INSERT INTO WikiPage_extraHistory (assetId, userId, dateStamp, actionTaken, url, title) VALUES (?, ?, ?, ?, ?, ?)", [$self->getId, $userId, $self->session->datetime->time, $action, $self->getUrl, $self->get('title')]);
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub view {
|
||||
my $self = shift;
|
||||
|
|
@ -341,11 +313,13 @@ sub view {
|
|||
historyLabel => $i18n->get("historyLabel"),
|
||||
wikiHomeLabel=>$i18n->get("wikiHomeLabel", "Asset_WikiMaster"),
|
||||
searchLabel=>$i18n->get("searchLabel", "Asset_WikiMaster"),
|
||||
recentChangesUrl=>$self->getUrl("func=recentChanges"),
|
||||
recentChangesUrl=>$self->getParent->getUrl("func=recentChanges"),
|
||||
recentChangesLabel=>$i18n->get("recentChangesLabel", "Asset_WikiMaster"),
|
||||
wikiHomeUrl=>$self->getUrl,
|
||||
mostPopularUrl=>$self->getParent->getUrl("func=mostPopular"),
|
||||
mostPopularLabel=>$i18n->get("mostPopularLabel", "Asset_WikiMaster"),
|
||||
wikiHomeUrl=>$self->getParent->getUrl,
|
||||
historyUrl=>$self->getUrl("func=getHistory"),
|
||||
editUrl=>$self->getUrl("func=getEditForm"),
|
||||
editUrl=>$self->getUrl("func=edit;ajax=1"),
|
||||
content => $self->getWiki->autolinkHtml($self->get('content')),
|
||||
};
|
||||
return $self->processTemplate($var, $self->getWiki->get("pageTemplateId"));
|
||||
|
|
@ -365,38 +339,33 @@ sub www_delete {
|
|||
sub www_edit {
|
||||
my $self = shift;
|
||||
return $self->session->privilege->insufficient unless $self->canEdit;
|
||||
if ($self->session->form->param("ajax")) {
|
||||
$self->session->style->sent(1);
|
||||
return $self->getEditForm;
|
||||
}
|
||||
return $self->getWiki->processStyle($self->getEditForm);
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_getEditForm {
|
||||
my $self = shift;
|
||||
return $self->session->privilege->insufficient unless $self->canEdit;
|
||||
return $self->getEditForm;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_getHistory {
|
||||
my $self = shift;
|
||||
# Buggo: hardcoded count
|
||||
my $var = {};
|
||||
$var->{title} = sprintf(WebGUI::International->new($self->session, 'Asset_WikiPage')->get('pageHistory title'), $self->get('title'));
|
||||
$self->getWiki->_appendPageHistoryVars($var, [0, 50], $self);
|
||||
my ($icon, $date) = $self->session->quick(qw(icon datetime));
|
||||
foreach my $revision (@{$self->getRevisions}) {
|
||||
my $user = WebGUI::User->new($self->session, $self->get("actionTakenBy"));
|
||||
push(@{$var->{pageHistoryEntries}}, {
|
||||
toolbar => $icon->delete("func=purgeRevision;revisionDate=".$self->get("revisionDate"), $self->get("url"), "Delete this revision?")
|
||||
.$icon->edit('func=edit;revision='.$self->get("revisionDate"), $self->get("url"))
|
||||
.$icon->view('func=view;revision='.$self->get("revisionDate"), $self->get("url")),
|
||||
date => $date->epochToHuman($self->get("revisionDate")),
|
||||
username => $user->username,
|
||||
actionTaken => $self->get("actionTaken"),
|
||||
interval => join(" ", $date->secondsToInterval(time() - $self->get("revisionDate")))
|
||||
});
|
||||
}
|
||||
return $self->processTemplate($var, $self->getWiki->get('pageHistoryTemplateId'));
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_protect {
|
||||
my $self = shift;
|
||||
return $self->session->privilege->insufficient unless $self->canProtect;
|
||||
return $self->www_view if $self->isProtected;
|
||||
$self->session->db->write("DELETE FROM WikiPage_protected WHERE assetId = ?", [$self->getId]);
|
||||
$self->session->db->write("INSERT INTO WikiPage_protected (assetId) VALUES (?)", [$self->getId]);
|
||||
$self->{_isProtected} = 1;
|
||||
$self->updateWikiHistory('protected');
|
||||
return $self->www_view;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 www_showConfirmation ( )
|
||||
|
|
@ -411,17 +380,6 @@ sub www_showConfirmation {
|
|||
return $self->getWiki->processStyle('<p>'.$i18n->get("page received").'</p><p><a href="'.$self->getWiki->getUrl.'">'.$i18n->get("493","WebGUI").'</a></p>');
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_unprotect {
|
||||
my $self = shift;
|
||||
return $self->session->privilege->insufficient unless $self->canProtect;
|
||||
return $self->www_view if !$self->isProtected;
|
||||
$self->session->db->write("DELETE FROM WikiPage_protected WHERE assetId = ?", [$self->getId]);
|
||||
$self->{_isProtected} = 0;
|
||||
$self->updateWikiHistory('unprotected');
|
||||
return $self->www_view;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_view {
|
||||
my $self = shift;
|
||||
|
|
@ -436,13 +394,5 @@ sub www_view {
|
|||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_wikiPurgeRevision {
|
||||
my $self = shift;
|
||||
return $self->session->privilege->insufficient unless $self->canDelete;
|
||||
$self->purgeRevision;
|
||||
$self->session->asset($self->getParent);
|
||||
return $self->getParent->www_view;
|
||||
}
|
||||
|
||||
1;
|
||||
|
|
|
|||
|
|
@ -33,21 +33,6 @@ sub _appendFuncTemplateVars {
|
|||
}
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub _appendPageHistoryVars {
|
||||
my $self = shift;
|
||||
my $var = shift;
|
||||
my $limit = shift;
|
||||
my $page = shift;
|
||||
my $time = $self->session->datetime->time;
|
||||
my $entries = $self->_templateSubvarsRefOfEdits($self->_editsRefOfPageHistory($page, $limit), $time);
|
||||
my $days = $self->_daysRefOfTemplateSubvars($entries);
|
||||
|
||||
$var->{'pageHistoryEntries'} = $entries;
|
||||
$var->{'pageHistoryDays'} = $days;
|
||||
return $self;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub _appendRecentChangesVars {
|
||||
my $self = shift;
|
||||
|
|
@ -114,14 +99,6 @@ sub _daysRefOfTemplateSubvars {
|
|||
return [map { {'dayDate' => $$_[0]{date}, 'dayEntries' => $_} } @days];
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub _editsRefOfPageHistory {
|
||||
my $self = shift;
|
||||
my $page = shift;
|
||||
my $limit = shift;
|
||||
$self->_editsRefOfQuery("a.assetId = ?", [$page->getId], undef, $limit);
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub _editsRefOfQuery {
|
||||
my $self = shift;
|
||||
|
|
@ -183,13 +160,11 @@ sub _templateSubvarOfEdit {
|
|||
$subvar->{isProtect} = ($subvar->{action} eq 'protected');
|
||||
$subvar->{isUnprotect} = ($subvar->{action} eq 'unprotected');
|
||||
$subvar->{isCreateOrEdit} = $subvar->{isEdit};
|
||||
|
||||
$subvar->{viewLatest} = $subvar->{url};
|
||||
$subvar->{editLatest} = $subvar->{url}.'?func=edit';
|
||||
|
||||
if ($subvar->{isEdit}) {
|
||||
$subvar->{viewRevision} = $subvar->{url}.'?func=view;revision='.$subvar->{dateStamp};
|
||||
$subvar->{editRevision} = $subvar->{url}.'?func=edit;revision='.$subvar->{dateStamp};
|
||||
my $icon = $self->session->icon;
|
||||
$subvar->{toolbar} = $icon->delete("func=purgeRevision;revisionDate=".$subvar->{dateStamp}, $subvar->{url}, "Delete this revision?")
|
||||
.$icon->edit('func=edit;revision='.$subvar->{dateStamp}, $subvar->{url})
|
||||
.$icon->view('func=view;revision='.$subvar->{dateStamp}, $subvar->{url});
|
||||
}
|
||||
|
||||
if ($subvar->{isEdit} and ($self->session->db->quickArray("SELECT MIN(revisionDate) FROM assetData WHERE assetId = ?", [$subvar->{assetId}]))[0] == $subvar->{dateStamp}) {
|
||||
|
|
@ -233,6 +208,43 @@ sub _templateSubvarsRefOfPages {
|
|||
return [map { $self->_templateSubvarOfPage($_) } @$pages];
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub appendMostPopular {
|
||||
my $self = shift;
|
||||
my $var = shift;
|
||||
my $limit = shift || $self->get("mostPopularCount");
|
||||
my $rs = $self->session->db->read("select asset.assetId, assetData.revisionDate from assetData left join asset on assetData.assetId=asset.assetId
|
||||
left join WikiPage on WikiPage.assetId=assetData.assetId and WikiPage.revisionDate=assetData.revisionDate
|
||||
where lineage like ? and lineage<>? order by views limit ?", [$self->get("lineage").'%', $self->get("lineage"), $limit]);
|
||||
while (my ($id, $version) = $rs->array) {
|
||||
my $asset = WebGUI::Asset->new($self->session, $id, "WebGUI::Asset::WikiPage", $version);
|
||||
push(@{$var->{mostPopular}}, {
|
||||
title=>$asset->getTitle,
|
||||
url=>$asset->getUrl,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub appendRecentChanges {
|
||||
my $self = shift;
|
||||
my $var = shift;
|
||||
my $limit = shift || $self->get("recentChangesCount");
|
||||
my $rs = $self->session->db->read("select asset.assetId, revisionDate from assetData left join asset on assetData.assetId=asset.assetId where
|
||||
lineage like ? and lineage<>? order by revisionDate limit ?", [$self->get("lineage").'%', $self->get("lineage"), $self->get("recentChangesCount")]);
|
||||
while (my ($id, $version) = $rs->array) {
|
||||
my $asset = WebGUI::Asset->new($self->session, $id, "WebGUI::Asset::WikiPage", $version);
|
||||
my $user = WebGUI::User->new($self->session, $asset->get("actionTakenBy"));
|
||||
push(@{$var->{recentChanges}}, {
|
||||
title=>$asset->getTitle,
|
||||
url=>$asset->getUrl,
|
||||
actionTaken=>$asset->get("lastAction"),
|
||||
username=>$user->username,
|
||||
date=>$self->session->datetime->epochToHuman($asset->get("revisionDate"))
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub autolinkHtml {
|
||||
my $self = shift;
|
||||
|
|
@ -345,6 +357,13 @@ sub definition {
|
|||
hoverHelp => $i18n->get('pageHistoryTemplateId hoverHelp'),
|
||||
label => $i18n->get('pageHistoryTemplateId label') },
|
||||
|
||||
mostPopularTemplateId => { fieldType => 'template',
|
||||
namespace => 'WikiMaster_mostPopular',
|
||||
defaultValue => 'WikiMPTmpl000000000001',
|
||||
tab => 'display',
|
||||
hoverHelp => $i18n->get('mostPopularTemplateId hoverHelp'),
|
||||
label => $i18n->get('mostPopularTemplateId label') },
|
||||
|
||||
recentChangesTemplateId => { fieldType => 'template',
|
||||
namespace => 'WikiMaster_recentChanges',
|
||||
defaultValue => 'WikiRCTmpl000000000001',
|
||||
|
|
@ -377,6 +396,18 @@ sub definition {
|
|||
tab => 'display',
|
||||
hoverHelp => $i18n->get('recentChangesCountFront hoverHelp'),
|
||||
label => $i18n->get('recentChangesCountFront label') },
|
||||
|
||||
mostPopularCount => { fieldType => 'integer',
|
||||
defaultValue => 50,
|
||||
tab => 'display',
|
||||
hoverHelp => $i18n->get('mostPopularCount hoverHelp'),
|
||||
label => $i18n->get('mostPopularCount label') },
|
||||
|
||||
mostPopularCountFront => { fieldType => 'integer',
|
||||
defaultValue => 10,
|
||||
tab => 'display',
|
||||
hoverHelp => $i18n->get('mostPopularCountFront hoverHelp'),
|
||||
label => $i18n->get('mostPopularCountFront label') },
|
||||
approvalWorkflow =>{
|
||||
fieldType=>"workflow",
|
||||
defaultValue=>"pbworkflow000000000003",
|
||||
|
|
@ -414,14 +445,6 @@ sub definition {
|
|||
return $class->SUPER::definition($session, $definition);
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub getContentLastModified {
|
||||
my $self = shift;
|
||||
my ($lastModified) = $self->session->db->quickArray("SELECT MAX(d.revisionDate) FROM assetData AS d INNER JOIN asset AS a ON a.assetId = d.assetId WHERE a.lineage LIKE CONCAT(?, '%')", [$self->get('lineage')]);
|
||||
return $lastModified;
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub prepareView {
|
||||
my $self = shift;
|
||||
|
|
@ -481,21 +504,47 @@ sub view {
|
|||
};
|
||||
my $template = $self->{_frontPageTemplate};
|
||||
$self->_appendSearchBoxVars($var);
|
||||
$self->_appendRecentChangesVars($var, [0, $self->get('recentChangesCountFront')]);
|
||||
$self->appendRecentChanges($var, $self->get('recentChangesCountFront'));
|
||||
$self->appendMostPopular($var, $self->get('mostPopularCountFront'));
|
||||
$self->_appendFuncTemplateVars($var, qw/recentChanges/);
|
||||
return $self->processTemplate($var, undef, $template);
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_mostPopular {
|
||||
my $self = shift;
|
||||
my $i18n = WebGUI::International->new($self->session, "Asset_WikiMaster");
|
||||
my $var = {
|
||||
resultsLabel=>$i18n->get("resultsLabel"),
|
||||
title => WebGUI::International->new($self->session, 'Asset_WikiMaster')->get('recentChanges title'),
|
||||
wikiHomeLabel=>$i18n->get("wikiHomeLabel"),
|
||||
searchLabel=>$i18n->get("searchLabel"),
|
||||
searchUrl=>$self->getUrl("func=search"),
|
||||
recentChangesUrl=>$self->getUrl("func=recentChanges"),
|
||||
recentChangesLabel=>$i18n->get("recentChangesLabel"),
|
||||
wikiHomeUrl=>$self->getUrl,
|
||||
};
|
||||
$self->appendMostPopular($var);
|
||||
return $self->processStyle($self->processTemplate($var, $self->get('recentChangesTemplateId')));
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_recentChanges {
|
||||
my $self = shift;
|
||||
my $template = WebGUI::Asset::Template->new($self->session, $self->get('recentChangesTemplateId'));
|
||||
$template->prepare;
|
||||
my $var = {};
|
||||
$var->{title} = WebGUI::International->new($self->session, 'Asset_WikiMaster')->get('recentChanges title');
|
||||
$self->_appendRecentChangesVars($var, [0, $self->get('recentChangesCount')]);
|
||||
return $self->processStyle($self->processTemplate($var, undef, $template));
|
||||
my $i18n = WebGUI::International->new($self->session, "Asset_WikiMaster");
|
||||
my $var = {
|
||||
resultsLabel=>$i18n->get("resultsLabel"),
|
||||
title => WebGUI::International->new($self->session, 'Asset_WikiMaster')->get('recentChanges title'),
|
||||
wikiHomeLabel=>$i18n->get("wikiHomeLabel"),
|
||||
searchLabel=>$i18n->get("searchLabel"),
|
||||
searchUrl=>$self->getUrl("func=search"),
|
||||
mostPopularUrl=>$self->getUrl("func=mostPopular"),
|
||||
mostPopularLabel=>$i18n->get("mostPopularLabel"),
|
||||
wikiHomeUrl=>$self->getUrl,
|
||||
};
|
||||
$self->appendRecentChanges($var);
|
||||
return $self->processStyle($self->processTemplate($var, $self->get('recentChangesTemplateId')));
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
|
@ -511,8 +560,10 @@ sub www_search {
|
|||
searchLabel=>$i18n->get("searchLabel"),
|
||||
recentChangesUrl=>$self->getUrl("func=recentChanges"),
|
||||
recentChangesLabel=>$i18n->get("recentChangesLabel"),
|
||||
mostPopularUrl=>$self->getUrl("func=mostPopular"),
|
||||
mostPopularLabel=>$i18n->get("mostPopularLabel"),
|
||||
wikiHomeUrl=>$self->getUrl,
|
||||
getEditFormUrl=>$self->getUrl("func=add;class=WebGUI::Asset::WikiPage"),
|
||||
getEditFormUrl=>$self->getUrl("func=add;class=WebGUI::Asset::WikiPage;ajax=1"),
|
||||
};
|
||||
my $queryString = $self->session->form->process('query', 'text');
|
||||
$self->_appendSearchBoxVars($var, $queryString);
|
||||
|
|
|
|||
|
|
@ -135,6 +135,33 @@ sub getRevisionCount {
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getRevisions ( [ status ] )
|
||||
|
||||
Returns an array reference of the revision objects of this asset.
|
||||
|
||||
=head3 status
|
||||
|
||||
Optionally specify to get the revisions based upon the status of the revisions. Options are "approved", "archived", or "pending". Defaults to any status.
|
||||
|
||||
=cut
|
||||
|
||||
sub getRevisions {
|
||||
my $self = shift;
|
||||
my $status = shift;
|
||||
my $statusClause = "";
|
||||
if ($status) {
|
||||
$statusClause = " and status=".$self->session->db->quote($status);
|
||||
}
|
||||
my @revisions = ();
|
||||
my $rs = $self->session->db->read("select revisionDate from assetData where assetId=".$self->session->db->quote($self->getId).$statusClause);
|
||||
while (my ($version) = $rs->array) {
|
||||
push(@revisions, WebGUI::Asset->new($self->session, $self->getId, $self->get("className"), $version));
|
||||
}
|
||||
return \@revisions;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getTagCount ( )
|
||||
|
||||
Returns the number of tags that have been attached to this asset. Think of it sort of like an absolute revision count, rather than counting the number of actual edits, we're counting the number of tags opened against this asset to be edited.
|
||||
|
|
|
|||
|
|
@ -73,10 +73,11 @@ our $I18N =
|
|||
'frontPageTemplateId label' =>
|
||||
{ lastUpdated => 1161031607, message => q|Front Page Template| },
|
||||
|
||||
'recentChangesTemplateId hoverHelp' =>
|
||||
{ lastUpdated => 1160157064, message => q|Which template to use for the recent changes display.| },
|
||||
'recentChangesTemplateId label' =>
|
||||
{ lastUpdated => 1160157064, message => q|Recent Changes Template| },
|
||||
'recentChangesTemplateId hoverHelp' => { lastUpdated => 1160157064, message => q|Which template to use for the recent changes display.| },
|
||||
'recentChangesTemplateId label' => { lastUpdated => 1160157064, message => q|Recent Changes Template| },
|
||||
|
||||
'mostPopularTemplateId hoverHelp' => { lastUpdated => 1160157064, message => q|Which template should be used to display the most popular listing?| },
|
||||
'mostPopularTemplateId label' => { lastUpdated => 1160157064, message => q|Most Popular Template| },
|
||||
|
||||
'pageHistoryTemplateId hoverHelp' =>
|
||||
{ lastUpdated => 1160505291, message => q|Which template to use for the page history display.| },
|
||||
|
|
@ -88,14 +89,15 @@ our $I18N =
|
|||
'searchTemplateId label' =>
|
||||
{ lastUpdated => 1161031607, message => q|Search Template| },
|
||||
|
||||
'recentChangesCount hoverHelp' =>
|
||||
{ lastUpdated => 1161031607, message => q|Maximum number of changes to display on the recent changes page.| },
|
||||
'recentChangesCount label' =>
|
||||
{ lastUpdated => 1161031607, message => q|Recent Changes Count| },
|
||||
'recentChangesCountFront hoverHelp' =>
|
||||
{ lastUpdated => 1161031607, message => q|Maximum number of changes to display on the front page.| },
|
||||
'recentChangesCountFront label' =>
|
||||
{ lastUpdated => 1161031607, message => q|Front Page Recent Changes Count| },
|
||||
'recentChangesCount hoverHelp' => { lastUpdated => 1161031607, message => q|Maximum number of changes to display on the recent changes page.| },
|
||||
'recentChangesCount label' => { lastUpdated => 1161031607, message => q|Recent Changes Count| },
|
||||
'recentChangesCountFront hoverHelp' => { lastUpdated => 1161031607, message => q|Maximum number of changes to display on the front page.| },
|
||||
'recentChangesCountFront label' => { lastUpdated => 1161031607, message => q|Front Page Recent Changes Count| },
|
||||
|
||||
'mostPopularCount hoverHelp' => { lastUpdated => 1161031607, message => q|Maximum number of popular page links to display on the most popular page.| },
|
||||
'mostPopularCount label' => { lastUpdated => 1161031607, message => q|Most Popular Count| },
|
||||
'mostPopularCountFront hoverHelp' => { lastUpdated => 1161031607, message => q|Maximum number of popular page links to display on the front page.| },
|
||||
'mostPopularCountFront label' => { lastUpdated => 1161031607, message => q|Front Page Most Popular Count| },
|
||||
|
||||
'func addPage link text' =>
|
||||
{ lastUpdated => 1160157064, message => q|Add a new page| },
|
||||
|
|
|
|||
|
|
@ -2,24 +2,17 @@ package WebGUI::i18n::English::Asset_WikiPage;
|
|||
|
||||
our $I18N =
|
||||
{
|
||||
'protectQuestionLabel' => { lastUpdated => 1160157064, message => 'Protect this page from editing?' },
|
||||
'titleLabel' => { lastUpdated => 1160157064, message => 'Title' },
|
||||
'contentLabel' => { lastUpdated => 1160157064, message => 'Content' },
|
||||
'attachmentLabel' => { lastUpdated => 1160157064, message => 'Attachment(s)' },
|
||||
'editing' => { lastUpdated => 1160157064, message => 'Editing' },
|
||||
'assetName' => { lastUpdated => 1160157064, message => 'Wiki Page' },
|
||||
|
||||
'page received' => { lastUpdated => 1160157064, message => q|Your page has been received and is being processed so it can be added to the site. It will be available for further editing after being processed. Please be patient.| },
|
||||
'editLabel' => { lastUpdated => 1160157064, message => q|Edit| },
|
||||
'viewLabel' => { lastUpdated => 1160157064, message => q|View| },
|
||||
'historyLabel' => { lastUpdated => 1160425002, message => q|History| },
|
||||
'protectLabel' => { lastUpdated => 1160425002, message => q|Protect| },
|
||||
'unprotectLabel' => { lastUpdated => 1160425002, message => q|Unprotect| },
|
||||
'deleteLabel' => { lastUpdated => 1161121377, message => q|Delete| },
|
||||
'func wikiPurgeRevision link text' => { lastUpdated => 1161121377, message => q|Delete this revision of this page| },
|
||||
'func delete link confirm' => { lastUpdated => 1161121377, message => q|Are you sure you want to delete this page? Deletions cannot be stored within version tags and take place immediately.| },
|
||||
'func wikiPurgeRevision link confirm' => { lastUpdated => 1161121377, message => q|Are you sure you want to delete this revision of this page? The revision will be permanently erased.| },
|
||||
|
||||
'pageHistory title' => { lastUpdated => 1161113157, message => q|History of "%s"| },
|
||||
};
|
||||
|
||||
1;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue