Merge branch 'master' of git@github.com:plainblack/webgui
This commit is contained in:
commit
945017d762
46 changed files with 1496 additions and 492 deletions
|
|
@ -350,7 +350,8 @@ sub view {
|
|||
my $self = shift;
|
||||
if (!$self->session->var->isAdminOn && $self->get("cacheTimeout") > 10 && !$self->session->form->process("overrideTemplateId") &&
|
||||
!$self->session->form->process($self->paginateVar) && !$self->session->form->process("makePrintable")) {
|
||||
my $out = WebGUI::Cache->new($self->session,"view_".$self->getId)->get;
|
||||
my $cache = $self->getCache;
|
||||
my $out = $cache->get if defined $cache;
|
||||
return $out if $out;
|
||||
}
|
||||
my %var;
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -1572,6 +1572,23 @@ sub view {
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 www_edit
|
||||
|
||||
Override the master class to add an "Unarchive All" link.
|
||||
|
||||
=cut
|
||||
|
||||
sub www_edit {
|
||||
my $self = shift;
|
||||
return $self->session->privilege->insufficient() unless $self->canEdit;
|
||||
return $self->session->privilege->locked() unless $self->canEditIfLocked;
|
||||
my $i18n = WebGUI::International->new($self->session, 'Asset_Collaboration');
|
||||
$self->getAdminConsole->addConfirmedSubmenuItem($self->getUrl('func=unarchiveAll'),$i18n->get("unarchive all"),$i18n->get("unarchive confirm"));
|
||||
return $self->getAdminConsole->render($self->getEditForm->print,$i18n->get("assetName"));
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 www_search ( )
|
||||
|
||||
The web method to display and use the forum search interface.
|
||||
|
|
@ -1627,6 +1644,35 @@ sub www_subscribe {
|
|||
return $self->www_view;
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
=head2 www_unarchiveAll ( )
|
||||
|
||||
Unarchive all the threads in this collaboration system
|
||||
|
||||
=cut
|
||||
|
||||
sub www_unarchiveAll {
|
||||
my ( $self ) = @_;
|
||||
my $session = $self->session;
|
||||
return $session->privilege->insufficient() unless $self->canEdit;
|
||||
my $pb = WebGUI::ProgressBar->new($session);
|
||||
my $i18n = WebGUI::International->new($session, 'Asset_Collaboration');
|
||||
$pb->start($i18n->get('unarchive all'), $self->getUrl('func=edit'));
|
||||
my $threadIds = $self->getLineage(['children'],{
|
||||
includeOnlyClasses => [ 'WebGUI::Asset::Post::Thread' ],
|
||||
statusToInclude => [ 'archived' ],
|
||||
} );
|
||||
ASSET: foreach my $threadId (@$threadIds) {
|
||||
my $thread = WebGUI::Asset->newPending($session, $threadId);
|
||||
if (!$thread || !$thread->canEdit) {
|
||||
next ASSET;
|
||||
}
|
||||
$thread->unarchive;
|
||||
}
|
||||
return $pb->finish( $self->getUrl('func=edit') );
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 www_unsubscribe ( )
|
||||
|
|
|
|||
|
|
@ -409,12 +409,8 @@ sub www_view {
|
|||
) {
|
||||
my $check = $self->checkView;
|
||||
return $check if (defined $check);
|
||||
my $cacheKey = "view_".$self->getId;
|
||||
if ($session->env->sslRequest) {
|
||||
$cacheKey .= '_ssl';
|
||||
}
|
||||
my $cache = WebGUI::Cache->new($session, $cacheKey);
|
||||
my $out = $cache->get if defined $cache;
|
||||
my $cache = $self->getCache;
|
||||
my $out = $cache->get if defined $cache;
|
||||
unless ($out) {
|
||||
$self->prepareView;
|
||||
$session->stow->set("cacheFixOverride", 1);
|
||||
|
|
|
|||
|
|
@ -644,7 +644,6 @@ sub view {
|
|||
|
||||
my ($varStatistics,$varStatisticsEncoded);
|
||||
my $var = $self->get;
|
||||
$var->{listing_loop} = $self->getListings;
|
||||
$var->{isLoggedIn} = ($session->user->userId ne "1");
|
||||
$var->{addMatrixListing_url} = $self->getUrl('func=add;class=WebGUI::Asset::MatrixListing');
|
||||
$var->{exportAttributes_url} = $self->getUrl('func=exportAttributes');
|
||||
|
|
@ -1193,6 +1192,7 @@ sub www_getCompareFormData {
|
|||
if($form->process("search")) {
|
||||
if ($searchParamList) {
|
||||
RESULT: foreach my $result (@{$self->getListings}) {
|
||||
my $checked = '';
|
||||
my $matrixListing_attributes = $session->db->buildHashRefOfHashRefs("
|
||||
select value, fieldType, attributeId from Matrix_attribute
|
||||
left join MatrixListing_attribute as listing using(attributeId)
|
||||
|
|
@ -1203,24 +1203,21 @@ sub www_getCompareFormData {
|
|||
my $fieldType = $matrixListing_attributes->{$param->{attributeId}}->{fieldType};
|
||||
my $listingValue = $matrixListing_attributes->{$param->{attributeId}}->{value};
|
||||
if(($fieldType eq 'MatrixCompare') && ($listingValue < $param->{value})){
|
||||
$result->{checked} = '';
|
||||
last PARAM;
|
||||
}
|
||||
elsif(($fieldType ne 'MatrixCompare' && $fieldType ne '') && ($param->{value} ne $listingValue)){
|
||||
$result->{checked} = '';
|
||||
last PARAM;
|
||||
}
|
||||
else{
|
||||
$result->{checked} = 'checked';
|
||||
$checked = 'checked';
|
||||
}
|
||||
}
|
||||
$result->{assetId} =~ s/-/_____/g;
|
||||
push @results, $result if $result->{checked} eq 'checked';
|
||||
push @results, $result if $checked eq 'checked';
|
||||
}
|
||||
}
|
||||
else {
|
||||
foreach my $result (@{$self->getListings}) {
|
||||
$result->{checked} = 'checked';
|
||||
$result->{assetId} =~ s/-/_____/g;
|
||||
push @results, $result;
|
||||
}
|
||||
|
|
@ -1390,7 +1387,7 @@ sub www_listAttributes {
|
|||
|
||||
=head2 www_search ( )
|
||||
|
||||
Returns the search screen.
|
||||
Returns the search screen. Uses www_getCompareFormData with search=1 for doing AJAX requests.
|
||||
|
||||
=cut
|
||||
|
||||
|
|
|
|||
|
|
@ -130,7 +130,8 @@ to be displayed within the page style
|
|||
sub view {
|
||||
my $self = shift;
|
||||
if (!$self->session->var->isAdminOn && $self->get("cacheTimeout") > 10) {
|
||||
my $out = WebGUI::Cache->new($self->session,"view_".$self->getId)->get;
|
||||
my $cache = $self->getCache;
|
||||
my $out = $cache->get if defined $cache;
|
||||
return $out if $out;
|
||||
}
|
||||
my $i18n = WebGUI::International->new($self->session, 'Asset_MultiSearch');
|
||||
|
|
|
|||
|
|
@ -534,7 +534,8 @@ if the user is not in Admin Mode.
|
|||
sub view {
|
||||
my $self = shift;
|
||||
if (!$self->session->var->isAdminOn && $self->get("cacheTimeout") > 10) {
|
||||
my $out = WebGUI::Cache->new($self->session,"view_".$self->getId)->get;
|
||||
my $cache = $self->getCache;
|
||||
my $out = $cache->get if defined $cache;
|
||||
return $out if $out;
|
||||
}
|
||||
# Initiate an empty debug loop
|
||||
|
|
|
|||
|
|
@ -159,7 +159,7 @@ sub appendSearchBoxVars {
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 autolinkHtml ($html)
|
||||
=head2 autolinkHtml ($html, [options])
|
||||
|
||||
Scan HTML for words and phrases that match wiki titles, and automatically
|
||||
link them to those wiki pages. Returns the modified HTML.
|
||||
|
|
@ -168,6 +168,14 @@ link them to those wiki pages. Returns the modified HTML.
|
|||
|
||||
The HTML to scan.
|
||||
|
||||
=head3 options
|
||||
|
||||
Either a hashref, or a hash of options.
|
||||
|
||||
=head4 skipTitles
|
||||
|
||||
An array reference of titles that should not be autolinked.
|
||||
|
||||
=cut
|
||||
|
||||
sub autolinkHtml {
|
||||
|
|
@ -175,18 +183,21 @@ sub autolinkHtml {
|
|||
my $html = shift;
|
||||
# opts is always the last parameter, and a hash ref
|
||||
my %opts = ref $_[-1] eq 'HASH' ? %{pop @_} : ();
|
||||
my $skipTitles = $opts{skipTitles} || [];
|
||||
$opts{skipTitles} ||= [];
|
||||
|
||||
# LC all the skip titles once, for efficiency
|
||||
my @skipTitles = map { lc $_ } @{ $opts{skipTitles} };
|
||||
# TODO: ignore caching for now, but maybe do it later.
|
||||
my %mapping = $self->session->db->buildHash("SELECT LOWER(d.title), d.url FROM asset AS i INNER JOIN assetData AS d ON i.assetId = d.assetId WHERE i.parentId = ? and className='WebGUI::Asset::WikiPage' and i.state='published' and d.status='approved'", [$self->getId]);
|
||||
foreach my $key (keys %mapping) {
|
||||
if (grep {lc $_ eq $key} @$skipTitles) {
|
||||
delete $mapping{$key};
|
||||
next;
|
||||
}
|
||||
$key =~ s{\(}{\\\(}gxms; # escape parens
|
||||
$key =~ s{\)}{\\\)}gxms; # escape parens
|
||||
$mapping{$key} = $self->session->url->gateway($mapping{$key});
|
||||
}
|
||||
# This query returns multiple entries for each asset, so we order by revisionDate and count on the hash to only have the
|
||||
# latest version.
|
||||
my %mapping = $self->session->db->buildHash("SELECT LOWER(d.title), d.url FROM asset AS i INNER JOIN assetData AS d ON i.assetId = d.assetId WHERE i.parentId = ? and className='WebGUI::Asset::WikiPage' and i.state='published' and d.status='approved' order by d.revisionDate ASC", [$self->getId]);
|
||||
TITLE: foreach my $title (keys %mapping) {
|
||||
my $url = delete $mapping{$title};
|
||||
##isIn short circuits and is faster than grep and/or first
|
||||
next TITLE if isIn($title, @skipTitles);
|
||||
$mapping{$title} = $self->session->url->gateway($url);
|
||||
}
|
||||
|
||||
return $html unless %mapping;
|
||||
# sort by length so it prefers matching longer titles
|
||||
my $matchString = join('|', map{quotemeta} sort {length($b) <=> length($a)} keys %mapping);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue