summaryrefslogtreecommitdiff
path: root/rt/share/html/Articles
diff options
context:
space:
mode:
authorIvan Kohler <ivan@freeside.biz>2012-06-07 16:55:45 -0700
committerIvan Kohler <ivan@freeside.biz>2012-06-07 16:55:45 -0700
commitc24d6e2242ae0e026684b8f95decf156aba6e75e (patch)
tree8597d00e2e6bf2cf400437b9344f43b1500da412 /rt/share/html/Articles
parent6686c29104e555ea23446fe1db330664fa110bc0 (diff)
rt 4.0.6
Diffstat (limited to 'rt/share/html/Articles')
-rw-r--r--rt/share/html/Articles/Article/Edit.html1
-rw-r--r--rt/share/html/Articles/Article/Elements/EditTopics55
-rw-r--r--rt/share/html/Articles/Article/ExtractIntoClass.html2
-rw-r--r--rt/share/html/Articles/Topics.html249
4 files changed, 116 insertions, 191 deletions
diff --git a/rt/share/html/Articles/Article/Edit.html b/rt/share/html/Articles/Article/Edit.html
index 756aa2cc9..d14c33076 100644
--- a/rt/share/html/Articles/Article/Edit.html
+++ b/rt/share/html/Articles/Article/Edit.html
@@ -157,6 +157,7 @@ elsif ( $id eq 'new' ) {
my $cfid = $1;
my $cf = RT::CustomField->new( $session{'CurrentUser'} );
+ $cf->SetContextObject( $ArticleObj );
$cf->Load( $cfid );
unless ( $cf->id ) {
$RT::Logger->error( "Couldn't load custom field #". $cfid );
diff --git a/rt/share/html/Articles/Article/Elements/EditTopics b/rt/share/html/Articles/Article/Elements/EditTopics
index 807360bf2..82e907135 100644
--- a/rt/share/html/Articles/Article/Elements/EditTopics
+++ b/rt/share/html/Articles/Article/Elements/EditTopics
@@ -47,35 +47,32 @@
%# END BPS TAGGED BLOCK }}}
<input type="hidden" name="EditTopics" value="1" />
<select multiple size="10" name="Topics">
-<%perl>
-if (@Classes) {
- $m->print("<optgroup label=\"Current classes (".join (' ',map {$_->Name} @Classes).")\">")
- unless $OnlyThisClass;
- $inTree->traverse(sub {
- my $tree = shift;
- my $topic = $tree->getNodeValue;
- $m->print("<option value=\"".$topic->Id."\""
- .(exists $topics{$topic->Id} ? " selected" : "").">"
- .("&nbsp;" x ($tree->getDepth*5)).($topic->Name || loc("(no name)"))."</option>\n");
- });
-}
-unless ($OnlyThisClass) {
- my $class = $Classes[-1]->Id;
- $otherTree->traverse(sub {
- my $tree = shift;
- my $topic = $tree->getNodeValue;
- unless ($topic->ObjectId == $class) {
- $class = $topic->ObjectId;
- $m->print("</optgroup>\n");
- my $c = RT::Class->new($session{'CurrentUser'});
- $c->Load($topic->ObjectId);
- $m->print("<optgroup label=\"".$c->Name."\">\n");
- }
- $m->print("<option value=\"".$topic->Id."\""
- .(exists $topics{$topic->Id} ? " selected" : "").">"
- .("&nbsp;" x ($tree->getDepth*5)).($topic->Name || loc("(no name)"))."</option>\n");
- });
-</%perl>
+% if (@Classes) {
+% unless ($OnlyThisClass) {
+<optgroup label="Current classes (<% join(" ", map {$_->Name} @Classes) %>)">
+% }
+% $inTree->traverse(sub {
+% my $tree = shift;
+% my $topic = $tree->getNodeValue;
+<option value="<% $topic->Id %>" <% exists $topics{$topic->Id} ? "selected" : "" %> >\
+<% "&nbsp;" x ($tree->getDepth*5) |n %><% $topic->Name || loc("(no name)") %></option>
+% });
+% }
+% unless ($OnlyThisClass) {
+% my $class = $Classes[-1]->Id;
+% $otherTree->traverse(sub {
+% my $tree = shift;
+% my $topic = $tree->getNodeValue;
+% unless ($topic->ObjectId == $class) {
+% $class = $topic->ObjectId;
+</optgroup>
+% my $c = RT::Class->new($session{'CurrentUser'});
+% $c->Load($topic->ObjectId);
+<optgroup label="<% $c->Name %>">
+% }
+<option value="<% $topic->Id %>" <% exists $topics{$topic->Id} ? "selected" : "" %> >\
+<% "&nbsp;" x ($tree->getDepth*5) |n %><% $topic->Name || loc("(no name)") %></option>
+% });
</optgroup>
% }
</select>
diff --git a/rt/share/html/Articles/Article/ExtractIntoClass.html b/rt/share/html/Articles/Article/ExtractIntoClass.html
index adf23fc0f..f3618feda 100644
--- a/rt/share/html/Articles/Article/ExtractIntoClass.html
+++ b/rt/share/html/Articles/Article/ExtractIntoClass.html
@@ -54,7 +54,7 @@
% my $Classes = RT::Classes->new($session{'CurrentUser'});
% $Classes->LimitToEnabled();
% while (my $Class = $Classes->Next) {
-<li><a href="ExtractIntoTopic.html?Ticket=<%$Ticket%>&Class=<%$Class->Id%>" onclick="document.getElementById('topics-<% $Class->Id %>').style.display = (document.getElementById('topics-<% $Class->Id %>').style.display == 'block') ? 'none' : 'block'; return false;"><%$Class->Name%></a>:
+<li><a href="ExtractIntoTopic.html?Ticket=<%$Ticket%>&Class=<%$Class->Id%>" onclick="document.getElementById('topics-'+<% $Class->Id |n,j%>).style.display = (document.getElementById('topics-'+<% $Class->Id |n,j%>).style.display == 'block') ? 'none' : 'block'; return false;"><%$Class->Name%></a>:
<%$Class->Description%>
<div id="topics-<%$Class->Id%>" style="display: none">
<form action="ExtractFromTicket.html">
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 &>
<a href="Topics.html"><&|/l&>All topics</&></a>
% if (defined $class) {
&gt; <a href="Topics.html?class=<%$currclass_id%>"><% $currclass_name %></a>
@@ -59,71 +58,41 @@
% }
<br />
<h1><&|/l&>Browse by topic</&></h1>
-<%perl>
-if (defined $class) {
- $m->print('<h2>'.'<a href="'.
- RT->Config->Get('WebPath')."/Articles/Topics.html?class=" . $currclass_id
- .'">'.$currclass_name."</a></h2>\n");
- ProduceTree(\@Actions, $currclass, $currclass_id, $currclass_name, 0, $id);
-} else {
- $m->print("<ul>\n");
- while (my $c = $Classes->Next) {
- $m->print('<li><h2>'.'<a href="'.
- RT->Config->Get('WebPath')."/Articles/Topics.html?class=" . $c->Id
- .'">'.$c->Name."</a></h2>\n");
- $m->print("\n</li>\n");
- }
- $m->print(qq|<li><h2><a href="|.RT->Config->Get('WebPath').qq|/Articles/Topics.html?class=0">|.loc('Global Topics').qq|</a></h2></li>\n|);
- $m->print("</ul>\n");
-}
-</%perl>
+% if (defined $class) {
+<h2><a href="<% RT->Config->Get('WebPath') %>/Articles/Topics.html?class=<% $currclass_id %>"><% $currclass_name %></a></h2>
+% 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 ) {
+<ul><li><& /Articles/Elements/ShowTopicLink, Topic => $t, Class => $currclass_id &>
+% $ProduceTree->( $id ) if $t->Id == $id;
+% }
+% for ( @showtopics ) {
+ </li></ul>
+% }
+% }
+% } else {
+<ul>
+% while (my $c = $Classes->Next) {
+<li><h2><a href="<% RT->Config->Get('WebPath') %>/Articles/Topics.html?class=<% $c->Id %>"><% $c->Name %></a></h2></li>
+% }
+<li><h2><a href="<% RT->Config->Get('WebPath') %>/Articles/Topics.html?class=0"><&|/l&>Global Topics</&></a></h2></li>
+</ul>
+% }
<br />
-<%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};
-}
-</%perl>
% 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 "<ul>";
- print &MakeLinks( $t, $currclass, $currclass_id, $currclass_name, $t->Children->Count );
- if ( $t->Id == $restrictid ) {
- &ProduceTree( $Actions, $currclass, $currclass_id, $currclass_name, $restrictid, undef );
- }
- }
- print "</ul>" 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 "<ul>" if $topics->Count;
- while ( my $t = $topics->Next ) {
- if ( $t->Children->Count ) {
- print &MakeLinks( $t, $currclass, $currclass_id, $currclass_name, 1 );
- &ProduceTree( $Actions, $currclass, $currclass_id, $currclass_name, $t->Id );
- } else {
- print &MakeLinks( $t, $currclass, $currclass_id, $currclass_name, 0 );
- }
- }
- print "</ul>\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("<ul>");
+ while ( my $t = $topics->Next ) {
+ $m->out("<li>");
+ $m->comp("/Articles/Elements/ShowTopicLink",
+ Topic => $t,
+ Class => $currclass_id,
+ );
+ $ProduceTree->( $t->Id ) if $t->Children->Count;
+ $m->out("</li>");
}
-}
-
-sub MakeLinks {
- my ( $topic, $currclass, $currclass_id, $currclass_name, $haschild ) = @_;
- my $query;
- my $output;
-
- if ( ref($topic) eq 'RT::Topic' ) {
-
- my $topic_info = $topic->Name() || loc("(no name)");
- $topic_info .= ": " . $topic->Description() if $topic->Description;
-
- if ($haschild) { # has topics below it
- $query = "Topics.html?id=" . $topic->Id . "&class=" . $currclass_id;
- $output = qq(<li><a href="$query">$topic_info</a>);
- } else {
- $output = qq(<li>$topic_info);
- }
+ $m->out("</ul>");
+};
- 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(<a href="$query">$article_text</a>);
- }
-
- $output .= "</li>\n";
-
- } else {
-
- # This builds a link for the class specified, with no particular topic.
- $query = "Topics.html?class=" . $currclass_id;
- $output = "<li><a href=\"$query\">" . $currclass_name . "</a>";
- $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};
}
-
</%init>
<%args>