[Rt-commit] rt branch, 3.9-trunk, updated. rt-3.9.7-795-gb3bc3f8

Thomas Sibley trs at bestpractical.com
Fri Dec 10 16:59:41 EST 2010


The branch, 3.9-trunk has been updated
       via  b3bc3f829363b47584d9b8a94ab58e8e36f1bc9d (commit)
      from  64bb6c12318c2180b50aba64c87a7a69e7abfe4f (commit)

Summary of changes:
 lib/RT/Interface/Web/Menu.pm  |   36 +++++++++++++++---------------------
 share/html/Elements/Menu      |   15 ++++++---------
 share/html/Elements/Tabs      |   16 ++++++++--------
 share/html/Elements/WidgetBar |    6 +++---
 share/html/Ticket/Create.html |    4 ++--
 5 files changed, 34 insertions(+), 43 deletions(-)

- Log -----------------------------------------------------------------
commit b3bc3f829363b47584d9b8a94ab58e8e36f1bc9d
Author: Thomas Sibley <trs at bestpractical.com>
Date:   Fri Dec 10 16:36:22 2010 -0500

    Clean up the menuing code to remove some cruft and unnecessary hacks
    
    Kill the link_item attribute.  We can figure that out based on other
    attributes.  Actually use the raw_html attribute.  escape_title stays
    because it is still useful as a smaller hammer than raw_html.  Respect
    the class attribute.  Cleanup and correct the doc.
    
    Link Tickets -> Current Search to the search results page, which is
    handy.
    
    Ideally we wouldn't wrap menu items without a path in an <a>, but we
    still need to for the sake of the menu styles.  If we wrap unlinked
    titles in span.menu-item's, we can style on .menu-item instead of a.

diff --git a/lib/RT/Interface/Web/Menu.pm b/lib/RT/Interface/Web/Menu.pm
index f5aa8a3..0d3fa62 100644
--- a/lib/RT/Interface/Web/Menu.pm
+++ b/lib/RT/Interface/Web/Menu.pm
@@ -57,8 +57,7 @@ use URI;
 use Scalar::Util qw(weaken);
 
 __PACKAGE__->mk_accessors(qw(
-    title sort_order target escape_title class render_children_inline
-    link_item raw_html key
+    title sort_order target escape_title class raw_html key
 ));
 
 =head1 NAME
@@ -70,9 +69,9 @@ RT::Interface::Web::Menu - Handle the API for menu navigation
 =head2 new PARAMHASH
 
 Creates a new L<RT::Interface::Web::Menu> object.  Possible keys in the
-I<PARAMHASH> are L</title>, L</parent>, L</sort_order>, L</path>, and
-L</active>.  See the subroutines with the respective name below for
-each option's use.
+I<PARAMHASH> are L</title>, L</parent>, L</sort_order>, L</path>, L</class>,
+L</raw_html>, and L</active>, and L</escape_title>.  See the subroutines with
+the respective name below for each option's use.
 
 =cut
 
