Annotation of loncom/interface/lonsyllabus.pm, revision 1.142

1.1       www         1: # The LearningOnline Network
                      2: # Syllabus
                      3: #
1.142   ! raeburn     4: # $Id: lonsyllabus.pm,v 1.141 2017/02/18 19:05:51 raeburn Exp $
1.1       www         5: #
                      6: # Copyright Michigan State University Board of Trustees
                      7: #
                      8: # This file is part of the LearningOnline Network with CAPA (LON-CAPA).
                      9: #
                     10: # LON-CAPA is free software; you can redistribute it and/or modify
                     11: # it under the terms of the GNU General Public License as published by
                     12: # the Free Software Foundation; either version 2 of the License, or
                     13: # (at your option) any later version.
                     14: #
                     15: # LON-CAPA is distributed in the hope that it will be useful,
                     16: # but WITHOUT ANY WARRANTY; without even the implied warranty of
                     17: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
                     18: # GNU General Public License for more details.
                     19: #
                     20: # You should have received a copy of the GNU General Public License
                     21: # along with LON-CAPA; if not, write to the Free Software
                     22: # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
                     23: #
                     24: # /home/httpd/html/adm/gpl.txt
                     25: #
                     26: # http://www.lon-capa.org/
                     27: #
                     28: 
                     29: package Apache::lonsyllabus;
                     30: 
                     31: use strict;
1.70      amueller   32: use Apache::lontemplate;
1.1       www        33: use Apache::Constants qw(:common);
                     34: use Apache::loncommon;
                     35: use Apache::lonnet;
