Annotation of loncom/interface/lonsyllabus.pm, revision 1.119
1.1 www 1: # The LearningOnline Network
2: # Syllabus
3: #
1.119 ! raeburn 4: # $Id: lonsyllabus.pm,v 1.118 2013/05/03 21:57:13 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');
1.119 ! raeburn 525: my $link = $protocol.'://'.&Apache::lonnet::hostname($homeserver).$r->uri;
! 526: $r->print('<div class="LC_left_float">'
! 527: .'<span class="LC_help_open_topic LC_info">'
! 528: .'<span class="LC_info">'
! 529: .&mt('Public link (no log-in): [_1]','<tt>'.$link.'</tt>')
! 530: .' </span>'.&Apache::loncommon::help_open_topic('Syllabus_ExtLink')
! 531: .'</span>'
! 532: .'</div><div style="padding:0;clear:both;margin:0;border:0"></div>');
1.117 raeburn 533: my $lonhost = $r->dir_config('lonHostID');
1.118 raeburn 534: $r->print(&chooser($external,$uploaded,$cdom,$cnum,$lonhost,\%syllabusfields,\%syllabus));
1.93 bisitz 535: }
1.109 bisitz 536: } else {
1.113 raeburn 537: #--------------------------------------------- Print last update unless editing
538: my $lastmod=$syllabus{'uploaded.lastmodified'};
539: $lastmod=($lastmod?&Apache::lonlocal::locallocaltime($lastmod):&mt('never'));
540: my $who;
541: if ($syllabus{'uploaded.lastmodified'}) {
542: if (($env{'user.name'} ne 'public') && ($env{'user.domain'} ne 'public')) {
543: $who = &Apache::loncommon::aboutmewrapper(
544: &Apache::loncommon::plainname($syllabus{'uploaded.name'},
545: $syllabus{'uploaded.domain'}),$syllabus{'uploaded.name'},
546: $syllabus{'uploaded.domain'});
547: } else {
548: # Public user?
549: # Only display name of user, but no link to personal information page
550: $who = &Apache::loncommon::plainname(
551: $syllabus{'uploaded.name'},
552: $syllabus{'uploaded.domain'});
553: }
554: }
555: if ($target ne 'tex') {
556: $r->print('<div class="LC_info">'.&mt('Last updated').': '.
557: $lastmod . ' '.
558: ($who ? &mt('by').' '.$who
559: : '' ) .
560: '</div>' );
561: } else {
562: $r->print('\\\\ '.&mt('Last updated').': '.$lastmod.' '.
563: ($who? &mt('by').'\\\\ '.
564: &Apache::loncommon::plainname($syllabus{'uploaded.name'},$syllabus{'uploaded.domain'})
565: :'')
566: .'\\\\');
567: }
1.109 bisitz 568: }
569:
1.113 raeburn 570: #-------------------------------------------------------------- Print Headtitle
1.90 amueller 571: if ($target ne 'tex') {
1.117 raeburn 572: my $display = 'block';
573: if ($external || $uploaded) {
574: $display = 'none';
575: }
576: $r->print('<div class="LC_Box" id="template" style="display: '.$display.'">'.
1.113 raeburn 577: '<h2 class="LC_hcell">'.$courseenv{'description'}.'</h2>');
578: if ($allowed) {
579: $r->print('<div style="margin: 0; float:left;">'.
580: '<h3>'.&Apache::lonnet::domain($cdom,'description').'</h3>'.
581: '</div>');
582: # Print Help Text if editing at right side of screen
583: $r->print('<div style="margin: 0; float:right;">'.
584: &Apache::loncommon::help_open_topic('Uploaded_Templates_TextBoxes',&mt('Help with filling in text boxes')).
585: '</div><br clear="all" />');
586: } else {
587: $r->print('<h3>'.&Apache::lonnet::domain($cdom,'description').'</h3>');
588: }
1.90 amueller 589: } else {
1.91 amueller 590: $r->print('\noindent{\large\textbf{'.$courseenv{'description'}.'}}\\\\\\\\\textbf{'.
591: &Apache::lonnet::domain($cdom,'description').'}\\\\');
1.90 amueller 592: }
1.80 neumanie 593: # -------------------------------------------------------- Get course personnel
594: my %coursepersonnel=&Apache::lonnet::get_course_adv_roles($cdom.'/'.$cnum);
595: if ($target ne 'tex') {
1.91 amueller 596: $r->print(&Apache::lonhtmlcommon::start_pick_box());
1.80 neumanie 597: } else {
1.91 amueller 598: $r->print('\begin{tabular}{|p{0.45\textwidth}|p{0.45\textwidth}|}\hline');
1.80 neumanie 599: }
600: my @personnel=sort(keys(%coursepersonnel));
601: my $lastpers=$personnel[$#personnel];
602: foreach my $element (@personnel) {
1.91 amueller 603: if ($target ne 'tex') {
604: $r->print(&Apache::lonhtmlcommon::row_title($element));
605: } else {
606: $r->print(' '.&Apache::lonxml::xmlparse($r,'tex',$element).' & ');
607: }
1.111 christia 608: my @coursepersonlist;
1.80 neumanie 609: foreach (split(/\,/,$coursepersonnel{$element})) {
1.91 amueller 610: my ($puname,$pudom)=split(/\:/,$_);
611: if ($target ne 'tex') {
1.80 neumanie 612: my $courseperson = &Apache::loncommon::plainname($puname,$pudom);
613: if (($env{'user.name'} eq '') || ($env{'user.name'} eq 'public') ||
614: ($env{'user.domain'} eq '') || ($env{'user.domain'} eq 'public')) {
1.111 christia 615: push(@coursepersonlist,$courseperson);
1.80 neumanie 616: } else {
1.111 christia 617: push(@coursepersonlist,&Apache::loncommon::aboutmewrapper($courseperson,
1.80 neumanie 618: $puname,$pudom));
619: }
1.91 amueller 620: } else {
1.111 christia 621: push(@coursepersonlist,&Apache::loncommon::plainname($puname,
1.80 neumanie 622: $pudom).' ');
1.91 amueller 623: }
624: }
1.111 christia 625: $r->print(join(", ",@coursepersonlist));
1.91 amueller 626: if ($target ne 'tex') {
1.80 neumanie 627: my $lastclose=$element eq $lastpers?1:0;
628: $r->print(&Apache::lonhtmlcommon::row_closure($lastclose));
1.91 amueller 629: } else {
630: $r->print('\\\\ \hline');
631: }
1.80 neumanie 632: }
633: if ($target ne 'tex') {
1.91 amueller 634: $r->print(&Apache::lonhtmlcommon::end_pick_box());
1.80 neumanie 635: } else {
1.91 amueller 636: $r->print('\end{tabular}\\\\');
1.80 neumanie 637: }
1.79 neumanie 638: # -------------------------------------------------------------- Announcements?
639: my $day = &Apache::lonannounce::showday(time,2,
1.91 amueller 640: &Apache::lonannounce::readcalendar($cdom.'_'.$cnum));
1.80 neumanie 641: if ($target ne 'tex') {
1.91 amueller 642: if ($allowed) {
1.117 raeburn 643: my $display = ' style="display:block;"';
644: if ($syllabus{'000_showrssfeeds'} eq 'no') {
645: $display = ' style="display:none;"';
646: }
647: &Apache::lontemplate::print_start_template($r,&mt('RSS Feeds and Blogs'),'LC_Box',
648: 'box_000_showrssfeeds',$display);
1.91 amueller 649: $r->print(&Apache::lonrss::advertisefeeds($cnum,$cdom,$forceedit));
650: my $editurl= &Apache::lonnet::absolute_url().'/adm/'.$cdom.'/'.$cnum.'/_rss.html';
651: $r->print( '<a href="'.$editurl.'">'.&mt('New RSS Feed or Blog').'</a>');
652: &Apache::lontemplate::print_end_template($r);
1.117 raeburn 653: } else {
654: unless ($syllabus{'000_showrssfeeds'} eq 'no') {
655: if (&Apache::lonrss::advertisefeeds($cnum,$cdom) ne '') {
656: &Apache::lontemplate::print_start_template($r,&mt('RSS Feeds and Blogs'),'LC_Box');
657: $r->print(&Apache::lonrss::advertisefeeds($cnum,$cdom,$forceedit));
658: &Apache::lontemplate::print_end_template($r);
659: }
660: }
1.91 amueller 661: }
1.79 neumanie 662: } else {
1.91 amueller 663: $r->print(&Apache::lonxml::xmlparse($r,'tex',$day));
1.86 bisitz 664: }
1.79 neumanie 665: # ---------------------------------------------------------------- Get syllabus
1.86 bisitz 666: if (($syllabus{'uploaded.lastmodified'}) || ($allowed)) {
1.90 amueller 667: if ($allowed) {
1.95 bisitz 668: $r->print('<form method="post" action="">'.
1.113 raeburn 669: '<input type="hidden" name="forceedit" value="'.$env{'form.forceedit'}.'" />');
1.90 amueller 670: }
1.117 raeburn 671:
1.106 faziophi 672: my $url_include_handler = sub {
1.117 raeburn 673: my ($r, $field, $message, $group, $data_ref, $fields_ref, $target, $allowed, $display) = @_;
1.106 faziophi 674: my %data = %{$data_ref};
675: my %fields = %{$fields_ref};
676: my $urls=$message;
677: $message='';
678: foreach my $filelink (split(/\n/,$urls)) {
679: my $output='';
680: # embed style?
681: my ($curfext)=($filelink=~/\.([^\.]+)$/);
682: my $embstyle=&Apache::loncommon::fileembstyle($curfext);
683: if (($embstyle eq 'ssi') || ($curfext=~/\/$/)) {# make ssi call and remove everything but the body contents
684: $output=&Apache::lonnet::ssi_body($filelink);
685: } elsif ($embstyle eq 'img') {# embed as an image
686: $output='<img src="'.$filelink.'" />';
687: }
688: if ($output ne '') {
689: if ($target ne 'tex') {
690: $message.='<p>'.$output.'</p>';
691: } else {
692: $message.=' '.&Apache::lonxml::xmlparse($r,'tex','<p>'.$output.'</p>').' ';
693: }
694: }
695: }
696: if ($allowed) {
697: &Apache::lonfeedback::newline_to_br(\$urls);
698: &Apache::lontemplate::print_start_template($r,$fields{$field}.
1.117 raeburn 699: &Apache::loncommon::help_open_topic('Syllabus_URLs'),'LC_Box',
700: 'box_'.$field,$display);
1.106 faziophi 701: $r->print($urls);
702: $r->print("<br /><div>");
703: &Apache::lontemplate::print_textarea_template($r, $data{$field},
704: $field, Apache::lontemplate->RICH_TEXT_ALWAYS_OFF);
705: &Apache::lontemplate::print_saveall_template($r);
706: $r->print("</div>");
707: &Apache::lontemplate::print_end_template($r);
1.86 bisitz 708:
1.106 faziophi 709: } else {
710: $r->print($message);
711: }
712: };
713: my %custom_hash = ( 'lll_includeurl' => $url_include_handler );
1.110 raeburn 714: &Apache::lontemplate::print_template_fields($r, \%syllabus, \%syllabusfields,
1.117 raeburn 715: $target, $allowed, Apache::lontemplate->RICH_TEXT_DETECT_HTML, \%custom_hash,
716: undef,\%displayfields);
1.90 amueller 717: if ($allowed) {
1.91 amueller 718: $r->print('</form>'.
1.110 raeburn 719: &Apache::lonhtmlcommon::htmlareaselectactive());
1.90 amueller 720: }
1.4 www 721: } else {
1.112 bisitz 722: if ($target ne 'tex') {$r->print('<p class="LC_info">');} else {$r->print('\par ');}
1.91 amueller 723: $r->print(&mt('No syllabus information provided.'));
724: if ($target ne 'tex') {$r->print('</p>');}
1.1 www 725: }
1.86 bisitz 726: if ($target ne 'tex') {
1.113 raeburn 727: $r->print('</div>');
1.65 raeburn 728: if ($env{'form.backto'} eq 'coursecatalog') {
729: $r->print('<form name="backtocat" method="post" action="/adm/coursecatalog">'.
1.66 raeburn 730: &Apache::lonhtmlcommon::echo_form_input(['backto','courseid']).
1.65 raeburn 731: '</form>');
732: }
1.91 amueller 733: $r->print(&Apache::loncommon::end_page());
1.48 albertel 734: } else {
1.91 amueller 735: $r->print('\end{document}');
1.48 albertel 736: }
1.1 www 737: return OK;
1.86 bisitz 738: }
1.1 www 739:
1.117 raeburn 740: sub chooser {
1.118 raeburn 741: my ($external,$uploaded,$cdom,$cnum,$lonhost,$fields,$values) = @_;
1.117 raeburn 742: my %lt = &Apache::lonlocal::texthash(
743: 'type' => 'Syllabus Type',
744: 'url' => 'External URL',
745: 'file' => 'Uploaded File',
746: 'template' => 'Syllabus Template',
747: 'templateboxes' => 'Choose template items ... ',
748: 'curr' => 'Current:',
749: 'rep' => 'Replace:',
750: 'upl' => 'Upload:',
751: 'pr' => 'Preview',
752: 'save' => 'Save',
753: 'chourl' => 'Choose external URL',
754: 'chofile' => 'Uploaded syllabus file',
755: 'parse' => 'Upload embedded images/multimedia files if HTML file',
756: );
757: my %checked = (
758: file => '',
759: url => '',
760: template => '',
761: );
762: my %display = (
763: file => 'none',
764: url => 'none',
765: templatebox => 'none',
766: );
767: my $check = ' checked="checked" ';
768: if ($uploaded) {
769: $checked{'file'} = $check;
770: $display{'file'} = 'block';
771: } elsif ($external) {
772: $checked{'url'} = $check;
773: $display{'url'} = 'block';
774: } else {
775: $checked{'template'} = $check;
776: $checked{'templatebox'} = $check;
777: $display{'templatebox'} = 'block';
778: }
779:
780: my $output =
781: '<form name="syllabus" method="post" enctype="multipart/form-data" action="">'."\n".
782: '<input type="hidden" name="forceedit" value="1" />'."\n".
783: '<div class="LC_left_float"><fieldset><legend>'.$lt{'type'}.'</legend>';
784: foreach my $item ('template','url','file') {
785: $output .= '<label><input type="radio" name="choice" value="'.$item.'" '.$checked{$item}.' onclick="toggleEditor('."'$item'".')" />'.
786: $lt{$item}.'</label><br />';
787: }
788: $output .= '</fieldset></div>'."\n".
789: '<div id="url" class="LC_left_float" style="display: '.$display{'url'}.'">'."\n".
790: '<fieldset><legend>'.$lt{'chourl'}.'</legend><span class="LC_nobreak">'."\n".
791: '<a href="javascript:extUrlPreview('."'syllabusurl'".');">'.$lt{'pr'}.'</a></span> '."\n".
792: '<input type="text" id="syllabusurl" name="externalsyllabus" value="'.$external.'" size="55" />'."\n".
793: ' <input type="submit" name="storeurl" value="'.$lt{'save'}.'" />'."\n".
794: '</fieldset></div>'."\n".
795: '<div id="file" class="LC_left_float" style="display: '.$display{'file'}.'"><fieldset><legend>'.$lt{'file'}.'</legend>';
796: if ($uploaded) {
797: my $protocol = $Apache::lonnet::protocol{$lonhost};
798: $protocol = 'http' if ($protocol ne 'https');
799: my $absurl = $protocol.'://'.&Apache::lonnet::hostname($lonhost).$uploaded;
800: my ($filename) = ($uploaded =~ m{([^/]+)$});
1.118 raeburn 801: my $file=&Apache::lonnet::filelocation("",$uploaded);
802: my $depbutton;
803: if ($file =~ /\.html?$/) {
804: my $filecontents=&Apache::lonnet::getfile($file);
805: unless ($filecontents eq -1) {
806: my $mm = new File::MMagic;
807: my $mimetype = $mm->checktype_contents($filecontents);
808: if ($mimetype eq 'text/html') {
809: my (%codebase,%allfiles);
810: my $parse_result = &Apache::lonnet::extract_embedded_items($uploaded,\%allfiles,
811: \%codebase,\$filecontents);
812: my $actionurl = "/public/$cdom/$cnum/syllabus";
813: my ($ignore,$num,$numpathchanges,$existing,$mapping) =
814: &Apache::loncommon::ask_for_embedded_content($actionurl,undef,\%allfiles,
815: \%codebase,
816: {'context' => 'rewrites',
817: 'ignore_remote_references' => 1,});
818: if (keys(%allfiles)) {
819: $depbutton = (' ' x 3).
820: &editfile_button().
821: &editbutton_js($uploaded);
822: }
823: }
824: }
825: }
826:
1.117 raeburn 827: $output .= '<span class="LC_nobreak">'.$lt{'curr'}.' '.
828: '<input type="hidden" name="uploadedfile" value="'.&HTML::Entities::encode($absurl).'?inhibitmenu=yes" id="currfile" />'.
1.118 raeburn 829: '<a href="javascript:extUrlPreview('."'currfile'".');">'.$filename.'</a></span>'.$depbutton.
830: '<br /><br />'.$lt{'rep'};
1.117 raeburn 831: } else {
832: $output .= $lt{'upl'};
833: }
834:
835: $output .= '<br />'."\n".
836: '<span class="LC_nobreak">'.
837: '<input type="file" name="syllabusfile" size="55" />'."\n".
838: ' <input type="submit" name="storefile" value="'.$lt{'save'}.'" />'.
839: '</span><br />'.
840: '<label>'.
841: '<input type="checkbox" name="parserflag" checked="checked" />'.
842: $lt{'parse'}.
843: '</label>'.
844: '</fieldset></div>'.
845: '<div id="templatebox" class="LC_left_float" style="display: '.
846: $display{'templatebox'}.';"><fieldset><legend>'.$lt{'templateboxes'}.
847: ' <input type="button" value="'.&mt('check all').'" '.
848: 'onclick="javascript:checkAll('."document.syllabus.showfield".');javascript:toggleBox('."'all'".');" />'.
849: (' 'x2).
850: '<input type="button" value="'.&mt('uncheck all').'" '.
851: 'onclick="javascript:uncheckAll('."document.syllabus.showfield".');javascript:toggleBox('."'all'".');" />'.
852: '</legend>'.
853: &fields_check_uncheck($fields,$values).
854: '</fieldset>'.
855: '</div>';
856: $output .= '<div style="padding:0;clear:both;margin:0;border:0"></div>'.
857: '</form>';
858: return $output;
859: }
860:
861: sub fields_check_uncheck {
862: my ($fields,$values) = @_;
863: return unless ((ref($fields) eq 'HASH') && (ref($values) eq 'HASH'));
864: my $numinrow = 4;
865: my $table;
866: my @fieldnames = sort(keys(%{$fields}));
867: unshift(@fieldnames,'000_showrssfeeds');
868: my $numfields = scalar(@fieldnames);
869: for (my $i=0; $i<$numfields; $i++) {
870: my $checked;
871: my $name = $fields->{$fieldnames[$i]};
872: if ($fieldnames[$i] eq '000_showrssfeeds') {
873: $name = &mt('RSS Feeds and Blogs');
874: unless ($values->{$fieldnames[$i]} eq 'on') {
875: $checked = ' checked="checked"';
876: }
877: } elsif ($values->{$fieldnames[$i]} ne '') {
878: $checked = ' checked="checked"';
879: }
880: my $rem = $i%($numinrow);
881: if ($rem == 0) {
882: if (($i > 0) && ($i < $numfields-1)) {
883: $table .= '</tr>';
884: }
885: if ($i < $numfields-1) {
886: $table .= '<tr>';
887: }
888: }
889: $table .=
890: '<td><label><input type="checkbox" name="showfield" value="'.$fieldnames[$i].'" '.
891: $checked.' id="showfield_'.$i.'" onclick="javascript:toggleBox('."'$fieldnames[$i]',this".');" />'.
892: $name.'</label></td>'."\n";
893: }
894: if ($table ne '') {
895: my $rem = $numfields%($numinrow);
896: my $colsleft = $numinrow - $rem;
897: if ($colsleft > 1 ) {
898: $table .= '<td colspan="'.$colsleft.'"> </td>';
899: } elsif ($colsleft == 1) {
900: $table .= '<td> </td>';
901: }
902: $table = '<table>'.$table.'</tr></table>';
903: }
904: return $table;
905: }
906:
907: sub process_upload {
908: my ($upload_output,$cnum,$cdom,$allfiles,$codebase) = @_;
909: my ($parseaction,$showupload,$mimetype);
910: my $dest = 'portfolio/syllabus';
911: if ($env{'form.parserflag'}) {
912: $parseaction = 'parse';
913: }
914: my $url=&Apache::lonnet::userfileupload('syllabusfile','syllabus',$dest,
915: $parseaction,$allfiles,
916: $codebase,undef,undef,undef,undef,
917: undef,undef,\$mimetype);
918: if ($url =~ m{^/uploaded/\Q$cdom\E/\Q$cnum\E.*/([^/]+)$}) {
919: my $stored = $1;
920: $showupload = '<p>'.&mt('Uploaded [_1]',
921: '<span class="LC_filename">'.$stored.'</span>').
922: '</p>';
923: } else {
924: my ($filename) = ($env{'form.syllabusfile.filename'} =~ m{([^/]+)$});
925: $$upload_output = '<div class="LC_error" id="uploadfileresult">'.
926: &mt('Unable to save file [_1].',
927: '<span class="LC_filename">'.$filename.'</span>').
928: '</div>';
929: return ();
930: }
931: my $needlink;
932: if (($parseaction eq 'parse') && ($mimetype eq 'text/html')) {
933: $$upload_output = $showupload;
934: my $total_embedded = scalar(keys(%{$allfiles}));
935: if ($total_embedded > 0) {
936: my $uploadphase = 'upload_embedded';
937: my $primaryurl = &HTML::Entities::encode($url,'<>&"');
938: my $state = &embedded_form_elems($uploadphase,$primaryurl);
939: my $actionurl = "/public/$cdom/$cnum/syllabus";
940: my ($embedded,$num,$numpathchanges,$existing);
941: ($embedded,$num,$numpathchanges,$existing) =
942: &Apache::loncommon::ask_for_embedded_content($actionurl,$state,
943: $allfiles,$codebase,
944: {'error_on_invalid_names' => 1,
945: 'ignore_remote_references' => 1,});
946: if ($embedded) {
947: $needlink = 1;
948: if ($num) {
949: $$upload_output .=
950: '<p>'.&mt('This file contains embedded multimedia objects, which need to be uploaded.').'</p>'.$embedded;
951: } elsif ($numpathchanges) {
952: $$upload_output .= $embedded;
953: } else {
954: $$upload_output .= $embedded;
955: &Apache::loncommon::modify_html_refs('syllabus','portfolio/syllabus',
956: $cnum,$cdom,'/userfiles',$url);
957: }
958: } else {
959: $$upload_output .= &mt('Embedded item(s) already present, so no additional upload(s) required').'<br />';
960: &Apache::loncommon::modify_html_refs('syllabus','portfolio/syllabus',
961: $cnum,$cdom,'/userfiles',$url);
962:
963: }
964: } else {
965: $$upload_output .= &mt('No embedded items identified').'<br />';
966: }
967: $$upload_output = '<div id="uploadfileresult">'.$$upload_output.'</div>';
968: }
969: return ($url,$needlink);
970: }
971:
972: sub embedded_form_elems {
973: my ($phase,$primaryurl) = @_;
974: return <<STATE;
975: <input type="hidden" name="forceedit" value="1" />
976: <input type="hidden" name="cmd" value="upload_embedded" />
977: <input type="hidden" name="phase" value="$phase" />
978: <input type="hidden" name="primaryurl" value="$primaryurl" />
979: STATE
980: }
981:
982: sub return_to_editor {
983: my ($cdom,$cnum) = @_;
984: my $actionurl = "/public/$cdom/$cnum/syllabus";
985: return '<p><form name="backtoeditor" method="post" action="'.$actionurl.'" />'.
986: '<input type="hidden" name="forceedit" value="1" />'."\n".
987: '<a href="javascript:document.backtoeditor.submit();">'.&mt('Return to Editor').
988: '</a></p>';
989: }
990:
1.118 raeburn 991: sub editfile_button {
992: my $buttontext=&mt('Edit');
993: return <<"END";
994: <input type="button" value="$buttontext" onclick="javascript:gotoeditor();" />
995: END
996: }
997:
998: sub editbutton_js {
999: my ($url) = @_;
1000: return <<ENDJS;
1001: <script type="text/javascript">
1002: // <![CDATA[
1003: function gotoeditor() {
1004: document.location.href = '$url?forceedit=1';
1005: }
1006: // ]]>
1007: </script>
1008: ENDJS
1009: }
1010:
1.1 www 1011: 1;
1012: __END__
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>