-
-
- $endpage
-ENDFRAME
+ if (($uselink) && ($title eq '')) {
+ if ($env{'form.symb'}) {
+ $title=&Apache::lonnet::gettitle($env{'form.symb'});
+ } else {
+ my $symb=&Apache::lonnet::symbread($r->uri);
+ if ($symb) {
+ $title=&Apache::lonnet::gettitle($symb);
+ }
+ }
+ }
+ if ($clientmobile || ($exttool eq 'window') || ($exttool eq 'tab') ||
+ ($is_ext eq 'tab') || ($is_ext eq 'window')) {
+ my $output = $startpage;
+ if ($is_pdf) {
+ $linktext = &mt('Link to PDF (for mobile devices)');
+ $output .= &create_link($url,$anchor,$title,$linktext);
+ } elsif (($exttool eq 'window') || ($exttool eq 'tab') ||
+ ($is_ext eq 'tab') || ($is_ext eq 'window')) {
+ my $preamble;
+ if ($linktext eq '') {
+ if ($exttool) {
+ $linktext = &mt('Launch External Tool');
+ } else {
+ $linktext = &mt('Link to External Resource');
+ }
+ }
+ if ($exttool) {
+ $url = &HTML::Entities::encode($url,'"<>&');
+ } else {
+ $url = &HTML::Entities::encode($url.$anchor,'&<>"');
+ }
+ if (($exttool eq 'tab') || ($is_ext eq 'tab')) {
+ my $target;
+ if ($exttool) {
+ $target = 'LCExternalToolTab';
+ } else {
+ if ($reuse) {
+ $target = 'LCExternalResTab';
+ } else {
+ $target = '_blank';
+ }
+ if ($title ne '') {
+ $preamble = ''.$title.'
';
+ }
+ }
+ $output .= '';
+ } else {
+ my ($target,$extlinkimg);
+ if ($exttool) {
+ $target = 'LCExternalToolPopUp';
+ } else {
+ $target = 'LCExternalResPopUp';
+ if ($title ne '') {
+ $preamble = ''.$title.'
';
+ }
+ $extlinkimg = '
';
+ unless ($reuse) {
+ my $resid;
+ if ($env{'request.course.id'}) {
+ unless ($env{'form.folderpath'} =~ /^supplemental/) {
+ my $symb=&Apache::lonnet::symbread($r->uri);
+ if ($symb) {
+ my $navmap = Apache::lonnavmaps::navmap->new();
+ if (ref($navmap)) {
+ my $res = $navmap->getBySymb($symb);
+ if (ref($res)) {
+ $resid = $res->id;
+ $resid =~ s/\./_/g;
+ }
+ }
+ }
+ }
+ }
+ if ($resid eq '') {
+ $resid = substr(Digest::MD5::md5_hex(Digest::MD5::md5_hex(time(). {}. rand(). $$)), 0, 8);
+ }
+ &js_escape(\$resid);
+ $target .= $resid;
+ }
+ }
+ $output .= <<"ENDLINK";
+
+
+ENDLINK
+ }
+ if ($exttool) {
+ if ($explanation ne '') {
+ $output .= ''.$explanation.'
';
+ }
+ if (&Apache::lonnet::EXT('resource.0.gradable')) {
+ $output .= &Apache::lonfeedback::list_discussion('tool','OPEN');
+ }
+ }
+ } else {
+ if ($uselink) {
+ $linktext = &mt('Link to resource');
+ $output .= &create_link($url,$anchor,$title,$linktext);
+ } else {
+ my $dest = &HTML::Entities::encode($url.$anchor,'&<>"');
+ $output .= ''."\n".
+ '\n".
+ "
\n";
+ }
+ }
+ $output .= $endpage;
+ return $output;
+ } elsif ($uselink) {
+ $linktext = &mt('Link to resource');
+ return $startpage.&create_link($url,$anchor,$title,$linktext).$endpage;
+ } else {
+ my $offset = 5;
+ &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['inhibitmenu']);
+ if ($env{'form.inhibitmenu'} eq 'yes') {
+ $offset = 0;
+ }
my $script = &Apache::lonhtmlcommon::scripttag(<