Diff for /loncom/interface/lonhtmlcommon.pm between versions 1.199 and 1.205

version 1.199, 2009/01/22 14:26:04 version 1.205, 2009/04/01 14:22:11
Line 1305  returns: nothing Line 1305  returns: nothing
     my @Crumbs;      my @Crumbs;
           
     sub breadcrumbs {      sub breadcrumbs {
         my ($component,$component_help,$menulink,$helplink,$css_class,$no_mt) = @_;          my ($component,$component_help,$menulink,$helplink,$css_class,$no_mt, $no_realBreadcrumb) = @_;
         #          #
  $css_class ||= 'LC_breadcrumbs';   $css_class ||= 'LC_breadcrumbs';
         my $Str1 = '<ol id="LC_MenuBreadcrumbs">';          my $Str1 = '<ol id="LC_MenuBreadcrumbs">';
   
    if($no_realBreadcrumb){
    $Str1 = '<ul class="LC_CourseBreadcrumbs">';
    }
   
         my $Str = '';          my $Str = '';
         #          #
         # Make the faq and bug data cascade          # Make the faq and bug data cascade
Line 1316  returns: nothing Line 1321  returns: nothing
         my $bug = '';          my $bug = '';
  my $help='';   my $help='';
  # Crumb Symbol   # Crumb Symbol
  my $crumbsymbol = ' &#x25b6; ';   my $crumbsymbol = '&raquo;&nbsp;';
         # The last breadcrumb does not have a link, so handle it separately.          # The last breadcrumb does not have a link, so handle it separately.
         my $last = pop(@Crumbs);          my $last = pop(@Crumbs);
         #          #
Line 1339  returns: nothing Line 1344  returns: nothing
                     no_mt  =>$no_mt_descr,                      no_mt  =>$no_mt_descr,
                 });                  });
         }          }
         my $links .=           my $links .= '<li>'.
             join($crumbsymbol,              join('</li><li>'.$crumbsymbol,
                  map {                   map {
                      $faq = $_->{'faq'} if (exists($_->{'faq'}));                       $faq = $_->{'faq'} if (exists($_->{'faq'}));
                      $bug = $_->{'bug'} if (exists($_->{'bug'}));                       $bug = $_->{'bug'} if (exists($_->{'bug'}));
                      $help = $_->{'help'} if (exists($_->{'help'}));                       $help = $_->{'help'} if (exists($_->{'help'}));
                      my $result = '<li><a href="'.$_->{'href'}.'" ';                       my $result = '<a href="'.$_->{'href'}.'" ';
                      if (defined($_->{'target'}) && $_->{'target'} ne '') {                       if (defined($_->{'target'}) && $_->{'target'} ne '') {
                          $result .= 'target="'.$_->{'target'}.'" ';                           $result .= 'target="'.$_->{'target'}.'" ';
                      }                       }
      if ($_->{'no_mt'}) {       if ($_->{'no_mt'}) {
  $result .='title="'.$_->{'title'}.'">'.   $result .='title="'.$_->{'title'}.'">'.
      $_->{'text'}.'</a></li>';       $_->{'text'}.'</a>';
      } else {       } else {
  $result .='title="'.&mt($_->{'title'}).'">'.   $result .='title="'.&mt($_->{'title'}).'">'.
      &mt($_->{'text'}).'</a></li>';       &mt($_->{'text'}).'</a>';
      }       }
                      $result;                       $result;
                      } @Crumbs                       } @Crumbs
                  );                   ).'</li>';
         $links .= $crumbsymbol if ($links ne '');          $links .= '<li>'.$crumbsymbol if ($links ne '');
  if ($last->{'no_mt'}) {   if ($last->{'no_mt'}) {
     $links .= '<li><b>'.$last->{'text'}.'</b></li>';      $links .= '<b>'.$last->{'text'}.'</b></li>';
  } else {   } else {
     $links .= '<li><b>'.&mt($last->{'text'}).'</b></li>';      $links .= '<b>'.&mt($last->{'text'}).'</b></li>';
  }   }
         #          #
         my $icons = '';          my $icons = '';
