Annotation of loncom/interface/lonextresedit.pm, revision 1.8.2.4.4.2
1.1 raeburn 1: # The LearningOnline Network
2: # Documents
3: #
1.8.2.4.4.2! raeburn 4: # $Id: lonextresedit.pm,v 1.8.2.4.4.1 2023/07/05 18:10:06 raeburn Exp $
1.1 raeburn 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::lonextresedit;
30:
31: use strict;
32: use Apache::Constants qw(:common :http);
33: use HTML::Entities;
34: use Apache::lonlocal;
35: use Apache::lonnet;
36: use Apache::loncommon;
37: use Apache::lonhtmlcommon;
38: use Apache::lonuserstate;
39: use LONCAPA::map();
40: use LONCAPA qw(:DEFAULT :match);
41:
42: sub handler {
43: my $r=shift;
44: &Apache::loncommon::content_type($r,'text/html');
45: $r->send_http_header;
46:
47: return OK if $r->header_only;
48:
49: # Check for access
50: if (! &Apache::lonnet::allowed('mdc',$env{'request.course.id'})) {
51: $env{'user.error.msg'}=
52: $r->uri.":mdc:0:0:Cannot modify course content.";
53: return HTTP_NOT_ACCEPTABLE;
54: }
55:
56: my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
57: my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
58: my $chome = $env{'course.'.$env{'request.course.id'}.'.home'};
1.8.2.4.4.1 raeburn 59: my ($supplementalflag,$updated,$output,$errormsg,$residx,$url,$title,
60: $symb,$type);
1.5 raeburn 61: if (($env{'form.folderpath'} =~ /^supplemental/) && ($env{'form.suppurl'})) {
62: $supplementalflag = 1;
1.8.2.4.4.1 raeburn 63: if (&unescape($env{'form.suppurl'}) =~ m{^/adm/$cdom/$cnum/\d+/ext\.tool$}) {
64: $type = 'tool';
65: }
1.7 raeburn 66: }
1.5 raeburn 67: if (($supplementalflag) || ($env{'form.symb'} =~ /^uploaded/)) {
1.7 raeburn 68: ($updated,$output,$errormsg,$residx,$url,$title,$symb) =
1.1 raeburn 69: &process_changes($supplementalflag,$cdom,$cnum,$chome);
70: if ($supplementalflag) {
1.8.2.4.4.1 raeburn 71: if ($url ne &unescape($env{'form.suppurl'})) {
1.1 raeburn 72: $env{'form.suppurl'} = $url;
73: }
74: if ($title ne $env{'form.title'}) {
75: $env{'form.title'} = $title;
76: }
1.5 raeburn 77: $env{'form.idx'} = $residx;
1.1 raeburn 78: } else {
79: if ($symb ne $env{'form.symb'}) {
80: $env{'form.symb'} = $symb;
81: }
1.8.2.4.4.1 raeburn 82: if ($url =~ m{/adm/$cdom/$cnum/\d+/ext\.tool$}) {
83: $type = 'tool';
84: }
1.1 raeburn 85: }
86: } else {
87: $errormsg = &mt('Information about external resource to edit is missing.');
88: }
89: if ($updated) {
1.8.2.4.4.1 raeburn 90: my $msg = &mt('External Resource updated');
91: if ($type eq 'tool') {
92: $msg = &mt('External Tool updated');
93: }
94: $output = &Apache::lonhtmlcommon::confirm_success($msg);
1.1 raeburn 95: }
96: if ($errormsg) {
97: $errormsg = '<p class="LC_error">'.$errormsg.'</p>';
98: }
1.8.2.4.4.1 raeburn 99: my %ltitools;
100: if ($type eq 'tool') {
1.8.2.4.4.2! raeburn 101: my (%domtools,%crstools);
! 102: my %tooltypes = &Apache::loncommon::usable_exttools();
! 103: if ($tooltypes{'dom'}) {
! 104: %domtools = &Apache::lonnet::get_domain_lti($cdom,'consumer');
! 105: }
! 106: if ($tooltypes{'crs'}) {
! 107: %crstools = &Apache::lonnet::get_course_lti($cnum,$cdom,'consumer');
! 108: }
! 109: %ltitools = (
! 110: dom => \%domtools,
! 111: crs => \%crstools,
! 112: );
1.8.2.4.4.1 raeburn 113: }
1.1 raeburn 114: my $js = &Apache::lonhtmlcommon::scripttag(&extedit_javascript());
115: my $pathitem = '<input type="hidden" name="folderpath" value="'.
116: &HTML::Entities::encode($env{'form.folderpath'},'<>&"').'" />';
1.8.2.4.4.1 raeburn 117: my $description = 'External Resource Editor';
118: if ($type eq 'tool') {
119: $description = 'External Tool Editor';
120: }
121: $r->print(&Apache::loncommon::start_page($description,$js).
1.1 raeburn 122: '<div class="LC_left_float">'.
123: $output.
124: $errormsg.
125: &extedit_form($supplementalflag,$residx,$url,$title,$pathitem,undef,
1.8.2.4.4.1 raeburn 126: 'direct',$env{'form.symb'},$type,$cdom,$cnum,\%ltitools).
1.1 raeburn 127: '</div>'.&Apache::loncommon::end_page());
128: return OK;
129: }
130:
131: sub process_changes {
132: my ($supplementalflag,$cdom,$cnum,$chome) = @_;
1.8.2.4.4.1 raeburn 133: my ($folder,$container,$output,$errormsg,$updated,$symb,$oldidx,$oldurl,$type,
134: $oldtitle,$newidx,$newurl,$newtitle,$residx,$url,$title,$marker,$args);
1.1 raeburn 135: if ($env{'form.symb'}) {
136: $symb = $env{'form.symb'};
1.5 raeburn 137: (my $map,$oldidx,$oldurl)=&Apache::lonnet::decode_symb($symb);
1.1 raeburn 138: if ($map =~ m{^uploaded/$cdom/$cnum/(default(_\d+|))\.(sequence|page)$}) {
139: $folder = $1;
140: $container = $3;
141: }
142: $oldtitle = &Apache::lonnet::gettitle($env{'form.symb'});
1.8.2.4.4.1 raeburn 143: if ($oldurl =~ m{^ext/(.+)$}) {
144: my $external = $1;
145: if ($external =~ m{^https://}) {
146: $oldurl = $external;
147: } else {
148: $oldurl = 'http://'.$oldurl;
149: }
150: $type = 'ext';
151: } else {
152: $type = 'tool';
153: }
1.1 raeburn 154: } elsif ($env{'form.folderpath'}) {
155: $folder = &unescape( (split('&',$env{'form.folderpath'}))[-2] );
156: $oldurl = &unescape($env{'form.suppurl'});
157: $oldtitle = &unescape($env{'form.title'});
158: $container = 'sequence';
159: $supplementalflag = 1;
1.8.2.4.4.1 raeburn 160: if ($oldurl =~ m{^/adm/$cdom/$cnum/\d+/ext\.tool$}) {
161: $type = 'tool';
1.5 raeburn 162: } else {
1.8.2.4.4.1 raeburn 163: $type = 'ext';
1.5 raeburn 164: }
165: }
166: $url = $oldurl;
167: $title = $oldtitle;
168: if ($env{'form.importdetail'}) {
169: ($newtitle,$newurl,$newidx) =
170: map {&unescape($_)} split(/\=/,$env{'form.importdetail'});
1.8.2.4.4.1 raeburn 171: if ($newurl =~ m{^(/adm/$cdom/$cnum/(\d+)/ext\.tool)\:?(.*)$}) {
172: $newurl = $1;
173: $marker = $2;
174: $args = $3;
1.8.2.4.4.2! raeburn 175: if ((!$symb) && (!$supplementalflag)) {
! 176: $symb = "uploaded/$cdom/$cnum/$folder.$container"."___$newidx"."___adm/$cdom/$cnum/$marker/ext.tool";
! 177: }
1.8.2.4.4.1 raeburn 178: }
1.5 raeburn 179: }
180: if ($supplementalflag) {
181: $residx = $newidx;
182: } else {
183: $residx = $oldidx;
184: }
1.1 raeburn 185: if ($folder && $container) {
186: if ($env{'form.importdetail'}) {
1.8.2.4.4.2! raeburn 187: my ($errtext,$fatal,$mismatchedid,$needreload,$newgradable,@imports);
1.5 raeburn 188: if (!$supplementalflag) {
189: if (($oldidx) && ($oldidx != $newidx)) {
190: $mismatchedid = 1;
191: }
1.1 raeburn 192: }
193: if ($mismatchedid) {
194: $errormsg = 'Wrong item identifier';
195: } elsif (($newtitle eq $oldtitle) && ($newurl eq $oldurl)) {
1.8.2.4.4.1 raeburn 196: if ($type eq 'tool') {
197: if ($args) {
1.8.2.4.4.2! raeburn 198: ($updated,$newgradable,$errormsg) = &update_exttool($marker,$cdom,$cnum,
! 199: $supplementalflag,$args);
! 200: if ($updated) {
! 201: if ($newgradable) {
! 202: my $map = "/uploaded/$cdom/$cnum/$folder.$container";
! 203: my ($errtext,$fatal) = &LONCAPA::map::mapread($map);
! 204: if ($fatal) {
! 205: $errormsg = &mt('Update failed: [_1].',$errtext);
! 206: } else {
! 207: &LONCAPA::map::storeparameter($residx,'parameter_0_gradable',
! 208: $newgradable,'string_yesno');
! 209: my ($outtext,$errtext) = &LONCAPA::map::storemap($map,1,1);
! 210: if ($errtext) {
! 211: $errormsg = &mt('Update failed: [_1].',$errtext);
! 212: } else {
! 213: $needreload = 1;
! 214: }
! 215: }
! 216: }
! 217: } else {
! 218: $output = &mt('No change');
1.8.2.4.4.1 raeburn 219: }
220: } else {
221: $output = &mt('No change');
222: }
223: } else {
224: $output = &mt('No change');
225: }
1.1 raeburn 226: } else {
227: my $map = "/uploaded/$cdom/$cnum/$folder.$container";
228: my ($errtext,$fatal) = &LONCAPA::map::mapread($map);
229: if ($fatal) {
230: $errormsg = &mt('Update failed: [_1].',$errtext);
231: } else {
232: my $saveurl = &LONCAPA::map::qtunescape($newurl);
233: my $savetitle = &LONCAPA::map::qtunescape($newtitle);
1.8.2.4.4.1 raeburn 234: my $ext = 'true';
235: if ($type eq 'tool') {
236: if ($args) {
1.8.2.4.4.2! raeburn 237: ($updated,$newgradable,$errormsg) = &update_exttool($marker,$cdom,$cnum,
! 238: $supplementalflag,$args);
! 239: if ($newgradable) {
! 240: &LONCAPA::map::storeparameter($residx,'parameter_0_gradable',$newgradable,
! 241: 'string_yesno');
! 242: $needreload = 1;
! 243: }
1.8.2.4.4.1 raeburn 244: }
245: $ext = 'false';
246: }
1.8.2.4.4.2! raeburn 247: my $dotimeupdate;
! 248: unless ($supplementalflag) {
! 249: if (($newgradable) || ($newurl ne $oldurl)) {
! 250: $dotimeupdate = 1;
! 251: }
! 252: }
1.1 raeburn 253: $LONCAPA::map::resources[$residx] =
1.8.2.4.4.1 raeburn 254: join(':', ($savetitle,$saveurl,$ext,'normal','res'));
1.8.2.4.4.2! raeburn 255: my ($outtext,$errtext) = &LONCAPA::map::storemap($map,1,$dotimeupdate);
1.1 raeburn 256: if ($errtext) {
257: $errormsg = &mt('Update failed: [_1].',$errtext);
258: } else {
259: $updated = 1;
1.5 raeburn 260: $title = $newtitle;
261: if ($newurl ne $oldurl) {
262: $url = $newurl;
1.8.2.4.4.1 raeburn 263: if ($ext eq 'true') {
264: $newurl =~ s{^http://}{};
265: $newurl = "ext/$newurl";
266: }
1.5 raeburn 267: }
1.1 raeburn 268: if (!$supplementalflag) {
269: if ($newurl ne $oldurl) {
1.5 raeburn 270: $symb = &Apache::lonnet::encode_symb($map,$residx,$newurl);
1.1 raeburn 271: } else {
272: $symb = $env{'form.symb'};
273: if ($symb) {
274: &Apache::lonnet::devalidate_title_cache($symb);
275: }
276: }
1.8.2.4.4.2! raeburn 277: $needreload = 1;
1.1 raeburn 278: }
279: }
280: }
281: }
1.8.2.4.4.2! raeburn 282: if ($needreload) {
! 283: my ($furl,$ferr) = &Apache::lonuserstate::readmap("$cdom/$cnum");
! 284: if ($ferr) {
! 285: $errormsg = &mt('Reload failed: [_1].',$ferr);
! 286: } else {
! 287: unless ($supplementalflag) {
! 288: &Apache::loncommon::update_content_constraints($cdom,$cnum,$chome,
! 289: $cdom.'_'.$cnum);
! 290: }
! 291: }
! 292: }
! 293: if (($type eq 'tool') && ($newgradable)) {
! 294: my $uri = &Apache::lonnet::declutter($url);
! 295: &Apache::lonnet::devalidate_cache_new('meta',$uri);
! 296: }
1.1 raeburn 297: } else {
298: $output = &mt('No change');
299: }
300: } else {
1.8.2.4.4.1 raeburn 301: if ($type eq 'tool') {
302: $errormsg = &mt('Information about current external tool is incomplete.');
303: } else {
304: $errormsg = &mt('Information about current external resource is incomplete.');
305: }
1.1 raeburn 306: }
1.5 raeburn 307: return ($updated,$output,$errormsg,$residx,$url,$title,$symb);
1.1 raeburn 308: }
309:
1.8.2.4.4.1 raeburn 310: sub update_exttool {
1.8.2.4.4.2! raeburn 311: my ($marker,$cdom,$cnum,$supplementalflag,$args) = @_;
! 312: my (%newhash,$changed,$newgradable,@deleted,$errormsg);
1.8.2.4.4.1 raeburn 313: ($newhash{'target'},$newhash{'width'},$newhash{'height'},$newhash{'linktext'},$newhash{'explanation'},
1.8.2.4.4.2! raeburn 314: $newhash{'crslabel'},$newhash{'crstitle'},$newhash{'crsappend'},$newhash{'gradable'}) = split(/:/,$args);
1.8.2.4.4.1 raeburn 315: foreach my $item ('linktext','explanation','crslabel','crstitle','crsappend') {
316: $newhash{$item} = &unescape($newhash{$item});
317: }
318: my %toolhash=&Apache::lonnet::dump('exttool_'.$marker,$cdom,$cnum);
1.8.2.4.4.2! raeburn 319: foreach my $item ('target','width','height','linktext','explanation','crslabel','crstitle','crsappend','gradable') {
1.8.2.4.4.1 raeburn 320: $newhash{$item} =~ s/^\s+//;
321: $newhash{$item} =~ s/\s+$//;
322: if (($item eq 'width') || ($item eq 'height') || ($item eq 'linktext') || ($item eq 'explanation')) {
323: if ($newhash{'target'} eq 'iframe') {
324: $newhash{$item} = '';
325: } elsif ($newhash{'target'} eq 'tab') {
326: if (($item eq 'width') || ($item eq 'height')) {
327: $newhash{$item} = '';
328: }
329: }
1.8.2.4.4.2! raeburn 330: } elsif ($item eq 'gradable') {
! 331: unless ($newhash{$item} == 1) {
! 332: $newhash{$item} = '';
! 333: }
1.8.2.4.4.1 raeburn 334: }
335: if ($toolhash{$item} ne $newhash{$item}) {
1.8.2.4.4.2! raeburn 336: if (($item eq 'gradable') && (!$supplementalflag)) {
! 337: if ($newhash{$item}) {
! 338: $newgradable = 'yes';
! 339: } else {
! 340: $newgradable = 'no';
! 341: }
! 342: }
1.8.2.4.4.1 raeburn 343: if ($newhash{$item} eq '') {
344: unless (($item eq 'target') ||
345: ((($item eq 'width') || ($item eq 'height')) &&
346: (($newhash{'target'} eq 'window') ||
347: (($newhash{'target'} eq '') && ($toolhash{'target'} eq 'window')))) ||
348: ((($item eq 'linktext') || ($item eq 'explanation')) &&
349: ((($newhash{'target'} =~ /^(window|tab)$/)) ||
350: (($newhash{'target'} eq '') && ($toolhash{'target'} =~ /^(window|tab)$/))))) {
351: delete($toolhash{$item});
352: push(@deleted,$item);
353: $changed = 1;
354: }
355: } else {
356: $toolhash{$item} = $newhash{$item};
357: $changed = 1;
358: }
359: }
360: }
361: if ($changed) {
362: my $putres = &Apache::lonnet::put('exttool_'.$marker,\%toolhash,$cdom,$cnum);
363: unless ($putres eq 'ok') {
364: $errormsg = &mt('Failed to save updated settings.').' '.&mt('Error: [_1].',$putres);
365: }
366: }
367: if (@deleted) {
368: &Apache::lonnet::del('exttool_'.$marker,\@deleted,$cdom,$cnum);
369: }
1.8.2.4.4.2! raeburn 370: return ($changed,$newgradable,$errormsg);
1.8.2.4.4.1 raeburn 371: }
372:
1.1 raeburn 373: sub extedit_form {
1.8.2.4.4.1 raeburn 374: my ($supplementalflag,$residx,$orig_url,$orig_title,$pathitem,$helpitem,$caller,
375: $symb,$type,$cdom,$cnum,$ltitools,$disabled) = @_;
376: if ($type ne 'tool') {
377: $type = 'ext';
378: }
1.1 raeburn 379: my %lt = &Apache::lonlocal::texthash(
380: ex => 'External Resource',
1.8.2.4.4.1 raeburn 381: et => 'External Tool',
1.1 raeburn 382: ed => 'Edit',
383: ee => 'External Resource Editor',
1.8.2.4.4.1 raeburn 384: te => 'External Tool Editor',
1.1 raeburn 385: pr => 'Preview',
386: sv => 'Save',
387: ul => 'URL',
388: ti => 'Title',
389: al => 'Add Link',
1.8.2.4.4.1 raeburn 390: at => 'Add Tool',
1.8.2.4.4.2! raeburn 391: dd => 'Defined in domain',
! 392: dc => 'Defined in course',
1.1 raeburn 393: );
394: my $tabid = 'aa';
395: my $size = 60;
396: if ($supplementalflag) {
397: $tabid = 'ee';
398: }
1.8.2.4.4.2! raeburn 399: my ($formname,$formid,$toggle,$fieldsetid,$urlid,$subdivid,$dispdivstyle,$dimendivstyle,
1.8.2.4.4.1 raeburn 400: $windivstyle,$linktextstyle,$explanationstyle,$labelstyle,$titlestyle,
1.8.2.4.4.2! raeburn 401: $appendstyle,$gradablestyle,$subdivstyle,$legend,$urlelem,$toolelem,%toolattr);
1.8.2.4.4.1 raeburn 402: $formname = 'new'.$type;
403: $toggle = $type;
404: $fieldsetid = 'upload'.$type.'form';
405: $urlid = $type.'url';
406: map { $toolattr{$_} = $type.$_; } ('dispdiv','dimendiv','dimenwidth','dimenheight',
407: 'crstitlediv','crslabeldiv','crsappenddiv',
1.8.2.4.4.2! raeburn 408: 'gradablediv','crstitle','crslabel','crsappend',
! 409: 'windiv','linktextdiv','explanationdiv',
! 410: 'linktext','explanation','providerurl');
1.8.2.4.4.1 raeburn 411: $dispdivstyle = 'display:none';
412: $dimendivstyle = 'display:none';
413: $windivstyle = 'display:none';
414: $linktextstyle = 'display:none';
415: $explanationstyle = 'display:none';
416: $labelstyle = 'display:none';
417: $titlestyle = 'display:none';
418: $appendstyle = 'display:none';
1.8.2.4.4.2! raeburn 419: $gradablestyle = 'display:none';
! 420: $subdivstyle = 'display:block';
1.8.2.4.4.1 raeburn 421: if ($supplementalflag) {
422: $formname = 'newsupp'.$type;
423: $toggle = 'supp'.$type;
424: $fieldsetid = 'uploadsupp'.$type.'form';
425: $urlid = 'supp'.$type.'url';
426: map { $toolattr{$_} = 'supp'.$toolattr{$_}; } (keys(%toolattr));
427: }
428: my ($link,$legend,$active,$srcclass,$extsrc,$preview,$title,$save,$crstitle,$crslabel,
429: $crsappend,$fieldsetstyle,$action,$hiddenelem,$form,$width,$height,$tooltarget,
1.8.2.4.4.2! raeburn 430: $linktext,$explanation,$providerurl,$chkgrd,$chknogrd,%chkstate);
1.1 raeburn 431: $fieldsetstyle = 'display: none;';
432: $action = '/adm/coursedocs';
1.8.2.2 raeburn 433: my $protocol = ($ENV{'SERVER_PORT'} == 443?'https':'http');
1.8.2.4.4.1 raeburn 434: my $rows = 2;
435: my $cols = 20;
1.1 raeburn 436: if ($residx) {
437: if ($caller eq 'direct') {
438: $fieldsetstyle = 'display: block;';
439: $action = '/adm/extresedit';
1.8.2.4.4.1 raeburn 440: $rows = 10;
441: $cols = 45;
442: if ($type eq 'tool') {
443: $legend = $lt{'te'};
444: } else {
445: $legend = $lt{'ee'};
446: }
447: $legend = '<legend>'.$legend.'</legend>';
1.1 raeburn 448: if ($symb) {
449: $hiddenelem = '<input type="hidden" name="symb" value="'.$symb.'" />';
450: } elsif ($supplementalflag) {
451: $hiddenelem = '<input type="hidden" name="suppurl" value="'.
452: &HTML::Entities::encode(&escape($orig_url),'<>&"').'" />'."\n".
453: '<input type="hidden" name="title" value="'.
454: &HTML::Entities::encode(&escape($orig_title),'<>&"').'" />';
455: }
1.8.2.4.4.1 raeburn 456: } else {
457: $link = '<a class="LC_docs_ext_edit" href="javascript:editext('."'$residx','$type'".');">'.$lt{'ed'}.'</a> '."\n";
1.1 raeburn 458: $size = 40;
1.3 raeburn 459: $active = '<input type="hidden" name="active" value="'.$tabid.'" />';
1.1 raeburn 460: }
1.8.2.4.4.1 raeburn 461: $formname = 'edit'.$type.'_'.$residx;
462: $fieldsetid = 'upload'.$type.$residx;
463: $urlid = $type.'url_'.$residx;
464: map { $toolattr{$_} .= '_'.$residx; } (keys(%toolattr));
1.1 raeburn 465: $srcclass = ' class="LC_nobreak"';
1.8.2.4.4.1 raeburn 466: if ($type eq 'ext') {
467: $extsrc = '<span class="LC_docs_ext_edit">'.$lt{'ul'}.' </span>';
468: $preview = ' <a class="LC_docs_ext_edit" href="javascript:extUrlPreview('."'$urlid','$protocol'".');">'.$lt{'pr'}.'</a>';
469: }
1.1 raeburn 470: $title = '<span class="LC_docs_ext_edit">'.$lt{'ti'}.' </span>';
471: $save = $lt{'sv'};
472: } else {
1.8.2.4.4.1 raeburn 473: $link = $lt{'ex'};
474: if ($type eq 'tool') {
475: $link = $lt{'et'};
476: }
477: $link = '<a class="LC_menubuttons_link" href="javascript:toggleUpload('."'$toggle'".');">'.$link.'</a>'.$helpitem;
478: if ($type eq 'tool') {
479: $legend = $lt{'te'};
480: } else {
481: $legend = $lt{'ee'};
482: }
483: $legend = '<legend>'.$legend.'</legend>';
1.1 raeburn 484: $title = $lt{'ti'}.':<br />';
485: $residx = 0;
1.8.2.4.4.1 raeburn 486: if ($type eq 'ext') {
487: $orig_url = 'http://';
488: $orig_title = $lt{'ex'};
489: $extsrc = $lt{'ul'}.':<br />';
490: $preview = '<input type="button" name="view" value="'.$lt{'pr'}.'" onclick="javascript:extUrlPreview('."'$urlid','$protocol'".');"'.$disabled.' />';
491: $save = $lt{'al'};
492: } else {
493: $orig_title = $lt{'et'};
494: $save = $lt{'at'};
495: $orig_url = "/adm/$cdom/$cnum/new/ext\.tool";
496: }
1.1 raeburn 497: $pathitem .= '<br />';
498: }
1.8.2.4.4.1 raeburn 499: $formid = $formname;
500: if ($type eq 'ext') {
501: $urlelem = '<input type="text" size="'.$size.'" name="exturl" id="'.$urlid.'" value="'.$orig_url.'"'.$disabled.' />';
502: } else {
503: my $class = 'LC_nobreak';
504: if ($residx) {
505: $class = 'LC_docs_ext_edit LC_nobreak';
506: if ($orig_url =~ m{^/adm/$cdom/$cnum/(\d+)/ext\.tool$}) {
507: my $marker = $1;
508: my %toolhash=&Apache::lonnet::dump('exttool_'.$marker,$cdom,$cnum);
1.8.2.4.4.2! raeburn 509: my ($tooltype,$tool,$ltihash);
! 510: if ($toolhash{'id'} =~/^c(\d+)$/) {
! 511: $tool = $1;
! 512: $tooltype = 'crs';
1.8.2.4.4.1 raeburn 513: if (ref($ltitools) eq 'HASH') {
1.8.2.4.4.2! raeburn 514: if (ref($ltitools->{'crs'}) eq 'HASH') {
! 515: $ltihash = $ltitools->{'crs'}->{$tool};
! 516: }
! 517: }
! 518: } elsif ($toolhash{'id'} =~/^\d+$/) {
! 519: $tooltype = 'dom';
! 520: $tool = $toolhash{'id'};
! 521: if (ref($ltitools) eq 'HASH') {
! 522: if (ref($ltitools->{'dom'}) eq 'HASH') {
! 523: $ltihash = $ltitools->{'dom'}->{$tool};
1.8.2.4.4.1 raeburn 524: }
525: }
526: }
1.8.2.4.4.2! raeburn 527: if (($tool ne '') && (ref($ltihash) eq 'HASH')) {
! 528: my $tooltitle = $ltihash->{'title'};
! 529: my $icon = $ltihash->{'image'};
! 530: my $image;
! 531: if ($icon) {
! 532: $image = '<img src="'.$icon.'" alt="'.$tooltitle.'" />';
! 533: }
! 534: if ($ltihash->{'url'} =~ m{://}) {
! 535: (my $prot,my $host,$providerurl) = ($ltihash->{'url'} =~ m{^([^/]+)://([^/]+)(|/.+)$});
! 536: } else {
! 537: $providerurl = $ltihash->{'url'};
! 538: }
! 539: $tooltarget = $toolhash{'target'};
! 540: if ($tooltarget eq 'window') {
! 541: $dimendivstyle = 'display:block';
! 542: $windivstyle = 'display:block';
! 543: $chkstate{'window'} = 'checked="checked" ';
! 544: } elsif ($tooltarget eq 'tab') {
! 545: $windivstyle = 'display:block';
! 546: $chkstate{'tab'} = 'checked="checked" ';
! 547: } else {
! 548: $chkstate{'iframe'} = 'checked="checked" ';
! 549: }
! 550: $width = $toolhash{'width'};
! 551: $height = $toolhash{'height'};
! 552: $linktext = $toolhash{'linktext'};
! 553: $explanation = $toolhash{'explanation'};
! 554: if ($toolhash{'gradable'}) {
! 555: $chkgrd = ' checked="checked"';
! 556: } else {
! 557: $chknogrd = ' checked="checked"';
! 558: }
! 559: if (ref($ltihash->{'crsconf'}) eq 'HASH') {
! 560: if ($ltihash->{'crsconf'}->{'title'}) {
! 561: $crstitle = $toolhash{'crstitle'};
! 562: $titlestyle = 'display:inline';
! 563: }
! 564: if ($ltihash->{'crsconf'}->{'label'}) {
! 565: $crslabel = $toolhash{'crslabel'};
! 566: $labelstyle = 'display:inline';
! 567: }
! 568: if ($ltihash->{'crsconf'}->{'append'}) {
! 569: $crsappend = $toolhash{'crsappend'};
! 570: $appendstyle = 'display:inline';
! 571: }
! 572: if ($ltihash->{'crsconf'}->{'target'}) {
! 573: $dispdivstyle = 'display:block';
! 574: }
! 575: if ($ltihash->{'crsconf'}->{'linktext'}) {
! 576: $linktextstyle = 'padding:0;display:inline';
! 577: }
! 578: if ($ltihash->{'crsconf'}->{'explanation'}) {
! 579: $explanationstyle = 'padding:0;display:inline';
! 580: }
! 581: }
! 582: $toolelem = '<span class="LC_nobreak">'.$image.' '.$tooltitle.'</span><br />';
! 583: $gradablestyle = 'display:inline';
! 584: }
1.8.2.4.4.1 raeburn 585: }
586: } else {
1.8.2.4.4.2! raeburn 587: $subdivstyle = 'display:none';
! 588: my $toolradio = 'exttooltype';
! 589: my $exttypeon = 'LC_exttoolon';
! 590: my $exttypeoff = 'LC_exttooloff';
! 591: my $exttypeonsty = 'display:none';
! 592: my $exttypeoffsty = 'display:none';
! 593: my $exttypeofftext;
! 594: if ($supplementalflag) {
! 595: $toolradio = 'suppexttooltype';
! 596: $exttypeon = 'LC_exttoolonsupp';
! 597: $exttypeoff = 'LC_exttooloffsupp';
! 598: }
! 599: my ($numcrstools,$numdomtools,$typeclick,%defcheck,%typedesc);
! 600: %typedesc = (
! 601: crs => 'Defined in course',
! 602: dom => 'Defined in domain',
! 603: );
! 604: #FIXME need crstype
! 605: my $seloptions;
! 606: $subdivid = 'LC_addtool';
! 607: if ($supplementalflag) {
! 608: $subdivid = 'LC_addtoolsupp';
! 609: }
1.8.2.4.4.1 raeburn 610: if (ref($ltitools) eq 'HASH') {
1.8.2.4.4.2! raeburn 611: if (ref($ltitools->{'crs'}) eq 'HASH') {
! 612: $numcrstools = scalar(keys(%{$ltitools->{'crs'}}));
1.8.2.4.4.1 raeburn 613: }
1.8.2.4.4.2! raeburn 614: if (ref($ltitools->{'dom'}) eq 'HASH') {
! 615: $numdomtools = scalar(keys(%{$ltitools->{'dom'}}));
! 616: }
! 617: if ($numcrstools || $numdomtools) {
! 618: $typeclick = ' onclick="'.
! 619: 'javascript:updateExttoolSel(this.form,'."'$toolradio','$supplementalflag'".');"';
! 620: } else {
! 621: $exttypeoffsty = 'display:block';
! 622: $exttypeofftext = &mt('No external tools defined in either the domain or the course are available for selection.');
! 623: }
! 624: if ($numcrstools && !$numdomtools) {
! 625: $defcheck{'crs'} = ' checked="checked"';
! 626: $subdivstyle = 'display:block';
! 627: $exttypeonsty = 'display:block';
! 628: my $firstoption = '<option value="" selected="selected">'.&mt('Select').'</option>';
! 629: $seloptions = &ordered_tooloptions($ltitools->{'crs'});
! 630: if ($seloptions) {
! 631: $seloptions = "$firstoption\n$seloptions";
! 632: }
! 633: $exttypeofftext = &mt('No external tools defined in the domain are available for selection.');
! 634: } elsif (!$numcrstools && $numdomtools) {
! 635: $defcheck{'dom'} = ' checked="checked"';
! 636: $subdivstyle = 'display:block';
! 637: $exttypeonsty = 'display:block';
! 638: my $firstoption = '<option value="" selected="selected">'.&mt('Select').'</option>';
! 639: $seloptions = &ordered_tooloptions($ltitools->{'dom'});
! 640: if ($seloptions) {
! 641: $seloptions = "$firstoption\n$seloptions";
1.8.2.4.4.1 raeburn 642: }
1.8.2.4.4.2! raeburn 643: #FIXME need crstype
! 644: $exttypeofftext = &mt('No external tools defined in the course are available for selection.');
1.8.2.4.4.1 raeburn 645: }
646: }
1.8.2.4.4.2! raeburn 647: foreach my $type ('crs','dom') {
! 648: $toolelem .= '<span class="LC_nobreak"> <label>'.
! 649: '<input type="radio" name="'.$toolradio.'" value="'.$type.'"'.$defcheck{$type}.
! 650: $typeclick.$disabled.' />'.$typedesc{$type}.'</label></span> '."\n";
! 651: }
! 652: $toolelem .= '<div id="'.$exttypeon.'" style="'.$exttypeonsty.'">'.
! 653: '<select name="exttoolid" onchange="javascript:updateExttool(this,'.
! 654: 'this.form,'."'$supplementalflag'".');"'.$disabled.'>'."\n".
! 655: $seloptions.
! 656: '</select><br /></div>'."\n".
! 657: '<div id="'.$exttypeoff.'" style="'.$exttypeoffsty.'">'.
! 658: $exttypeofftext.
! 659: '<br /></div>'."\n";
1.8.2.4.4.1 raeburn 660: $crslabel = $env{'course.'.$cdom.'_'.$cnum.'.internal.coursecode'};
661: $crstitle = $env{'course.'.$cdom.'_'.$cnum.'.description'};
662: $crsappend = '';
1.8.2.4.4.2! raeburn 663: $chknogrd = ' checked="checked"';
1.8.2.4.4.1 raeburn 664: }
665: $toolelem .= '<div id="'.$toolattr{'dispdiv'}.'" style="'.$dispdivstyle.'">'.
666: '<span class="'.$class.'">'.&mt('Display target:').' '.
667: '<label><input type="radio" name="exttooltarget" value="iframe" '.$chkstate{'iframe'}.'onclick="updateTooldim(this.form,'.
668: "'$toolattr{dimendiv}','$toolattr{windiv}','$toolattr{dimenwidth}','$toolattr{dimenheight}',
669: '$toolattr{linktext}','$toolattr{explanation}'".');"'.$disabled.' />'.&mt('iframe').'</label>'.(' 'x2).
670: '<label><input type="radio" name="exttooltarget" value="tab" '.$chkstate{'tab'}.'onclick="updateTooldim(this.form,'.
671: "'$toolattr{dimendiv}','$toolattr{windiv}','$toolattr{dimenwidth}','$toolattr{dimenheight}',
672: '$toolattr{linktext}','$toolattr{explanation}'".');"'.$disabled.' />'.&mt('tab').'</label>'.(' 'x2).
673: '<label><input type="radio" name="exttooltarget" value="window" '.$chkstate{'window'}.'onclick="updateTooldim(this.form,'.
674: "'$toolattr{dimendiv}','$toolattr{windiv}','$toolattr{dimenwidth}','$toolattr{dimenheight}',
675: '$toolattr{linktext}','$toolattr{explanation}'".');"'.$disabled.' />'.&mt('window').'</label></span>'.
676: '<div id="'.$toolattr{'dimendiv'}.'" style="'.$dimendivstyle.'"><span class="'.$class.'">'.
677: &mt('Width').': <input type="text" size="4" id="'.$toolattr{'dimenwidth'}.'" name="exttoolwidth" value="'.$width.'"'.$disabled.' />'.(' 'x2).
678: &mt('Height').': <input type="text" size="4" id="'.$toolattr{'dimenheight'}.'" name="exttoolheight" value="'.$height.'"'.$disabled.' /></span>'."\n".
679: '</div></div>';
680: $toolelem .= '<div id="'.$toolattr{'windiv'}.'" style="'.$windivstyle.'">'.
681: '<div id="'.$toolattr{'linktextdiv'}.'" class="LC_left_float" style="'.$linktextstyle.'">'.
682: '<span class="'.$class.'">'.&mt('Link Text').'</span><br /><input type="text" size="25" id="'.$toolattr{'linktext'}.
683: '" name="exttoollinktext" value="'.$linktext.'"'.$disabled.' />'.
684: '</div><div id="'.$toolattr{'explanationdiv'}.'" class="LC_left_float" style="'.$explanationstyle.'">'.
685: '<span class="'.$class.'">'.&mt('Explanation').'</span><br />'.
686: '<textarea rows="'.$rows.'" cols="'.$cols.'" id="'.$toolattr{'explanation'}.'" name="exttoolexplanation" '.$disabled.'>'.
687: $explanation.'</textarea></div><div style="padding:0;clear:both;margin:0;border:0"></div>'.
688: '</div>';
689: $toolelem .= '<div id="'.$toolattr{'crslabeldiv'}.'" style="'.$labelstyle.'">'.
690: '<span class="'.$class.'">'.&mt('Course label:').' '.
691: '<input type="text" id="'.$toolattr{'crslabel'}.'" name="exttoollabel" value="'.$crslabel.'"'.$disabled.' /></span><br />'.
692: '</div>'.
693: '<div id="'.$toolattr{'crstitlediv'}.'" style="'.$titlestyle.'">'.
694: '<span class="'.$class.'">'.&mt('Course title:').' '.
695: '<input type="text" id="'.$toolattr{'crstitle'}.'" name="exttooltitle" value="'.$crstitle.'"'.$disabled.' /></span><br />'.
696: '</div>'.
697: '<div id="'.$toolattr{'crsappenddiv'}.'" style="'.$appendstyle.'">'.
698: '<span class="'.$class.'">'.&mt('Append to URL[_1]',
699: '<span id="'.$toolattr{'providerurl'}.'"> ('.$providerurl.')<br /></span>').
700: '<input type="text" id="'.$toolattr{'crsappend'}.'" size="30" name="exttoolappend" value="'.$crsappend.'"'.$disabled.' /></span><br />'.
1.8.2.4.4.2! raeburn 701: '</div>'.
! 702: '<div id="'.$toolattr{'gradablediv'}.'" style="'.$gradablestyle.'">'.
! 703: '<span class="'.$class.'">'.&mt('Gradable').' '.
! 704: '<label><input type="radio" name="exttoolgradable" value="1"'.$chkgrd.$disabled.
! 705: ' />'.&mt('Yes').'</label>'.(' 'x2).
! 706: '<label><input type="radio" name="exttoolgradable" value="0"'.$chknogrd.$disabled.
! 707: ' />'.&mt('No').'</label></span></div>';
1.8.2.4.4.1 raeburn 708: }
709: my $chooser = $toolelem;
710: if ($type eq 'ext') {
711: $chooser = "
712: <div>
713: <span$srcclass>
714: $extsrc
715: $urlelem
716: $preview
717: </span>
718: </div>
719: ";
720: }
1.3 raeburn 721: $form = <<ENDFORM;
1.8.2.4.4.1 raeburn 722: <form action="$action" method="post" name="$formname" id="$formid">
1.2 raeburn 723: <fieldset id="$fieldsetid" style="$fieldsetstyle">
1.1 raeburn 724: $legend
725: $active
1.8.2.4.4.1 raeburn 726: $chooser
1.8.2.4.4.2! raeburn 727: <div id="$subdivid" style="$subdivstyle">
1.1 raeburn 728: <span$srcclass>
729: $title
1.8.2.1 raeburn 730: <input type="text" size="$size" name="exttitle" value="$orig_title" $disabled />
1.1 raeburn 731: <input type="hidden" name="importdetail" value="" />
732: $pathitem
733: $hiddenelem
1.8.2.4.4.1 raeburn 734: <input type="button" value="$save" onclick="javascript:setExternal(this.form,'$residx','$type','$orig_url','$supplementalflag');" $disabled />
1.1 raeburn 735: </span>
1.8.2.4.4.1 raeburn 736: </div>
1.1 raeburn 737: </fieldset>
738: </form>
739: ENDFORM
1.3 raeburn 740: if (wantarray) {
741: return ($link,$form);
742: } else {
743: return $link.$form;
744: }
1.1 raeburn 745: }
746:
1.8.2.4.4.2! raeburn 747: sub ordered_tooloptions {
! 748: my ($toolsref) = @_;
! 749: my ($seloptions,@ids,@titles);
! 750: if (ref($toolsref) eq 'HASH') {
! 751: my %bynum;
! 752: foreach my $id (keys(%{$toolsref})) {
! 753: if (ref($toolsref->{$id}) eq 'HASH') {
! 754: my $order = $toolsref->{$id}->{'order'};
! 755: $bynum{$order} = [$id,$toolsref->{$id}];
! 756: }
! 757: }
! 758: foreach my $item (sort { $a <=> $b } keys(%bynum)) {
! 759: if (ref($bynum{$item}) eq 'ARRAY') {
! 760: if (ref($bynum{$item}->[1]) eq 'HASH') {
! 761: my $tooltitle = $bynum{$item}->[1]->{'title'};
! 762: push(@titles,$tooltitle);
! 763: push(@ids,$bynum{$item}->[0]);
! 764: $seloptions .= '<option value="'.$bynum{$item}->[0].'">'.$tooltitle.'</option>'."\n";
! 765: }
! 766: }
! 767: }
! 768: }
! 769: if (wantarray) {
! 770: return (\@ids,\@titles);
! 771: } else {
! 772: return $seloptions;
! 773: }
! 774: }
! 775:
1.1 raeburn 776: sub display_editor {
1.8.2.3 raeburn 777: my ($url,$folderpath,$symb,$idx,$type,$cdom,$cnum,$hostname) = @_;
1.8.2.1 raeburn 778: my ($residx,$supplementalflag,$title,$pathitem,$output,$js,$navmap);
1.1 raeburn 779: if ($folderpath =~ /^supplemental/) {
780: $supplementalflag = 1;
781: $residx = $idx;
782: $title = &unescape($env{'form.title'});
783: $pathitem = '<input type="hidden" name="folderpath" value="'.&HTML::Entities::encode($folderpath,'<>&"').'" />';
784: } elsif ($symb =~ /^uploaded/) {
785: (my $map,$residx,my $res) =
786: &Apache::lonnet::decode_symb($symb);
787: $title = &Apache::lonnet::gettitle($symb);
1.8.2.1 raeburn 788: my $path = &Apache::loncommon::symb_to_docspath($symb,\$navmap);
1.4 raeburn 789: $pathitem = '<input type="hidden" name="folderpath" value="'.&HTML::Entities::encode($path,'<>&"').'" />';
1.1 raeburn 790: }
1.8.2.4.4.2! raeburn 791: my (%ltitools,%tooltypes);
1.8.2.4.4.1 raeburn 792: if ($type eq 'tool') {
1.8.2.4.4.2! raeburn 793: my (%domtools,%crstools);
! 794: %tooltypes = &Apache::loncommon::usable_exttools();
! 795: if ($tooltypes{'dom'}) {
! 796: %domtools = &Apache::lonnet::get_domain_lti($cdom,'consumer');
! 797: }
! 798: if ($tooltypes{'crs'}) {
! 799: %crstools = &Apache::lonnet::get_course_lti($cnum,$cdom,'consumer');
! 800: }
! 801: %ltitools = (
! 802: dom => \%domtools,
! 803: crs => \%crstools,
! 804: );
1.8.2.4.4.1 raeburn 805: }
1.8.2.1 raeburn 806: $js = &Apache::lonhtmlcommon::scripttag(&extedit_javascript());
1.1 raeburn 807: my $args = { 'force_register' => $env{'form.register'} };
1.8.2.3 raeburn 808: if ($hostname) {
809: $args->{'hostname'} = $hostname;
810: }
1.8.2.4.4.1 raeburn 811: my $description = 'External Resource Editor';
812: if ($type eq 'tool') {
813: $description = 'External Tool Editor';
814: }
815: return &Apache::loncommon::start_page($description,$js,$args).
1.1 raeburn 816: '<div class="LC_left_float">'.
1.8.2.4.4.1 raeburn 817: &extedit_form($supplementalflag,$residx,$url,$title,$pathitem,undef,'direct',
818: $symb,$type,$cdom,$cnum,\%ltitools).
1.1 raeburn 819: '</div>'.
820: &Apache::loncommon::end_page();
821: }
822:
823: sub extedit_javascript {
1.8.2.4.4.1 raeburn 824: my ($toolsref) = @_;
1.8.2.4.4.2! raeburn 825: my ($toolsjs,$exttoolnums,$exttooloptions);
1.8.2.4.4.1 raeburn 826: if (ref($toolsref) eq 'HASH') {
1.8.2.4.4.2! raeburn 827: $toolsjs = " var ltitools = new Array();\n".
! 828: " var ltitoolsUrl = new Array();\n".
! 829: " var ltitoolsTarget = new Array();\n".
! 830: " var ltitoolsWidth = new Array();\n".
! 831: " var ltitoolsHeight = new Array();\n".
! 832: " var ltitoolsLinkDef = new Array();\n".
! 833: " var ltitoolsExplainDef = new Array();\n".
! 834: " var ltitoolsDisplay = new Array();\n".
! 835: " var ltitoolsLink = new Array();\n".
! 836: " var ltitoolsExplain = new Array();\n".
! 837: " var ltitoolsLabel = new Array();\n".
! 838: " var ltitoolsTitle = new Array();\n".
! 839: " var ltitoolsAppend = new Array();\n";
! 840: $exttoolnums = " var ltitoolsnum = new Array();\n".
! 841: " var tooloptval = new Array();\n".
! 842: " var toolopttxt = new Array();\n";
! 843: my $idx = 0;
! 844: foreach my $type ('crs','dom') {
! 845: if (ref($toolsref->{$type}) eq 'HASH') {
! 846: my $num = scalar(keys(%{$toolsref->{$type}}));
! 847: $toolsjs .= " ltitools[$idx] = new Array($num);\n".
! 848: " ltitoolsUrl[$idx] = new Array($num);\n".
! 849: " ltitoolsTarget[$idx] = new Array($num);\n".
! 850: " ltitoolsWidth[$idx] = new Array($num);\n".
! 851: " ltitoolsHeight[$idx] = new Array($num);\n".
! 852: " ltitoolsLinkDef[$idx] = new Array($num);\n".
! 853: " ltitoolsExplainDef[$idx] = new Array($num);\n".
! 854: " ltitoolsDisplay[$idx] = new Array($num);\n".
! 855: " ltitoolsLink[$idx] = new Array($num);\n".
! 856: " ltitoolsExplain[$idx] = new Array($num);\n".
! 857: " ltitoolsLabel[$idx] = new Array($num);\n".
! 858: " ltitoolsTitle[$idx] = new Array($num);\n".
! 859: " ltitoolsAppend[$idx] = new Array($num);\n";
! 860: my $i=0;
! 861: foreach my $key (sort { $a <=> $b } keys(%{$toolsref->{$type}})) {
! 862: if (ref($toolsref->{$type}->{$key}) eq 'HASH') {
! 863: if (ref($toolsref->{$type}->{$key}->{'display'}) eq 'HASH') {
! 864: my $target = $toolsref->{$type}->{$key}->{'display'}->{'target'};
! 865: my $width = $toolsref->{$type}->{$key}->{'display'}->{'width'};
! 866: my $height = $toolsref->{$type}->{$key}->{'display'}->{'height'};
! 867: my $linkdef = $toolsref->{$type}->{$key}->{'display'}->{'linktext'};
! 868: my $explaindef = $toolsref->{$type}->{$key}->{'display'}->{'explanation'};
! 869: my $providerurl;
! 870: if ($toolsref->{$type}->{$key}->{'url'} =~ m{://}) {
! 871: (my $prot,my $host,$providerurl) =
! 872: ($toolsref->{$type}->{$key}->{'url'} =~ m{^([^/]+)://([^/]+)(|/.+)$});
! 873: } else {
! 874: $providerurl = $toolsref->{$type}->{$key}->{'url'};
! 875: }
! 876: $providerurl = &LONCAPA::map::qtunescape($providerurl);
! 877: $toolsjs .= " ltitools[$idx][$i] = '$key';\n".
! 878: " ltitoolsTarget[$idx][$i] = '$target';\n".
! 879: " ltitoolsWidth[$idx][$i] = '$width';\n".
! 880: " ltitoolsHeight[$idx][$i] = '$height';\n".
! 881: " ltitoolsLinkDef[$idx][$i] = '$linkdef';\n".
! 882: " ltitoolsExplainDef[$idx][$i] = '$explaindef';\n".
! 883: " ltitoolsUrl[$idx][$i] = '$providerurl';\n";
! 884: }
! 885: if (ref($toolsref->{$type}->{$key}->{'crsconf'}) eq 'HASH') {
! 886: my $display = $toolsref->{$type}->{$key}->{'crsconf'}->{'target'};
! 887: $toolsjs .= " ltitoolsDisplay[$idx][$i] = '$display';\n";
! 888: my $linktext = $toolsref->{$type}->{$key}->{'crsconf'}->{'linktext'};
! 889: $toolsjs .= " ltitoolsLink[$idx][$i] = '$linktext';\n";
! 890: my $explanation = $toolsref->{$type}->{$key}->{'crsconf'}->{'explanation'};
! 891: $toolsjs .= " ltitoolsExplain[$idx][$i] = '$explanation';\n";
! 892: my $label = $toolsref->{$type}->{$key}->{'crsconf'}->{'label'};
! 893: $toolsjs .= " ltitoolsLabel[$idx][$i] = '$label';\n";
! 894: my $title = $toolsref->{$type}->{$key}->{'crsconf'}->{'title'};
! 895: $toolsjs .= " ltitoolsTitle[$idx][$i] = '$title';\n";
! 896: my $append = $toolsref->{$type}->{$key}->{'crsconf'}->{'append'};
! 897: $toolsjs .= " ltitoolsAppend[$idx][$i] = '$append';\n";
! 898: }
! 899: }
! 900: $i++;
! 901: }
! 902: my $firstoption = '<option value="" selected="selected">'.&mt('Select').'</option>';
! 903: my ($idsref,$titlesref) = &ordered_tooloptions($toolsref->{$type});
! 904: if ((ref($idsref) eq 'ARRAY') && (ref($titlesref) eq 'ARRAY')) {
! 905: my $count = scalar(@{$idsref});
! 906: $exttooloptions .= " tooloptval[$idx] = new Array($count);\n".
! 907: " toolopttxt[$idx] = new Array($count);\n";
! 908: for (my $n=0; $n<@{$idsref}; $n++) {
! 909: my $id = $idsref->[$n];
! 910: my $text = $titlesref->[$n];
! 911: $exttooloptions .= " tooloptval[$idx][$n] = '$id';\n".
! 912: " toolopttxt[$idx][$n] = '$text';\n";
1.8.2.4.4.1 raeburn 913: }
914: }
1.8.2.4.4.2! raeburn 915: $exttoolnums .= " ltitoolsnum[$idx] = $i;\n";
1.8.2.4.4.1 raeburn 916: }
1.8.2.4.4.2! raeburn 917: $idx ++;
1.8.2.4.4.1 raeburn 918: }
919: }
1.8 damieng 920: my %js_lt = &Apache::lonlocal::texthash(
1.1 raeburn 921: invurl => 'Invalid URL',
922: titbl => 'Title is blank',
1.8.2.4.4.2! raeburn 923: invtool => 'Please select an external tool',
1.8.2.4 raeburn 924: mixfra => 'Show preview in pop-up? (http in https page + no framing)',
925: mixonly => 'Show preview in pop-up? (http in https page)',
926: fraonly => 'Show preview in pop-up? (framing disallowed)',
927: nopopup => 'Pop-up blocked',
928: nopriv => 'Insufficient privileges to use preview',
929: badurl => 'URL is not: http://hostname/path or https://hostname/path',
1.8.2.4.4.2! raeburn 930: sele => 'Select',
1.1 raeburn 931: );
1.8 damieng 932: &js_escape(\%js_lt);
1.1 raeburn 933:
934: my $urlregexp = <<'ENDREGEXP';
935: /^([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
936: ENDREGEXP
937:
938: return <<ENDJS;
939:
940: var regexp = $urlregexp;
941:
1.8.2.4.4.1 raeburn 942: function setExternal(extform,residx,type,exttoolurl,supplementalflag) {
1.1 raeburn 943: var title=extform.exttitle.value;
944: if (!String.trim) {
945: String.prototype.trim = function() {return this.replace(\/^\\s+|\\s+$\/g, "");}; }
946: if (title == null || title.trim()=="") {
1.8 damieng 947: alert("$js_lt{'titbl'}");
1.1 raeburn 948: extform.exttitle.focus();
949: return;
950: }
1.8.2.4.4.1 raeburn 951: if (type == 'ext') {
952: var url=extform.exturl.value;
953: if (!regexp.test(url)) {
954: alert("$js_lt{'invurl'}");
955: extform.exturl.focus();
956: return;
957: } else {
958: url = escape(url);
959: title = escape(title);
960: if (residx > 0) {
961: eval("extform.importdetail.value=title+'='+url+'='+residx;extform.submit();");
962: } else {
963: eval("extform.importdetail.value=title+'='+url;extform.submit();");
964: }
965: }
966: } else {
1.7 raeburn 967: title = escape(title);
1.8.2.4.4.1 raeburn 968: var info = exttoolurl;
1.8.2.4.4.2! raeburn 969: var prefix = '';
! 970: if (supplementalflag == 1) {
! 971: prefix = 'supp';
! 972: }
1.8.2.4.4.1 raeburn 973: if (residx == 0) {
974: var toolid = parseInt(extform.exttoolid.options[extform.exttoolid.selectedIndex].value);
975: if (isNaN(toolid)) {
976: alert("$js_lt{'invtool'}");
977: return;
978: }
1.8.2.4.4.2! raeburn 979: var typeelem = extform.elements[prefix+'exttooltype'];
! 980: if (typeelem.length) {
! 981: for (var i=0; i<typeelem.length; i++) {
! 982: if (typeelem[i].checked) {
! 983: tooltype = typeelem[i].value;
! 984: }
! 985: }
! 986: }
! 987: if (tooltype == 'crs') {
! 988: info += ':c'+toolid;
! 989: } else {
! 990: info += ':'+toolid;
! 991: }
1.8.2.4.4.1 raeburn 992: }
993: var dispdiv = prefix+'tooldispdiv';
994: var windiv = prefix+'toolwindiv';
1.1 raeburn 995: if (residx > 0) {
1.8.2.4.4.1 raeburn 996: dispdiv += '_'+residx;
997: windiv += '_'+residx;
998: }
999: if (document.getElementById(dispdiv)) {
1000: if (document.getElementById(dispdiv).style.display == 'block') {
1001: if (extform.exttooltarget.length) {
1002: for (var i=0; i<extform.exttooltarget.length; i++) {
1003: if (extform.exttooltarget[i].checked) {
1004: if (extform.exttooltarget[i].value == 'window') {
1005: var width = extform.exttoolwidth.value;
1006: width.trim();
1007: var height = extform.exttoolheight.value;
1008: height.trim();
1009: info += ':window:'+width+':'+height;
1010: } else if (extform.exttooltarget[i].value == 'tab') {
1011: info += ':tab::';
1012: } else {
1013: info += ':iframe::';
1014: }
1015: }
1016: }
1017: }
1018: } else {
1019: info += ':::';
1020: }
1.1 raeburn 1021: } else {
1.8.2.4.4.1 raeburn 1022: info += ':::';
1023: }
1024: if (document.getElementById(windiv)) {
1025: if (document.getElementById(windiv).style.display == 'block') {
1026: var linktextdiv = prefix+'toollinktextdiv';
1027: var explanationdiv = prefix+'toolexplanationdiv';
1028: if (residx > 0) {
1029: linktextdiv += '_'+residx;
1030: explanationdiv += '_'+residx;
1031: }
1032: if (document.getElementById(linktextdiv).style.display == 'inline') {
1033: var linktext = extform.exttoollinktext.value;
1034: linktext.trim();
1035: info += ':'+escape(linktext);
1036: } else {
1037: info += ':';
1038: }
1039: if (document.getElementById(explanationdiv).style.display == 'inline') {
1040: var explaintext = extform.exttoolexplanation.value;
1041: explaintext.trim();
1042: info += ':'+escape(explaintext);
1043: } else {
1044: info += ':';
1045: }
1046: } else {
1047: info += '::';
1048: }
1049: } else {
1050: info += '::';
1051: }
1052: var labelinput = prefix+'toolcrslabel';
1053: var titleinput = prefix+'toolcrstitle';
1054: var appendinput = prefix+'toolcrsappend';
1055: if (residx > 0) {
1056: labelinput += '_'+residx;
1057: titleinput += '_'+residx;
1058: appendinput += '_'+residx;
1059: }
1060: if (document.getElementById(labelinput)) {
1061: var crslabel = document.getElementById(labelinput).value;
1062: crslabel.trim();
1063: info += ':'+escape(crslabel);
1064: } else {
1065: info += ':';
1066: }
1067: if (document.getElementById(titleinput)) {
1068: var crstitle = document.getElementById(titleinput).value;
1069: crstitle.trim();
1070: info += ':'+escape(crstitle);
1071: } else {
1072: info += ':';
1073: }
1074: if (document.getElementById(appendinput)) {
1075: var crsappend = document.getElementById(appendinput).value;
1076: crsappend.trim();
1077: info += ':'+escape(crsappend);
1078: } else {
1079: info += ':';
1080: }
1.8.2.4.4.2! raeburn 1081: var gradablediv = prefix+'toolgradablediv';
! 1082: if (residx > 0) {
! 1083: gradablediv += '_'+residx;
! 1084: }
! 1085: if (document.getElementById(gradablediv)) {
! 1086: if (document.getElementById(gradablediv).style.display == 'inline') {
! 1087: if (extform.exttoolgradable.length) {
! 1088: for (var i=0; i<extform.exttoolgradable.length; i++) {
! 1089: if (extform.exttoolgradable[i].checked) {
! 1090: if (extform.exttoolgradable[i].value == '1') {
! 1091: info += ':1';
! 1092: } else {
! 1093: info += ':';
! 1094: }
! 1095: break;
! 1096: }
! 1097: }
! 1098: } else {
! 1099: info += ':';
! 1100: }
! 1101: } else {
! 1102: info += ':';
! 1103: }
! 1104: } else {
! 1105: info += ':';
! 1106: }
1.8.2.4.4.1 raeburn 1107: info=escape(info);
1108: if (residx > 0) {
1109: eval("extform.importdetail.value=title+'='+info+'='+residx;extform.submit();");
1110: } else {
1111: eval("extform.importdetail.value=title+'='+info;extform.submit();");
1.1 raeburn 1112: }
1113: }
1114: }
1115:
1.8.2.4.4.1 raeburn 1116: function editext(residx,type) {
1117: if (document.getElementById('upload'+type+residx)) {
1118: var curr = document.getElementById('upload'+type+residx).style.display;
1.1 raeburn 1119: if (curr == 'none') {
1120: disp = 'block';
1121: } else {
1122: disp = 'none';
1123: }
1.8.2.4.4.1 raeburn 1124: document.getElementById('upload'+type+residx).style.display=disp;
1.1 raeburn 1125: }
1126: resize_scrollbox('contentscroll','1','1');
1127: return;
1128: }
1129:
1.8.2.2 raeburn 1130: function extUrlPreview(caller,protocol) {
1.1 raeburn 1131: if (document.getElementById(caller)) {
1132: var url = document.getElementById(caller).value;
1133: if (regexp.test(url)) {
1.8.2.2 raeburn 1134: var http_regex = /^http\:\/\//gi;
1.8.2.4 raeburn 1135: var mixed = 0;
1136: var noiframe = 0;
1137: var nopriv = 0;
1138: var badurl = 0;
1139: var name = "externalpreview";
1.8.2.2 raeburn 1140: if ((protocol == 'https') && (http_regex.test(url))) {
1.8.2.4 raeburn 1141: mixed = 1;
1.8.2.2 raeburn 1142: }
1.8.2.4 raeburn 1143: var http = new XMLHttpRequest();
1144: var lcurl = "/adm/exturlcheck";
1145: var params = "exturl="+url;
1146: http.open("POST",lcurl, true);
1147: http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
1148: http.onreadystatechange = function() {
1149: if (http.readyState == 4) {
1150: if (http.status == 200) {
1151: if (http.responseText.length > 0) {
1152: if (http.responseText == 1) {
1153: noiframe = 1;
1154: } else if (http.responseText == -1) {
1155: nopriv = 1;
1156: } else if (http.responseText == 0) {
1157: badurl = 1;
1158: }
1159: }
1160: openPreviewWindow(url,name,noiframe,mixed,nopriv,badurl);
1161: }
1162: }
1163: }
1164: http.send(params);
1.1 raeburn 1165: } else {
1.8 damieng 1166: alert("$js_lt{'invurl'}");
1.1 raeburn 1167: }
1168: }
1169: }
1170:
1.8.2.4 raeburn 1171: var previewLCWindow = null;
1172: function openPreviewWindow(url,name,noiframe,mixed,nopriv,badurl) {
1173: if (previewLCWindow !=null) {
1174: previewLCWindow.close();
1175: }
1176: if (badurl) {
1177: alert("$js_lt{'badurl'}");
1178: } else if (nopriv) {
1179: alert("$js_lt{'nopriv'}");
1180: } else if ((noiframe == 1) || (mixed == 1)) {
1181: var encurl = encodeURI(url);
1182: var msg;
1183: if (mixed == 1) {
1184: if (noiframe == 1) {
1185: msg = "$js_lt{'mixfra'}";
1186: } else {
1187: msg = "$js_lt{'mixonly'}";
1188: }
1189: } else {
1190: msg = "$js_lt{'fraonly'}";
1191: }
1192: if (confirm(msg)) {
1193: previewLCWindow = window.open(url,name,"height=400,width=500,scrollbars=1,resizable=1,menubar=0,location=1");
1194: if (previewLCWindow != null) {
1195: previewLCWindow.focus();
1196: } else {
1197: alert("$js_lt{'nopopup'}");
1198: }
1199: }
1200: } else {
1201: openMyModal(url,500,400,'yes');
1202: }
1203: }
1204:
1.8.2.4.4.2! raeburn 1205: function updateExttoolSel(form,radioname,supplementalflag) {
! 1206: var prefix = '';
! 1207: var typepick;
! 1208: var radelem = form.elements[radioname];
! 1209: if (radelem.length) {
! 1210: for (var i=0; i<radelem.length; i++) {
! 1211: if (radelem[i].checked) {
! 1212: if (radelem[i].value == 'crs') {
! 1213: typepick = 0;
! 1214: } else if (radelem[i].value == 'dom') {
! 1215: typepick = 1;
! 1216: }
! 1217: break;
! 1218: }
! 1219: }
! 1220: }
! 1221: if (supplementalflag == 1) {
! 1222: prefix = 'supp';
! 1223: }
! 1224: $exttoolnums
! 1225: $exttooloptions
! 1226: if ((typepick == 0) || (typepick == 1)) {
! 1227: var selelem = form.elements['exttoolid'];
! 1228: var i, numopts = selelem.options.length -1;
! 1229: if (numopts >=0) {
! 1230: for (i = numopts; i >= 0; i--) {
! 1231: selelem.remove(i);
! 1232: }
! 1233: }
! 1234: if (ltitoolsnum[typepick]) {
! 1235: if ((Array.isArray(tooloptval[typepick])) && (Array.isArray(toolopttxt[typepick]))) {
! 1236: var len = tooloptval[typepick].length;
! 1237: if (len) {
! 1238: selelem.options[selelem.options.length] = new Option('$js_lt{sele}','',1,1);
! 1239: var j;
! 1240: for (j=0; j<len; j++) {
! 1241: selelem.options[selelem.options.length] = new Option(toolopttxt[typepick][j],tooloptval[typepick][j]);
! 1242: }
! 1243: selelem.selectedIndex = 0;
! 1244: }
! 1245: }
! 1246: if (document.getElementById('LC_exttoolon'+prefix)) {
! 1247: document.getElementById('LC_exttoolon'+prefix).style.display = 'block';
! 1248: }
! 1249: if (document.getElementById('LC_exttooloff'+prefix)) {
! 1250: document.getElementById('LC_exttooloff'+prefix).style.display = 'none';
! 1251: }
! 1252: if (document.getElementById('LC_addtool'+prefix)) {
! 1253: document.getElementById('LC_addtool'+prefix).style.display = 'block';
! 1254: }
! 1255: } else {
! 1256: if (document.getElementById('LC_exttoolon'+prefix)) {
! 1257: document.getElementById('LC_exttoolon'+prefix).style.display = 'none';
! 1258: }
! 1259: if (document.getElementById('LC_exttooloff'+prefix)) {
! 1260: document.getElementById('LC_exttooloff'+prefix).style.display = 'block';
! 1261: }
! 1262: if (document.getElementById('LC_addtool'+prefix)) {
! 1263: document.getElementById('LC_addtool'+prefix).style.display = 'none';
! 1264: }
! 1265: }
! 1266: if (selelem.options.length == 0) {
! 1267: selelem.options[selelem.options.length] = new Option('','');
! 1268: selelem.selectedIndex = 0;
! 1269: }
! 1270: updateExttool(selelem,form,supplementalflag);
! 1271: resize_scrollbox('contentscroll','1','1');
! 1272: }
! 1273: return;
! 1274: }
! 1275:
1.8.2.4.4.1 raeburn 1276: function updateExttool(caller,form,supplementalflag) {
1277: var prefix = '';
1278: if (supplementalflag == 1) {
1279: prefix = 'supp';
1280: }
1281: dispdiv = prefix+'tooldispdiv';
1282: dimendiv = prefix+'tooldimendiv';
1283: widthinput = prefix+'tooldimenwidth';
1284: heightinput = prefix+'tooldimenheight';
1285: labeldiv = prefix+'toolcrslabeldiv';
1286: titlediv = prefix+'toolcrstitlediv';
1287: appenddiv = prefix+'toolcrsappenddiv';
1.8.2.4.4.2! raeburn 1288: gradablediv = prefix+'toolgradablediv';
1.8.2.4.4.1 raeburn 1289: providerurl = prefix+'toolproviderurl';
1290: labelinput = prefix+'toolcrslabel';
1291: titleinput = prefix+'toolcrstitle';
1292: appendinput = prefix+'toolcrsappend';
1293: windiv = prefix+'toolwindiv';
1294: linktextdiv = prefix+'toollinktextdiv';
1295: linktextinput = prefix+'toollinktext';
1296: explanationdiv = prefix+'toolexplanationdiv';
1297: explanationinput = prefix+'toolexplanation';
1298: if (document.getElementById(dispdiv)) {
1299: var toolpick = caller.options[caller.selectedIndex].value;
1300: $toolsjs
1301: if (toolpick == '') {
1302: if (document.getElementById(dispdiv)) {
1303: document.getElementById(dispdiv).style.display = 'none';
1304: }
1305: if (document.getElementById(dimendiv)) {
1306: document.getElementById(dimendiv).style.display = 'none';
1307: }
1308: if (document.getElementById(windiv)) {
1309: document.getElementById(windiv).style.display = 'none';
1310: }
1311: if (document.getElementById(linktextdiv)) {
1312: document.getElementById(linktextdiv).style.display = 'none';
1313: }
1314: if (document.getElementById(explanationdiv)) {
1315: document.getElementById(explanationdiv).style.display = 'none';
1316: }
1317: if (document.getElementById(labeldiv)) {
1318: document.getElementById(labeldiv).style.display = 'none';
1319: }
1320: if (document.getElementById(titlediv)) {
1321: document.getElementById(titlediv).style.display = 'none';
1322: }
1323: if (document.getElementById(appenddiv)) {
1324: document.getElementById(appenddiv).style.display = 'none';
1325: }
1.8.2.4.4.2! raeburn 1326: if (document.getElementById(gradablediv)) {
! 1327: document.getElementById(gradablediv).style.display = 'none';
! 1328: }
1.8.2.4.4.1 raeburn 1329: } else {
1.8.2.4.4.2! raeburn 1330: var tooltype = '';
! 1331: var typeelem = form.elements[prefix+'exttooltype'];
! 1332: if (typeelem.length) {
! 1333: for (var i=0; i<typeelem.length; i++) {
! 1334: if (typeelem[i].checked) {
! 1335: tooltype = typeelem[i].value;
! 1336: }
! 1337: }
! 1338: }
! 1339: if ((tooltype == 'crs') || (tooltype == 'dom')) {
! 1340: var i = 0;
! 1341: if (tooltype == 'dom') {
! 1342: i = 1;
! 1343: }
! 1344: if (ltitools[i].length > 0) {
! 1345: for (var j=0; j<ltitools[i].length; j++) {
! 1346: if (ltitools[i][j] == toolpick) {
! 1347: if (document.getElementById(dispdiv)) {
! 1348: if (ltitoolsDisplay[i][j]) {
! 1349: document.getElementById(dispdiv).style.display = 'block';
! 1350: if (form.exttooltarget.length) {
! 1351: for (var k=0; k<form.exttooltarget.length; k++) {
! 1352: if (form.exttooltarget[k].value == ltitoolsTarget[i][j]) {
! 1353: form.exttooltarget[k].checked = true;
! 1354: break;
! 1355: }
1.8.2.4.4.1 raeburn 1356: }
1357: }
1358: }
1.8.2.4.4.2! raeburn 1359: var dimen = 'none';
! 1360: var dimenwidth = '';
! 1361: var dimenheight = '';
! 1362: if ((ltitoolsDisplay[i][j]) && (ltitoolsTarget[i][j] == 'window')) {
! 1363: dimen = 'block';
! 1364: dimenwidth = ltitoolsWidth[i][j];
! 1365: dimenheight = ltitoolsHeight[i][j];
! 1366: }
! 1367: if (document.getElementById(dimendiv)) {
! 1368: document.getElementById(dimendiv).style.display = dimen;
! 1369: }
! 1370: if (document.getElementById(widthinput)) {
! 1371: document.getElementById(widthinput).value = dimenwidth;
! 1372: }
! 1373: if (document.getElementById(heightinput)) {
! 1374: document.getElementById(heightinput).value = dimenheight;
1.8.2.4.4.1 raeburn 1375: }
1376: }
1.8.2.4.4.2! raeburn 1377: if (document.getElementById(windiv)) {
! 1378: if ((ltitoolsTarget[i][j] == 'window') || (ltitoolsTarget[i][j] == 'tab')) {
! 1379: document.getElementById(windiv).style.display = 'block';
1.8.2.4.4.1 raeburn 1380: } else {
1.8.2.4.4.2! raeburn 1381: document.getElementById(windiv).style.display = 'none';
! 1382: }
! 1383: if (document.getElementById(linktextdiv)) {
! 1384: if (ltitoolsLink[i][j]) {
! 1385: document.getElementById(linktextdiv).style.display = 'inline';
! 1386: } else {
! 1387: document.getElementById(linktextdiv).style.display = 'none';
! 1388: }
! 1389: }
! 1390: if (document.getElementById(linktextinput)) {
! 1391: if (ltitoolsLink[i][j]) {
! 1392: document.getElementById(linktextinput).value = ltitoolsLinkDef[i][j];
! 1393: } else {
! 1394: document.getElementById(linktextinput).value = '';
! 1395: }
! 1396: }
! 1397: if (document.getElementById(explanationdiv)) {
! 1398: if (ltitoolsExplain[i][j]) {
! 1399: document.getElementById(explanationdiv).style.display = 'inline';
! 1400: } else {
! 1401: document.getElementById(explanationdiv).style.display = 'none';
! 1402: }
! 1403: }
! 1404: if (document.getElementById(explanationinput)) {
! 1405: if (ltitoolsExplain[i][j]) {
! 1406: document.getElementById(explanationinput).value = ltitoolsExplainDef[i][j];
! 1407: } else {
! 1408: document.getElementById(explananationinput).value = '';
! 1409: }
1.8.2.4.4.1 raeburn 1410: }
1411: }
1.8.2.4.4.2! raeburn 1412: if (document.getElementById(labeldiv)) {
! 1413: if (ltitoolsLabel[i][j]) {
! 1414: document.getElementById(labeldiv).style.display = 'inline';
1.8.2.4.4.1 raeburn 1415: } else {
1.8.2.4.4.2! raeburn 1416: document.getElementById(labeldiv).style.display = 'none';
1.8.2.4.4.1 raeburn 1417: }
1418: }
1.8.2.4.4.2! raeburn 1419: if (document.getElementById(titlediv)) {
! 1420: if (ltitoolsTitle[i][j]) {
! 1421: document.getElementById(titlediv).style.display = 'inline';
1.8.2.4.4.1 raeburn 1422: } else {
1.8.2.4.4.2! raeburn 1423: document.getElementById(titlediv).style.display = 'none';
1.8.2.4.4.1 raeburn 1424: }
1425: }
1.8.2.4.4.2! raeburn 1426: if (document.getElementById(appenddiv)) {
! 1427: if (ltitoolsAppend[i][j]) {
! 1428: document.getElementById(appenddiv).style.display = 'inline';
! 1429: if (document.getElementById(providerurl)) {
! 1430: if ((ltitoolsUrl[i][j] != '') && (ltitoolsUrl[i][j] != null)) {
! 1431: document.getElementById(providerurl).innerHTML = ' ('+ltitoolsUrl[i][j]+')<br />';
! 1432: }
! 1433: }
! 1434: } else {
! 1435: document.getElementById(appenddiv).style.display = 'none';
! 1436: if (document.getElementById(providerurl)) {
! 1437: document.getElementById(providerurl).innerHTML = '';
1.8.2.4.4.1 raeburn 1438: }
1439: }
1.8.2.4.4.2! raeburn 1440: }
! 1441: if (document.getElementById(gradablediv)) {
! 1442: if (supplementalflag != 1) {
! 1443: document.getElementById(gradablediv).style.display = 'inline';
1.8.2.4.4.1 raeburn 1444: }
1445: }
1.8.2.4.4.2! raeburn 1446: break;
1.8.2.4.4.1 raeburn 1447: }
1448: }
1449: }
1450: }
1451: }
1452: }
1453: }
1454:
1455: function updateTooldim(form,dimendiv,windiv,widthinput,heightinput,linkinput,explaininput) {
1456: if (form.exttooltarget.length) {
1457: for (var i=0; i<form.exttooltarget.length; i++) {
1458: if (form.exttooltarget[i].checked) {
1459: var dimen = 'none';
1460: var linkconf = 'none';
1461: if (form.exttooltarget[i].value == 'window') {
1462: dimen = 'block';
1463: linkconf = 'block';
1464: } else {
1465: if (form.exttooltarget[i].value == 'tab') {
1466: linkconf = 'block';
1467: } else {
1468: if (document.getElementById(widthinput)) {
1469: document.getElementById(widthinput).value = '';
1470: }
1471: if (document.getElementById(heightinput)) {
1472: document.getElementById(heightinput).value = '';
1473: }
1474: if (document.getElementById(linkinput)) {
1475: document.getElementById(linkinput).value = '';
1476: }
1477: if (document.getElementById(explaininput)) {
1478: document.getElementById(explaininput).value = '';
1479: }
1480: }
1481: }
1482: if (document.getElementById(dimendiv)) {
1483: document.getElementById(dimendiv).style.display = dimen;
1484: }
1485: if (document.getElementById(windiv)) {
1486: document.getElementById(windiv).style.display = linkconf;
1487: }
1488: break;
1489: }
1490: }
1491: }
1492: }
1493:
1.1 raeburn 1494: ENDJS
1495:
1496: }
1497:
1498: 1;
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>