X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=rt%2Fshare%2Fhtml%2FArticles%2FTopics.html;h=5187315f7acf97831ac51e5ba797dd71f78a525e;hb=c24d6e2242ae0e026684b8f95decf156aba6e75e;hp=9a07c089ad58788f6e55679bfadc9f9cea162e25;hpb=6686c29104e555ea23446fe1db330664fa110bc0;p=freeside.git diff --git a/rt/share/html/Articles/Topics.html b/rt/share/html/Articles/Topics.html index 9a07c089a..5187315f7 100644 --- a/rt/share/html/Articles/Topics.html +++ b/rt/share/html/Articles/Topics.html @@ -48,7 +48,6 @@ <& /Elements/Header, Title => loc('Browse by topic') &> <& /Elements/Tabs &> -<& /Elements/ListActions, actions => \@Actions &> <&|/l&>All topics % if (defined $class) { > <% $currclass_name %> @@ -59,71 +58,41 @@ % }

<&|/l&>Browse by topic

-<%perl> -if (defined $class) { - $m->print('

'.''.$currclass_name."

\n"); - ProduceTree(\@Actions, $currclass, $currclass_id, $currclass_name, 0, $id); -} else { - $m->print("\n"); -} - +% if (defined $class) { +

<% $currclass_name %>

+% my $rtopic = RT::Topic->new( $session{'CurrentUser'} ); +% $rtopic->Load($id); +% unless ( $rtopic->Id() +% && $rtopic->ObjectId() == $currclass->Id ) +% { +% # Show all of them +% $ProduceTree->( 0 ); +% } else { +% my @showtopics = ( $rtopic ); +% my $parent = $rtopic->ParentObj; +% while ( $parent->Id ) { +% unshift @showtopics, $parent; +% $parent = $parent->ParentObj; +% } +% # List the topics. +% for my $t ( @showtopics ) { + +% } +% } +% } else { + +% }
-<%perl> -my @articles; -if ($id or $showall) { - my $Articles = RT::ObjectTopics->new($session{'CurrentUser'}); - $Articles->Limit(FIELD => 'ObjectType', VALUE => 'RT::Article'); - if ($id) { - $Articles->Limit(FIELD => 'Topic', VALUE => $id, ENTRYAGGREGATOR => 'OR'); - if ($showall) { - my $kids = $currtopic->Children; - while (my $k = $kids->Next) { - $Articles->Limit(FIELD => 'Topic', VALUE => $k->Id, - ENTRYAGGREGATOR => 'OR'); - } - } - } - @articles = map {$a = RT::Article->new($session{'CurrentUser'}); $a->Load($_->ObjectId); $a} @{$Articles->ItemsArrayRef} -} elsif ($class) { - my $Articles = RT::Articles->new($session{'CurrentUser'}); - my $TopicsAlias = $Articles->Join( - TYPE => 'left', - ALIAS1 => 'main', - FIELD1 => 'id', - TABLE2 => 'ObjectTopics', - FIELD2 => 'ObjectId', - ); - $Articles->Limit( - LEFTJOIN => $TopicsAlias, - FIELD => 'ObjectType', - VALUE => 'RT::Article', - ); - $Articles->Limit( - ALIAS => $TopicsAlias, - FIELD => 'Topic', - OPERATOR => 'IS', - VALUE => 'NULL', - QUOTEVALUE => 0, - ); - $Articles->Limit( - FIELD => 'Class', - OPERATOR => '=', - VALUE => $class, - ); - @articles = @{$Articles->ItemsArrayRef}; -} - % if (@articles) { % if ($id) { @@ -139,7 +108,6 @@ if ($id or $showall) { % } <%init> -my @Actions; my $Classes; my $currclass; my $currclass_id; @@ -167,106 +135,65 @@ if ($id) { $currtopic->Load($id); } -# A subroutine that iterates through topics and their children, producing -# the necessary ul, li, and href links for the table of contents. Thank -# heaven for query caching. The $restrict variable is used to display only -# the branch of the hierarchy which contains that topic ID. - -sub ProduceTree { - my ( $Actions, $currclass, $currclass_id, $currclass_name, $parentid, $restrictid ) = @_; - $parentid = 0 unless $parentid; - - # Deal with tree restriction, if any. - if ($restrictid) { - my $rtopic = RT::Topic->new( $session{'CurrentUser'} ); - $rtopic->Load($restrictid); - unless ( $rtopic->Id() - && $rtopic->ObjectId() == $currclass_id ) - { - push( @{$Actions},"Could not restrict view to topic $restrictid"); - - # Start over, without the restriction. - &ProduceTree( $Actions, $currclass, $currclass_id, $currclass_name, $parentid, undef ); - } else { - my @showtopics; - push( @showtopics, $rtopic ); - my $parent = $rtopic->ParentObj; - while ( $parent->Id ) { - push( @showtopics, $parent ); - my $newparent = $parent->ParentObj; - $parent = $newparent; - } - - # List the topics. - my $indents = @showtopics; - while ( my $t = pop @showtopics ) { - print "" x $indents; - } - } else { - - # No restriction in place. Build the entire tree. - my $topics = RT::Topics->new( $session{'CurrentUser'} ); - $topics->LimitToObject($currclass); - $topics->LimitToKids($parentid); - $topics->OrderBy( FIELD => 'Name' ); - print "\n" if $topics->Count; +my $ProduceTree; +$ProduceTree = sub { + my ( $parentid ) = @_; + my $topics = RT::Topics->new( $session{'CurrentUser'} ); + $topics->LimitToObject($currclass); + $topics->LimitToKids($parentid || 0); + $topics->OrderBy( FIELD => 'Name' ); + return unless $topics->Count; + $m->out(""); +}; - my $Articles = RT::ObjectTopics->new( $session{'CurrentUser'} ); - $Articles->Limit( FIELD => 'ObjectType', VALUE => 'RT::Article' ); - $Articles->Limit( FIELD => 'Topic', VALUE => $topic->Id ); - if ( $Articles->Count ) { - my $article_text = " (" . loc( "[quant,_1,article]", $Articles->Count ) . ")"; - my $query = "Topics.html?id=" . $topic->Id . "&class=$currclass_id&showall=1"; - $output .= qq($article_text); - } - - $output .= "\n"; - - } else { - - # This builds a link for the class specified, with no particular topic. - $query = "Topics.html?class=" . $currclass_id; - $output = "
  • " . $currclass_name . ""; - $output .= ": " . $currclass->Description if $currclass->Description; +my @articles; +if ($id) { + my $Articles = RT::ObjectTopics->new($session{'CurrentUser'}); + $Articles->Limit(FIELD => 'ObjectType', VALUE => 'RT::Article'); + $Articles->Limit(FIELD => 'Topic', VALUE => $id); + while (my $objtopic = $Articles->Next) { + my $a = RT::Article->new($session{'CurrentUser'}); + $a->Load($objtopic->ObjectId); + push @articles, $a; } - - return $output; +} elsif ($class) { + my $Articles = RT::Articles->new($session{'CurrentUser'}); + my $TopicsAlias = $Articles->Join( + TYPE => 'left', + ALIAS1 => 'main', + FIELD1 => 'id', + TABLE2 => 'ObjectTopics', + FIELD2 => 'ObjectId', + ); + $Articles->Limit( + LEFTJOIN => $TopicsAlias, + FIELD => 'ObjectType', + VALUE => 'RT::Article', + ); + $Articles->Limit( + ALIAS => $TopicsAlias, + FIELD => 'Topic', + OPERATOR => 'IS', + VALUE => 'NULL', + QUOTEVALUE => 0, + ); + $Articles->Limit( + FIELD => 'Class', + OPERATOR => '=', + VALUE => $class, + ); + @articles = @{$Articles->ItemsArrayRef}; } - <%args>