Annotation of loncom/interface/lonsyllabus.pm, revision 1.118
1.1 www 1: # The LearningOnline Network
2: # Syllabus
3: #
1.118 ! raeburn 4: # $Id: lonsyllabus.pm,v 1.117 2013/04/24 02:43:59 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.19 www 38: use Apache::lonannounce;
1.23 www 39: use Apache::lonlocal;
1.32 www 40: use Apache::lonhtmlcommon;
1.38 www 41: use Apache::lonspeller();
1.54 albertel 42: use HTML::Entities();
1.1 www 43:
44: sub handler {
45: my $r = shift;
1.46 www 46: &Apache::loncommon::content_type($r,'text/html');
47: $r->send_http_header;
48: return OK if $r->header_only;
1.45 www 49:
1.46 www 50: my $target=$env{'form.grade_target'};
1.45 www 51: # --------------------------------------------------- Get course info from URL
52: my (undef,undef,$cdom,$cnum)=split(/\//,$r->uri);
1.46 www 53: # ------------------------------------------------------------ Get query string
54: &Apache::loncommon::get_unprocessed_cgi
1.116 raeburn 55: ($ENV{'QUERY_STRING'},['register','forceedit','todocs',
1.115 raeburn 56: 'folderpath','title']);
1.45 www 57: # ----------------------------------------------------- Is this even a course?
58: my $homeserver=&Apache::lonnet::homeserver($cnum,$cdom);
59: if ($homeserver eq 'no_host') {
60: &Apache::loncommon::content_type($r,'text/html');
61: $r->send_http_header;
1.106 faziophi 62: &Apache::loncommon::simple_error_page($r,'No syllabus available',
1.91 amueller 63: 'No syllabus available');
1.45 www 64: return OK;
1.113 raeburn 65: } elsif (!&Apache::lonnet::is_course($cdom,$cnum)) {
66: &Apache::loncommon::content_type($r,'text/html');
67: $r->send_http_header;
68: &Apache::loncommon::simple_error_page($r,'No syllabus available',
69: 'The course/community for which the syllabus was requested does not exist.');
70: return OK;
1.45 www 71: }
72: # ------------------------------------- There is such a course, get environment
73: my %courseenv=&Apache::lonnet::dump('environment',$cdom,$cnum);
1.46 www 74:
1.1 www 75: # ------------------------------------------------------------ Print the screen
1.49 albertel 76:
77: if ($target eq 'tex') {
1.91 amueller 78: $r->print(&Apache::lonprintout::print_latex_header($env{'form.latex_type'}));
1.86 bisitz 79: }
1.117 raeburn 80:
81: # --------------------------------------------------------------- Force Student
82: my ($forceedit,$forcestudent);
83: if ($env{'form.forceedit'}) { $forceedit=1; }
84: if (!$forceedit) {
85: $forcestudent=1;
86: }
87:
88: # --------------------------------------------------------------- Check Privileges
89: my $allowed = 0;
90: if ($env{'user.environment'}) {
91: # does this user have privileges to post, etc?
92: if ($env{'request.course.id'}
93: && $cdom eq $env{'course.'.$env{'request.course.id'}.'.domain'}
94: && $cnum eq $env{'course.'.$env{'request.course.id'}.'.num'}) {
95: $allowed=&Apache::lonnet::allowed('mdc',$env{'request.course.id'});
96: if ($forcestudent or $target eq 'tex') { $allowed=0; }
97: }
98: }
99:
1.46 www 100: # -------------------------------------------------- Let's see who handles this
1.117 raeburn 101: my $external=$courseenv{'externalsyllabus'};
102: my $uploaded=$courseenv{'uploadedsyllabus'};
1.49 albertel 103:
1.117 raeburn 104: if ($uploaded =~/\w/) {
105: if ($external =~ m{\Q$uploaded\E$}) {
106: undef($external);
107: }
108: unless ($allowed && $forceedit) {
109: my $file=&Apache::lonnet::filelocation("",$uploaded);
110: if ($file =~ /\.(sty|css|js|txt|tex|html?)$/) {
111: my $filetype;
112: if ($file =~ /\.(sty|css|js|txt|tex)$/) {
113: $filetype=$1;
114: } else {
115: $filetype='html';
116: }
117: my $result = '';
118: my $filecontents=&Apache::lonnet::getfile($file);
119: if ($filecontents eq -1) {
120: $r->print(&mt('Syllabus file unavailable'));
121: } elsif ($filetype eq 'html') {
122: my %mystyle;
123: &Apache::structuretags::reset_problem_globals();
124: my $oldfile = $env{'request.filename'};
125: $env{'request.filename'} = $uploaded;
126: $result = &Apache::lonxml::xmlparse($r,'web',$filecontents,
127: '',%mystyle);
128: &Apache::structuretags::reset_problem_globals();
129: &Apache::lonhomework::finished_parsing();
130: $env{'request.filename'} = $oldfile;
131: &Apache::lonxml::add_messages(\$result);
132: $r->print($result);
133: }
134: } else {
135: $r->print(&Apache::lonwrapper::wrapper($uploaded));
136: }
137: return OK;
138: }
139: } elsif ($external=~/\w/) {
140: unless ($allowed && $forceedit) {
141: $r->print(&Apache::lonwrapper::wrapper($external));
142: return OK;
143: }
1.90 amueller 144: }
1.42 www 145:
1.46 www 146: # ------------------------------ The buck stops here: internal syllabus display
1.5 www 147: # --------------------------------------------------------- The syllabus fields
1.23 www 148: my %syllabusfields=&Apache::lonlocal::texthash(
1.5 www 149: 'aaa_instructorinfo' => 'Instructor Information',
150: 'bbb_description' => 'Course Description',
151: 'ccc_prereq' => 'Prerequisites',
1.7 www 152: 'cdc_classhours' => 'Class Hours',
1.5 www 153: 'ddd_officehours' => 'Office Hours',
154: 'eee_helproom' => 'Helproom Hours',
1.7 www 155: 'efe_projectinfo' => 'Project Information',
1.5 www 156: 'fff_examinfo' => 'Exam Information',
1.7 www 157: 'fgf_deadlines' => 'Deadlines',
1.5 www 158: 'ggg_grading' => 'Grading Information',
1.7 www 159: 'hhh_readings' => 'Readings',
160: 'iii_coursepack' => 'Coursepack',
161: 'jjj_weblinks' => 'Web Links',
1.9 www 162: 'kkk_textbook' => 'Textbook',
163: 'lll_includeurl' => 'URLs To Include in Syllabus');
1.86 bisitz 164: # ----------------------------------------------------------------- Make header
1.28 sakharuk 165: if ($target ne 'tex') {
1.91 amueller 166: my $rss_link = &Apache::lonrss::rss_link($cnum,$cdom);
1.65 raeburn 167: my $js;
168: if ($env{'form.backto'} eq 'coursecatalog') {
169: $js .= <<"ENDSCRIPT";
170:
171: <script type="text/javascript">
1.117 raeburn 172: // <![CDATA[
173:
1.65 raeburn 174: function ToCatalog(caller) {
175: numidx = getIndexByName('coursenum');
1.90 amueller 176: if (numidx > -1) {
177: if (caller != 'details') {
178: document.backtocat.elements[numidx].value = '';
179: }
1.65 raeburn 180: }
181: document.backtocat.submit();
182: }
183:
184: function getIndexByName(item) {
185: for (var i=0;i<document.backtocat.elements.length;i++) {
186: if (document.backtocat.elements[i].name == item) {
187: return i;
188: }
189: }
190: return -1;
191: }
192:
1.117 raeburn 193: // ]]>
194: </script>
195:
196: ENDSCRIPT
197: }
198: if ($allowed && $forceedit) {
199: my $check_uncheck = &Apache::loncommon::check_uncheck_jscript();
200: my $invurl = &mt('Invalid URL');
201: my $urlregexp = <<'ENDREGEXP';
202: /^([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
203: ENDREGEXP
204:
205: $js .= <<"ENDSCRIPT";
206:
207: <script type="text/javascript">
208: // <![CDATA[
209:
210: function toggleEditor(pick) {
211: var choices = new Array('template','url','file','templatebox');
212: for (var i=0; i<choices.length; i++) {
213: if (((choices[i] == 'templatebox') && (pick == 'template')) ||
214: (choices[i] == pick)) {
215: document.getElementById(choices[i]).style.display='block';
216: } else {
217: document.getElementById(choices[i]).style.display='none';
218: }
219: }
220: return;
221: }
222:
223: var regexp = $urlregexp;
224:
225: function extUrlPreview(caller) {
226: if (document.getElementById(caller)) {
227: var url = document.getElementById(caller).value;
228: if (regexp.test(url)) {
229: openMyModal(url,500,400,'yes');
230: } else {
231: alert("$invurl");
232: }
233: }
234: }
235:
236: function toggleBox(name,caller) {
237: if (name == 'all') {
238: if (document.syllabus.showfield.length > 0) {
239: for (var i=0; i<document.syllabus.showfield.length; i++) {
240: if (document.syllabus.showfield[i].checked) {
241: if (document.getElementById('box_'+document.syllabus.showfield[i].value)) {
242: document.getElementById('box_'+document.syllabus.showfield[i].value).style.display='block';
243: }
244: } else {
245: if (document.getElementById('box_'+document.syllabus.showfield[i].value)) {
246: document.getElementById('box_'+document.syllabus.showfield[i].value).style.display='none';
247: }
248: }
249: }
250: }
251: } else {
252: if (caller.checked) {
253: if (document.getElementById('box_'+caller.value)) {
254: document.getElementById('box_'+caller.value).style.display='block';
255: }
256: } else {
257: if (document.getElementById('box_'+caller.value)) {
258: document.getElementById('box_'+caller.value).style.display='none';
259: }
260: }
261: }
262: return;
263: }
264:
265: $check_uncheck
266:
267: // ]]>
1.65 raeburn 268: </script>
269:
270: ENDSCRIPT
271: }
1.115 raeburn 272: my $args = {'function' => undef,
273: 'domain' => $cdom};
1.113 raeburn 274: my $forcereg;
275: if ($env{'form.register'}) {
276: $forcereg = 1;
1.115 raeburn 277: $args->{'force_register'} = $forcereg;
1.113 raeburn 278: }
279: if ($env{'form.backto'} eq 'coursecatalog') {
280: &Apache::lonhtmlcommon::clear_breadcrumbs();
1.115 raeburn 281: my $brcrum = [{href=>"javascript:ToCatalog();",
282: text=>&mt('Course/Community Catalog'),
283: no_mt=>1}
284: ];
1.113 raeburn 285: if ($env{'form.coursenum'} ne '') {
286: push(@{$brcrum},
287: {href=>"javascript:ToCatalog('details')",
288: text=>"Course details"});
289: }
290: push(@{$brcrum},
291: {href=>$r->uri,
292: text=>"Course syllabus"});
1.114 raeburn 293: $args->{'bread_crumbs'} = $brcrum;
1.115 raeburn 294: } elsif ($env{'form.folderpath'} =~ /^supplemental/) {
295: my $crstype = &Apache::loncommon::course_type();
296: my $title = $env{'form.title'};
297: if ($title eq '') {
298: $title = &mt('Syllabus');
299: }
300: my $brcrum =
301: &Apache::lonhtmlcommon::docs_breadcrumbs(undef,$crstype,undef,$title,1);
302: if (ref($brcrum) eq 'ARRAY') {
303: $args->{'bread_crumbs'} = $brcrum;
304: }
1.114 raeburn 305: }
1.91 amueller 306: my $start_page =
1.114 raeburn 307: &Apache::loncommon::start_page("Syllabus", $rss_link.$js,$args);
1.91 amueller 308: $r->print($start_page);
1.17 www 309: }
310: # ---------------------------------------------------------- Load syllabus info
1.4 www 311: my %syllabus=&Apache::lonnet::dump('syllabus',$cdom,$cnum);
1.117 raeburn 312: my %displayfields;
1.4 www 313:
1.2 www 314: # This handler might be called anonymously ...
315: # ----------------------------------------------------- Only if not public call
1.117 raeburn 316: if ($allowed) {
317: #store what the user typed in to the template
318: if ($env{'form.storesyl'}) {
1.91 amueller 319: foreach my $syl_field (keys(%syllabusfields)) {
1.90 amueller 320: my $field=$env{'form.'.$syl_field};
1.91 amueller 321: chomp($field);
1.90 amueller 322: $field=~s/\s+$//s;
1.91 amueller 323: $field=~s/^\s+//s;
324: $field=~s/\<br\s*\/*\>$//s;
325: $field=&Apache::lonfeedback::clear_out_html($field,1);
1.98 amueller 326: #here it will be stored
1.91 amueller 327: $syllabus{$syl_field}=$field;
1.90 amueller 328: if ($syl_field eq 'lll_includeurl') { # clean up included URLs
329: my $field='';
1.91 amueller 330: foreach my $value (split(/\n/,$syllabus{$syl_field})) {
331: my $url=$value;
1.9 www 332: # get rid of leading and trailing spaces
1.90 amueller 333: $url=~s/^\s+//;
334: $url=~s/\s+$//;
335: if ($url=~m|^https?\://([^/]+)/(.+)$|) {
1.91 amueller 336: my $host = $1;
1.90 amueller 337: my $remainder=$2;
1.9 www 338: # remove the hostname from internal URLs
1.91 amueller 339: my $hostname = &Apache::lonnet::hostname($host);
340: my %all_hostnames = &Apache::lonnet::all_hostnames();
341: foreach my $possible_host (keys(%all_hostnames)) {
1.90 amueller 342: if ($possible_host =~ /\Q$hostname\E/i) {
1.91 amueller 343: $url=$remainder;
344: }
345: }
346: }
1.9 www 347: # norm internal URLs
1.90 amueller 348: unless ($url=~/^https?\:/) {
1.91 amueller 349: $url=&Apache::lonnet::clutter($url);
1.90 amueller 350: }
1.9 www 351: # re-assemble field
1.90 amueller 352: if ($url) {
1.91 amueller 353: $field.=$url."\n";
1.90 amueller 354: }
1.91 amueller 355: }
1.90 amueller 356: $syllabus{$syl_field}=$field;
1.91 amueller 357: }
1.90 amueller 358: }
359: $syllabus{'uploaded.domain'}=$env{'user.domain'};
360: $syllabus{'uploaded.name'}=$env{'user.name'};
361: $syllabus{'uploaded.lastmodified'}=time;
362: &Apache::lonnet::put('syllabus',\%syllabus,$cdom,$cnum);
1.117 raeburn 363: my %storehash;
364: if ($courseenv{'uploadedsyllabus'}) {
365: &Apache::lonnet::delenv('course.'.$env{'request.course.id'}.'.uploadedsyllabus');
366: $storehash{'uploadedsyllabus'} = '';
367: }
368: if ($courseenv{'externalsyllabus'}) {
369: &Apache::lonnet::delenv('course.'.$env{'request.course.id'}.'.externalsyllabus');
370: $storehash{'externalsyllabus'} = '';
371: }
372: if ($courseenv{'externalsyllabus'} || $courseenv{'uploadedsyllabus'}) {
373: &Apache::lonnet::put('environment',\%storehash,$cdom,$cnum);
374: undef($uploaded);
375: undef($external);
376: }
377: } elsif ($env{'form.storeurl'}) {
378: if ($env{'form.externalsyllabus'} =~ m{^https?://}) {
379: if ($env{'form.externalsyllabus'} eq $external) {
380: $r->print('<div class="LC_info">'.
381: &mt('External URL unchanged.').
382: '</div>');
383: if ($uploaded) {
384: my $prefix;
385: my $home=&Apache::lonnet::homeserver($cnum,$cdom);
386: if ($home ne 'no_host') {
387: my $protocol = $Apache::lonnet::protocol{$home};
388: $protocol = 'http' if ($protocol ne 'https');
389: $prefix = $protocol.'://'.&Apache::lonnet::hostname($home);
390: }
391: unless ($external =~ m{^\Q$prefix/uploaded/$cdom/$cnum/portfolio/syllabus\E}) {
392: &Apache::lonnet::delenv('course.'.$env{'request.course.id'}.'.uploadedsyllabus');
393: &Apache::lonnet::put('environment',{uploadedsyllabus => ''},
394: $cdom,$cnum);
395: undef($uploaded);
396: }
397: }
398: } else {
399: $external=$env{'form.externalsyllabus'};
400: $external =~ s/(`)//g;
401: my $putres =
402: &Apache::lonnet::put('environment',{externalsyllabus=>$external},
403: $cdom,$cnum);
404: if ($putres eq 'ok') {
405: &Apache::lonnet::appenv({'course.'.$env{'request.course.id'}.'.externalsyllabus' => $external});
406: $r->print('<div>'.
407: &Apache::lonhtmlcommon::confirm_success(&mt('External URL saved.')).
408: '</div>');
409: if ($uploaded) {
410: my $prefix;
411: my $home=&Apache::lonnet::homeserver($cnum,$cdom);
412: if ($home ne 'no_host') {
413: my $protocol = $Apache::lonnet::protocol{$home};
414: $protocol = 'http' if ($protocol ne 'https');
415: $prefix = $protocol.'://'.&Apache::lonnet::hostname($home);
416: }
417: unless ($external =~ m{^\Q$prefix/uploaded/$cdom/$cnum/portfolio/syllabus\E}) {
418: &Apache::lonnet::delenv('course.'.$env{'request.course.id'}.'.uploadedsyllabus');
419: &Apache::lonnet::put('environment',{uploadedsyllabus => ''},
420: $cdom,$cnum);
421: undef($uploaded);
422: }
423: }
424: } else {
425: $r->print('<div class="LC_error">'.
426: &mt('An error occurred storing the external URL: [_1]',$putres).
427: '</div>');
428: }
429: }
430: } else {
431: $r->print('<div class="LC_error">'.
432: &mt('External URL not saved -- invalid URL.').
433: '</div>');
434: }
435: } elsif ($env{'form.storefile'}) {
436: # Process file upload - phase one - upload and parse primary file.
437: my %allfiles = ();
438: my %codebase = ();
439: my ($upload_result,$upload_output,$uploadphase);
440: if ($env{'form.syllabusfile.filename'}) {
441: my ($url,$needlink) = &process_upload(\$upload_output,$cnum,$cdom,
442: \%allfiles,\%codebase);
443: $r->print($upload_output);
444: if ($url =~ m{^/uploaded/\Q$cdom\E/\Q$cnum\E.*/[^/]+$}) {
445: my $exturl;
446: my $home=&Apache::lonnet::homeserver($cnum,$cdom);
447: if ($home ne 'no_host') {
448: my $protocol = $Apache::lonnet::protocol{$home};
449: $protocol = 'http' if ($protocol ne 'https');
450: $exturl = $protocol.'://'.&Apache::lonnet::hostname($home).$url;
451: }
452: my %storehash = (
453: uploadedsyllabus => $url,
454: );
455: if ($exturl) {
456: $storehash{'externalsyllabus'} = $exturl;
457: if ($exturl =~ /\.(html?|txt|js|css)$/) {
458: $exturl .= '?inhibitmenu=yes';
459: }
460: } else {
461: $storehash{'externalsyllabus'} = '',
462: }
463: my $putres =
464: &Apache::lonnet::put('environment',\%storehash,$cdom,$cnum);
465: if ($putres eq 'ok') {
466: &Apache::lonnet::make_public_indefinitely($url);
467: foreach my $key (keys(%storehash)) {
468: &Apache::lonnet::appenv({'course.'.$env{'request.course.id'}.'.'.$key => $storehash{$key}});
469: }
470: $uploaded = $url;
471: if ($needlink) {
472: $r->print(&return_to_editor($cdom,$cnum).
473: &Apache::loncommon::end_page());
474: return OK;
475: }
476: }
477: }
478: }
479: } elsif ($env{'form.phase'} eq 'upload_embedded') {
480: # Process file upload - phase two - upload embedded objects
481: my $uploadphase = 'check_embedded';
482: my $primaryurl = &HTML::Entities::encode($env{'form.primaryurl'},'<>&"');
483: my $state = &embedded_form_elems($uploadphase,$primaryurl);
484: my $url_root = '/uploaded/'.$cdom.'/'.$cnum;
485: my $actionurl = "/public/$cdom/$cnum/syllabus";
486: my ($result,$flag,$numpathchgs) =
487: &Apache::loncommon::upload_embedded('syllabus','portfolio/syllabus',
488: $cnum,$cdom,'/userfiles',$url_root,undef,undef,undef,$state,
489: $actionurl);
490: unless ($numpathchgs) {
491: my $modres =
492: &Apache::loncommon::modify_html_refs('syllabus','portfolio/syllabus',
493: $cnum,$cdom,
494: '/userfiles',$env{'form.primaryurl'});
495: $result .= $modres;
496: }
497: $r->print($result.&return_to_editor($cdom,$cnum).
498: &Apache::loncommon::end_page());
499: return OK;
500: } elsif ($env{'form.phase'} eq 'check_embedded') {
501: # Process file upload - phase three - modify references in HTML file
502: my $uploadphase = 'modified_orightml';
503: my $result =
504: &Apache::loncommon::modify_html_refs('syllabus','portfolio/syllabus',
505: $cnum,$cdom,
506: '/userfiles',$env{'form.primaryurl'});
507: $r->print($result.&return_to_editor($cdom,$cnum).
508: &Apache::loncommon::end_page());
509: return OK;
510: }
511: foreach my $field (keys(%syllabusfields)) {
512: if ($syllabus{$field} ne '') {
513: $displayfields{$field} = ' style="display:block;"';
514: } else {
515: $displayfields{$field} = ' style="display:none;"';
516: }
1.90 amueller 517: }
1.4 www 518: }
1.85 bisitz 519:
1.113 raeburn 520: if ($allowed) {
521: #---------------------------------- Print External URL Syllabus Info if editing
522: if ($target ne 'tex') {
523: my $protocol = $Apache::lonnet::protocol{$homeserver};
524: $protocol = 'http' if ($protocol ne 'https');
525: $r->print('<div class="LC_info">'
526: .'<p>'
527: .&mt('This syllabus can be publicly viewed at [_1]'
528: ,'<tt>'.$protocol.'://'.&Apache::lonnet::hostname($homeserver).$r->uri.'</tt>')
529: .' '.&Apache::loncommon::help_open_topic('Syllabus_ExtLink')
530: .'</p>'
531: .'</div>');
1.117 raeburn 532: my $lonhost = $r->dir_config('lonHostID');
1.118 ! raeburn 533: $r->print(&chooser($external,$uploaded,$cdom,$cnum,$lonhost,\%syllabusfields,\%syllabus));
1.93 bisitz 534: }
1.109 bisitz 535: } else {
1.113 raeburn 536: #--------------------------------------------- Print last update unless editing
537: my $lastmod=$syllabus{'uploaded.lastmodified'};
538: $lastmod=($lastmod?&Apache::lonlocal::locallocaltime($lastmod):&mt('never'));
539: my $who;
540: if ($syllabus{'uploaded.lastmodified'}) {
541: if (($env{'user.name'} ne 'public') && ($env{'user.domain'} ne 'public')) {
542: $who = &Apache::loncommon::aboutmewrapper(
543: &Apache::loncommon::plainname($syllabus{'uploaded.name'},
544: $syllabus{'uploaded.domain'}),$syllabus{'uploaded.name'},
545: $syllabus{'uploaded.domain'});
546: } else {
547: # Public user?
548: # Only display name of user, but no link to personal information page
549: $who = &Apache::loncommon::plainname(
550: $syllabus{'uploaded.name'},
551: $syllabus{'uploaded.domain'});
552: }
553: }
554: if ($target ne 'tex') {
555: $r->print('<div class="LC_info">'.&mt('Last updated').': '.
556: $lastmod . ' '.
557: ($who ? &mt('by').' '.$who
558: : '' ) .
559: '</div>' );
560: } else {
561: $r->print('\\\\ '.&mt('Last updated').': '.$lastmod.' '.
562: ($who? &mt('by').'\\\\ '.
563: &Apache::loncommon::plainname($syllabus{'uploaded.name'},$syllabus{'uploaded.domain'})
564: :'')
565: .'\\\\');
566: }
1.109 bisitz 567: }
568:
1.113 raeburn 569: #-------------------------------------------------------------- Print Headtitle
1.90 amueller 570: if ($target ne 'tex') {
1.117 raeburn 571: my $display = 'block';
572: if ($external || $uploaded) {
573: $display = 'none';
574: }
575: $r->print('<div class="LC_Box" id="template" style="display: '.$display.'">'.
1.113 raeburn 576: '<h2 class="LC_hcell">'.$courseenv{'description'}.'</h2>');
577: if ($allowed) {
578: $r->print('<div style="margin: 0; float:left;">'.
579: '<h3>'.&Apache::lonnet::domain($cdom,'description').'</h3>'.
580: '</div>');
581: # Print Help Text if editing at right side of screen
582: $r->print('<div style="margin: 0; float:right;">'.
583: &Apache::loncommon::help_open_topic('Uploaded_Templates_TextBoxes',&mt('Help with filling in text boxes')).
584: '</div><br clear="all" />');
585: } else {
586: $r->print('<h3>'.&Apache::lonnet::domain($cdom,'description').'</h3>');
587: }
1.90 amueller 588: } else {
1.91 amueller 589: $r->print('\noindent{\large\textbf{'.$courseenv{'description'}.'}}\\\\\\\\\textbf{'.
590: &Apache::lonnet::domain($cdom,'description').'}\\\\');
1.90 amueller 591: }
1.80 neumanie 592: # -------------------------------------------------------- Get course personnel
593: my %coursepersonnel=&Apache::lonnet::get_course_adv_roles($cdom.'/'.$cnum);
594: if ($target ne 'tex') {
1.91 amueller 595: $r->print(&Apache::lonhtmlcommon::start_pick_box());
1.80 neumanie 596: } else {
1.91 amueller 597: $r->print('\begin{tabular}{|p{0.45\textwidth}|p{0.45\textwidth}|}\hline');
1.80 neumanie 598: }
599: my @personnel=sort(keys(%coursepersonnel));
600: my $lastpers=$personnel[$#personnel];
601: foreach my $element (@personnel) {
1.91 amueller 602: if ($target ne 'tex') {
603: $r->print(&Apache::lonhtmlcommon::row_title($element));
604: } else {
605: $r->print(' '.&Apache::lonxml::xmlparse($r,'tex',$element).' & ');
606: }
1.111 christia 607: my @coursepersonlist;
1.80 neumanie 608: foreach (split(/\,/,$coursepersonnel{$element})) {
1.91 amueller 609: my ($puname,$pudom)=split(/\:/,$_);
610: if ($target ne 'tex') {
1.80 neumanie 611: my $courseperson = &Apache::loncommon::plainname($puname,$pudom);
612: if (($env{'user.name'} eq '') || ($env{'user.name'} eq 'public') ||
613: ($env{'user.domain'} eq '') || ($env{'user.domain'} eq 'public')) {
1.111 christia 614: push(@coursepersonlist,$courseperson);
1.80 neumanie 615: } else {
1.111 christia 616: push(@coursepersonlist,&Apache::loncommon::aboutmewrapper($courseperson,
1.80 neumanie 617: $puname,$pudom));
618: }
1.91 amueller 619: } else {
1.111 christia 620: push(@coursepersonlist,&Apache::loncommon::plainname($puname,
1.80 neumanie 621: $pudom).' ');
1.91 amueller 622: }
623: }
1.111 christia 624: $r->print(join(", ",@coursepersonlist));
1.91 amueller 625: if ($target ne 'tex') {
1.80 neumanie 626: my $lastclose=$element eq $lastpers?1:0;
627: $r->print(&Apache::lonhtmlcommon::row_closure($lastclose));
1.91 amueller 628: } else {
629: $r->print('\\\\ \hline');
630: }
1.80 neumanie 631: }
632: if ($target ne 'tex') {
1.91 amueller 633: $r->print(&Apache::lonhtmlcommon::end_pick_box());
1.80 neumanie 634: } else {
1.91 amueller 635: $r->print('\end{tabular}\\\\');
1.80 neumanie 636: }
1.79 neumanie 637: # -------------------------------------------------------------- Announcements?
638: my $day = &Apache::lonannounce::showday(time,2,
1.91 amueller 639: &Apache::lonannounce::readcalendar($cdom.'_'.$cnum));
1.80 neumanie 640: if ($target ne 'tex') {
1.91 amueller 641: if ($allowed) {
1.117 raeburn 642: my $display = ' style="display:block;"';
643: if ($syllabus{'000_showrssfeeds'} eq 'no') {
644: $display = ' style="display:none;"';
645: }
646: &Apache::lontemplate::print_start_template($r,&mt('RSS Feeds and Blogs'),'LC_Box',
647: 'box_000_showrssfeeds',$display);
1.91 amueller 648: $r->print(&Apache::lonrss::advertisefeeds($cnum,$cdom,$forceedit));
649: my $editurl= &Apache::lonnet::absolute_url().'/adm/'.$cdom.'/'.$cnum.'/_rss.html';
650: $r->print( '<a href="'.$editurl.'">'.&mt('New RSS Feed or Blog').'</a>');
651: &Apache::lontemplate::print_end_template($r);
1.117 raeburn 652: } else {
653: unless ($syllabus{'000_showrssfeeds'} eq 'no') {
654: if (&Apache::lonrss::advertisefeeds($cnum,$cdom) ne '') {
655: &Apache::lontemplate::print_start_template($r,&mt('RSS Feeds and Blogs'),'LC_Box');
656: $r->print(&Apache::lonrss::advertisefeeds($cnum,$cdom,$forceedit));
657: &Apache::lontemplate::print_end_template($r);
658: }
659: }
1.91 amueller 660: }
1.79 neumanie 661: } else {
1.91 amueller 662: $r->print(&Apache::lonxml::xmlparse($r,'tex',$day));
1.86 bisitz 663: }
1.79 neumanie 664: # ---------------------------------------------------------------- Get syllabus
1.86 bisitz 665: if (($syllabus{'uploaded.lastmodified'}) || ($allowed)) {
1.90 amueller 666: if ($allowed) {
1.95 bisitz 667: $r->print('<form method="post" action="">'.
1.113 raeburn 668: '<input type="hidden" name="forceedit" value="'.$env{'form.forceedit'}.'" />');
1.90 amueller 669: }
1.117 raeburn 670:
1.106 faziophi 671: my $url_include_handler = sub {
1.117 raeburn 672: my ($r, $field, $message, $group, $data_ref, $fields_ref, $target, $allowed, $display) = @_;
1.106 faziophi 673: my %data = %{$data_ref};
674: my %fields = %{$fields_ref};
675: my $urls=$message;
676: $message='';
677: foreach my $filelink (split(/\n/,$urls)) {
678: my $output='';
679: # embed style?
680: my ($curfext)=($filelink=~/\.([^\.]+)$/);
681: my $embstyle=&Apache::loncommon::fileembstyle($curfext);
682: if (($embstyle eq 'ssi') || ($curfext=~/\/$/)) {# make ssi call and remove everything but the body contents
683: $output=&Apache::lonnet::ssi_body($filelink);
684: } elsif ($embstyle eq 'img') {# embed as an image
685: $output='<img src="'.$filelink.'" />';
686: }
687: if ($output ne '') {
688: if ($target ne 'tex') {
689: $message.='<p>'.$output.'</p>';
690: } else {
691: $message.=' '.&Apache::lonxml::xmlparse($r,'tex','<p>'.$output.'</p>').' ';
692: }
693: }
694: }
695: if ($allowed) {
696: &Apache::lonfeedback::newline_to_br(\$urls);
697: &Apache::lontemplate::print_start_template($r,$fields{$field}.
1.117 raeburn 698: &Apache::loncommon::help_open_topic('Syllabus_URLs'),'LC_Box',
699: 'box_'.$field,$display);
1.106 faziophi 700: $r->print($urls);
701: $r->print("<br /><div>");
702: &Apache::lontemplate::print_textarea_template($r, $data{$field},
703: $field, Apache::lontemplate->RICH_TEXT_ALWAYS_OFF);
704: &Apache::lontemplate::print_saveall_template($r);
705: $r->print("</div>");
706: &Apache::lontemplate::print_end_template($r);
1.86 bisitz 707:
1.106 faziophi 708: } else {
709: $r->print($message);
710: }
711: };
712: my %custom_hash = ( 'lll_includeurl' => $url_include_handler );
1.110 raeburn 713: &Apache::lontemplate::print_template_fields($r, \%syllabus, \%syllabusfields,
1.117 raeburn 714: $target, $allowed, Apache::lontemplate->RICH_TEXT_DETECT_HTML, \%custom_hash,
715: undef,\%displayfields);
1.90 amueller 716: if ($allowed) {
1.91 amueller 717: $r->print('</form>'.
1.110 raeburn 718: &Apache::lonhtmlcommon::htmlareaselectactive());
1.90 amueller 719: }
1.4 www 720: } else {
1.112 bisitz 721: if ($target ne 'tex') {$r->print('<p class="LC_info">');} else {$r->print('\par ');}
1.91 amueller 722: $r->print(&mt('No syllabus information provided.'));
723: if ($target ne 'tex') {$r->print('</p>');}
1.1 www 724: }
1.86 bisitz 725: if ($target ne 'tex') {
1.113 raeburn 726: $r->print('</div>');
1.65 raeburn 727: if ($env{'form.backto'} eq 'coursecatalog') {
728: $r->print('<form name="backtocat" method="post" action="/adm/coursecatalog">'.
1.66 raeburn 729: &Apache::lonhtmlcommon::echo_form_input(['backto','courseid']).
1.65 raeburn 730: '</form>');
731: }
1.91 amueller 732: $r->print(&Apache::loncommon::end_page());
1.48 albertel 733: } else {
1.91 amueller 734: $r->print('\end{document}');
1.48 albertel 735: }
1.1 www 736: return OK;
1.86 bisitz 737: }
1.1 www 738:
1.117 raeburn 739: sub chooser {
1.118 ! raeburn 740: my ($external,$uploaded,$cdom,$cnum,$lonhost,$fields,$values) = @_;
1.117 raeburn 741: my %lt = &Apache::lonlocal::texthash(
742: 'type' => 'Syllabus Type',
743: 'url' => 'External URL',
744: 'file' => 'Uploaded File',
745: 'template' => 'Syllabus Template',
746: 'templateboxes' => 'Choose template items ... ',
747: 'curr' => 'Current:',
748: 'rep' => 'Replace:',
749: 'upl' => 'Upload:',
750: 'pr' => 'Preview',
751: 'save' => 'Save',
752: 'chourl' => 'Choose external URL',
753: 'chofile' => 'Uploaded syllabus file',
754: 'parse' => 'Upload embedded images/multimedia files if HTML file',
755: );
756: my %checked = (
757: file => '',
758: url => '',
759: template => '',
760: );
761: my %display = (
762: file => 'none',
763: url => 'none',
764: templatebox => 'none',
765: );
766: my $check = ' checked="checked" ';
767: if ($uploaded) {
768: $checked{'file'} = $check;
769: $display{'file'} = 'block';
770: } elsif ($external) {
771: $checked{'url'} = $check;
772: $display{'url'} = 'block';
773: } else {
774: $checked{'template'} = $check;
775: $checked{'templatebox'} = $check;
776: $display{'templatebox'} = 'block';
777: }
778:
779: my $output =
780: '<form name="syllabus" method="post" enctype="multipart/form-data" action="">'."\n".
781: '<input type="hidden" name="forceedit" value="1" />'."\n".
782: '<div class="LC_left_float"><fieldset><legend>'.$lt{'type'}.'</legend>';
783: foreach my $item ('template','url','file') {
784: $output .= '<label><input type="radio" name="choice" value="'.$item.'" '.$checked{$item}.' onclick="toggleEditor('."'$item'".')" />'.
785: $lt{$item}.'</label><br />';
786: }
787: $output .= '</fieldset></div>'."\n".
788: '<div id="url" class="LC_left_float" style="display: '.$display{'url'}.'">'."\n".
789: '<fieldset><legend>'.$lt{'chourl'}.'</legend><span class="LC_nobreak">'."\n".
790: '<a href="javascript:extUrlPreview('."'syllabusurl'".');">'.$lt{'pr'}.'</a></span> '."\n".
791: '<input type="text" id="syllabusurl" name="externalsyllabus" value="'.$external.'" size="55" />'."\n".
792: ' <input type="submit" name="storeurl" value="'.$lt{'save'}.'" />'."\n".
793: '</fieldset></div>'."\n".
794: '<div id="file" class="LC_left_float" style="display: '.$display{'file'}.'"><fieldset><legend>'.$lt{'file'}.'</legend>';
795: if ($uploaded) {
796: my $protocol = $Apache::lonnet::protocol{$lonhost};
797: $protocol = 'http' if ($protocol ne 'https');
798: my $absurl = $protocol.'://'.&Apache::lonnet::hostname($lonhost).$uploaded;
799: my ($filename) = ($uploaded =~ m{([^/]+)$});
1.118 ! raeburn 800: my $file=&Apache::lonnet::filelocation("",$uploaded);
! 801: my $depbutton;
! 802: if ($file =~ /\.html?$/) {
! 803: my $filecontents=&Apache::lonnet::getfile($file);
! 804: unless ($filecontents eq -1) {
! 805: my $mm = new File::MMagic;
! 806: my $mimetype = $mm->checktype_contents($filecontents);
! 807: if ($mimetype eq 'text/html') {
! 808: my (%codebase,%allfiles);
! 809: my $parse_result = &Apache::lonnet::extract_embedded_items($uploaded,\%allfiles,
! 810: \%codebase,\$filecontents);
! 811: my $actionurl = "/public/$cdom/$cnum/syllabus";
! 812: my ($ignore,$num,$numpathchanges,$existing,$mapping) =
! 813: &Apache::loncommon::ask_for_embedded_content($actionurl,undef,\%allfiles,
! 814: \%codebase,
! 815: {'context' => 'rewrites',
! 816: 'ignore_remote_references' => 1,});
! 817: if (keys(%allfiles)) {
! 818: $depbutton = (' ' x 3).
! 819: &editfile_button().
! 820: &editbutton_js($uploaded);
! 821: }
! 822: }
! 823: }
! 824: }
! 825:
1.117 raeburn 826: $output .= '<span class="LC_nobreak">'.$lt{'curr'}.' '.
827: '<input type="hidden" name="uploadedfile" value="'.&HTML::Entities::encode($absurl).'?inhibitmenu=yes" id="currfile" />'.
1.118 ! raeburn 828: '<a href="javascript:extUrlPreview('."'currfile'".');">'.$filename.'</a></span>'.$depbutton.
! 829: '<br /><br />'.$lt{'rep'};
1.117 raeburn 830: } else {
831: $output .= $lt{'upl'};
832: }
833:
834: $output .= '<br />'."\n".
835: '<span class="LC_nobreak">'.
836: '<input type="file" name="syllabusfile" size="55" />'."\n".
837: ' <input type="submit" name="storefile" value="'.$lt{'save'}.'" />'.
838: '</span><br />'.
839: '<label>'.
840: '<input type="checkbox" name="parserflag" checked="checked" />'.
841: $lt{'parse'}.
842: '</label>'.
843: '</fieldset></div>'.
844: '<div id="templatebox" class="LC_left_float" style="display: '.
845: $display{'templatebox'}.';"><fieldset><legend>'.$lt{'templateboxes'}.
846: ' <input type="button" value="'.&mt('check all').'" '.
847: 'onclick="javascript:checkAll('."document.syllabus.showfield".');javascript:toggleBox('."'all'".');" />'.
848: (' 'x2).
849: '<input type="button" value="'.&mt('uncheck all').'" '.
850: 'onclick="javascript:uncheckAll('."document.syllabus.showfield".');javascript:toggleBox('."'all'".');" />'.
851: '</legend>'.
852: &fields_check_uncheck($fields,$values).
853: '</fieldset>'.
854: '</div>';
855: $output .= '<div style="padding:0;clear:both;margin:0;border:0"></div>'.
856: '</form>';
857: return $output;
858: }
859:
860: sub fields_check_uncheck {
861: my ($fields,$values) = @_;
862: return unless ((ref($fields) eq 'HASH') && (ref($values) eq 'HASH'));
863: my $numinrow = 4;
864: my $table;
865: my @fieldnames = sort(keys(%{$fields}));
866: unshift(@fieldnames,'000_showrssfeeds');
867: my $numfields = scalar(@fieldnames);
868: for (my $i=0; $i<$numfields; $i++) {
869: my $checked;
870: my $name = $fields->{$fieldnames[$i]};
871: if ($fieldnames[$i] eq '000_showrssfeeds') {
872: $name = &mt('RSS Feeds and Blogs');
873: unless ($values->{$fieldnames[$i]} eq 'on') {
874: $checked = ' checked="checked"';
875: }
876: } elsif ($values->{$fieldnames[$i]} ne '') {
877: $checked = ' checked="checked"';
878: }
879: my $rem = $i%($numinrow);
880: if ($rem == 0) {
881: if (($i > 0) && ($i < $numfields-1)) {
882: $table .= '</tr>';
883: }
884: if ($i < $numfields-1) {
885: $table .= '<tr>';
886: }
887: }
888: $table .=
889: '<td><label><input type="checkbox" name="showfield" value="'.$fieldnames[$i].'" '.
890: $checked.' id="showfield_'.$i.'" onclick="javascript:toggleBox('."'$fieldnames[$i]',this".');" />'.
891: $name.'</label></td>'."\n";
892: }
893: if ($table ne '') {
894: my $rem = $numfields%($numinrow);
895: my $colsleft = $numinrow - $rem;
896: if ($colsleft > 1 ) {
897: $table .= '<td colspan="'.$colsleft.'"> </td>';
898: } elsif ($colsleft == 1) {
899: $table .= '<td> </td>';
900: }
901: $table = '<table>'.$table.'</tr></table>';
902: }
903: return $table;
904: }
905:
906: sub process_upload {
907: my ($upload_output,$cnum,$cdom,$allfiles,$codebase) = @_;
908: my ($parseaction,$showupload,$mimetype);
909: my $dest = 'portfolio/syllabus';
910: if ($env{'form.parserflag'}) {
911: $parseaction = 'parse';
912: }
913: my $url=&Apache::lonnet::userfileupload('syllabusfile','syllabus',$dest,
914: $parseaction,$allfiles,
915: $codebase,undef,undef,undef,undef,
916: undef,undef,\$mimetype);
917: if ($url =~ m{^/uploaded/\Q$cdom\E/\Q$cnum\E.*/([^/]+)$}) {
918: my $stored = $1;
919: $showupload = '<p>'.&mt('Uploaded [_1]',
920: '<span class="LC_filename">'.$stored.'</span>').
921: '</p>';
922: } else {
923: my ($filename) = ($env{'form.syllabusfile.filename'} =~ m{([^/]+)$});
924: $$upload_output = '<div class="LC_error" id="uploadfileresult">'.
925: &mt('Unable to save file [_1].',
926: '<span class="LC_filename">'.$filename.'</span>').
927: '</div>';
928: return ();
929: }
930: my $needlink;
931: if (($parseaction eq 'parse') && ($mimetype eq 'text/html')) {
932: $$upload_output = $showupload;
933: my $total_embedded = scalar(keys(%{$allfiles}));
934: if ($total_embedded > 0) {
935: my $uploadphase = 'upload_embedded';
936: my $primaryurl = &HTML::Entities::encode($url,'<>&"');
937: my $state = &embedded_form_elems($uploadphase,$primaryurl);
938: my $actionurl = "/public/$cdom/$cnum/syllabus";
939: my ($embedded,$num,$numpathchanges,$existing);
940: ($embedded,$num,$numpathchanges,$existing) =
941: &Apache::loncommon::ask_for_embedded_content($actionurl,$state,
942: $allfiles,$codebase,
943: {'error_on_invalid_names' => 1,
944: 'ignore_remote_references' => 1,});
945: if ($embedded) {
946: $needlink = 1;
947: if ($num) {
948: $$upload_output .=
949: '<p>'.&mt('This file contains embedded multimedia objects, which need to be uploaded.').'</p>'.$embedded;
950: } elsif ($numpathchanges) {
951: $$upload_output .= $embedded;
952: } else {
953: $$upload_output .= $embedded;
954: &Apache::loncommon::modify_html_refs('syllabus','portfolio/syllabus',
955: $cnum,$cdom,'/userfiles',$url);
956: }
957: } else {
958: $$upload_output .= &mt('Embedded item(s) already present, so no additional upload(s) required').'<br />';
959: &Apache::loncommon::modify_html_refs('syllabus','portfolio/syllabus',
960: $cnum,$cdom,'/userfiles',$url);
961:
962: }
963: } else {
964: $$upload_output .= &mt('No embedded items identified').'<br />';
965: }
966: $$upload_output = '<div id="uploadfileresult">'.$$upload_output.'</div>';
967: }
968: return ($url,$needlink);
969: }
970:
971: sub embedded_form_elems {
972: my ($phase,$primaryurl) = @_;
973: return <<STATE;
974: <input type="hidden" name="forceedit" value="1" />
975: <input type="hidden" name="cmd" value="upload_embedded" />
976: <input type="hidden" name="phase" value="$phase" />
977: <input type="hidden" name="primaryurl" value="$primaryurl" />
978: STATE
979: }
980:
981: sub return_to_editor {
982: my ($cdom,$cnum) = @_;
983: my $actionurl = "/public/$cdom/$cnum/syllabus";
984: return '<p><form name="backtoeditor" method="post" action="'.$actionurl.'" />'.
985: '<input type="hidden" name="forceedit" value="1" />'."\n".
986: '<a href="javascript:document.backtoeditor.submit();">'.&mt('Return to Editor').
987: '</a></p>';
988: }
989:
1.118 ! raeburn 990: sub editfile_button {
! 991: my $buttontext=&mt('Edit');
! 992: return <<"END";
! 993: <input type="button" value="$buttontext" onclick="javascript:gotoeditor();" />
! 994: END
! 995: }
! 996:
! 997: sub editbutton_js {
! 998: my ($url) = @_;
! 999: return <<ENDJS;
! 1000: <script type="text/javascript">
! 1001: // <![CDATA[
! 1002: function gotoeditor() {
! 1003: document.location.href = '$url?forceedit=1';
! 1004: }
! 1005: // ]]>
! 1006: </script>
! 1007: ENDJS
! 1008: }
! 1009:
1.1 www 1010: 1;
1011: __END__
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>