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

version 1.117, 2013/04/24 02:43:59 version 1.120, 2013/05/06 16:15:59
Line 143  sub handler { Line 143  sub handler {
         }          }
     }      }
   
       my $crstype = &Apache::loncommon::course_type();
   
 # ------------------------------ The buck stops here: internal syllabus display  # ------------------------------ The buck stops here: internal syllabus display
 # --------------------------------------------------------- The syllabus fields  # --------------------------------------------------------- The syllabus fields
     my %syllabusfields=&Apache::lonlocal::texthash(      my %syllabusfields=&Apache::lonlocal::texthash(
Line 292  ENDSCRIPT Line 294  ENDSCRIPT
                    text=>"Course syllabus"});                     text=>"Course syllabus"});
             $args->{'bread_crumbs'} = $brcrum;              $args->{'bread_crumbs'} = $brcrum;
         } elsif ($env{'form.folderpath'} =~ /^supplemental/) {          } elsif ($env{'form.folderpath'} =~ /^supplemental/) {
             my $crstype = &Apache::loncommon::course_type();  
             my $title = $env{'form.title'};              my $title = $env{'form.title'};
             if ($title eq '') {              if ($title eq '') {
                 $title = &mt('Syllabus');                  $title = &mt('Syllabus');
Line 522  ENDSCRIPT Line 523  ENDSCRIPT
         if ($target ne 'tex') {          if ($target ne 'tex') {
             my $protocol = $Apache::lonnet::protocol{$homeserver};              my $protocol = $Apache::lonnet::protocol{$homeserver};
             $protocol = 'http' if ($protocol ne 'https');              $protocol = 'http' if ($protocol ne 'https');
             $r->print('<div class="LC_info">'              my $link = $protocol.'://'.&Apache::lonnet::hostname($homeserver).$r->uri;
                      .'<p>'              $r->print('<div class="LC_left_float">'
                      .&mt('This syllabus can be publicly viewed at [_1]'                       .'<span class="LC_help_open_topic LC_info">'
                           ,'<tt>'.$protocol.'://'.&Apache::lonnet::hostname($homeserver).$r->uri.'</tt>')                       .'<span class="LC_info">'
                      .'&nbsp;'.&Apache::loncommon::help_open_topic('Syllabus_ExtLink')                       .&mt('Public link (no log-in): [_1]','<tt>'.$link.'</tt>')
                      .'</p>'                       .'&nbsp;</span>'.&Apache::loncommon::help_open_topic('Syllabus_ExtLink')
                      .'</div>');                       .'</span>'
                        .'</div><div style="padding:0;clear:both;margin:0;border:0"></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 645  ENDSCRIPT Line 647  ENDSCRIPT
             }              }
             &Apache::lontemplate::print_start_template($r,&mt('RSS Feeds and Blogs'),'LC_Box',              &Apache::lontemplate::print_start_template($r,&mt('RSS Feeds and Blogs'),'LC_Box',
                                                        'box_000_showrssfeeds',$display);                                                         'box_000_showrssfeeds',$display);
             $r->print(&Apache::lonrss::advertisefeeds($cnum,$cdom,$forceedit));              my ($numfeeds,$hiddenfeeds,$rsslinktext);
               my $feeds=&Apache::lonrss::advertisefeeds($cnum,$cdom,$forceedit,\$numfeeds,\$hiddenfeeds);
               if ($numfeeds) {
                   $r->print($feeds);
                   $rsslinktext = &mt('New RSS Feed or Blog');
               } else {
                   my $msg = '<br />'.
                             &mt("RSS Feeds and Blogs item is not included in a student's view of the syllabus.");
                   if ($hiddenfeeds) {
                       $r->print('<p class="LC_info">'.
                                 &mt('All feeds currently hidden').
                                 $msg.
                                 '</p>');
                   } else {
                       $r->print('<p class="LC_info">'.
                                 &mt('No current feeds').
                                 $msg.
                                 '</p>');
                   }
                   $rsslinktext = &mt('Manage Course RSS Feeds/Blogs');
                   if ($crstype eq 'Community') {
                       $rsslinktext = &mt('Manage Communiity RSS Feeds/Blogs');
                   }
               }
             my $editurl= &Apache::lonnet::absolute_url().'/adm/'.$cdom.'/'.$cnum.'/_rss.html';              my $editurl= &Apache::lonnet::absolute_url().'/adm/'.$cdom.'/'.$cnum.'/_rss.html';
             $r->print( '<a href="'.$editurl.'">'.&mt('New RSS Feed or Blog').'</a>');              $r->print( '<a href="'.$editurl.'">'.$rsslinktext.'</a>');
             &Apache::lontemplate::print_end_template($r);              &Apache::lontemplate::print_end_template($r);
         } else {          } else {
             unless ($syllabus{'000_showrssfeeds'} eq 'no') {              unless ($syllabus{'000_showrssfeeds'} eq 'no') {
                 if (&Apache::lonrss::advertisefeeds($cnum,$cdom) ne '') {                  my $feeds = &Apache::lonrss::advertisefeeds($cnum,$cdom,$forceedit);
                   if ($feeds ne '') {
                     &Apache::lontemplate::print_start_template($r,&mt('RSS Feeds and Blogs'),'LC_Box');                      &Apache::lontemplate::print_start_template($r,&mt('RSS Feeds and Blogs'),'LC_Box');
                     $r->print(&Apache::lonrss::advertisefeeds($cnum,$cdom,$forceedit));                      $r->print($feeds);
                     &Apache::lontemplate::print_end_template($r);                      &Apache::lontemplate::print_end_template($r);
                 }                  }
             }              }
Line 737  ENDSCRIPT Line 763  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 823  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 1013  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.120


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