@@ -97,6 +96,10 @@ sub new {
 
 Sets or returns the string that the menu item will be displayed as.
 
+=head2 escape_title [BOOLEAN]
+
+Sets or returns whether or not to HTML escape the title before output.
+
 =head2 parent [MENU]
 
 Gets or sets the parent L<RT::Interface::Web::Menu> of this item; this defaults
@@ -104,9 +107,9 @@ to null. This ensures that the reference is weakened.
 
 =head2 raw_html [STRING]
 
-Sets the content of this menu item to a raw blob of HTML. When
-asked or output, rather than constructing a link, we will return
-this raw content. No escaping is done.
+Sets the content of this menu item to a raw blob of HTML. When building the
+menu, rather than constructing a link, we will return this raw content. No
+escaping is done.
 
 =cut
 
@@ -132,18 +135,8 @@ Get or set the frame or pseudo-target for this link. something like L<_blank>
 
 =head2 class [STRING]
 
-Gets or sets the CSS class the link should have in addition to the default
-classes.  This is only used if L</link> isn't specified.
-
-=head2 render_children_inline [BOOLEAN]
-
-Gets or sets whether children are rendered inline as a menu "group" instead
-of a true submenu.  Only used when rendering with YUI for now.
-Defaults to false.
-
-Note that YUI doesn't support rendering nested menu groups, so having direct
-parent/children render_children_inline is likely not going to do what you
-want or expect.
+Gets or sets the CSS class the menu item should have in addition to the default
+classes.  This is only used if L</raw_html> isn't specified.
 
 =head2 path
 
@@ -169,6 +162,8 @@ sub path {
 Gets or sets if the menu item is marked as active.  Setting this
 cascades to all of the parents of the menu item.
 
+This is currently B<unused>.
+
 =cut
 
 sub active {
@@ -215,7 +210,6 @@ sub child {
                     key         => $key,
                     title       => $key,
                     escape_title=> 1,
-                    link_item   => 1,
                     %args
                 }
             );
diff --git a/share/html/Elements/Menu b/share/html/Elements/Menu
index 48cdc56..da6a754 100755
--- a/share/html/Elements/Menu
+++ b/share/html/Elements/Menu
@@ -55,16 +55,13 @@
 class="has-children" \
 % }
 >\
-% if ($child->link_item) {
-% my $url = (not $child->path or $child->path =~ m{^\w+:/}) ? $child->path : RT->Config->Get('WebPath').$child->path;
-<a id="<%$item_id%>" <% $child->path ? ' href="'.$url.'"' : '' |n%><% $child->target ? ' target="'.$child->target.'"' : '' %>>\
-% }
-% if ($child->escape_title) {
-<%$child->title%>\
+
+% if ($child->raw_html) {
+<% $child->raw_html |n %>
 % } else {
-<%$child->title |n%>\
-% }
-% if ($child->link_item) {
+% my $url = (not $child->path or $child->path =~ m{^\w+:/}) ? $child->path : RT->Config->Get('WebPath').$child->path;
+<a id="<%$item_id%>" class="menu-item <% $child->class || '' %>"<% $child->path ? ' href="'.$url.'"' : '' |n%><% $child->target ? ' target="'.$child->target.'"' : '' |n %>>\
+<% $child->escape_title ? $m->interp->apply_escapes($child->title, 'h') : $child->title |n %>\
 </a>\
 % }
 % if ($child->has_children) {
diff --git a/share/html/Elements/Tabs b/share/html/Elements/Tabs
index 710a91c..eae90a1 100755
--- a/share/html/Elements/Tabs
+++ b/share/html/Elements/Tabs
@@ -406,9 +406,7 @@ if ( $request_path !~ qr{^/SelfService/} ) {
 
             my $actions = PageMenu()->child( actions => title => loc('Actions'), sort_order  => 95 );
             my $tabs = PageMenu();
-            $tabs->child( bookmark => title => $m->scomp( '/Ticket/Elements/Bookmark', id => $id ),
-                      escape_title => 0,
-                      link_item    => 0,
+            $tabs->child( bookmark => raw_html => $m->scomp( '/Ticket/Elements/Bookmark', id => $id ),
                 sort_order => 99
             );
 
@@ -566,7 +564,8 @@ if ( $request_path !~ qr{^/SelfService/} ) {
 
         my $current_search_menu;
         if ( $request_path =~ qr{^/Ticket} ) {
-            $current_search_menu = $search->child( current_search => title => loc('Current Search'), link_item => 1 );
+            $current_search_menu = $search->child( current_search => title => loc('Current Search') );
+            $current_search_menu->path("/Search/Results.html$args") if $has_query;
         } else {
             $current_search_menu = PageMenu();
         }
@@ -589,6 +588,7 @@ if ( $request_path !~ qr{^/SelfService/} ) {
             }
 
             $current_search_menu->child( results => title => loc('Show Results') => path => "/Search/Results.html$args" );
+
             $current_search_menu->child( bulk => title => loc('Bulk Update') => path => "/Search/Bulk.html$args" );
             $current_search_menu->child( chart => title => loc('Graph'),
                                          path => "/Search/Chart.html$args" );
@@ -655,8 +655,8 @@ if ( $request_path !~ qr{^/SelfService/} ) {
         PageMenu()->child( edit => title => loc('Edit'), path => '/Prefs/MyRT.html' );
     }
 
-    PageWidgets()->child( simple_search => title => $m->scomp('SimpleSearch'), escape_title => 0 );
-    PageWidgets()->child( create_ticket => title => $m->scomp('CreateTicket'), escape_title => 0 );
+    PageWidgets()->child( simple_search => raw_html => $m->scomp('SimpleSearch') );
+    PageWidgets()->child( create_ticket => raw_html => $m->scomp('CreateTicket') );
 
     $m->callback( CallbackName => 'Privileged' );
 }
@@ -704,10 +704,10 @@ if ( $request_path =~ qr{^/SelfService} ) {
     }
 
     if ($session{'CurrentUser'}->HasRight( Right => 'ShowArticle', Object => $RT::System )) {
-        PageWidgets->child( 'goto-article' => title => $m->scomp('/SelfService/Elements/SearchArticle'), escape_title => 0 );
+        PageWidgets->child( 'goto-article' => raw_html => $m->scomp('/SelfService/Elements/SearchArticle') );
     }
 
-    PageWidgets->child( goto         => title => $m->scomp('/SelfService/Elements/GotoTicket'), escape_title => 0 );
+    PageWidgets->child( goto => raw_html => $m->scomp('/SelfService/Elements/GotoTicket') );
 
     $m->callback( CallbackName => 'SelfService' );
 }
diff --git a/share/html/Elements/WidgetBar b/share/html/Elements/WidgetBar
index 1dcab6b..252d2c7 100644
--- a/share/html/Elements/WidgetBar
+++ b/share/html/Elements/WidgetBar
@@ -47,10 +47,10 @@
 %# END BPS TAGGED BLOCK }}}
 % return unless ($menu);
 % for my $child ($menu->children) {
-% if ($child->escape_title) {
-<%$child->title%>\
+% if (defined $child->raw_html) {
+<% $child->raw_html |n %>
 % } else {
-<%$child->title |n%>\
+<% $child->title %>\
 % }
 % }
 <%ARGS>
diff --git a/share/html/Ticket/Create.html b/share/html/Ticket/Create.html
index 738f44a..9529865 100755
--- a/share/html/Ticket/Create.html
+++ b/share/html/Ticket/Create.html
@@ -453,8 +453,8 @@ if ((!exists $ARGS{'AddMoreAttach'}) and (defined($ARGS{'id'}) and $ARGS{'id'} e
         }
     }
 }
-PageMenu->child( basics => title =>  q[<a href="#basics" onclick="return switchVisibility('Ticket-Create-basics','Ticket-Create-details');">] . loc('Basics') . q[</a>], escape_title => 0, link_item => 0);
-PageMenu->child( details => title =>  q[<a href="#details" onclick="return switchVisibility('Ticket-Create-details','Ticket-Create-basics');">] . loc('Details') . q[</a>], escape_title => 0, link_item => 0);
+PageMenu->child( basics => raw_html =>  q[<a href="#basics" onclick="return switchVisibility('Ticket-Create-basics','Ticket-Create-details');">] . loc('Basics') . q[</a>]);
+PageMenu->child( details => raw_html =>  q[<a href="#details" onclick="return switchVisibility('Ticket-Create-details','Ticket-Create-basics');">] . loc('Details') . q[</a>]);
 </%INIT>
 
 <%ARGS>

-----------------------------------------------------------------------


More information about the Rt-commit mailing list