1 %# BEGIN BPS TAGGED BLOCK {{{
5 %# This software is Copyright (c) 1996-2014 Best Practical Solutions, LLC
6 %# <sales@bestpractical.com>
8 %# (Except where explicitly superseded by other copyright notices)
13 %# This work is made available to you under the terms of Version 2 of
14 %# the GNU General Public License. A copy of that license should have
15 %# been provided with this software, but in any event can be snarfed
18 %# This work is distributed in the hope that it will be useful, but
19 %# WITHOUT ANY WARRANTY; without even the implied warranty of
20 %# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21 %# General Public License for more details.
23 %# You should have received a copy of the GNU General Public License
24 %# along with this program; if not, write to the Free Software
25 %# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
26 %# 02110-1301 or visit their web page on the internet at
27 %# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html.
30 %# CONTRIBUTION SUBMISSION POLICY:
32 %# (The following paragraph is not intended to limit the rights granted
33 %# to you to modify and distribute this software under the terms of
34 %# the GNU General Public License and is only of importance to you if
35 %# you choose to contribute your changes and enhancements to the
36 %# community by submitting them to Best Practical Solutions, LLC.)
38 %# By intentionally submitting any modifications, corrections or
39 %# derivatives to this work, or any other work intended for use with
40 %# Request Tracker, to Best Practical Solutions, LLC, you confirm that
41 %# you are the copyright holder for those contributions and you grant
42 %# Best Practical Solutions, LLC a nonexclusive, worldwide, irrevocable,
43 %# royalty-free, perpetual, license to use, copy, create derivative
44 %# works based on those contributions, and sublicense and distribute
45 %# those contributions and any derivatives thereof.
47 %# END BPS TAGGED BLOCK }}}
48 <& /Elements/Header, Title => loc('Browse by topic') &>
51 <a href="Topics.html"><&|/l&>All topics</&></a>
52 % if (defined $class) {
53 > <a href="Topics.html?class=<%$currclass_id%>"><% $currclass_name %></a>
57 > <& /Articles/Elements/ShowTopic, topic => $currtopic &>
60 <h1><&|/l&>Browse by topic</&></h1>
61 % if (defined $class) {
62 <h2><a href="<% RT->Config->Get('WebPath') %>/Articles/Topics.html?class=<% $currclass_id %>"><% $currclass_name %></a></h2>
63 % my $rtopic = RT::Topic->new( $session{'CurrentUser'} );
65 % unless ( $rtopic->Id()
66 % && $rtopic->ObjectId() == $currclass->Id )
69 % $ProduceTree->( 0 );
71 % my @showtopics = ( $rtopic );
72 % my $parent = $rtopic->ParentObj;
73 % while ( $parent->Id ) {
74 % unshift @showtopics, $parent;
75 % $parent = $parent->ParentObj;
78 % for my $t ( @showtopics ) {
79 <ul><li><& /Articles/Elements/ShowTopicLink, Topic => $t, Class => $currclass_id &>
80 % $ProduceTree->( $id ) if $t->Id == $id;
82 % for ( @showtopics ) {
88 % while (my $c = $Classes->Next) {
89 <li><h2><a href="<% RT->Config->Get('WebPath') %>/Articles/Topics.html?class=<% $c->Id %>"><% $c->Name %></a></h2></li>
91 <li><h2><a href="<% RT->Config->Get('WebPath') %>/Articles/Topics.html?class=0"><&|/l&>Global Topics</&></a></h2></li>
99 <h2><&|/l, $currtopic->Name&>Articles in [_1]</&></h2>
101 <h2><&|/l&>Articles with no topics</&></h2>
104 % for my $a (@articles) {
105 <li><a href="Article/Display.html?id=<% $a->Id %>"><% $a->Name || loc("(no name)") %></a></li>
117 if ( defined $class ) {
119 $currclass = RT::Class->new( $session{'CurrentUser'} );
120 $currclass->Load($class);
121 $currclass_id = $currclass->Id;
122 $currclass_name = $currclass->Name;
124 $currclass = $RT::System;
126 $currclass_name = 'Global Topics';
129 $Classes = RT::Classes->new( $session{'CurrentUser'} );
130 $Classes->LimitToEnabled();
134 $currtopic = RT::Topic->new( $session{'CurrentUser'} );
135 $currtopic->Load($id);
140 my ( $parentid ) = @_;
141 my $topics = RT::Topics->new( $session{'CurrentUser'} );
142 $topics->LimitToObject($currclass);
143 $topics->LimitToKids($parentid || 0);
144 $topics->OrderBy( FIELD => 'Name' );
145 return unless $topics->Count;
147 while ( my $t = $topics->Next ) {
149 $m->comp("/Articles/Elements/ShowTopicLink",
151 Class => $currclass_id,
153 $ProduceTree->( $t->Id ) if $t->Children->Count;
161 my $Articles = RT::ObjectTopics->new($session{'CurrentUser'});
162 $Articles->Limit(FIELD => 'ObjectType', VALUE => 'RT::Article');
163 $Articles->Limit(FIELD => 'Topic', VALUE => $id);
164 while (my $objtopic = $Articles->Next) {
165 my $a = RT::Article->new($session{'CurrentUser'});
166 $a->Load($objtopic->ObjectId);
170 my $Articles = RT::Articles->new($session{'CurrentUser'});
171 my $TopicsAlias = $Articles->Join(
175 TABLE2 => 'ObjectTopics',
176 FIELD2 => 'ObjectId',
179 LEFTJOIN => $TopicsAlias,
180 FIELD => 'ObjectType',
181 VALUE => 'RT::Article',
184 ALIAS => $TopicsAlias,
195 @articles = @{$Articles->ItemsArrayRef};