Diff for /loncom/interface/lonsyllabus.pm between versions 1.117 and 1.118

version 1.117, 2013/04/24 02:43:59 version 1.118, 2013/05/03 21:57:13
Line 530  ENDSCRIPT Line 530  ENDSCRIPT
                      .'</p>'                       .'</p>'
                      .'</div>');                       .'</div>');
             my $lonhost = $r->dir_config('lonHostID');              my $lonhost = $r->dir_config('lonHostID');
             $r->print(&chooser($external,$uploaded,$lonhost,\%syllabusfields,\%syllabus));              $r->print(&chooser($external,$uploaded,$cdom,$cnum,$lonhost,\%syllabusfields,\%syllabus));
         }          }
     } else {      } else {
 #--------------------------------------------- Print last update unless editing  #--------------------------------------------- Print last update unless editing
Line 737  ENDSCRIPT Line 737  ENDSCRIPT
 }  }
   
 sub chooser {  sub chooser {
     my ($external,$uploaded,$lonhost,$fields,$values) = @_;      my ($external,$uploaded,$cdom,$cnum,$lonhost,$fields,$values) = @_;
     my %lt = &Apache::lonlocal::texthash(      my %lt = &Apache::lonlocal::texthash(
                  'type'          => 'Syllabus Type',                   'type'          => 'Syllabus Type',
                  'url'           => 'External URL',                   'url'           => 'External URL',
Line 797  sub chooser { Line 797  sub chooser {
         $protocol = 'http' if ($protocol ne 'https');          $protocol = 'http' if ($protocol ne 'https');
         my $absurl = $protocol.'://'.&Apache::lonnet::hostname($lonhost).$uploaded;          my $absurl = $protocol.'://'.&Apache::lonnet::hostname($lonhost).$uploaded;
         my ($filename) = ($uploaded =~ m{([^/]+)$});          my ($filename) = ($uploaded =~ m{([^/]+)$});
           my $file=&Apache::lonnet::filelocation("",$uploaded);
           my $depbutton;
           if ($file =~ /\.html?$/) {
               my $filecontents=&Apache::lonnet::getfile($file);
               unless ($filecontents eq -1) {
                   my $mm = new File::MMagic;
                   my $mimetype = $mm->checktype_contents($filecontents);
                   if ($mimetype eq 'text/html') {
                       my (%codebase,%allfiles);
                       my $parse_result = &Apache::lonnet::extract_embedded_items($uploaded,\%allfiles,
                                                                                  \%codebase,\$filecontents);
                       my $actionurl = "/public/$cdom/$cnum/syllabus";
                       my ($ignore,$num,$numpathchanges,$existing,$mapping) =
                           &Apache::loncommon::ask_for_embedded_content($actionurl,undef,\%allfiles,
                                                                        \%codebase,
                                                                        {'context' => 'rewrites',
                                                                         'ignore_remote_references' => 1,});
                       if (keys(%allfiles)) {
                           $depbutton = ('&nbsp;' x 3).
                                        &editfile_button().
                                        &editbutton_js($uploaded);
                       }
                   }
               }
           }
   
         $output .= '<span class="LC_nobreak">'.$lt{'curr'}.'&nbsp;'.          $output .= '<span class="LC_nobreak">'.$lt{'curr'}.'&nbsp;'.
                    '<input type="hidden" name="uploadedfile" value="'.&HTML::Entities::encode($absurl).'?inhibitmenu=yes" id="currfile" />'.                     '<input type="hidden" name="uploadedfile" value="'.&HTML::Entities::encode($absurl).'?inhibitmenu=yes" id="currfile" />'.
                    '<a href="javascript:extUrlPreview('."'currfile'".');">'.$filename.'</a></span><br /><br />'.$lt{'rep'};                     '<a href="javascript:extUrlPreview('."'currfile'".');">'.$filename.'</a></span>'.$depbutton.
                      '<br /><br />'.$lt{'rep'};
     } else {      } else {
         $output .= $lt{'upl'};          $output .= $lt{'upl'};
     }      }
Line 960  sub return_to_editor { Line 987  sub return_to_editor {
            '</a></p>';             '</a></p>';
 }  }
   
   sub editfile_button {
       my $buttontext=&mt('Edit');
       return <<"END";
                   <input type="button" value="$buttontext" onclick="javascript:gotoeditor();" />
   END
   }
   
   sub editbutton_js {
       my ($url) = @_;
       return <<ENDJS;
                   <script type="text/javascript">
                   // <![CDATA[
                     function gotoeditor() {
                         document.location.href = '$url?forceedit=1';
                     }
                   // ]]>
                   </script>
   ENDJS
   }
   
 1;  1;
 __END__  __END__

Removed from v.1.117  
changed lines
  Added in v.1.118


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>