--- loncom/interface/loncommon.pm 2008/03/23 23:13:26 1.636.2.5 +++ loncom/interface/loncommon.pm 2008/05/31 01:51:42 1.658 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # a pile of common routines # -# $Id: loncommon.pm,v 1.636.2.5 2008/03/23 23:13:26 raeburn Exp $ +# $Id: loncommon.pm,v 1.658 2008/05/31 01:51:42 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -67,6 +67,7 @@ use Apache::loncoursedata(); use Apache::lontexconvert(); use Apache::lonclonecourse(); use LONCAPA qw(:DEFAULT :match); +use DateTime::TimeZone; # ---------------------------------------------- Designs use vars qw(%defaultdesign); @@ -78,6 +79,7 @@ my $readit; ## Global Variables ## + # ----------------------------------------------- SSI with retries: # @@ -91,7 +93,7 @@ my $readit; Performs an ssi with some number of retries. Retries continue either until the result is ok or until the retry count supplied by the -caller is exhausted. +caller is exhausted. Inputs: @@ -123,20 +125,23 @@ sub ssi_with_retries { my ($resource, $retries, %form) = @_; - my $ok = 0; # True if we got a good response. + my $ok = 0; # True if we got a good response. my $content; my $response; # Try to get the ssi done. within the retries count: do { - ($content, $response) = &Apache::lonnet::ssi($resource, %form); - $ok = $response->is_success; - $retries--; + ($content, $response) = &Apache::lonnet::ssi($resource, %form); + $ok = $response->is_success; + if (!$ok) { + &Apache::lonnet::logthis("Failed ssi_with_retries on $resource: ".$response->is_success.', '.$response->code.', '.$response->message); + } + $retries--; } while (!$ok && ($retries > 0)); if (!$ok) { - $content = ''; # On error return an empty content. + $content = ''; # On error return an empty content. } return ($content, $response); @@ -280,14 +285,14 @@ BEGIN { =over 4 -=item * browser_and_searcher_javascript () +=item * &browser_and_searcher_javascript() XXReturns a string containing javascript with two functions, C and C. Returned string does not contain EscriptE tags. -=item * openbrowser(formname,elementname,only,omit) [javascript] +=item * &openbrowser(formname,elementname,only,omit) [javascript] inputs: formname, elementname, only, omit @@ -300,7 +305,7 @@ with the given extension. Can be a comm Specifying 'omit' will restrict the browser to NOT displaying files with the given extension. Can be a comma separated list. -=item * opensearcher(formname, elementname) [javascript] +=item * &opensearcher(formname,elementname) [javascript] Inputs: formname, elementname @@ -385,7 +390,7 @@ sub storeresurl { unless ($resurl=~/^\/res/) { return 0; } $resurl=~s/\/$//; &Apache::lonnet::put('environment',{'lastresurl' => $resurl}); - &Apache::lonnet::appenv('environment.lastresurl' => $resurl); + &Apache::lonnet::appenv({'environment.lastresurl' => $resurl}); return 1; } @@ -443,6 +448,25 @@ sub selectstudent_link { return ''; } +sub authorbrowser_javascript { + return <<"ENDAUTHORBRW"; + +ENDAUTHORBRW +} + sub coursebrowser_javascript { my ($domainfilter,$sec_element,$formname)=@_; my $crs_or_grp_alert = &mt('Please select the type of LON-CAPA entity - Course or Group - for which you wish to add/modify a user role'); @@ -580,6 +604,12 @@ sub selectcourse_link { '","'.$udomele.'","'.$desc.'","'.$extra_element.'","'.$multflag.'","'.$selecttype.'");'."'>".&mt('Select Course').""; } +sub selectauthor_link { + my ($form,$udom)=@_; + return ''. + &mt('Select Author').''; +} + sub check_uncheck_jscript { my $jscript = <<"ENDSCRT"; function checkAll(field) { @@ -605,10 +635,24 @@ ENDSCRT return $jscript; } +sub select_timezone { + my ($name,$selected,$onchange)=@_; + my $output=" menus. The select menus will be linked in that @@ -773,7 +817,7 @@ END =pod -=item * help_open_topic($topic, $text, $stayOnPage, $width, $height) +=item * &help_open_topic($topic,$text,$stayOnPage,$width,$height) Returns a string corresponding to an HTML link to the given help $topic, where $topic corresponds to the name of a .tex file in @@ -827,7 +871,7 @@ sub help_open_topic { # Add the graphic my $title = &mt('Online Help'); - my $helpicon=&lonhttpdurl("/adm/help/gif/smallHelp.gif"); + my $helpicon=&lonhttpdurl("/res/adm/pages/help.png"); $template .= <<"ENDTEMPLATE"; (Help: $topic) ENDTEMPLATE @@ -1083,7 +1127,7 @@ ENDTEMPLATE =pod -=item * change_content_javascript(): +=item * &change_content_javascript(): This and the next function allow you to create small sections of an otherwise static HTML page that you can update on the fly with @@ -1138,7 +1182,7 @@ DOMBASED =pod -=item * changable_area($name, $origContent): +=item * &changable_area($name,$origContent): This provides a "changable area" that can be modified on the fly via the Javascript code provided in C. $name is @@ -1162,7 +1206,7 @@ sub changable_area { =pod -=item * viewport_geometry_js { +=item * &viewport_geometry_js Provides javascript object (Geometry) which can provide information about the viewport geometry for the client browser. @@ -1209,7 +1253,7 @@ GEOMETRY =pod -=item * viewport_size_js { +=item * &viewport_size_js() Provides a javascript function to set values of two form elements - width and height (elements are passed in as arguments to the javascript function) to the dimensions of the user's browser window. @@ -1233,7 +1277,7 @@ DIMS =pod -=item * resize_textarea_js +=item * &resize_textarea_js() emits the needed javascript to resize a textarea to be as big as possible @@ -1242,6 +1286,7 @@ the id of the element to resize, second surrounds everything that comes after the textarea, this routine needs to be attached to the for the onload and onresize events. +=back =cut @@ -1294,8 +1339,6 @@ RESIZE =pod -=back - =head1 Excel and CSV file utility routines =over 4 @@ -1307,7 +1350,7 @@ RESIZE =pod -=item * csv_translate($text) +=item * &csv_translate($text) Translate $text to allow it to be output as a 'comma separated values' format. @@ -1328,7 +1371,7 @@ sub csv_translate { =pod -=item * define_excel_formats +=item * &define_excel_formats() Define some commonly used Excel cell formats. @@ -1384,7 +1427,7 @@ sub define_excel_formats { =pod -=item * create_workbook +=item * &create_workbook() Create an Excel worksheet. If it fails, output message on the request object and return undefs. @@ -1427,7 +1470,7 @@ sub create_workbook { =pod -=item * create_text_file +=item * &create_text_file() Create a file to write to and eventually make available to the user. If file creation fails, outputs an error message on the request object and @@ -1495,7 +1538,7 @@ sub domain_select { =over 4 -=item * multiple_select_form($name,$value,$size,$hash,$order) +=item * &multiple_select_form($name,$value,$size,$hash,$order) Returns a string containing a form to allow a user to select options from a hash option_name => displayed text. @@ -1632,7 +1675,7 @@ sub select_level_form { =pod -=item * select_dom_form($defdom,$name,$includeempty,$showdomdesc) +=item * &select_dom_form($defdom,$name,$includeempty,$showdomdesc) Returns a string containing a