Line 1383  returns: nothing Line 1388  returns: nothing
  $faq,$bug);   $faq,$bug);
  }   }
         #          #
         $Str1 .= $links.'</ol>';  
   
    if($no_realBreadcrumb){
           $Str1 .= $links.'</ul>';
    } else {
           $Str1 .= $links.'</ol>';
    }
         #          #
         if (defined($component)) {          if (defined($component)) {
             $Str .= "\n".'<table class="'.$css_class.'">'              $Str .= "\n".'<table class="'.$css_class.'">'
Line 2032  END Line 2043  END
 # An array of following structure:  # An array of following structure:
 #   ({ categorytitle => 'Categorytitle',  #   ({ categorytitle => 'Categorytitle',
 # items => [  # items => [
 #    { linktext    => 'Text to be displayed',  #    {
 # url    => 'URL the link is pointing to, i.e. /adm/site?action=dosomething',  #           linktext    => 'Text to be displayed',
   # url        => 'URL the link is pointing to, i.e. /adm/site?action=dosomething',
 # permission  => 'Contains permissions as returned from lonnet::allowed(),  # permission  => 'Contains permissions as returned from lonnet::allowed(),
 # must evaluate to true in order to activate the link',  #         must evaluate to true in order to activate the link',
 # icon        =>  'icon filename',  # icon        =>  'icon filename',
 # alttext    => 'alt text for the icon',  # alttext    => 'alt text for the icon',
 # help    => 'Name of the corresponding helpfile',  # help    => 'Name of the corresponding helpfile',
Line 2054  END Line 2066  END
 # subject to change during this project.  # subject to change during this project.
 # Don't rely on its current functionality as it might be   # Don't rely on its current functionality as it might be 
 # changed or removed.  # changed or removed.
 # TODO:  
 # check for empty values  
 # --------------------------  # --------------------------
   
 sub generate_menu {  sub generate_menu {
     my @menu = @_;      my @menu = @_;
     my $menu_html = qq|<div class="LC_columnSection">|;  
   
     foreach my $category (@menu) { #FIXME: insert appropriate classnames for styles when they're finished.      # usage: $wrap->(element, content, {attribute => value,...});
  $menu_html .='<div class="LC_ContentBoxSpecial">      # output: content enclosed in html conform tags
  <h3 class="LC_hcell">'.mt($category->{'categorytitle'}).'</h3>      my $wrap = sub {
  <ul class="LC_ListStyleNormal">';          return
  foreach my $item ( @{ $category->{items} } ) {              qq|<$_[0]|
     next unless $item->{'permission'};            . join( '', map { qq| $_="${$_[2]}{$_}"| } keys %{ $_[2] } )
     $menu_html .= qq|<li class="LC_menubuttons_inline_text"><a href="$item->{'url'}" title="|.mt($item->{'linktitle'}).'">';            . ($_[1] ? qq|>$_[1]</$_[0]>| : qq|/>|). "\n";
             if($item->{'icon'}){      };
                 $menu_html .= qq|<img class ="LC_noBorder LC_middle" src="/res/adm/pages/$item->{'icon'}" alt="|;      
  if($item->{'alttext'}){      # subs for specific html elements
     $menu_html .= $item->{'alttext'}.'"/></a>';      my $h3  = sub { return $wrap->( "h3",  @_ ) };
  } else { #use linktext as alt text for the icon      my $div = sub { return $wrap->( "div", @_ ) };
     $menu_html .= qq|$item->{'linktext'}"/></a>|;      my $ul  = sub { return $wrap->( "ul",  @_ ) };
                 }       my $li  = sub { return $wrap->( "li",  @_ ) };
             }      my $a   = sub { return $wrap->( "a",   @_ ) };
     $menu_html .= qq|<a href="$item->{'url'}" title="|.mt($item->{'linktitle'}).'">';      my $img = sub { return $wrap->( "img", @_ ) };
             $menu_html .= mt($item->{'linktext'}).'</a>';      
     if (exists($item->{'help'})) {      my @categories; # each element represents the entire markup for a category
  $menu_html .= Apache::loncommon::help_open_topic($item->{'help'});     
     }      foreach my $category (@menu) {
     $menu_html .= '</li>';          my @links;  # contains the links for the current $category
  }          foreach my $link (@{$$category{items}}) {
  $menu_html .= '</ul></div>';              next unless $$link{permission};
               
               # create the markup for the current $link and push it into @links.
               # each entry consists of an image and a text optionally followed 
               # by a help link.
               push @links, $li->(
                           $a->(
                               $img->("", {
                                   class => "LC_noBorder LC_middle",
                                   src   => "/res/adm/pages/$$link{icon}",
                                   alt   => mt(defined($$link{alttext}) ?
                                   $$link{alttext} : $$link{linktext})
                               }), {
                               href  => $$link{url},
                               title => mt($$link{linktitle})
                               }).
                           $a->(mt($$link{linktext}), {
                               href  => $$link{url},
                               title => mt($$link{linktitle}),
                               class => "LC_menubuttons_link"
                               }).
                            (defined($$link{help}) ? 
                            Apache::loncommon::help_open_topic($$link{help}) : ''),
                            {class => "LC_menubuttons_inline_text"});
           }
   
           # wrap categorytitle in <h3>, concatenate with 
           # joined and in <ul> tags wrapped @links
           # and wrap everything in an enclosing <div> and push it into
           # @categories
           # such that each element looks like:
           # <div><h3>title</h3><ul><li>...</li>...</ul></div>
           # the category won't be added if there aren't any links
           push @categories, 
               $div->($h3->(mt($$category{categorytitle}), {class=>"LC_hcell"}).
               $ul->(join('' ,@links),  {class =>"LC_ListStyleNormal" }),
               {class=>"LC_ContentBoxSpecial LC_400Box"}) if scalar(@links);
     }      }
     $menu_html .= qq|</div>|;  
     return $menu_html;  
 }  
   
       # wrap the joined @categories in another <div> (column layout)
       return $div->(join('', @categories), {class => "LC_columnSection"});
   }
   
 1;  1;
   

Removed from v.1.199  
changed lines
  Added in v.1.205


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>