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