--- loncom/interface/loncommon.pm 2006/07/19 08:36:11 1.431 +++ loncom/interface/loncommon.pm 2007/03/03 01:40:28 1.513 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # a pile of common routines # -# $Id: loncommon.pm,v 1.431 2006/07/19 08:36:11 albertel Exp $ +# $Id: loncommon.pm,v 1.513 2007/03/03 01:40:28 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -59,12 +59,14 @@ use Apache::lonnet; use GDBM_File; use POSIX qw(strftime mktime); use Apache::lonmenu(); +use Apache::lonenc(); use Apache::lonlocal; use HTML::Entities; use Apache::lonhtmlcommon(); use Apache::loncoursedata(); use Apache::lontexconvert(); -use LONCAPA; +use Apache::lonclonecourse(); +use LONCAPA qw(:DEFAULT :match); my $readit; @@ -156,7 +158,7 @@ BEGIN { opendir(DIR,$designdir); while ($filename=readdir(DIR)) { if ($filename!~/\.tab$/) { next; } - my ($domain)=($filename=~/^(\w+)\./); + my ($domain)=($filename=~/^($match_domain)\./); { my $designfile = $designdir.'/'.$filename; if ( open (my $fh,"<$designfile") ) { @@ -256,7 +258,7 @@ of the element the selection from the se sub browser_and_searcher_javascript { my ($mode)=@_; if (!defined($mode)) { $mode='edit'; } - my $resurl=&lastresurl(); + my $resurl=&escape_single(&lastresurl()); return < -1) { + var domid = getIndexByName(formid,udom); + if (domid > -1) { + if (document.forms[formid].elements[domid].type == 'select-one') { + domainfilter=document.forms[formid].elements[domid].options[document.forms[formid].elements[domid].selectedIndex].value; + } + if (document.forms[formid].elements[domid].type == 'hidden') { + domainfilter=document.forms[formid].elements[domid].value; + } + } } - var domainfilter='$domainfilter'; if (domainfilter != null) { if (domainfilter != '') { url += 'domainfilter='+domainfilter+'&'; @@ -407,11 +416,18 @@ sub coursebrowser_javascript { url += 'form=' + formname + '&cnumelement='+uname+ '&cdomelement='+udom+ '&cnameelement='+desc; - if (extra_element !=null && extra_element != '' && formname == 'rolechoice') { - url += '&roleelement='+extra_element; - if (domainfilter == null || domainfilter == '') { - url += '&domainfilter='+extra_element; + if (extra_element !=null && extra_element != '') { + if (formname == 'rolechoice') { + url += '&roleelement='+extra_element; + if (domainfilter == null || domainfilter == '') { + url += '&domainfilter='+extra_element; + } } + else { + if (formname == 'portform') { + url += '&setroles='+extra_element; + } + } } if (multflag !=null && multflag != '') { url += '&multiple='+multflag; @@ -434,14 +450,74 @@ sub coursebrowser_javascript { stdeditbrowser = open(url,title,options,'1'); stdeditbrowser.focus(); } - + + function getFormIdByName(formname) { + for (var i=0;i".&mt('Select [_1]',$selecttype).""; + return "".&mt('Select Course').""; } sub check_uncheck_jscript { @@ -672,14 +748,14 @@ sub help_open_topic { { $template .= "". - "
$text"; + "$text"; } # Add the graphic my $title = &mt('Online Help'); my $helpicon=&lonhttpdurl("/adm/help/gif/smallHelp.gif"); $template .= <<"ENDTEMPLATE"; - (Help: $topic) + (Help: $topic) ENDTEMPLATE if ($text ne '') { $template.='
' }; return $template; @@ -728,9 +804,7 @@ sub update_help_link { my $banner_link = "/adm/helpmenu?page=banner&topic=$topic&component_help=$component_help&faq=$faq&bug=$bug&origurl=$origurl&stamp=$timestamp&stayonpage=$stayOnPage"; my $output .= <<"ENDOUTPUT"; ENDOUTPUT return $output; @@ -766,29 +840,35 @@ sub help_open_menu { sub top_nav_help { my ($text) = @_; - my ($topic,$component_help,$faq,$bug,$stayOnPage,$width,$height); - - $text = "" if (not defined $text); - $stayOnPage = 0 if (not defined $stayOnPage); - if ($env{'browser.interface'} eq 'textual' || - $env{'environment.remote'} eq 'off' ) { - $stayOnPage=1; - } - $width = 620 if (not defined $width); - $height = 600 if (not defined $height); - my $link=''; + $text = &mt($text); + + my $stayOnPage = + ($env{'browser.interface'} eq 'textual' || + $env{'environment.remote'} eq 'off' ); + my $link= ($stayOnPage) ? "javascript:helpMenu('display')" + : "javascript:helpMenu('open')"; + my $banner_link = &update_help_link(undef,undef,undef,undef,$stayOnPage); + my $title = &mt('Get help'); - if ($stayOnPage) { - $link = "javascript:helpMenu('display')"; - } else { - $link = "javascript:helpMenu('open')"; - } + + return <<"END"; +$banner_link + $text +END +} + +sub help_menu_js { + my ($text) = @_; + + my $stayOnPage = + ($env{'browser.interface'} eq 'textual' || + $env{'environment.remote'} eq 'off' ); + + my $width = 620; + my $height = 600; my $helptopic=&general_help(); - my $banner_link = &update_help_link($topic,$component_help,$faq,$bug,$stayOnPage); my $details_link = '/adm/help/'.$helptopic.'.hlp'; - my $template; my $nothing=&Apache::lonhtmlcommon::javascript_nothing(); - my $helpicon=&lonhttpdurl("/adm/lonIcons/helpgateway.gif"); my $start_page = &Apache::loncommon::start_page('Help Menu', undef, {'frameset' => 1, @@ -800,8 +880,8 @@ sub top_nav_help { &Apache::loncommon::end_page({'frameset' => 1, 'js_ready' => 1,}); - $template .= <<"ENDTEMPLATE"; - -$banner_link - $text + ENDTEMPLATE return $template; } @@ -868,14 +946,14 @@ sub help_open_bug { { $template .= "". - "
$text"; + "$text"; } # Add the graphic my $title = &mt('Report a Bug'); my $bugicon=&lonhttpdurl("/adm/lonMisc/smallBug.gif"); $template .= <<"ENDTEMPLATE"; - (Bug: $topic) + (Bug: $topic) ENDTEMPLATE if ($text ne '') { $template.='
' }; return $template; @@ -913,14 +991,14 @@ sub help_open_faq { { $template .= "". - "
$text"; + "$text"; } # Add the graphic my $title = &mt('View the FAQ'); my $faqicon=&lonhttpdurl("/adm/lonMisc/smallFAQ.gif"); $template .= <<"ENDTEMPLATE"; - (FAQ: $topic) + (FAQ: $topic) ENDTEMPLATE if ($text ne '') { $template.='
' }; return $template; @@ -1187,37 +1265,13 @@ sub create_text_file { ## Home server