% if ( $show_actions and @tabs ){
% } % %# ====================================================================== % <%args> $action => '' # e.g. uri ends with ?action=edit $revision => '' # e.g. uri ends with ?action=view&revision=127 $username => '' # for appending &username=... in special/user pages $id => '' # e.g. uri has id=17 in there % <%init> # uri's like page?revision=234 have an implied action=view # which is set in course_template.mhtml # This next line is therefore just for safety. $action = 'view' if ($revision and not $action); my $show_actions = 0; # set below to 1 if user can edit the page. my %class; # css style classes for action tabs my %uri; # what each tab does my %link; # displayed tab text. Tab is hidden if false. my @tabs; if ($page->action_tabs){ # special pages may define available tabs. @tabs = @{ $page->action_tabs }; } else { @tabs = ('edit', 'history', '<', 'revision', '>', 'current', ); } my $base_uri = $r->uri; my $rev_arg = ''; my $mod_arg = ''; my $uri_head; my $uri_tail; # if ($page->can_write && not $page->is_directory){ if ($page->can_write){ $show_actions = 1; my $base_uri = $r->uri; my $rev_arg = $revision ? "revision=$revision" : ''; if ($action =~ m/edit/){ $class{edit} = 'front-yellow'; } else { $class{edit} = 'behind-yellow'; $uri{edit} = "$base_uri?action=edit" . ($rev_arg ? "&$rev_arg" : '') . ($id ? "&id=$id" : '') . ($username ? "&username=$username" : ''); } $link{edit} = 'edit'; if ($action =~ m{history}){ $class{history} = 'front'; } else { $class{history} = 'behind'; $uri{history} = "$base_uri?action=history"; } $link{history} = 'history'; # false if no svn versions ? # are there actions that still leave current tab in front? # if ($action !~ m{edit|history|view}){ if ($action){ $class{current} = 'behind-gap'; $uri{current} = $base_uri . ($username ? "?username=$username" : ''); } else { $class{current} = 'front-gap'; } $link{current} = 'current'; if ($revision){ #my $mode = $action eq 'edit' ? 'edit' : 'view'; my $action_arg = $action eq 'edit' ? 'action=edit' : ''; my ($first, $last, $prev, $next)=$page->revision_summary($revision); $class{'<'} = 'behind-gap'; $link{'<'} = '<'; if ($revision == $first){ $uri{'<'} = ''; $link{'<'} = ' '; } else { $uri{'<'} = "$base_uri?$action_arg&revision=$prev"; } if ($action =~ m{view}){ $class{revision} = 'front'; } else { $class{revision} = 'behind'; $uri{revision} = "$base_uri?$rev_arg"; } $link{revision} = "revision $revision"; $class{'>'} = 'behind'; $link{'>'} = '>'; if ($revision == $last){ $uri{'>'} = ''; $link{'>'} = ' '; } else { $uri{'>'} = "$base_uri?$action_arg&revision=$next"; } } } % <%doc> This component displays the various possible editing actions as tabs at the top of the content rectangle, i.e. -------- ----------- ----------- | edit | | history | etc. | current | ----------------------------------- ------ | page content | | | -------------------------------------------------- The "front" tab is the one whose background merges with the page content, suggesting how the page is seen. The current possibilities are edit action=edit history action=history < action=prev view or edit previous revision rev N action=view view or edit revision N > action=next view or edit next revision current action not set See htdocs/styles/wikiacademia.css for the css style classes. $Id: actions.mhtml 19353 2007-12-19 07:55:55Z mahoney $