&');
+ if ($symb) {
+ $cfile .= '&symb='.&HTML::Entities::encode($symb,'"<>&');
+ } elsif ($folderpath) {
+ $cfile .= '&folderpath='.&HTML::Entities::encode($folderpath,'"<>&');
+ }
+ if ($forceedit) {
+ $cfile .= '&forceedit=1';
+ }
+ if ($forcereg) {
+ $cfile .= '®ister=1';
+ }
+ $jscall = "need_switchserver('".&Apache::loncommon::escape_single($cfile)."');";
+ }
+ } else {
+ unless ($cfile =~ m{^/priv/}) {
+ if ($symb) {
+ $cfile .= (($cfile=~/\?/)?'&':'?')."symb=$symb";
+ } elsif ($folderpath) {
+ $cfile .= (($cfile=~/\?/)?'&':'?').
+ 'folderpath='.&HTML::Entities::encode(&escape($folderpath),'"<>&');
+ if ($title) {
+ $cfile .= (($cfile=~/\?/)?'&':'?').
+ 'title='.&HTML::Entities::encode(&escape($title),'"<>&');
+ }
+ if ($idx) {
+ $cfile .= (($cfile=~/\?/)?'&':'?').'idx='.$idx;
+ }
+ if ($suppurl) {
+ $cfile .= (($cfile=~/\?/)?'&':'?').
+ 'suppurl='.&HTML::Entities::encode(&escape($suppurl));
+ }
+ }
+ if ($forceedit) {
+ $cfile .= (($cfile=~/\?/)?'&':'?').'forceedit=1';
+ }
+ if ($forcereg) {
+ $cfile .= (($cfile=~/\?/)?'&':'?').'register=1';
+ }
+ if ($todocs) {
+ $cfile .= (($cfile=~/\?/)?'&':'?').'todocs=1';
+ }
+ }
+ $jscall = "go('".&Apache::loncommon::escape_single($cfile)."')";
+ }
+ return $jscall;
+}
+
+##############################################
+##############################################
+
# javascript_valid_email
#
# Generates javascript to validate an e-mail address.
@@ -2271,7 +3608,7 @@ END
sub htmltag{
return
qq|<$_[0]|
- . join( '', map { qq| $_="${$_[2]}{$_}"| if ${$_[2]}{$_} } keys %{ $_[2] } )
+ . join( '', map { qq| $_="${$_[2]}{$_}"| if ${$_[2]}{$_} } keys(%{ $_[2] }) )
. ($_[1] ? qq|>$_[1]$_[0]>| : qq|/>|). "\n";
};
@@ -2279,7 +3616,7 @@ sub htmltag{
# USAGE: inittags(@tags);
#
# EXAMPLES:
-# - my ($h1, $h2, $h3) = initTags( qw( h1 h2 h3 ) )
+# - my ($h1, $h2, $h3) = inittags( qw( h1 h2 h3 ) )
# $h1->("This is a headline") #Returns: This is a headline
#
# NOTES: See sub htmltag for further information.
@@ -2327,6 +3664,45 @@ sub scripttag {
return htmltag('script', $content, {type => 'text/javascript'});
};
+=pod
+
+=item &list_from_array( \@array, { listattr =>{}, itemattr =>{} } )
+
+Constructs a XHTML list from \@array.
+
+=over
+
+=item input:
+
+=over
+
+=item \@array
+
+A reference to the array containing text that will be wrapped in tags.
+
+=item { listattr => {}, itemattr =>{} }
+
+Attributes for and - passed in as hash references.
+See htmltag() for more details.
+
+=back
+
+=back
+
+returns: XHTML list as String.
+
+=cut
+
+# \@items, {listattr => { class => 'abc', id => 'xyx' }, itemattr => {class => 'abc', id => 'xyx'}}
+sub list_from_array {
+ my ($items, $args) = @_;
+ return unless (ref($items) eq 'ARRAY');
+ return unless scalar @$items;
+ my ($ul, $li) = inittags( qw(ul li) );
+ my $listitems = join '', map { $li->($_, $args->{itemattr}) } @$items;
+ return $ul->( $listitems, $args->{listattr} );
+}
+
##############################################
##############################################
@@ -2357,12 +3733,6 @@ sub scripttag {
#
# Outputs: A scalar containing the html markup for the menu.
-# ---- Remove when done ----
-# This routine is part of the redesign of LON-CAPA and it's
-# subject to change during this project.
-# Don't rely on its current functionality as it might be
-# changed or removed.
-# --------------------------
sub generate_menu {
my @menu = @_;
# subs for specific html elements
@@ -2378,16 +3748,21 @@ sub generate_menu {
# 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.
+ my $src;
+ if ($$link{icon} ne '') {
+ $src = '/res/adm/pages/'.$$link{icon};
+ }
push(@links,$li->(
$a->(
$img->("", {
class => "LC_noBorder LC_middle",
- src => "/res/adm/pages/$$link{icon}",
+ src => $src,
alt => mt(defined($$link{alttext}) ?
$$link{alttext} : $$link{linktext})
}), {
href => $$link{url},
- title => mt($$link{linktitle})
+ title => mt($$link{linktitle}),
+ class => 'LC_menubuttons_link'
}).
$a->(mt($$link{linktext}), {
href => $$link{url},
@@ -2421,7 +3796,7 @@ sub generate_menu {
=pod
-=item &start_funclist
+=item &start_funclist()
Start list of available functions
@@ -2432,13 +3807,19 @@ should be included in this list.
If the optional headline text is not provided, a default text will be used.
+=over
+
+=item Related routines:
-Related routines:
=over 4
-add_item_funclist
-end_funclist
+
+=item add_item_funclist
+
+=item end_funclist
+
=back
+=back
Inputs: (optional) headline text
@@ -2461,14 +3842,22 @@ sub start_funclist {
=pod
-=item &add_item_funclist
+=item &add_item_funclist()
Adds an item to the list of available functions
-Related routines:
+=over
+
+=item Related routines:
+
=over 4
-start_funclist
-end_funclist
+
+=item start_funclist
+
+=item end_funclist
+
+=back
+
=back
Inputs: content item with text and link to function
@@ -2485,19 +3874,19 @@ sub add_item_funclist {
return '
- '.$content.'
'."\n";
}
-##############################################
-##############################################
-
=pod
-=item &end_funclist
+=item &end_funclist()
End list of available functions
-Related routines:
-=over 4
-start_funclist
-add_item_funclist
+=over
+
+=item Related routines:
+
+ start_funclist
+ add_item_funclist
+
=back
Inputs: ./.
@@ -2506,13 +3895,81 @@ Returns: HTML code with function list en
=cut
-##############################################
-##############################################
-
sub end_funclist {
return "
\n";
}
+=pod
+
+=item &funclist_from_array( \@array, {legend => 'text for legend'} )
+
+Constructs a XHTML list from \@array with the first item being visually
+highlighted and set to the value of legend or 'Functions' if legend is
+empty.
+
+=over
+
+=item \@array
+
+A reference to the array containing text that will be wrapped in tags.
+
+=item { legend => 'text' }
+
+A string that's used as visually highlighted first item. 'Functions' is used if
+it's value evaluates to false.
+
+=back
+
+returns: XHTML list as string.
+
+=back
+
+=cut
+
+sub funclist_from_array {
+ my ($items, $args) = @_;
+ return unless(ref($items) eq 'ARRAY');
+ $args->{legend} ||= mt('Functions');
+ return list_from_array( [$args->{legend}, @$items],
+ { listattr => {class => 'LC_funclist'} });
+}
+
+=pod
+
+=over
+
+=item &actionbox( \@array )
+
+Constructs a XHTML list from \@array with the first item being visually
+highlighted and set to the value 'Actions'. The list is wrapped in a division.
+
+The actionlist is used to offer contextual actions, mostly at the bottom
+of a page, on which the outcome of an processed action is shown,
+e.g. a file operation in Authoring Space.
+
+=over
+
+=item \@array
+
+A reference to the array containing text. Details: sub funclist_from_array
+
+=back
+
+Returns: XHTML div as string.
+
+=back
+
+=cut
+
+sub actionbox {
+ my ($items) = @_;
+ return unless(ref($items) eq 'ARRAY');
+ return
+ ''
+ .&funclist_from_array($items, {legend => &mt('Actions')})
+ .'
';
+}
+
1;
__END__