1.5       www        36: use Apache::lontexconvert;
1.11      www        37: use Apache::lonfeedback;
1.133     raeburn    38: use Apache::lonhtmlgateway;
1.19      www        39: use Apache::lonannounce;
1.23      www        40: use Apache::lonlocal;
1.32      www        41: use Apache::lonhtmlcommon;
1.38      www        42: use Apache::lonspeller();
1.54      albertel   43: use HTML::Entities();
1.1       www        44: 
                     45: sub handler {
                     46:     my $r = shift;
1.46      www        47:     &Apache::loncommon::content_type($r,'text/html');
                     48:     $r->send_http_header;
                     49:     return OK if $r->header_only;
1.45      www        50: 
1.46      www        51:     my $target=$env{'form.grade_target'};
1.45      www        52: # --------------------------------------------------- Get course info from URL
                     53:     my (undef,undef,$cdom,$cnum)=split(/\//,$r->uri);
1.46      www        54: # ------------------------------------------------------------ Get query string
                     55:     &Apache::loncommon::get_unprocessed_cgi
1.116     raeburn    56:                         ($ENV{'QUERY_STRING'},['register','forceedit','todocs',
1.132     raeburn    57:                                                'folderpath','title','only_body']);
1.45      www        58: # ----------------------------------------------------- Is this even a course?
                     59:     my $homeserver=&Apache::lonnet::homeserver($cnum,$cdom);
                     60:     if ($homeserver eq 'no_host') {
                     61:         &Apache::loncommon::content_type($r,'text/html');
                     62:         $r->send_http_header;
1.106     faziophi   63:         &Apache::loncommon::simple_error_page($r,'No syllabus available',
1.91      amueller   64:                           'No syllabus available');
1.45      www        65:         return OK;
1.113     raeburn    66:     } elsif (!&Apache::lonnet::is_course($cdom,$cnum)) {
                     67:         &Apache::loncommon::content_type($r,'text/html');
                     68:         $r->send_http_header;
                     69:         &Apache::loncommon::simple_error_page($r,'No syllabus available',
                     70:                           'The course/community for which the syllabus was requested does not exist.');
                     71:         return OK;
1.45      www        72:     }
                     73: # ------------------------------------- There is such a course, get environment
                     74:     my %courseenv=&Apache::lonnet::dump('environment',$cdom,$cnum);
1.125     raeburn    75:     my $crstype = &Apache::loncommon::course_type();
1.46      www        76: 
1.117     raeburn    77: # --------------------------------------------------------------- Force Student
                     78:     my ($forceedit,$forcestudent);
                     79:     if ($env{'form.forceedit'}) { $forceedit=1; }
                     80:     if (!$forceedit) {
                     81:         $forcestudent=1;
                     82:     }
                     83: 
                     84: # --------------------------------------------------------------- Check Privileges
                     85:     my $allowed = 0;
                     86:     if ($env{'user.environment'}) {
                     87: # does this user have privileges to post, etc?
                     88:         if ($env{'request.course.id'}
                     89:         && $cdom eq $env{'course.'.$env{'request.course.id'}.'.domain'}
                     90:         && $cnum eq $env{'course.'.$env{'request.course.id'}.'.num'}) {
                     91:             $allowed=&Apache::lonnet::allowed('mdc',$env{'request.course.id'});
                     92:             if ($forcestudent or $target eq 'tex') { $allowed=0; }
                     93:         }
                     94:     }
                     95: 
1.46      www        96: # -------------------------------------------------- Let's see who handles this
1.117     raeburn    97:     my $external=$courseenv{'externalsyllabus'};
                     98:     my $uploaded=$courseenv{'uploadedsyllabus'};
1.122     raeburn    99:     my $minimal=$courseenv{'minimalsyllabus'};
1.49      albertel  100: 
1.132     raeburn   101:     if (($minimal =~/\w/) || ($uploaded =~/\w/)) {
1.137     raeburn   102:         my ($item,$is_pdf);
1.122     raeburn   103:         if ($minimal =~/\w/) {
                    104:             if ($external =~ m{\Q$minimal\E$}) {
                    105:                 undef($external);
                    106:             }
                    107:             $item = $minimal;
                    108:         } elsif ($uploaded =~/\w/) {
                    109:             if ($external =~ m{\Q$uploaded\E$}) {
                    110:                 undef($external);
                    111:             }
                    112:             $item = $uploaded;
1.137     raeburn   113:             if ($item =~ /\.pdf$/i) {
                    114:                 $is_pdf = 1;
                    115:             }
1.117     raeburn   116:         }
                    117:         unless ($allowed && $forceedit) {
1.122     raeburn   118:             my $file=&Apache::lonnet::filelocation("",$item);
1.141     raeburn   119:             if ($file =~ /\.(tex|x?html?)$/) {
1.125     raeburn   120:                 my $filetype = $1;
1.117     raeburn   121:                 my $filecontents=&Apache::lonnet::getfile($file);
                    122:                 if ($filecontents eq -1) {
                    123:                     $r->print(&mt('Syllabus file unavailable'));
1.125     raeburn   124:                 } elsif ($filetype eq 'tex') {
1.130     raeburn   125:                     if ($target eq 'tex') {
                    126:                         $r->print($filecontents);
                    127:                     } else {
1.140     raeburn   128:                         my $texengine = $env{'form.texengine'};
                    129:                         if ($texengine eq '') {
                    130:                             $texengine = 'tth';
                    131:                         } elsif (lc($texengine) eq 'jsmath') {
                    132:                             $texengine = 'MathJax';
                    133:                         }
                    134:                         my $result = &Apache::lontexconvert::converted(\$filecontents,$texengine);
1.130     raeburn   135:                         my %args;
                    136:                         &get_breadcrumbs($cdom,$cnum,$crstype,\%args);
1.132     raeburn   137:                         if ($env{'form.only_body'}) {
                    138:                             $args{'only_body'} = 1;
                    139:                         }
1.137     raeburn   140:                         if ($env{'request.use_absolute'}) {
                    141:                             $args{'use_absolute'} = $env{'request.use_absolute'};
                    142:                         }
1.130     raeburn   143:                         $r->print(&Apache::loncommon::start_page("Syllabus",undef,\%args).
                    144:                                   $result.
                    145:                                   &Apache::loncommon::end_page());
                    146:                     }
1.125     raeburn   147:                 } else {
1.117     raeburn   148:                     my %mystyle;
1.130     raeburn   149:                     unless ($target eq 'tex') {
                    150:                         $target = 'web';
                    151:                     }
1.117     raeburn   152:                     &Apache::structuretags::reset_problem_globals();
                    153:                     my $oldfile = $env{'request.filename'};
1.122     raeburn   154:                     $env{'request.filename'} = $item;
1.130     raeburn   155:                     my $result = &Apache::lonxml::xmlparse($r,$target,$filecontents,
1.125     raeburn   156:                                                            '',%mystyle);
1.117     raeburn   157:                     &Apache::structuretags::reset_problem_globals();
                    158:                     &Apache::lonhomework::finished_parsing();
                    159:                     $env{'request.filename'} = $oldfile;
                    160:                     &Apache::lonxml::add_messages(\$result);
                    161:                     $r->print($result);
                    162:                 }
                    163:             } else {
1.130     raeburn   164:                 if ($target eq 'tex') {
                    165:                     $r->print(&Apache::lonprintout::print_latex_header($env{'form.latex_type'}).
                    166:                               ' \strut \\\\ \textbf{'.&mt('Syllabus').'} \strut \\\\ '.
                    167:                               &mt('Unsupported file type.').' \strut \\\\ '.
                    168:                               &mt('Print the syllabus directly from your web browser').
                    169:                               '\end{document}');
                    170:                 } else {
1.141     raeburn   171:                     my $brcrum;
                    172:                     if ($env{'form.folderpath'} =~ /^supplemental/) {
                    173:                         my $title = $env{'form.title'};
                    174:                         if ($title eq '') {
                    175:                             $title = &mt('Syllabus');
                    176:                         }
                    177:                         $brcrum =
                    178:                             &Apache::lonhtmlcommon::docs_breadcrumbs(undef,$crstype,undef,$title,1);
                    179:                     }
                    180:                     $r->print(&Apache::lonwrapper::wrapper($item,$brcrum,$env{'request.use_absolute'},
1.139     raeburn   181:                                                            undef,$is_pdf,undef,&mt('Syllabus')));
1.130     raeburn   182:                 }
1.117     raeburn   183:             }
                    184:             return OK;
                    185:         }
                    186:     } elsif ($external=~/\w/) {
                    187:         unless ($allowed && $forceedit) {
1.130     raeburn   188:             if ($target eq 'tex') {
                    189:                 $r->print(&Apache::lonprintout::print_latex_header($env{'form.latex_type'}).
                    190:                          ' \strut \\\\ \textbf{'.&mt('Syllabus').'} \strut \\\\ '.$external.' '.
                    191:                          ' \strut \\\\ '.&mt('Print the syllabus directly from your web browser').
                    192:                          '\end{document}');
                    193:             } else {
1.137     raeburn   194:                 my $is_ext = 1;
1.141     raeburn   195:                 my ($is_pdf,$brcrum);
1.137     raeburn   196:                 if ($external =~ /\.pdf$/i) {
                    197:                     $is_pdf = 1;
                    198:                 }
1.141     raeburn   199:                 if ($env{'form.folderpath'} =~ /^supplemental/) {
                    200:                     my $title = $env{'form.title'};
                    201:                     if ($title eq '') {
                    202:                         $title = &mt('Syllabus');
                    203:                     }
                    204:                     $brcrum =
                    205:                         &Apache::lonhtmlcommon::docs_breadcrumbs(undef,$crstype,undef,$title,1);
                    206:                 }
                    207:                 $r->print(&Apache::lonwrapper::wrapper($external,$brcrum,$env{'request.use_absolute'},
1.139     raeburn   208:                                                        $is_ext,$is_pdf,undef,&mt('Syllabus')));
1.130     raeburn   209:             }
1.117     raeburn   210:             return OK;
                    211:         }
1.90      amueller  212:     }
1.42      www       213: 
1.130     raeburn   214: # ------------------------------------------------------------ Print the screen
                    215: 
                    216:     if ($target eq 'tex') {
                    217:         $r->print(&Apache::lonprintout::print_latex_header($env{'form.latex_type'}));
                    218:     }
1.120     raeburn   219: 
1.46      www       220: # ------------------------------ The buck stops here: internal syllabus display
1.5       www       221: # --------------------------------------------------------- The syllabus fields
1.23      www       222:     my %syllabusfields=&Apache::lonlocal::texthash(
1.5       www       223:        'aaa_instructorinfo' => 'Instructor Information',
                    224:        'bbb_description'    => 'Course Description',
                    225:        'ccc_prereq'         => 'Prerequisites',
1.7       www       226:        'cdc_classhours'     => 'Class Hours',
1.5       www       227:        'ddd_officehours'    => 'Office Hours',
                    228:        'eee_helproom'       => 'Helproom Hours',
1.7       www       229:        'efe_projectinfo'    => 'Project Information',
1.5       www       230:        'fff_examinfo'       => 'Exam Information',
1.7       www       231:        'fgf_deadlines'      => 'Deadlines',
1.5       www       232:        'ggg_grading'        => 'Grading Information',
1.7       www       233:        'hhh_readings'       => 'Readings',
                    234:        'iii_coursepack'     => 'Coursepack',
                    235:        'jjj_weblinks'       => 'Web Links',
1.9       www       236:        'kkk_textbook'       => 'Textbook',
                    237:        'lll_includeurl'     => 'URLs To Include in Syllabus');
1.121     raeburn   238: # ---------------------------------------------------------- Load syllabus info
                    239:     my %syllabus=&Apache::lonnet::dump('syllabus',$cdom,$cnum);
                    240:     my ($output,%displayfields,%noshow);
1.65      raeburn   241: 
1.121     raeburn   242: # This handler might be called anonymously ...
                    243: # ----------------------------------------------------- Only if not public call
                    244:     if ($allowed) {
1.122     raeburn   245:         if (($env{'form.choice'} =~ /^(template|minimal|url|file)$/) ||
1.121     raeburn   246:             ($env{'form.phase'} =~ /^(upload|check)_embedded$/)) {
                    247:             my $earlyout;
1.122     raeburn   248:             ($earlyout,$uploaded,$external,$minimal,$output) =
                    249:                 &save_changes($cnum,$cdom,$uploaded,$external,$minimal,
                    250:                               \%syllabus,\%syllabusfields,\%courseenv);
                    251:             if (($env{'form.choice'} eq 'minimal') && 
                    252:                 ($minimal eq "/uploaded/$cdom/$cnum/portfolio/syllabus/loncapa.html")) { 
                    253:                 delete($env{'form.symb'});
                    254:                 delete($env{'request.symb'});
                    255:                 $r->internal_redirect("$minimal?editmode=1&forceedit=1");
                    256:                 return OK;
                    257:             }
1.121     raeburn   258:             if ($earlyout) {
                    259:                 if ($target ne 'tex') {
                    260:                     &print_header($r,$cnum,$cdom,$crstype,$allowed,$forceedit,
                    261:                                   \%syllabus,\%syllabusfields);
1.122     raeburn   262:                     $r->print($output.
                    263:                               &Apache::loncommon::end_page());
1.121     raeburn   264:                 }
                    265:                 return OK;
1.90      amueller  266:             }
1.65      raeburn   267:         }
                    268:     }
1.121     raeburn   269:     if ($target ne 'tex') {
                    270:         &print_header($r,$cnum,$cdom,$crstype,$allowed,$forceedit,\%syllabus,
                    271:                       \%syllabusfields);
                    272:         $r->print($output);
1.117     raeburn   273:     }
                    274: 
1.121     raeburn   275: # -------------------------------------------- Determine which fields are shown 
1.117     raeburn   276: 
1.121     raeburn   277:     if ($syllabus{'uploaded.fields'}) {
                    278:         if ($syllabus{'uploaded.fields'} eq 'none') {
                    279:             foreach my $field (keys(%syllabusfields)) {
                    280:                 $displayfields{$field} = ' style="display:none;"';
                    281:                 $noshow{$field} = 1;
1.117     raeburn   282:             }
                    283:         } else {
1.121     raeburn   284:             my %included;
                    285:             map { $included{$_} = 1; } split(/,/,$syllabus{'uploaded.fields'});
                    286:             foreach my $field (keys(%syllabusfields)) {
                    287:                 my ($prefix) = split(/_/,$field);
                    288:                 if ($included{$prefix}) {
                    289:                     $displayfields{$field} = ' style="display:block;"';
1.117     raeburn   290:                 } else {
1.121     raeburn   291:                     $displayfields{$field} = ' style="display:none;"';
                    292:                     $noshow{$field} = 1;
1.117     raeburn   293:                 }
                    294:             }
                    295:         }
1.121     raeburn   296:     } else {
1.117     raeburn   297:         foreach my $field (keys(%syllabusfields)) {
                    298:             if ($syllabus{$field} ne '') {
                    299:                 $displayfields{$field} = ' style="display:block;"';
                    300:             } else {
                    301:                 $displayfields{$field} = ' style="display:none;"';
                    302:             }
1.90      amueller  303:         }
1.4       www       304:     }
1.85      bisitz    305: 
1.113     raeburn   306:     if ($allowed) {
                    307: #---------------------------------- Print External URL Syllabus Info if editing
                    308:         if ($target ne 'tex') {
                    309:             my $protocol = $Apache::lonnet::protocol{$homeserver};
                    310:             $protocol = 'http' if ($protocol ne 'https');
1.119     raeburn   311:             my $link = $protocol.'://'.&Apache::lonnet::hostname($homeserver).$r->uri;
1.142   ! raeburn   312:             if (($protocol eq 'https') && ($external =~ m{^http://})) {
        !           313:                 $link .= '?usehttp=1';
        !           314:             }
1.119     raeburn   315:             $r->print('<div class="LC_left_float">'
                    316:                      .'<span class="LC_help_open_topic LC_info">'
                    317:                      .'<span class="LC_info">'
                    318:                      .&mt('Public link (no log-in): [_1]','<tt>'.$link.'</tt>')
                    319:                      .'&nbsp;</span>'.&Apache::loncommon::help_open_topic('Syllabus_ExtLink')
                    320:                      .'</span>'
1.121     raeburn   321:                      .'</div><div style="padding:0;clear:both;margin:0;border:0"></div>'."\n");
1.117     raeburn   322:             my $lonhost = $r->dir_config('lonHostID');
1.122     raeburn   323:             $r->print(&chooser($external,$uploaded,$minimal,$cdom,$cnum,$lonhost,
                    324:                                \%syllabusfields,\%syllabus));
1.93      bisitz    325:         }
1.109     bisitz    326:     } else {
1.113     raeburn   327: #--------------------------------------------- Print last update unless editing
                    328:         my $lastmod=$syllabus{'uploaded.lastmodified'};
                    329:         $lastmod=($lastmod?&Apache::lonlocal::locallocaltime($lastmod):&mt('never'));
                    330:         my $who;
                    331:         if ($syllabus{'uploaded.lastmodified'}) {
                    332:             if (($env{'user.name'} ne 'public') && ($env{'user.domain'} ne 'public')) {
                    333:                 $who = &Apache::loncommon::aboutmewrapper(
                    334:                        &Apache::loncommon::plainname($syllabus{'uploaded.name'},
                    335:                        $syllabus{'uploaded.domain'}),$syllabus{'uploaded.name'},
                    336:                        $syllabus{'uploaded.domain'});
                    337:             } else {
                    338: # Public user?
                    339: # Only display name of user, but no link to personal information page
                    340:                 $who = &Apache::loncommon::plainname(
                    341:                            $syllabus{'uploaded.name'},
                    342:                            $syllabus{'uploaded.domain'});
                    343:             }
                    344:         }
                    345:         if ($target ne 'tex') {
                    346:             $r->print('<div class="LC_info">'.&mt('Last updated').': '.
                    347:                       $lastmod . ' '.
                    348:                       ($who ? &mt('by').' '.$who
                    349:                            : '' ) .
                    350:                       '</div>' );
                    351:         } else {
                    352:             $r->print('\\\\ '.&mt('Last updated').': '.$lastmod.' '.
                    353:                      ($who? &mt('by').'\\\\ '.
                    354:                      &Apache::loncommon::plainname($syllabus{'uploaded.name'},$syllabus{'uploaded.domain'})
                    355:                      :'')
                    356:                     .'\\\\');
                    357:         }
1.109     bisitz    358:     }
                    359: 
1.113     raeburn   360: #-------------------------------------------------------------- Print Headtitle
1.90      amueller  361:     if ($target ne 'tex') {
1.117     raeburn   362:         my $display = 'block';
1.122     raeburn   363:         if ($external || $uploaded || $minimal) {
1.117     raeburn   364:             $display = 'none';
                    365:         }
                    366:         $r->print('<div class="LC_Box" id="template" style="display: '.$display.'">'.
1.113     raeburn   367:                    '<h2 class="LC_hcell">'.$courseenv{'description'}.'</h2>');
                    368:         if ($allowed) {
1.121     raeburn   369:             $r->print('<div style="margin: 0; float:left;">'.
                    370:                       '<h3>'.&Apache::lonnet::domain($cdom,'description').'</h3>'.
                    371:                       '</div>');
1.113     raeburn   372: # Print Help Text if editing at right side of screen
1.121     raeburn   373:             $r->print('<div style="margin: 0; float:right;">'.
                    374:                       &Apache::loncommon::help_open_topic('Uploaded_Templates_TextBoxes',&mt('Help with filling in text boxes')).
                    375:                       '</div><br clear="all" />');
1.113     raeburn   376:         } else {
                    377:             $r->print('<h3>'.&Apache::lonnet::domain($cdom,'description').'</h3>');
                    378:         }
1.90      amueller  379:     } else {
1.91      amueller  380:         $r->print('\noindent{\large\textbf{'.$courseenv{'description'}.'}}\\\\\\\\\textbf{'.
                    381:         &Apache::lonnet::domain($cdom,'description').'}\\\\');
1.90      amueller  382:     }
1.80      neumanie  383: # -------------------------------------------------------- Get course personnel
1.121     raeburn   384:     my $hidepersonnel;
                    385:     if (($syllabus{'uploaded.fields'}) &&
                    386:         (($syllabus{'uploaded.fields'} eq 'none') ||
                    387:          ($syllabus{'uploaded.fields'} !~ /000/))) {
                    388:         $hidepersonnel = 1;
                    389:     }
1.80      neumanie  390:     if ($target ne 'tex') {
1.121     raeburn   391:         if ($allowed) {
                    392:             my $display = ' style="display:block;"';
                    393:             if ($hidepersonnel) {
                    394:                 $display = ' style="display:none;"';
                    395:             }
                    396:             &Apache::lontemplate::print_start_template($r,&mt('Personnel'),'LC_Box',
                    397:                                                        'box_000_showpeople',$display);
1.127     raeburn   398:             $r->print(&get_personnel($r,$target,$cdom,$cnum,$allowed,$crstype,\%syllabus));
1.121     raeburn   399:             &Apache::lontemplate::print_end_template($r);
1.91      amueller  400:         } else {
1.121     raeburn   401:             unless ($hidepersonnel) {
                    402:                 &Apache::lontemplate::print_start_template($r,&mt('Personnel'),'LC_Box');
1.127     raeburn   403:                 $r->print(&get_personnel($r,$target,$cdom,$cnum,$allowed,$crstype,\%syllabus));  
1.121     raeburn   404:                 &Apache::lontemplate::print_end_template($r);
1.91      amueller  405:             }
                    406:         }
1.121     raeburn   407:     } else {
                    408:         unless ($hidepersonnel) {
1.127     raeburn   409:             $r->print(&get_personnel($r,$target,$cdom,$cnum,$allowed,$crstype,%syllabus));
1.91      amueller  410:         }
1.80      neumanie  411:     }
1.79      neumanie  412: # -------------------------------------------------------------- Announcements?
                    413:     my $day = &Apache::lonannounce::showday(time,2,
1.91      amueller  414:              &Apache::lonannounce::readcalendar($cdom.'_'.$cnum));
1.121     raeburn   415:     my $hidefeeds;
                    416:     if (($syllabus{'uploaded.fields'}) &&
                    417:         (($syllabus{'uploaded.fields'} eq 'none') ||
                    418:          ($syllabus{'uploaded.fields'} !~ /111/))) {
                    419:         $hidefeeds = 1;
                    420:     }
1.80      neumanie  421:     if ($target ne 'tex') {
1.91      amueller  422:         if ($allowed) {
1.117     raeburn   423:             my $display = ' style="display:block;"';
1.121     raeburn   424:             if ($hidefeeds) {
1.117     raeburn   425:                 $display = ' style="display:none;"';
                    426:             }
                    427:             &Apache::lontemplate::print_start_template($r,&mt('RSS Feeds and Blogs'),'LC_Box',
1.121     raeburn   428:                                                        'box_111_showrssfeeds',$display);
1.120     raeburn   429:             my ($numfeeds,$hiddenfeeds,$rsslinktext);
1.121     raeburn   430:             my $feeds=&Apache::lonrss::advertisefeeds($cnum,$cdom,$forceedit,\$numfeeds,
                    431:                                                       \$hiddenfeeds);
1.120     raeburn   432:             if ($numfeeds) {
                    433:                 $r->print($feeds);
                    434:                 $rsslinktext = &mt('New RSS Feed or Blog');
                    435:             } else {
                    436:                 my $msg = '<br />'.
                    437:                           &mt("RSS Feeds and Blogs item is not included in a student's view of the syllabus.");
                    438:                 if ($hiddenfeeds) {
                    439:                     $r->print('<p class="LC_info">'.
                    440:                               &mt('All feeds currently hidden').
                    441:                               $msg.
                    442:                               '</p>');
                    443:                 } else {
                    444:                     $r->print('<p class="LC_info">'.
                    445:                               &mt('No current feeds').
                    446:                               $msg.
                    447:                               '</p>');
                    448:                 }
                    449:                 $rsslinktext = &mt('Manage Course RSS Feeds/Blogs');
                    450:                 if ($crstype eq 'Community') {
1.135     raeburn   451:                     $rsslinktext = &mt('Manage Community RSS Feeds/Blogs');
1.120     raeburn   452:                 }
                    453:             }
1.91      amueller  454:             my $editurl= &Apache::lonnet::absolute_url().'/adm/'.$cdom.'/'.$cnum.'/_rss.html';
1.120     raeburn   455:             $r->print( '<a href="'.$editurl.'">'.$rsslinktext.'</a>');
1.91      amueller  456:             &Apache::lontemplate::print_end_template($r);
1.117     raeburn   457:         } else {
1.121     raeburn   458:             unless ($hidefeeds) {
1.120     raeburn   459:                 my $feeds = &Apache::lonrss::advertisefeeds($cnum,$cdom,$forceedit);
                    460:                 if ($feeds ne '') {
1.117     raeburn   461:                     &Apache::lontemplate::print_start_template($r,&mt('RSS Feeds and Blogs'),'LC_Box');
1.120     raeburn   462:                     $r->print($feeds);
1.117     raeburn   463:                     &Apache::lontemplate::print_end_template($r);
                    464:                 }
                    465:             }
1.91      amueller  466:         }
1.79      neumanie  467:     } else {
1.91      amueller  468:         $r->print(&Apache::lonxml::xmlparse($r,'tex',$day));
1.86      bisitz    469:     }
1.79      neumanie  470: # ---------------------------------------------------------------- Get syllabus
1.86      bisitz    471:     if (($syllabus{'uploaded.lastmodified'}) || ($allowed)) {
1.106     faziophi  472: 		my $url_include_handler = sub {
1.117     raeburn   473: 			my ($r, $field, $message, $group, $data_ref, $fields_ref, $target, $allowed, $display) = @_;
1.106     faziophi  474: 			my %data = %{$data_ref};
                    475: 			my %fields = %{$fields_ref};
                    476: 			my $urls=$message;
                    477: 			$message='';
                    478: 			foreach my $filelink (split(/\n/,$urls)) {
                    479: 				my $output='';
                    480: 			   # embed style?
                    481: 				my ($curfext)=($filelink=~/\.([^\.]+)$/);
                    482: 				my $embstyle=&Apache::loncommon::fileembstyle($curfext);
                    483: 				if (($embstyle eq 'ssi') || ($curfext=~/\/$/)) {# make ssi call and remove everything but the body contents
                    484: 					$output=&Apache::lonnet::ssi_body($filelink);
                    485: 				} elsif ($embstyle eq 'img') {# embed as an image
                    486: 					$output='<img src="'.$filelink.'" />';
                    487: 				}
                    488: 				if ($output ne '') {
                    489: 					   if ($target ne 'tex') {
                    490: 						   $message.='<p>'.$output.'</p>';
                    491: 					   } else {
                    492: 						   $message.=' '.&Apache::lonxml::xmlparse($r,'tex','<p>'.$output.'</p>').' ';
                    493: 					   }
                    494: 				}
                    495: 			}
                    496: 			if ($allowed) {
                    497: 				 &Apache::lonfeedback::newline_to_br(\$urls);
                    498: 				 &Apache::lontemplate::print_start_template($r,$fields{$field}.
1.117     raeburn   499: 						  &Apache::loncommon::help_open_topic('Syllabus_URLs'),'LC_Box',
                    500:                                                   'box_'.$field,$display);
1.106     faziophi  501: 				 $r->print($urls);
                    502: 				 $r->print("<br /><div>");
                    503: 				 &Apache::lontemplate::print_textarea_template($r, $data{$field},
                    504: 					$field, Apache::lontemplate->RICH_TEXT_ALWAYS_OFF);
                    505: 				 &Apache::lontemplate::print_saveall_template($r);                         
                    506: 				 $r->print("</div>");
                    507: 				 &Apache::lontemplate::print_end_template($r);
1.86      bisitz    508: 
1.106     faziophi  509: 			} else {
                    510: 				$r->print($message);
                    511: 			}
                    512: 		};
                    513: 		my %custom_hash = ( 'lll_includeurl' => $url_include_handler );
1.110     raeburn   514: 		&Apache::lontemplate::print_template_fields($r, \%syllabus, \%syllabusfields, 
1.117     raeburn   515: 			$target, $allowed, Apache::lontemplate->RICH_TEXT_DETECT_HTML, \%custom_hash,
1.121     raeburn   516:                         undef,\%displayfields,\%noshow);
1.90      amueller  517:         if ($allowed) {
1.129     raeburn   518:             $r->print('</div></form>'.
1.110     raeburn   519:             &Apache::lonhtmlcommon::htmlareaselectactive());
1.90      amueller  520:         }
1.4       www       521:     } else {
1.112     bisitz    522:         if ($target ne 'tex') {$r->print('<p class="LC_info">');} else {$r->print('\par ');}
1.91      amueller  523:         $r->print(&mt('No syllabus information provided.'));
                    524:         if ($target ne 'tex') {$r->print('</p>');}
1.1       www       525:     }
1.86      bisitz    526:     if ($target ne 'tex') {
1.65      raeburn   527:         if ($env{'form.backto'} eq 'coursecatalog') {
                    528:             $r->print('<form name="backtocat" method="post" action="/adm/coursecatalog">'.
1.66      raeburn   529:                       &Apache::lonhtmlcommon::echo_form_input(['backto','courseid']).
1.65      raeburn   530:                       '</form>');
                    531:         }
1.91      amueller  532:         $r->print(&Apache::loncommon::end_page());
1.48      albertel  533:     } else {
1.91      amueller  534:         $r->print('\end{document}');
1.48      albertel  535:     }
1.1       www       536:     return OK;
1.86      bisitz    537: }
1.1       www       538: 
1.121     raeburn   539: sub print_header {
                    540:     my ($r,$cnum,$cdom,$crstype,$allowed,$forceedit,$syllabus,$syllabusfields) = @_;
                    541:     return unless ((ref($syllabus) eq 'HASH') || (ref($syllabusfields) eq 'HASH'));
                    542: # ----------------------------------------------------------------- Make header
                    543:     my $rss_link = &Apache::lonrss::rss_link($cnum,$cdom);
                    544:     my $js;
                    545:     if ($env{'form.backto'} eq 'coursecatalog') {
                    546:         $js .= <<"ENDSCRIPT";
                    547: 
                    548: <script type="text/javascript">
                    549: // <![CDATA[
                    550: 
                    551: function ToCatalog(caller) {
                    552:     numidx = getIndexByName('coursenum');
                    553:         if (numidx > -1) {
                    554:             if (caller != 'details') {
                    555:                 document.backtocat.elements[numidx].value = '';
                    556:             }
                    557:         }
                    558:     document.backtocat.submit();
                    559: }
                    560: 
                    561: function getIndexByName(item) {
                    562:     for (var i=0;i<document.backtocat.elements.length;i++) {
                    563:         if (document.backtocat.elements[i].name == item) {
                    564:             return i;
                    565:         }
                    566:     }
                    567:     return -1;
                    568: }
                    569: 
                    570: // ]]>
                    571: </script>
                    572: 
                    573: ENDSCRIPT
                    574:     }
                    575:     if ($allowed && $forceedit) {
                    576:         my $check_uncheck = &Apache::loncommon::check_uncheck_jscript();
                    577:         my @fieldnames = sort(keys(%{$syllabusfields}));
                    578:         unshift(@fieldnames,'000_showpeople','111_showrssfeeds');
                    579:         my (@checked,@unchecked);
                    580:         if ($syllabus->{'uploaded.fields'} eq 'none') {
                    581:             my $lastidx = scalar(@fieldnames)-1;
                    582:             @unchecked = (0..$lastidx);
                    583:         } elsif ($syllabus->{'uploaded.fields'}) {
                    584:             my %included;
                    585:             map { $included{$_} = 1; } split(/,/,$syllabus->{'uploaded.fields'});
                    586:             for (my $i=0; $i<@fieldnames; $i++) {
                    587:                 my ($prefix) = split(/_/,$fieldnames[$i]);
                    588:                 if ($included{$prefix}) {
                    589:                     push(@checked,$i);
                    590:                 } else {
                    591:                     push(@unchecked,$i);
                    592:                 }
                    593:             }
                    594:         } else {
                    595:             @checked = (0,1);
                    596:             for (my $i=2; $i<@fieldnames; $i++) {
                    597:                 if ($syllabus->{$fieldnames[$i]}) {
                    598:                     push(@checked,$i);
                    599:                 } else {
                    600:                     push(@unchecked,$i);
                    601:                 }
                    602:             }
                    603:         }
                    604:         my $fieldstr = "var fields = new Array('".join("','",@fieldnames)."');";
                    605:         my $checkedstr = "var include = new Array('".join("','",@checked)."');";
                    606:         my $uncheckedstr = "var exclude = new Array('".join("','",@unchecked)."');";
                    607:         my $invurl = &mt('Invalid URL');
1.138     damieng   608:         &js_escape(\$invurl);
1.121     raeburn   609:         my $urlregexp = <<'ENDREGEXP';
                    610: /^([a-z]([a-z]|\d|\+|-|\.)*):(\/\/(((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:)*@)?((\[(|(v[\da-f]{1,}\.(([a-z]|\d|-|\.|_|~)|[!\$&'\(\)\*\+,;=]|:)+))\])|((\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5]))|(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=])*)(:\d*)?)(\/(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*|(\/((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)+(\/(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*)?)|((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)+(\/(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*)|((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)){0})(\?((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|[\uE000-\uF8FF]|\/|\?)*)?(\#((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|\/|\?)*)?$/i
                    611: ENDREGEXP
                    612: 
                    613:         $js .= <<"ENDSCRIPT";
                    614: 
                    615: <script type="text/javascript">
                    616: // <![CDATA[
                    617: 
                    618: function toggleEditor(pick) {
1.122     raeburn   619:     var choices = new Array('template','minimal','url','file','templatebox');
1.121     raeburn   620:     for (var i=0; i<choices.length; i++) {
                    621:         if (((choices[i] == 'templatebox') && (pick == 'template')) ||
                    622:             (choices[i] == pick)) {
                    623:             document.getElementById(choices[i]).style.display='block';
                    624:         } else {
                    625:             document.getElementById(choices[i]).style.display='none';
                    626:         }
                    627:     }
                    628:     return;
                    629: }
                    630: 
                    631: var regexp = $urlregexp;
                    632: 
1.142   ! raeburn   633: function extUrlPreview(caller,protocol) {
1.121     raeburn   634:     if (document.getElementById(caller)) {
                    635:         var url = document.getElementById(caller).value;
                    636:         if (regexp.test(url)) {
1.142   ! raeburn   637:             var http_regex = /^http\:\/\//gi;
        !           638:             if ((protocol == 'https') && (http_regex.test(url))) {
        !           639:                 window.open(url,"syllabuspreview","height=400,width=500,scrollbars=1,resizable=1,menubar=0,location=1");
        !           640:             } else {
        !           641:                 openMyModal(url,500,400,'yes');
        !           642:             }
1.121     raeburn   643:         } else {
                    644:             alert("$invurl");
                    645:         }
                    646:     }
                    647: }
                    648: 
                    649: function toggleBox(name,caller) {
                    650:     if (name == 'all') {
                    651:         if (document.syllabus.showfield.length > 0) {
                    652:             for (var i=0; i<document.syllabus.showfield.length; i++) {
                    653:                 if (document.syllabus.showfield[i].checked) {
                    654:                     if (document.getElementById('box_'+document.syllabus.showfield[i].value)) {
                    655:                         document.getElementById('box_'+document.syllabus.showfield[i].value).style.display='block';
                    656:                     }
                    657:                 } else {
                    658:                     if (document.getElementById('box_'+document.syllabus.showfield[i].value)) {
                    659:                         document.getElementById('box_'+document.syllabus.showfield[i].value).style.display='none';
                    660:                     }
                    661:                 }
                    662:             }
                    663:         }
                    664:     } else {
                    665:         if (caller.checked) {
                    666:             if (document.getElementById('box_'+caller.value)) {
                    667:                 document.getElementById('box_'+caller.value).style.display='block';
                    668:             }
                    669:         } else {
                    670:             if (document.getElementById('box_'+caller.value)) {
                    671:                 document.getElementById('box_'+caller.value).style.display='none';
                    672:             }
                    673:         }
                    674:     }
                    675:     return;
                    676: }
                    677: 
                    678: function setTemplateBoxes() {
                    679:     $fieldstr
                    680:     $checkedstr
                    681:     $uncheckedstr
                    682:     if (include.length > 0) {
                    683:         for (var i=0; i<include.length; i++) {
                    684:             if (document.getElementById('showfield_'+include[i])) {
                    685:                 document.getElementById('showfield_'+include[i]).checked = true;
                    686:                 if (document.getElementById('box_'+fields[include[i]])) {
                    687:                     document.getElementById('box_'+fields[include[i]]).style.display='block';
                    688:                 }
                    689:             }
                    690:         }
                    691:     }
                    692:     if (exclude.length > 0) {
                    693:         for (var i=0; i<exclude.length; i++) {
                    694:             if (document.getElementById('showfield_'+exclude[i])) {
                    695:                 document.getElementById('showfield_'+exclude[i]).checked = false;
                    696:                 if (document.getElementById('box_'+fields[exclude[i]])) {
                    697:                     document.getElementById('box_'+fields[exclude[i]]).style.display='none';
                    698:                 }
                    699:             }
                    700:         }
                    701:     }
                    702:     return;
                    703: }
                    704: 
                    705: $check_uncheck
                    706: 
                    707: // ]]>
                    708: </script>
                    709: 
                    710: ENDSCRIPT
                    711:     }
                    712:     my $args = {'function'       => undef,
                    713:                 'domain'         => $cdom};
                    714:     my $forcereg;
                    715:     if ($env{'form.register'}) {
                    716:         $forcereg = 1;
                    717:         $args->{'force_register'} = $forcereg;
                    718:     }
                    719:     if ($env{'form.backto'} eq 'coursecatalog') {
                    720:         &Apache::lonhtmlcommon::clear_breadcrumbs();
                    721:         my $brcrum = [{href=>"javascript:ToCatalog();",
                    722:                        text=>&mt('Course/Community Catalog'),
                    723:                        no_mt=>1}
                    724:                      ];
                    725:         if ($env{'form.coursenum'} ne '') {
                    726:             push(@{$brcrum},
                    727:                   {href=>"javascript:ToCatalog('details')",
                    728:                    text=>"Course details"});
                    729:         }
                    730:         push(@{$brcrum},
                    731:               {href=>$r->uri,
                    732:                text=>"Course syllabus"});
                    733:         $args->{'bread_crumbs'} = $brcrum;
1.125     raeburn   734:     } else {
                    735:         &get_breadcrumbs($cdom,$cnum,$crstype,$args);
                    736:     }
                    737:     if ($allowed) {
                    738:         my %loaditem = (
                    739:                          onload => 'setTemplateBoxes();',
                    740:                        );
                    741:         $args->{'add_entries'} = \%loaditem;
1.137     raeburn   742:     } else {
                    743:         if ($env{'request.use_absolute'}) {
                    744:             $args->{'use_absolute'} = $env{'request.use_absolute'};
                    745:         }
1.125     raeburn   746:     }
1.132     raeburn   747:     if ($env{'form.only_body'}) {
                    748:         $args->{'only_body'} = 1;
                    749:     }
1.125     raeburn   750:     my $start_page =
                    751:         &Apache::loncommon::start_page("Syllabus", $rss_link.$js,$args);
                    752:     if ($start_page) {
                    753:         $r->print($start_page);
                    754:     }
                    755: }
                    756: 
                    757: sub get_breadcrumbs{
                    758:     my ($cdom,$cnum,$crstype,$args) = @_;
                    759:     return unless (ref($args) eq 'HASH');
                    760:     if ($env{'form.folderpath'} =~ /^supplemental/) {
1.121     raeburn   761:         my $title = $env{'form.title'};
                    762:         if ($title eq '') {
                    763:             $title = &mt('Syllabus');
                    764:         }
                    765:         my $brcrum =
                    766:             &Apache::lonhtmlcommon::docs_breadcrumbs(undef,$crstype,undef,$title,1);
                    767:         if (ref($brcrum) eq 'ARRAY') {
                    768:             $args->{'bread_crumbs'} = $brcrum;
                    769:         }
                    770:     } else {
                    771:         if ((&Apache::lonnet::is_on_map("public/$cdom/$cnum/syllabus"))
                    772:                  && (($env{'form.symb'}) || ($env{'form.register'}))) {
                    773:             &Apache::lonhtmlcommon::clear_breadcrumbs();
                    774:         } else {
                    775:             $args->{'bread_crumbs'} = [
                    776:                                         {'href' => "/public/$cdom/$cnum/syllabus",
                    777:                                          'text' => 'Syllabus'},
                    778:                                       ];
                    779:         }
                    780:     }
1.125     raeburn   781:     return;
1.121     raeburn   782: }
                    783: 
1.117     raeburn   784: sub chooser {
1.122     raeburn   785:     my ($external,$uploaded,$minimal,$cdom,$cnum,$lonhost,$fields,$values) = @_;
1.117     raeburn   786:     my %lt = &Apache::lonlocal::texthash(
                    787:                  'type'          => 'Syllabus Type',
                    788:                  'url'           => 'External URL',
1.122     raeburn   789:                  'file'          => 'Uploaded file',
                    790:                  'minimal'       => 'Minimal template',
                    791:                  'template'      => 'Standard template',
1.117     raeburn   792:                  'templateboxes' => 'Choose template items ... ',
                    793:                  'curr'          => 'Current:',
                    794:                  'rep'           => 'Replace:',
                    795:                  'upl'           => 'Upload:',
                    796:                  'pr'            => 'Preview',
                    797:                  'save'          => 'Save',
1.122     raeburn   798:                  'sved'          => 'Save and Edit',
                    799:                  'chourl'        => 'External URL',
1.117     raeburn   800:                  'chofile'       => 'Uploaded syllabus file',
                    801:                  'parse'         => 'Upload embedded images/multimedia files if HTML file',
                    802:     );
                    803:     my %checked = (
                    804:                     file     => '',
1.122     raeburn   805:                     minimal  => '',
1.117     raeburn   806:                     url      => '',
                    807:                     template => '',
                    808:                   );
                    809:     my %display = (
                    810:                     file        => 'none',
1.122     raeburn   811:                     minimal     => 'none',
1.117     raeburn   812:                     url         => 'none',
                    813:                     templatebox => 'none',
                    814:                   );
                    815:     my $check = ' checked="checked" ';
                    816:     if ($uploaded) {
                    817:         $checked{'file'} = $check;
                    818:         $display{'file'} = 'block';
                    819:     } elsif ($external) {
                    820:         $checked{'url'}  = $check;
                    821:         $display{'url'} = 'block';
1.122     raeburn   822:     } elsif ($minimal) {
                    823:         $checked{'minimal'} = $check;
                    824:         $display{'minimal'} = 'block';
1.117     raeburn   825:     } else {
                    826:         $checked{'template'} = $check;
                    827:         $checked{'templatebox'} = $check;
                    828:         $display{'templatebox'} = 'block';
                    829:     }
1.142   ! raeburn   830:     my $protocol = ($ENV{'SERVER_PORT'} == 443?'https':'http');
1.117     raeburn   831: 
                    832:     my $output = 
                    833:         '<form name="syllabus" method="post" enctype="multipart/form-data" action="">'."\n".
                    834:         '<input type="hidden" name="forceedit" value="1" />'."\n".
                    835:         '<div class="LC_left_float"><fieldset><legend>'.$lt{'type'}.'</legend>';
1.122     raeburn   836:     foreach my $item ('minimal','template','url','file') {
1.117     raeburn   837:         $output .= '<label><input type="radio" name="choice" value="'.$item.'" '.$checked{$item}.' onclick="toggleEditor('."'$item'".')" />'.
                    838:                    $lt{$item}.'</label><br />';
                    839:     }
                    840:     $output .= '</fieldset></div>'."\n".
                    841:                '<div id="url" class="LC_left_float" style="display: '.$display{'url'}.'">'."\n".
                    842:                '<fieldset><legend>'.$lt{'chourl'}.'</legend><span class="LC_nobreak">'."\n".
1.142   ! raeburn   843:                '<a href="javascript:extUrlPreview('."'syllabusurl','$protocol'".');">'.$lt{'pr'}.'</a></span>&nbsp;'."\n".
1.117     raeburn   844:                '<input type="text" id="syllabusurl" name="externalsyllabus" value="'.$external.'" size="55" />'."\n".
                    845:                '&nbsp;<input type="submit" name="storeurl" value="'.$lt{'save'}.'" />'."\n".
                    846:                '</fieldset></div>'."\n".
1.122     raeburn   847:                '<div id="minimal" class="LC_left_float" style="display: '.$display{'minimal'}.'">'."\n".
                    848:                '<fieldset><legend>'.$lt{'minimal'}.'</legend>';
                    849:     if ($minimal) {
                    850:         my ($absurl,$filename,$depbutton) = &syllabus_file_info($minimal,$cnum,$cdom,$lonhost,'minimal');
                    851:         $output .= '<a href="javascript:extUrlPreview('."'currminimal'".');">'.$lt{'pr'}.'</a>'.
                    852:                    '<input type="hidden" name="minimalfile" value="'.&HTML::Entities::encode($absurl).'?inhibitmenu=yes" id="currminimal" />'.
                    853:                    $depbutton;
                    854:     } else {
                    855:         $output .= &mt('Title of Syllabus Page:').'&nbsp;'.
                    856:                    '<input type="text" id="minimaltitle" name="syllabustitle" value="'.&mt('Syllabus').'" size="30" />'."\n".
                    857:                    '&nbsp;<input type="submit" name="storeminimal" value="'.$lt{'sved'}.'" />'."\n";
                    858:     }
                    859:     $output .= '</fieldset></div>'."\n".
                    860:                '<div id="file" class="LC_left_float" style="display: '.$display{'file'}.'">'."\n".
                    861:                '<fieldset><legend>'.$lt{'file'}.'</legend>';
1.117     raeburn   862:     if ($uploaded) {
1.122     raeburn   863:         my ($absurl,$filename,$depbutton) = &syllabus_file_info($uploaded,$cnum,$cdom,$lonhost,'file');
1.117     raeburn   864:         $output .= '<span class="LC_nobreak">'.$lt{'curr'}.'&nbsp;'.
                    865:                    '<input type="hidden" name="uploadedfile" value="'.&HTML::Entities::encode($absurl).'?inhibitmenu=yes" id="currfile" />'.
1.118     raeburn   866:                    '<a href="javascript:extUrlPreview('."'currfile'".');">'.$filename.'</a></span>'.$depbutton.
                    867:                    '<br /><br />'.$lt{'rep'};
1.117     raeburn   868:     } else {
                    869:         $output .= $lt{'upl'};
                    870:     }
                    871:     $output .= '<br />'."\n".
                    872:                '<span class="LC_nobreak">'.
                    873:                '<input type="file" name="syllabusfile" size="55" />'."\n".
                    874:                '&nbsp;<input type="submit" name="storefile" value="'.$lt{'save'}.'" />'.
                    875:                '</span><br />'.
                    876:                '<label>'.
                    877:                '<input type="checkbox" name="parserflag" checked="checked" />'.
                    878:                $lt{'parse'}.
                    879:                '</label>'.
                    880:                '</fieldset></div>'.
                    881:                '<div id="templatebox" class="LC_left_float" style="display: '.
                    882:                $display{'templatebox'}.';"><fieldset><legend>'.$lt{'templateboxes'}.
                    883:                '&nbsp;<input type="button" value="'.&mt('check all').'" '.
                    884:                'onclick="javascript:checkAll('."document.syllabus.showfield".');javascript:toggleBox('."'all'".');" />'.
                    885:                ('&nbsp;'x2).
                    886:                '<input type="button" value="'.&mt('uncheck all').'" '.
                    887:                'onclick="javascript:uncheckAll('."document.syllabus.showfield".');javascript:toggleBox('."'all'".');" />'.
                    888:                '</legend>'.
                    889:                &fields_check_uncheck($fields,$values).
1.121     raeburn   890:                '</fieldset><br />'.
                    891:                '<input type="submit" name="storesyl" value="'.&mt('Save All').'" />'.
1.117     raeburn   892:                '</div>';
1.121     raeburn   893:     $output .= '<div style="padding:0;clear:both;margin:0;border:0"></div>';
1.117     raeburn   894:     return $output;
                    895: }
                    896: 
1.122     raeburn   897: sub syllabus_file_info {
                    898:     my ($item,$cnum,$cdom,$lonhost,$context) = @_;
                    899:     my $protocol = $Apache::lonnet::protocol{$lonhost};
                    900:     $protocol = 'http' if ($protocol ne 'https');
                    901:     my $absurl = $protocol.'://'.&Apache::lonnet::hostname($lonhost).$item;
                    902:     my ($filename) = ($item =~ m{([^/]+)$});
                    903:     my $file=&Apache::lonnet::filelocation("",$item);
1.125     raeburn   904:     my ($depbutton,$filetype,$editable);
                    905:     if ($file =~ /\.(xhtml|xml|tex|html|htm)$/) {
                    906:         $filetype=$1;
                    907:     }
                    908:     if ($filetype) {
                    909:         unless ($filetype eq 'tex') {
                    910:             $filetype='html';
                    911:         }
                    912:     }
                    913:     if ($filetype eq 'html') {
1.122     raeburn   914:         my $filecontents=&Apache::lonnet::getfile($file);
                    915:         unless ($filecontents eq -1) {
                    916:             my $mm = new File::MMagic;
                    917:             my $mimetype = $mm->checktype_contents($filecontents);
                    918:             if ($mimetype eq 'text/html') {
                    919:                 my (%codebase,%allfiles);
                    920:                 my $parse_result = &Apache::lonnet::extract_embedded_items($item,\%allfiles,
                    921:                                                                            \%codebase,\$filecontents);
                    922:                 my $actionurl = "/public/$cdom/$cnum/syllabus";
                    923:                 my ($ignore,$num,$numpathchanges,$existing,$mapping) =
                    924:                     &Apache::loncommon::ask_for_embedded_content($actionurl,undef,\%allfiles,
                    925:                                                                  \%codebase,
                    926:                                                                  {'context' => 'rewrites',
                    927:                                                                   'ignore_remote_references' => 1,});
1.125     raeburn   928:                 $editable = 1;
1.122     raeburn   929:             }
                    930:         }
                    931:     }
1.125     raeburn   932:     $depbutton = ('&nbsp;' x 3).
                    933:                  &editfile_button($item,$context,$editable).
                    934:                  &editbutton_js();
1.122     raeburn   935:     return ($absurl,$filename,$depbutton);
                    936: }
                    937: 
1.117     raeburn   938: sub fields_check_uncheck {
                    939:     my ($fields,$values) = @_;
                    940:     return unless ((ref($fields) eq 'HASH') && (ref($values) eq 'HASH'));
                    941:     my $numinrow = 4;
                    942:     my $table;
                    943:     my @fieldnames = sort(keys(%{$fields}));
1.121     raeburn   944:     unshift(@fieldnames,'000_showpeople','111_showrssfeeds'); 
1.117     raeburn   945:     my $numfields = scalar(@fieldnames);
1.121     raeburn   946:     my %included;
                    947:     if (($values->{'uploaded.fields'}) && ($values->{'uploaded.fields'} ne 'none')) {
                    948:         map { $included{$_} = 1; } split(/,/,$values->{'uploaded.fields'});
                    949:     }
1.117     raeburn   950:     for (my $i=0; $i<$numfields; $i++) {
1.121     raeburn   951:         my ($name,$checked);
                    952:         if ($fieldnames[$i] eq '000_showpeople') {
                    953:             $name = &mt('Personnel');
                    954:         } elsif ($fieldnames[$i] eq '111_showrssfeeds') {
1.117     raeburn   955:             $name = &mt('RSS Feeds and Blogs');
1.121     raeburn   956:         } else {
                    957:             $name = $fields->{$fieldnames[$i]};
                    958:         }
                    959:         if ($values->{'uploaded.fields'}) {
                    960:             unless ($values->{'uploaded.fields'} eq 'none') {
                    961:                 my ($prefix) = split(/_/,$fieldnames[$i]);
                    962:                 if ($included{$prefix}) {
                    963:                     $checked = ' checked="checked"';
                    964:                 }
                    965:             }
                    966:         } else {
                    967:             if ($fieldnames[$i] eq '000_showpeople') {
                    968:                 $checked = ' checked="checked"';
                    969:             } elsif ($fieldnames[$i] eq '111_showrssfeeds') {
1.117     raeburn   970:                 $checked = ' checked="checked"';
1.121     raeburn   971:             } else {
                    972:                 if ($values->{$fieldnames[$i]} ne '') {
                    973:                     $checked = ' checked="checked"';
                    974:                 }
1.117     raeburn   975:             }
                    976:         }
                    977:         my $rem = $i%($numinrow);
                    978:         if ($rem == 0) {
1.121     raeburn   979:             if (($i > 0) && ($i < $numfields)) {
1.117     raeburn   980:                 $table .= '</tr>';
                    981:             }
1.121     raeburn   982:             if ($i < $numfields) {
1.117     raeburn   983:                 $table .= '<tr>';
                    984:             }
                    985:         }
1.121     raeburn   986:         if ($i == $numfields-1) {
                    987:             my $rem = $numfields%($numinrow);
                    988:             my $colsleft = $numinrow - $rem;
                    989:             if ($colsleft > 1) {
                    990:                 $table .= '<td colspan="'.$colsleft.'">';
                    991:             } else {
                    992:                 $table .= '</td>';
                    993:             }
                    994:         } else {
                    995:             $table .= '<td>';
                    996:         }
1.117     raeburn   997:         $table .=
1.121     raeburn   998:             '<label><input type="checkbox" name="showfield" value="'.$fieldnames[$i].'" '.
1.117     raeburn   999:             $checked.' id="showfield_'.$i.'" onclick="javascript:toggleBox('."'$fieldnames[$i]',this".');" />'.
                   1000:             $name.'</label></td>'."\n";
                   1001:     }
                   1002:     if ($table ne '') {
                   1003:         my $rem = $numfields%($numinrow);
                   1004:         my $colsleft = $numinrow - $rem;
                   1005:         if ($colsleft > 1 ) {
                   1006:             $table .= '<td colspan="'.$colsleft.'">&nbsp;</td>';
                   1007:         } elsif ($colsleft == 1) {
                   1008:             $table .= '<td>&nbsp;</td>';
                   1009:         }
                   1010:         $table = '<table>'.$table.'</tr></table>';
                   1011:     }
                   1012:     return $table;
                   1013: }
                   1014: 
1.121     raeburn  1015: sub get_personnel {
1.127     raeburn  1016:     my ($r,$target,$cdom,$cnum,$allowed,$crstype,$syllabus) = @_;
                   1017:     my (%hiddenroles,%hiddenusers);
                   1018:     if (ref($syllabus) eq 'HASH') {
                   1019:         if (ref($syllabus->{'personnel'}) eq 'HASH') {
                   1020:             if ($syllabus->{'personnel'}{'hiderole'}) {
                   1021:                 map { $hiddenroles{$_} = 1; } split(/,/,$syllabus->{'personnel'}{'hiderole'});
                   1022:             }
                   1023:             if ($syllabus->{'personnel'}{'hideuser'}) {
                   1024:                 map { $hiddenusers{$_} = 1; } split(/,/,$syllabus->{'personnel'}{'hideuser'});
                   1025:             }
                   1026:         }
                   1027:     }
1.121     raeburn  1028:     my $output;
1.127     raeburn  1029:     my %coursepersonnel=&Apache::lonnet::get_course_adv_roles($cdom.'/'.$cnum,1);
1.121     raeburn  1030:     if ($target ne 'tex') {
1.127     raeburn  1031:         if ($allowed) {
                   1032:             $r->print(&Apache::loncommon::start_data_table().
                   1033:                       &Apache::loncommon::start_data_table_header_row().
                   1034:                       '<th>'.&mt('Role hidden?').'</th><th>'.&mt('Role').'</th>'.
                   1035:                       '<th>'.&mt('Personnel (hidden if checked)').'</th>'.
                   1036:                       &Apache::loncommon::end_data_table_header_row());
                   1037:         } else {
                   1038:             $r->print(&Apache::lonhtmlcommon::start_pick_box());
                   1039:         }
1.121     raeburn  1040:     } else {
                   1041:         $r->print('\begin{tabular}{|p{0.45\textwidth}|p{0.45\textwidth}|}\hline');
                   1042:     }
                   1043:     my @personnel=sort(keys(%coursepersonnel));
                   1044:     my $lastpers=$personnel[$#personnel];
                   1045:     foreach my $element (@personnel) {
1.127     raeburn  1046:         unless ($allowed) {
                   1047:             next if ($hiddenroles{$element}) 
                   1048:         }
                   1049:         my ($role,$sec);
                   1050:         if ($element =~ /:/) {
                   1051:             ($role,$sec) = split(/:/,$element);
                   1052:         } else {
                   1053:             $role = $element;
                   1054:         }
                   1055:         my $roletext = &Apache::lonnet::plaintext($role,$crstype);
                   1056:         if ($sec) {
                   1057:             $roletext .=' ('.&Apache::lonlocal::mt('Section [_1]',$sec).')';
                   1058:         }
1.121     raeburn  1059:         if ($target ne 'tex') {
1.127     raeburn  1060:             if ($allowed) {
                   1061:                 my $checked;
                   1062:                 if ($hiddenroles{$element}) {
                   1063:                     $checked = ' checked="checked"';
                   1064:                 }
                   1065:                 $r->print(&Apache::loncommon::start_data_table_row().
                   1066:                           '<td>'.
                   1067:                           '<input type="checkbox" name="hiderole" value="'.$element.'" '.
                   1068:                           $checked.' />'.
                   1069:                           '</td><td>'.$roletext.'</td><td>');
                   1070:             } else {
                   1071:                 $r->print(&Apache::lonhtmlcommon::row_title($roletext));
                   1072:             }
1.121     raeburn  1073:         } else {
1.127     raeburn  1074:             $r->print(' '.&Apache::lonxml::xmlparse($r,'tex',$roletext).' & ');
1.121     raeburn  1075:         }
                   1076:         my @coursepersonlist;
                   1077:         foreach my $user (split(/\,/,$coursepersonnel{$element})) {
                   1078:             my ($puname,$pudom)=split(/\:/,$user);
                   1079:             if ($target ne 'tex') {
                   1080:                 my $courseperson = &Apache::loncommon::plainname($puname,$pudom);
1.127     raeburn  1081:                 my $checked;
                   1082:                 if ($hiddenusers{$element.'&'.$puname.':'.$pudom}) {
                   1083:                     $checked = ' checked="checked"';
                   1084:                 }
                   1085:                 if ($allowed) {
                   1086:                     my $item = '<span class="LC_nobreak"><label>'.
1.129     raeburn  1087:                                '<input type="checkbox" name="hideuser" value="'.$element.'&amp;'.$puname.':'.$pudom.'"'.$checked.' />'.
1.127     raeburn  1088:                                &Apache::loncommon::aboutmewrapper($courseperson
                   1089: ,
                   1090:                                                $puname,$pudom).
                   1091:                                '</label>'.('&nbsp;'x2).'</span> ';
                   1092:                     push(@coursepersonlist,$item);
                   1093: 
1.121     raeburn  1094:                 } else {
1.127     raeburn  1095:                     next if ($hiddenusers{$element.'&'.$puname.':'.$pudom});
                   1096:                     if (($env{'user.name'} eq '') || ($env{'user.name'} eq 'public') ||
                   1097:                         ($env{'user.domain'} eq '') || ($env{'user.domain'} eq 'public')) {
                   1098:                         push(@coursepersonlist,$courseperson);
                   1099:                     } else {
                   1100:                         push(@coursepersonlist,&Apache::loncommon::aboutmewrapper($courseperson,
                   1101:                                                $puname,$pudom));
                   1102:                     }
1.121     raeburn  1103:                 }
                   1104:             } else {
                   1105:                 push(@coursepersonlist,&Apache::loncommon::plainname($puname,
                   1106:                               $pudom).' ');
                   1107:             }
                   1108:         }
1.127     raeburn  1109:         if ($allowed) {
                   1110:             $r->print(join('',@coursepersonlist));
                   1111:         } else {
                   1112:             $r->print(join(', ',@coursepersonlist));
                   1113:         }
1.121     raeburn  1114:         if ($target ne 'tex') {
1.127     raeburn  1115:             if ($allowed) {
1.129     raeburn  1116:                 $r->print('</td>'.&Apache::loncommon::end_data_table_row());
1.127     raeburn  1117:             } else {
                   1118:                 my $lastclose=$element eq $lastpers?1:0;
                   1119:                 $r->print(&Apache::lonhtmlcommon::row_closure($lastclose));
                   1120:             }
1.121     raeburn  1121:         } else {
                   1122:             $r->print('\\\\ \hline');
                   1123:         }
                   1124:     }
                   1125:     if ($target ne 'tex') {
1.127     raeburn  1126:         if ($allowed) {
                   1127:             $r->print(&Apache::loncommon::end_data_table());
                   1128:         } else {
                   1129:             $r->print(&Apache::lonhtmlcommon::end_pick_box());
                   1130:         }
1.121     raeburn  1131:     } else {
                   1132:         $r->print('\end{tabular}\\\\');
                   1133:     }
                   1134:     return;
                   1135: }
                   1136: 
                   1137: sub save_changes {
1.122     raeburn  1138:     my ($cnum,$cdom,$uploaded,$external,$minimal,$syllabus,$syllabusfields,$courseenv) = @_;
1.121     raeburn  1139:     my ($earlyout,$output);
1.131     raeburn  1140:     unless ((ref($syllabus) eq 'HASH') && (ref($syllabusfields) eq 'HASH') ||
                   1141:             (ref($courseenv) eq 'HASH')) {
1.122     raeburn  1142:         return ($earlyout,$uploaded,$external,$minimal,$output);
1.121     raeburn  1143:     }
1.142   ! raeburn  1144:     my ($was_ext,$is_ext,$putres);
        !          1145:     if ($external) {
        !          1146:         $was_ext = $external;
        !          1147:     }
1.128     raeburn  1148:     if (($env{'form.deleteuploaded_file'}) || ($env{'form.deleteuploaded_minimal'})) {
1.122     raeburn  1149:         my %storehash;
                   1150:         if (($env{'form.choice'} eq 'file') && 
1.128     raeburn  1151:             ($env{'form.deleteuploaded_file'}) && ($uploaded =~ /\w/)) {
1.131     raeburn  1152:             if ($courseenv->{'uploadedsyllabus'} =~ m{^\Q/uploaded/$cdom/$cnum/portfolio\E(/syllabus/.+)$}) {
                   1153:                 my $filename = $1;
                   1154:                 &update_access_permissions($cdom,$cnum,$filename);
                   1155:             }
1.122     raeburn  1156:             &Apache::lonnet::delenv('course.'.$env{'request.course.id'}.'.uploadedsyllabus');
                   1157:             &Apache::lonnet::delenv('course.'.$env{'request.course.id'}.'.externalsyllabus');
                   1158:             $storehash{'uploadedsyllabus'} = '';
                   1159:             $storehash{'externalsyllabus'} = '';
1.142   ! raeburn  1160:             $putres = &Apache::lonnet::put('environment',\%storehash,$cdom,$cnum);
1.122     raeburn  1161:             undef($uploaded);
                   1162:             undef($external);
                   1163:         } elsif (($env{'form.choice'} eq 'minimal') &&
1.128     raeburn  1164:                  ($env{'form.deleteuploaded_minimal'}) && ($minimal =~ /\w/)) {
1.131     raeburn  1165:             my $minimalurl = "/uploaded/$cdom/$cnum/portfolio/syllabus/loncapa.html";
                   1166:             if ($courseenv->{'minimalsyllabus'} eq "$minimalurl") {
                   1167:                 my $filecontents=&Apache::lonnet::getfile(&Apache::lonnet::filelocation("",$minimalurl));
                   1168:                 unless ($filecontents eq -1) {
                   1169:                     $env{'form.output'} = $filecontents; 
                   1170:                     &Apache::lonnet::finishuserfileupload($cnum,$cdom,'output',
                   1171:                                                           'portfolio/syllabus/loncapa.html.bak');
                   1172:                     $minimalurl = &default_minimal_syllabus($cnum,$cdom);
                   1173:                 }
                   1174:             }
                   1175:             &update_access_permissions($cdom,$cnum,'/syllabus/loncapa.html');
1.122     raeburn  1176:             &Apache::lonnet::delenv('course.'.$env{'request.course.id'}.'.externalsyllabus');
                   1177:             &Apache::lonnet::delenv('course.'.$env{'request.course.id'}.'.minimalsyllabus');
                   1178:             $storehash{'externalsyllabus'} = '';
                   1179:             $storehash{'minimalsyllabus'} = '';
1.142   ! raeburn  1180:             $putres = &Apache::lonnet::put('environment',\%storehash,$cdom,$cnum);
1.122     raeburn  1181:             undef($external);
                   1182:             undef($minimal);
                   1183:         }
                   1184:     } elsif ($env{'form.choice'} eq 'template') {
1.121     raeburn  1185: #store what the user typed in to the template
                   1186:         my @shown = &Apache::loncommon::get_env_multiple('form.showfield');
                   1187:         $syllabus->{'uploaded.fields'} = '';
                   1188:         if (@shown == 0) {
                   1189:             $syllabus->{'uploaded.fields'} = 'none';
                   1190:         } else {
                   1191:             foreach my $field (sort(@shown)) {
                   1192:                 if (($field eq '000_showpeople') ||
                   1193:                     ($field eq '111_showrssfeeds') ||
                   1194:                     ($syllabusfields->{$field})) {
                   1195:                     my ($prefix) = split(/_/,$field);
                   1196:                     $syllabus->{'uploaded.fields'} .= $prefix.',';
                   1197:                 }
1.127     raeburn  1198:                 if ($field eq '000_showpeople') {
                   1199:                     my @hideusers = &Apache::loncommon::get_env_multiple('form.hideuser');
                   1200:                     my @hideroles = &Apache::loncommon::get_env_multiple('form.hiderole');
                   1201:                     my %coursepersonnel=&Apache::lonnet::get_course_adv_roles($cdom.'/'.$cnum,1);
                   1202:                     my %personnel;
                   1203:                     foreach my $key (keys(%coursepersonnel)) {
                   1204:                         map { $personnel{$key}{$_} = 1; } split(/,/,$coursepersonnel{$key});
                   1205:                     }
                   1206:                     %{$syllabus->{'personnel'}} = ();
                   1207:                     $syllabus->{'personnel'}{'hideuser'} = '';
                   1208:                     $syllabus->{'personnel'}{'hiderole'} = '';
                   1209:                     foreach my $role (@hideroles) {
                   1210:                         if (exists($personnel{$role})) {
                   1211:                             $syllabus->{'personnel'}{'hiderole'} .= $role.',';
                   1212:                         }
                   1213:                     }
                   1214:                     foreach my $item (@hideusers) {
                   1215:                         my ($role,$user) = split(/\&/,$item);
                   1216:                         if (ref($personnel{$role}) eq 'HASH') {
                   1217:                             if ($personnel{$role}{$user}) {
                   1218:                                 $syllabus->{'personnel'}{'hideuser'} .= $item.',';
                   1219:                             }
                   1220:                         }
                   1221:                     }
                   1222:                     $syllabus->{'personnel'}{'hideuser'} =~ s/,$//;
                   1223:                     $syllabus->{'personnel'}{'hiderole'} =~ s/,$//;
                   1224:                 }
1.121     raeburn  1225:             }
                   1226:             $syllabus->{'uploaded.fields'} =~ s/,$//;
                   1227:         }
                   1228:         foreach my $syl_field (keys(%{$syllabusfields})) {
                   1229:             my $field=$env{'form.'.$syl_field};
                   1230:             chomp($field);
1.133     raeburn  1231:             my $gateway = Apache::lonhtmlgateway->new();
                   1232:             $field = $gateway->process_incoming_html($field,1);
1.121     raeburn  1233:                             #here it will be stored
                   1234:             $syllabus->{$syl_field}=$field;
                   1235:             if ($syl_field eq 'lll_includeurl') { # clean up included URLs
                   1236:                 my $field='';
                   1237:                 foreach my $value (split(/\n/,$syllabus->{$syl_field})) {
                   1238:                     my $url=$value;
                   1239: # get rid of leading and trailing spaces
                   1240:                     $url=~s/^\s+//;
                   1241:                     $url=~s/\s+$//;
                   1242:                     if ($url=~m|^https?\://([^/]+)/(.+)$|) {
                   1243:                         my $host = $1;
                   1244:                         my $remainder=$2;
                   1245: # remove the hostname from internal URLs
                   1246:                         my $hostname = &Apache::lonnet::hostname($host);
                   1247:                         my %all_hostnames = &Apache::lonnet::all_hostnames();
                   1248:                         foreach my $possible_host (keys(%all_hostnames)) {
                   1249:                             if ($possible_host =~ /\Q$hostname\E/i) {
                   1250:                                 $url=$remainder;
                   1251:                             }
                   1252:                         }
                   1253:                     }
                   1254: # norm internal URLs
                   1255:                     unless ($url=~/^https?\:/) {
                   1256:                         $url=&Apache::lonnet::clutter($url);
                   1257:                     }
                   1258: # re-assemble field
                   1259:                     if ($url) {
                   1260:                         $field.=$url."\n";
                   1261:                     }
                   1262:                 }
                   1263:                 $syllabus->{$syl_field}=$field;
                   1264:             }
                   1265:         }
                   1266:         my $now = time;
                   1267:         $syllabus->{'uploaded.domain'}=$env{'user.domain'};
                   1268:         $syllabus->{'uploaded.name'}=$env{'user.name'};
                   1269:         $syllabus->{'uploaded.lastmodified'} = $now;
1.142   ! raeburn  1270:         $putres = &Apache::lonnet::put('syllabus',$syllabus,$cdom,$cnum);
1.121     raeburn  1271:         if ($putres eq 'ok') {
1.123     raeburn  1272:             ($uploaded,$minimal,$external) = 
                   1273:                 &update_syllabus_env($cdom,$cnum,$courseenv,$env{'form.choice'},$uploaded,
                   1274:                                      $minimal,$external);
1.121     raeburn  1275:             $output = '<div>'.
                   1276:                       &Apache::lonhtmlcommon::confirm_success(&mt('Template saved.')).
                   1277:                       '</div>';
                   1278:         } else {
                   1279:             $output = '<div class="LC_error">'.
                   1280:                       &mt('An error occurred storing the template: [_1]',$putres).
                   1281:                       '</div>';
                   1282:         }
                   1283:     } elsif ($env{'form.choice'} eq 'url') {
                   1284:         if ($env{'form.externalsyllabus'} =~ m{^https?://}) {
                   1285:             if ($env{'form.externalsyllabus'} eq $external) {
                   1286:                 $output = '<div class="LC_info">'.
                   1287:                           &mt('External URL unchanged.').
                   1288:                           '</div>';
1.123     raeburn  1289:                 ($uploaded,$minimal,$external) =
                   1290:                     &update_syllabus_env($cdom,$cnum,$courseenv,$env{'form.choice'},$uploaded,
                   1291:                                          $minimal,$external);
1.121     raeburn  1292:             } else {
                   1293:                 $external=$env{'form.externalsyllabus'};
                   1294:                 $external =~ s/(`)//g;
1.142   ! raeburn  1295:                 $putres =
1.121     raeburn  1296:                     &Apache::lonnet::put('environment',{externalsyllabus=>$external},
                   1297:                                          $cdom,$cnum);
                   1298:                 if ($putres eq 'ok') {
                   1299:                     &Apache::lonnet::appenv({'course.'.$env{'request.course.id'}.'.externalsyllabus' => $external});
                   1300:                     $output = '<div>'.
                   1301:                               &Apache::lonhtmlcommon::confirm_success(&mt('External URL saved.')).
                   1302:                              '</div>';
1.123     raeburn  1303:                     ($uploaded,$minimal,$external) =
                   1304:                         &update_syllabus_env($cdom,$cnum,$courseenv,$env{'form.choice'},$uploaded,
                   1305:                                              $minimal,$external);
1.121     raeburn  1306:                 } else {
                   1307:                     $output = '<div class="LC_error">'.
                   1308:                               &mt('An error occurred storing the external URL: [_1]',$putres).
                   1309:                               '</div>';
                   1310:                 }
                   1311:             }
1.142   ! raeburn  1312:             $is_ext = $external;
1.121     raeburn  1313:         } else {
                   1314:             $output = '<div class="LC_error">'.
                   1315:                       &mt('External URL not saved -- invalid URL.').
                   1316:                       '</div>';
                   1317:         }
1.122     raeburn  1318:     } elsif (($env{'form.choice'} eq 'file') || ($env{'form.choice'} eq 'minimal')) {
1.121     raeburn  1319:         # Process file upload - phase one - upload and parse primary file.
1.122     raeburn  1320:         my ($upload_result,$uploadphase,$url,$needlink,$error,$errormsg);
                   1321:         if ($env{'form.choice'} eq 'file') {
                   1322:             if ($env{'form.syllabusfile.filename'}) {
                   1323:                 my %allfiles = ();
                   1324:                 my %codebase = ();
                   1325:                 ($url,$needlink) = &process_upload(\$output,$cnum,$cdom,
                   1326:                                                    \%allfiles,\%codebase);
                   1327:             } else {
1.134     raeburn  1328:                 $output = '<div class="LC_info">'.
1.122     raeburn  1329:                           &mt('No file uploaded').
                   1330:                           '</div>';
                   1331:             }
                   1332:         } elsif ($env{'form.choice'} eq 'minimal') {
1.131     raeburn  1333:             $url = "/uploaded/$cdom/$cnum/portfolio/syllabus/loncapa.html";
                   1334:             my $filecontents=&Apache::lonnet::getfile(&Apache::lonnet::filelocation("",$url));
                   1335:             if ($filecontents eq -1) {
                   1336:                 $url = &default_minimal_syllabus($cnum,$cdom);
1.122     raeburn  1337:             }
                   1338:         }
                   1339:         if ($url =~ m{^/uploaded/\Q$cdom\E/\Q$cnum\E.*/[^/]+$}) {
1.123     raeburn  1340:             my $exturl = &home_http_host($cdom,$cnum);
                   1341:             if ($exturl) {
                   1342:                 $exturl .= $url;
1.122     raeburn  1343:             }
                   1344:             my %storehash;
                   1345:             if ($env{'form.choice'} eq 'minimal') {
                   1346:                 $storehash{'minimalsyllabus'} = $url;
                   1347:             } else {
                   1348:                 $storehash{'uploadedsyllabus'} = $url;
                   1349:             }
                   1350:             if ($exturl) {
                   1351:                 $storehash{'externalsyllabus'} = $exturl;
                   1352:                 if ($exturl =~ /\.(html?|txt|js|css)$/) {
                   1353:                     $exturl .= '?inhibitmenu=yes';
                   1354:                 }
                   1355:             } else {
                   1356:                 $storehash{'externalsyllabus'} = '',
                   1357:             }
1.142   ! raeburn  1358:             $putres =
1.122     raeburn  1359:                 &Apache::lonnet::put('environment',\%storehash,$cdom,$cnum);
                   1360:             if ($putres eq 'ok') {
                   1361:                 &Apache::lonnet::make_public_indefinitely($url);
                   1362:                 foreach my $key (keys(%storehash)) {
                   1363:                     &Apache::lonnet::appenv({'course.'.$env{'request.course.id'}.'.'.$key => $storehash{$key}});
                   1364:                 }
                   1365:                 if ($env{'form.choice'} eq 'minimal') {
                   1366:                     $minimal = $url;
1.121     raeburn  1367:                 } else {
1.122     raeburn  1368:                     $uploaded = $url;
1.121     raeburn  1369:                 }
1.122     raeburn  1370:                 if ($needlink) {
                   1371:                     $output .= &return_to_editor($cdom,$cnum);
                   1372:                     $earlyout = 1;
1.121     raeburn  1373:                 }
1.123     raeburn  1374:                 ($uploaded,$minimal,$external) =
                   1375:                     &update_syllabus_env($cdom,$cnum,$courseenv,$env{'form.choice'},$uploaded,
                   1376:                                          $minimal,$external);
1.122     raeburn  1377:             } else {
                   1378:                 $error = 1;
                   1379:                 $errormsg = $putres;
                   1380:             }
                   1381:         } else {
                   1382:             $error = 1;
                   1383:         }
                   1384:         if ($error) {
                   1385:             $output = '<div class="LC_error">';
                   1386:             if ($env{'form.choice'} eq 'minimal') {
                   1387:                 $output = &mt('An error occurred creating the minimal template file [_1]',$errormsg);
                   1388:             } else {
                   1389:                 $output = &mt('An error occurred storing the uploaded file [_1]',$errormsg);
1.121     raeburn  1390:             }
1.122     raeburn  1391:             $output .= '</div>';
1.121     raeburn  1392:         }
                   1393:     } elsif ($env{'form.phase'} eq 'upload_embedded') {
                   1394:         # Process file upload - phase two - upload embedded objects
                   1395:         my $uploadphase = 'check_embedded';
                   1396:         my $primaryurl = &HTML::Entities::encode($env{'form.primaryurl'},'<>&"');
                   1397:         my $state = &embedded_form_elems($uploadphase,$primaryurl);
                   1398:         my $url_root = '/uploaded/'.$cdom.'/'.$cnum;
                   1399:         my $actionurl = "/public/$cdom/$cnum/syllabus";
                   1400:         my ($result,$flag,$numpathchgs) =
                   1401:             &Apache::loncommon::upload_embedded('syllabus','portfolio/syllabus',
                   1402:                 $cnum,$cdom,'/userfiles',$url_root,undef,undef,undef,$state,
                   1403:                 $actionurl);
                   1404:         unless ($numpathchgs) {
                   1405:             my $modres =
                   1406:                 &Apache::loncommon::modify_html_refs('syllabus','portfolio/syllabus',
                   1407:                                                      $cnum,$cdom,
                   1408:                                                      '/userfiles',$env{'form.primaryurl'});
                   1409:             $result .= $modres;
                   1410:         }
1.122     raeburn  1411:         $output = $result.&return_to_editor($cdom,$cnum);
1.121     raeburn  1412:         $earlyout = 1;
                   1413:     } elsif ($env{'form.phase'} eq 'check_embedded') {
                   1414:         # Process file upload - phase three - modify references in HTML file
                   1415:         my $uploadphase = 'modified_orightml';
                   1416:         my $result =
                   1417:             &Apache::loncommon::modify_html_refs('syllabus','portfolio/syllabus',
                   1418:                                                  $cnum,$cdom,
                   1419:                                                  '/userfiles',$env{'form.primaryurl'});
1.122     raeburn  1420:         $output = $result.&return_to_editor($cdom,$cnum);
1.121     raeburn  1421:         $earlyout = 1;
                   1422:     }
1.142   ! raeburn  1423:     if ($putres eq 'ok') {
        !          1424:         if ((($is_ext) && ($is_ext ne $was_ext)) || ($was_ext)) {
        !          1425:             my $chome = &Apache::lonnet::homeserver($cnum,$cdom);
        !          1426:             unless ($chome eq 'no_host') {
        !          1427:                 my %crsinfo = &Apache::lonnet::courseiddump($cdom,'.',1,'.','.',$cnum,undef,undef,'.');
        !          1428:                 if (ref($crsinfo{$cdom.'_'.$cnum}) eq 'HASH') {
        !          1429:                     if ($external =~ m{^http://}) {
        !          1430:                         $crsinfo{$cdom.'_'.$cnum}{'extsyllplain'} = 1;
        !          1431:                     } elsif ($crsinfo{$cdom.'_'.$cnum}{'extsyllplain'}) {
        !          1432:                         delete($crsinfo{$cdom.'_'.$cnum}{'extsyllplain'});
        !          1433:                     }
        !          1434:                     &Apache::lonnet::courseidput($cdom,\%crsinfo,$chome,'notime');
        !          1435:                 }
        !          1436:             }
        !          1437:         }
        !          1438:     }
1.122     raeburn  1439:     return ($earlyout,$uploaded,$external,$minimal,$output);
1.121     raeburn  1440: }
                   1441: 
1.131     raeburn  1442: sub default_minimal_syllabus {
                   1443:     my ($cnum,$cdom) = @_;
                   1444:     my $title;
                   1445:     if ($env{'form.syllabustitle'}) {
                   1446:         $title = $env{'form.syllabustitle'};
                   1447:         $title =~ s{`}{}g;
                   1448:         $title=~s/^\s+//;
                   1449:         $title=~s/\s+$//;
                   1450:     }
                   1451:     if ($title eq '') {
                   1452:         $title = &mt('Syllabus');
                   1453:     }
                   1454:     my $initialtext = &mt('Replace with your own content.');
                   1455:     my $newhtml = <<END;
                   1456: <html>
                   1457: <head>
                   1458: <title>$title</title>
                   1459: </head>
                   1460: <body bgcolor="#ffffff">
                   1461: <h2>$title</h2>
                   1462: $initialtext
                   1463: </body>
                   1464: </html>
                   1465: END
                   1466:     $env{'form.output'}=$newhtml;
                   1467:     return &Apache::lonnet::finishuserfileupload($cnum,$cdom,'output',
                   1468:                                                  'portfolio/syllabus/loncapa.html');
                   1469: }
                   1470: 
1.123     raeburn  1471: sub update_syllabus_env {
1.124     raeburn  1472:     my ($cdom,$cnum,$courseenv,$saved,$uploaded,$minimal,$external) = @_;
1.125     raeburn  1473:     return ($uploaded,$minimal,$external) unless(ref($courseenv) eq 'HASH');
1.123     raeburn  1474:     my $now = time;
                   1475:     my (@envkeys,%storehash);
                   1476:     if ($saved eq 'template') {
1.131     raeburn  1477:         if ($uploaded || $env{'course.'.$env{'request.course.id'}.'.uploadedsyllabus'}) {
1.123     raeburn  1478:             push(@envkeys,'uploaded');
                   1479:         }
1.131     raeburn  1480:         if ($minimal || $env{'course.'.$env{'request.course.id'}.'.minimalsyllabus'}) {
1.123     raeburn  1481:             push(@envkeys,'minimal');
                   1482:         }
1.131     raeburn  1483:         if ($external || $env{'course.'.$env{'request.course.id'}.'.externalsyllabus'}) {
1.123     raeburn  1484:             push(@envkeys,'external');
                   1485:         }
                   1486:         $storehash{'updatedsyllabus'} = $now;
                   1487:         &Apache::lonnet::appenv({'course.'.$env{'request.course.id'}.'.updatedsyllabus' => $now
                   1488: });
                   1489:     } elsif ($saved eq 'url') {
                   1490:         my $prefix = &home_http_host($cdom,$cnum);
                   1491:         if ($external =~ m{^\Q$prefix/uploaded/$cdom/$cnum/portfolio/syllabus/\E(.+)$}) {
                   1492:             my $file = $1;
                   1493:             if ($file eq 'loncapa.html') {
1.131     raeburn  1494:                 if ($uploaded || $env{'course.'.$env{'request.course.id'}.'.uploadedsyllabus'}) {
1.123     raeburn  1495:                     push(@envkeys,'uploaded');
                   1496:                 }
1.131     raeburn  1497:             } elsif ($minimal || $env{'course.'.$env{'request.course.id'}.'.minimalsyllabus'}) {
1.123     raeburn  1498:                 push(@envkeys,'minimal');
                   1499:             }
                   1500:         } else {
1.131     raeburn  1501:             if ($uploaded || $env{'course.'.$env{'request.course.id'}.'.uploadedsyllabus'}) {
1.123     raeburn  1502:                 push(@envkeys,'uploaded');
                   1503:             }
1.131     raeburn  1504:             if ($minimal || $env{'course.'.$env{'request.course.id'}.'.minimalsyllabus'}) {
1.123     raeburn  1505:                 push(@envkeys,'minimal');
                   1506:             }
                   1507:         }
                   1508:     } elsif ($saved eq 'file') {
1.131     raeburn  1509:         if ($minimal || $env{'course.'.$env{'request.course.id'}.'.minimalsyllabus'}) {
1.123     raeburn  1510:             push(@envkeys,'minimal');
                   1511:         }
                   1512:     } elsif ($saved eq 'minimal') {
1.131     raeburn  1513:         if ($uploaded || $env{'course.'.$env{'request.course.id'}.'.uploadedsyllabus'}) {
1.123     raeburn  1514:             push(@envkeys,'uploaded');
                   1515:         }
                   1516:     }
                   1517:     if (@envkeys > 0) {
                   1518:         foreach my $item (@envkeys) {
                   1519:             my $key = $item.'syllabus';
1.130     raeburn  1520:             if ($courseenv->{$key} ne '') {
1.123     raeburn  1521:                 &Apache::lonnet::delenv('course.'.$env{'request.course.id'}.'.'.$key);
1.131     raeburn  1522:                 if ($item eq 'minimal') {
                   1523:                     &update_access_permissions($cdom,$cnum,'/syllabus/loncapa.html');
                   1524:                 } elsif ($item eq 'uploaded') {
                   1525:                     if ($courseenv->{$key} =~ m{^\Q/uploaded/$cdom/$cnum/portfolio\E(/syllabus/.+)$}) {
                   1526:                         my $filename = $1;
                   1527:                         &update_access_permissions($cdom,$cnum,$filename);
                   1528:                     }
                   1529:                 }
1.123     raeburn  1530:                 $storehash{$key} = '';
1.131     raeburn  1531:             } elsif ($env{'course.'.$env{'request.course.id'}.'.'.$key} ne '') {
                   1532:                 &Apache::lonnet::delenv('course.'.$env{'request.course.id'}.'.'.$key);
1.123     raeburn  1533:             }
                   1534:             if ($item eq 'uploaded') {
                   1535:                 undef($uploaded);
                   1536:             }
                   1537:             if ($item eq 'external') {
                   1538:                 undef($external);
                   1539:             }
                   1540:             if ($item eq 'minimal') {
                   1541:                 undef($minimal);
                   1542:             }
                   1543:         }
                   1544:     }
                   1545:     if (keys(%storehash) > 0) {
                   1546:         &Apache::lonnet::put('environment',\%storehash,$cdom,$cnum);
                   1547:     }
                   1548:     return ($uploaded,$minimal,$external);
                   1549: }
                   1550: 
1.131     raeburn  1551: sub update_access_permissions {
                   1552:     my ($cdom,$cnum,$file_name) = @_;
                   1553:     my $current_permissions = &Apache::lonnet::get_portfile_permissions($cdom,$cnum);
                   1554:     my %access_controls =
                   1555:         &Apache::lonnet::get_access_controls($current_permissions,'',$file_name);
                   1556:     if (keys(%access_controls) > 0) {
                   1557:         my %changes;
                   1558:         foreach my $key (keys(%{$access_controls{$file_name}})) {
                   1559:             $changes{'delete'}{$key} = 1;
                   1560:         }
                   1561:         if (keys(%changes) > 0) {
                   1562:             my ($outcome,$deloutcome,$new_values,$translation) =
                   1563:                 &Apache::lonnet::modify_access_controls($file_name,\%changes,
                   1564:                                                         $cdom,$cnum);
                   1565:         }
                   1566:     }
                   1567:     return; 
                   1568: }
                   1569: 
1.123     raeburn  1570: sub home_http_host {
                   1571:     my ($cdom,$cnum) = @_;
                   1572:     my $home=&Apache::lonnet::homeserver($cnum,$cdom);
                   1573:     if ($home ne 'no_host') {
                   1574:         my $protocol = $Apache::lonnet::protocol{$home};
                   1575:         $protocol = 'http' if ($protocol ne 'https');
1.136     raeburn  1576:         return $protocol.'://'.&Apache::lonnet::hostname($home);
1.123     raeburn  1577:     }
                   1578:     return;
                   1579: }
                   1580: 
1.117     raeburn  1581: sub process_upload {
                   1582:     my ($upload_output,$cnum,$cdom,$allfiles,$codebase) = @_;
                   1583:     my ($parseaction,$showupload,$mimetype);
                   1584:     my $dest = 'portfolio/syllabus';
                   1585:     if ($env{'form.parserflag'}) {
                   1586:         $parseaction = 'parse';
                   1587:     }
                   1588:     my $url=&Apache::lonnet::userfileupload('syllabusfile','syllabus',$dest,
                   1589:                                             $parseaction,$allfiles,
                   1590:                                             $codebase,undef,undef,undef,undef,
                   1591:                                             undef,undef,\$mimetype);
                   1592:     if ($url =~ m{^/uploaded/\Q$cdom\E/\Q$cnum\E.*/([^/]+)$}) {
                   1593:         my $stored = $1;
                   1594:         $showupload = '<p>'.&mt('Uploaded [_1]',
                   1595:                                 '<span class="LC_filename">'.$stored.'</span>').
                   1596:                       '</p>';
                   1597:     } else {
                   1598:         my ($filename) = ($env{'form.syllabusfile.filename'} =~ m{([^/]+)$});
                   1599:         $$upload_output = '<div class="LC_error" id="uploadfileresult">'.
                   1600:                           &mt('Unable to save file [_1].',
                   1601:                               '<span class="LC_filename">'.$filename.'</span>').
                   1602:                           '</div>';
                   1603:         return (); 
                   1604:     }
                   1605:     my $needlink;
                   1606:     if (($parseaction eq 'parse') && ($mimetype eq 'text/html')) {
                   1607:         $$upload_output = $showupload;
                   1608:         my $total_embedded = scalar(keys(%{$allfiles}));
                   1609:         if ($total_embedded > 0) {
                   1610:             my $uploadphase = 'upload_embedded';
                   1611:             my $primaryurl = &HTML::Entities::encode($url,'<>&"');
                   1612:             my $state = &embedded_form_elems($uploadphase,$primaryurl);
                   1613:             my $actionurl = "/public/$cdom/$cnum/syllabus";
                   1614:             my ($embedded,$num,$numpathchanges,$existing);
                   1615:             ($embedded,$num,$numpathchanges,$existing) =
                   1616:                 &Apache::loncommon::ask_for_embedded_content($actionurl,$state,
                   1617:                                                              $allfiles,$codebase,
                   1618:                                                             {'error_on_invalid_names'   => 1,
                   1619:                                                              'ignore_remote_references' => 1,});
                   1620:             if ($embedded) {
                   1621:                 $needlink = 1;
                   1622:                 if ($num) {
                   1623:                     $$upload_output .=
                   1624:                         '<p>'.&mt('This file contains embedded multimedia objects, which need to be uploaded.').'</p>'.$embedded;
                   1625:                 } elsif ($numpathchanges) {
                   1626:                     $$upload_output .= $embedded;
                   1627:                 } else {
                   1628:                     $$upload_output .= $embedded;
                   1629:                     &Apache::loncommon::modify_html_refs('syllabus','portfolio/syllabus',
                   1630:                                                          $cnum,$cdom,'/userfiles',$url);
                   1631:                 }
                   1632:             } else {
                   1633:                 $$upload_output .= &mt('Embedded item(s) already present, so no additional upload(s) required').'<br />';
                   1634:                 &Apache::loncommon::modify_html_refs('syllabus','portfolio/syllabus',
                   1635:                                                      $cnum,$cdom,'/userfiles',$url);
                   1636: 
                   1637:             }
                   1638:         } else {
                   1639:             $$upload_output .= &mt('No embedded items identified').'<br />';
                   1640:         }
                   1641:         $$upload_output = '<div id="uploadfileresult">'.$$upload_output.'</div>';
                   1642:     }
                   1643:     return ($url,$needlink);
                   1644: }
                   1645: 
                   1646: sub embedded_form_elems {
                   1647:     my ($phase,$primaryurl) = @_;
                   1648:     return <<STATE;
                   1649:     <input type="hidden" name="forceedit" value="1" />
                   1650:     <input type="hidden" name="cmd" value="upload_embedded" />
                   1651:     <input type="hidden" name="phase" value="$phase" />
                   1652:     <input type="hidden" name="primaryurl" value="$primaryurl" />
                   1653: STATE
                   1654: }
                   1655: 
                   1656: sub return_to_editor {
                   1657:     my ($cdom,$cnum) = @_;
                   1658:     my $actionurl = "/public/$cdom/$cnum/syllabus";
                   1659:     return '<p><form name="backtoeditor" method="post" action="'.$actionurl.'" />'.
                   1660:            '<input type="hidden" name="forceedit" value="1" />'."\n".
                   1661:            '<a href="javascript:document.backtoeditor.submit();">'.&mt('Return to Editor').
                   1662:            '</a></p>';
                   1663: }
                   1664: 
1.118     raeburn  1665: sub editfile_button {
1.125     raeburn  1666:     my ($url,$context,$editable) = @_;
1.122     raeburn  1667:     my $edittext=&mt('Edit');
                   1668:     my $deltext=&mt('Delete');
1.125     raeburn  1669:     my $output;
                   1670:     if ($editable) {
                   1671:         $output = '
                   1672:                 <input type="button" value="'.$edittext.'" onclick="javascript:gotoeditor('."'$url'".');" name="edit_'.$context.'" />
                   1673:                 &nbsp;&nbsp;&nbsp;';
                   1674:     }
                   1675:     $output .= '
                   1676:                 <input type="button" value="'.$deltext.'" onclick="javascript:dodelete('."'$context'".');" name="del_'.$context.'" />
1.128     raeburn  1677:                 <input type="hidden" value="" name="deleteuploaded_'.$context.'" id="deleteuploaded_'.$context.'" />
1.125     raeburn  1678:     ';
                   1679:     return $output;
1.118     raeburn  1680: }
                   1681: 
                   1682: sub editbutton_js {
1.138     damieng  1683:     my %js_lt = &Apache::lonlocal::texthash(
1.126     raeburn  1684:                min    => 'Are you sure you want to delete the contents of the syllabus template?',
                   1685:                file   => 'Are you sure you want to delete the uploaded syllabus file?',
                   1686:                noundo => 'This action cannot be reversed.'
                   1687:              );
1.138     damieng  1688:     &js_escape(\%js_lt);
1.118     raeburn  1689:     return <<ENDJS;
                   1690:                 <script type="text/javascript">
                   1691:                 // <![CDATA[
1.122     raeburn  1692:                   function gotoeditor(url) {
                   1693:                       document.location.href = url+'?editmode=1&forceedit=1';
                   1694:                   }
                   1695:                   function dodelete(caller,url) {
1.128     raeburn  1696:                       if (document.getElementById('deleteuploaded_'+caller)) {
                   1697:                           document.getElementById('deleteuploaded_'+caller).value=1;
                   1698:                           if (caller == 'minimal') {
1.138     damieng  1699:                               if (confirm("$js_lt{'min'}"+"\\n"+"$js_lt{'noundo'}")) {
1.128     raeburn  1700:                                   document.syllabus.submit();
                   1701:                               }
1.126     raeburn  1702:                           }
1.128     raeburn  1703:                           if (caller == 'file') {
1.138     damieng  1704:                               if (confirm("$js_lt{'file'}"+"\\n"+"$js_lt{'noundo'}")) {
1.128     raeburn  1705:                                   document.syllabus.submit();
                   1706:                               }
1.126     raeburn  1707:                           }
                   1708:                       }
                   1709:                       return;   
1.118     raeburn  1710:                   }
                   1711:                 // ]]>
                   1712:                 </script>
                   1713: ENDJS
                   1714: }
                   1715: 
1.1       www      1716: 1;
                   1717: __END__

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