Diff for /loncom/xml/lonxml.pm between versions 1.531.2.10 and 1.535

version 1.531.2.10, 2013/08/08 12:47:13 version 1.535, 2012/11/30 11:45:57
Line 228  sub xmlend { Line 228  sub xmlend {
     return $discussion;      return $discussion;
 }  }
   
 sub tokeninputfield {  
     my $defhost=$Apache::lonnet::perlvar{'lonHostID'};  
     $defhost=~tr/a-z/A-Z/;  
     return (<<ENDINPUTFIELD)  
 <script type="text/javascript">  
     function updatetoken() {  
         var comp=new Array;  
         var barcode=unescape(document.tokeninput.barcode.value);  
         comp=barcode.split('*');  
         if (typeof(comp[0])!="undefined") {  
             document.tokeninput.codeone.value=comp[0];  
         }  
         if (typeof(comp[1])!="undefined") {  
             document.tokeninput.codetwo.value=comp[1];  
         }  
         if (typeof(comp[2])!="undefined") {  
             comp[2]=comp[2].toUpperCase();  
             document.tokeninput.codethree.value=comp[2];  
         }  
         document.tokeninput.barcode.value='';  
     }  
 </script>  
 <form method="post" name="tokeninput" action="">  
 <table border="2" bgcolor="#FFFFBB">  
 <tr><th>DocID Checkin</th></tr>  
 <tr><td>  
 <table>  
 <tr>  
 <td>Scan in Barcode</td>  
 <td><input type="text" size="22" name="barcode"  
 onchange="updatetoken()"/></td>  
 </tr>  
 <tr><td><i>or</i> Type in DocID</td>  
 <td>  
 <input type="text" size="5" name="codeone" />  
 <b><font size="+2">*</font></b>  
 <input type="text" size="5" name="codetwo" />  
 <b><font size="+2">*</font></b>  
 <input type="text" size="10" name="codethree" value="$defhost"  
 onchange="this.value=this.value.toUpperCase()" />  
 </td></tr>  
 </table>  
 </td></tr>  
 <tr><td><input type="submit" value="Check in DocID" /></td></tr>  
 </table>  
 </form>  
 ENDINPUTFIELD  
 }  
   
 sub maketoken {  
     my ($symb,$tuname,$tudom,$tcrsid)=@_;  
     unless ($symb) {  
         $symb=&Apache::lonnet::symbread();  
     }  
     unless ($tuname) {  
         $tuname=$env{'user.name'};  
         $tudom=$env{'user.domain'};  
         $tcrsid=$env{'request.course.id'};  
     }  
     return &Apache::lonnet::checkout($symb,$tuname,$tudom,$tcrsid);  
 }  
   
 sub printtokenheader {  
     my ($target,$token,$tsymb,$tcrsid,$tudom,$tuname)=@_;  
     unless ($token) { return ''; }  
   
     my ($symb,$courseid,$domain,$name) = &Apache::lonnet::whichuser();  
     unless ($tsymb) {  
         $tsymb=$symb;  
     }  
     unless ($tuname) {  
         $tuname=$name;  
         $tudom=$domain;  
         $tcrsid=$courseid;  
     }  
   
     my $plainname=&Apache::loncommon::plainname($tuname,$tudom);  
   
     if ($target eq 'web') {  
         my %idhash=&Apache::lonnet::idrget($tudom,($tuname));  
         return  
  '<img align="right" src="/cgi-bin/barcode.png?encode='.$token.'" />'.  
                &mt('Checked out for').' '.$plainname.  
                '<br />'.&mt('User').': '.$tuname.' at '.$tudom.  
                '<br />'.&mt('ID').': '.$idhash{$tuname}.  
                '<br />'.&mt('CourseID').': '.$tcrsid.  
                '<br />'.&mt('Course').': '.$env{'course.'.$tcrsid.'.description'}.  
                '<br />'.&mt('DocID').': '.$token.  
                '<br />'.&mt('Time').': '.&Apache::lonlocal::locallocaltime().'<hr />';  
     } else {  
         return $token;  
     }  
 }  
   
 sub printalltags {  sub printalltags {
   my $temp;    my $temp;
   foreach $temp (sort keys %Apache::lonxml::alltags) {    foreach $temp (sort keys %Apache::lonxml::alltags) {
Line 1629  sub inserteditinfo { Line 1535  sub inserteditinfo {
 // ]]>  // ]]>
 </script>  </script>
 FULLPAGE  FULLPAGE
       my $textareaclass;  
       if ($filetype eq 'html') {        if ($filetype eq 'html') {
           my $context;            if ($symb || $folderpath) {
           if ($env{'request.course.id'}) {                $deps_button = &Apache::lonhtmlcommon::dependencies_button()."\n";
               my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};                $initialize .= 
               my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};                    &Apache::lonhtmlcommon::dependencycheck_js($symb,$itemtitle,
               if ($uri =~ m{^\Q/uploaded/$cdom/$cnum/portfolio/syllabus/\E}) {                                                               undef,$folderpath,$uri)."\n";
                   $context = 'syllabus';  
                   $deps_button = &Apache::lonhtmlcommon::dependencies_button()."\n";  
                   $initialize .=  
                       &Apache::lonhtmlcommon::dependencycheck_js(undef,&mt('Syllabus'),  
                                                                  $uri,undef,  
                                                                  "/public/$cdom/$cnum/syllabus").  
                       "\n";  
                   if (&Apache::lonhtmlcommon::htmlareabrowser()) {  
                       $textareaclass = 'class="LC_richDefaultOn"';  
                   }  
               }  
           }  
           unless ($context eq 'syllabus') {  
               if ($symb || $folderpath) {  
                   $deps_button = &Apache::lonhtmlcommon::dependencies_button()."\n";  
                   $initialize .=  
                       &Apache::lonhtmlcommon::dependencycheck_js($symb,$itemtitle,  
                                                                  undef,$folderpath,$uri)."\n";  
               }  
           }            }
           $dragmath_button = '<span id="math_filecont">'.&Apache::lonhtmlcommon::dragmath_button('filecont',1).'</span>';            $dragmath_button = '<span id="math_filecont">'.&Apache::lonhtmlcommon::dragmath_button('filecont',1).'</span>';
           $initialize .= "\n".&Apache::lonhtmlcommon::dragmath_js('EditMathPopup');            $initialize .= "\n".&Apache::lonhtmlcommon::dragmath_js('EditMathPopup');
Line 1667  FULLPAGE Line 1553  FULLPAGE
       }        }
   
       my $titledisplay=&display_title();        my $titledisplay=&display_title();
         my $textareaclass;
       my %lt=&Apache::lonlocal::texthash('st' => 'Save and Edit',        my %lt=&Apache::lonlocal::texthash('st' => 'Save and Edit',
  'vi' => 'Save and View',   'vi' => 'Save and View',
  'dv' => 'Discard Edits and View',   'dv' => 'Discard Edits and View',
Line 1682  FULLPAGE Line 1569  FULLPAGE
               $htmlerror='<span class="LC_error">'.$htmlerror.'</span>';                $htmlerror='<span class="LC_error">'.$htmlerror.'</span>';
           }            }
           if (&Apache::lonhtmlcommon::htmlareabrowser()) {            if (&Apache::lonhtmlcommon::htmlareabrowser()) {
               unless ($textareaclass) {                $textareaclass = 'class="LC_richDefaultOff"';
                   $textareaclass = 'class="LC_richDefaultOff"';  
               }  
           }            }
       }        }
       my $editfooter=(<<ENDFOOTER);        my $editfooter=(<<ENDFOOTER);
 $initialize  $initialize
 <a name="editsection" />  <a name="editsection" />
 <form $form_events method="post" name="xmledit" action="">  <form $form_events method="post" name="xmledit">
   <div class="LC_edit_problem_editxml_header">    <div class="LC_edit_problem_editxml_header">
     <table class="LC_edit_problem_header_title"><tr><td>      <table class="LC_edit_problem_header_title"><tr><td>
         $filename          $filename
Line 1785  sub handler { Line 1670  sub handler {
     } else {      } else {
  $filetype='html';   $filetype='html';
     }      }
     unless ($env{'request.uri'}) {  
         $env{'request.uri'}=$request->uri;  
         &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},  
                                                 ['todocs']);  
     }  
     my ($cdom,$cnum);  
     if ($env{'request.course.id'}) {  
         $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};  
         $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};  
         if ($filetype eq 'html') {  
             if ($request->uri =~ m{^\Q/uploaded/$cdom/$cnum/portfolio/syllabus/\E.+$}) {  
                 if (&Apache::lonnet::allowed('mdc',$env{'request.course.id'})) {  
                     &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},  
                                                             ['editmode']);  
                 }  
             }  
         }  
     }  
     if ($filetype eq 'sty') {      if ($filetype eq 'sty') {
         $breadcrumbtext = 'Style File Editor';          $breadcrumbtext = 'Style File Editor';
     } elsif ($filetype eq 'js') {      } elsif ($filetype eq 'js') {
Line 1905  ENDNOTFOUND Line 1772  ENDNOTFOUND
                 my $brcrum;                  my $brcrum;
                 if ($env{'request.state'} eq 'construct') {                  if ($env{'request.state'} eq 'construct') {
                     $brcrum = [{'href' => &Apache::loncommon::authorspace($request->uri),                      $brcrum = [{'href' => &Apache::loncommon::authorspace($request->uri),
                                 'text' => 'Authoring Space'},                                  'text' => 'Construction Space'},
                                {'href' => '',                                 {'href' => '',
                                 'text' => $breadcrumbtext}];                                  'text' => $breadcrumbtext}];
                 } else {                  } else {
Line 1932  ENDNOTFOUND Line 1799  ENDNOTFOUND
     $displayfile=$request->uri;      $displayfile=$request->uri;
             if ($request->uri =~ m{^/uploaded/}) {              if ($request->uri =~ m{^/uploaded/}) {
                 if ($env{'request.course.id'}) {                  if ($env{'request.course.id'}) {
                     if ($request->uri =~ m{^\Q/uploaded/$cdom/$cnum/supplemental/\E}) {                      my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
                       my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
                       if ($request->uri =~ m{^\Q/uploaded/$cdom/$cnum/\Esupplemental/}) {
                         &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},                          &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
                                                                 ['folderpath','title']);                                                                  ['folderpath','title']);
                     } elsif ($request->uri =~ m{^\Q/uploaded/$cdom/$cnum/portfolio/syllabus/\E(.+)$}) {  
                         my $filename = $1;  
                         if ($1 eq 'loncapa.html') {  
                             $displayfile = &mt('Syllabus (minimal template)');  
                         } else {  
                             $displayfile = &mt('Syllabus file: [_1]',$1);  
                         }  
                         $itemtitle = &mt('Syllabus');  
                     }                      }
                 }                  }
                 unless ($itemtitle) {                  ($symb,$itemtitle,$displayfile) = 
                     ($symb,$itemtitle,$displayfile) =                       &get_courseupload_hierarchy($request->uri,
                         &get_courseupload_hierarchy($request->uri,                                                  $env{'form.folderpath'},$env{'form.title'});
                                                     $env{'form.folderpath'},  
                                                     $env{'form.title'});  
                 }  
             } else {              } else {
         $displayfile=~s/^\/[^\/]*//;          $displayfile=~s/^\/[^\/]*//;
             }              }
Line 1967  ENDNOTFOUND Line 1825  ENDNOTFOUND
             if ($env{'request.state'} eq 'construct') {              if ($env{'request.state'} eq 'construct') {
                 $options{'bread_crumbs'} = [{                  $options{'bread_crumbs'} = [{
                             'href' => &Apache::loncommon::authorspace($request->uri),                              'href' => &Apache::loncommon::authorspace($request->uri),
                             'text' => 'Authoring Space'},                              'text' => 'Construction Space'},
                            {'href' => '',                             {'href' => '',
                             'text' => $breadcrumbtext}];                              'text' => $breadcrumbtext}];
                 $header = &Apache::loncommon::head_subbox(                  $header = &Apache::loncommon::head_subbox(
Line 2002  sub display_title { Line 1860  sub display_title {
     $title = substr($title, rindex($title, '/') + 1);      $title = substr($title, rindex($title, '/') + 1);
  }   }
         $result = "<script type='text/javascript'>top.document.title = '$title - LON-CAPA "          $result = "<script type='text/javascript'>top.document.title = '$title - LON-CAPA "
                   .&mt('Authoring Space')."';</script>";                    .&mt('Construction Space')."';</script>";
     }      }
     return $result;      return $result;
 }  }
Line 2017  sub get_courseupload_hierarchy { Line 1875  sub get_courseupload_hierarchy {
             while (@folders) {              while (@folders) {
                 my $folder=shift(@folders);                  my $folder=shift(@folders);
                 my $foldername=shift(@folders);                  my $foldername=shift(@folders);
                 $foldername =~ s/\:(\d*)\:(\w*)\:(\w*):(\d*)\:?(\d*)$//;  
                 push(@pathitems,&unescape($foldername));                  push(@pathitems,&unescape($foldername));
             }              }
             if ($title) {              if ($title) {
Line 2194  sub add_messages { Line 2051  sub add_messages {
   
 sub get_param {  sub get_param {
     my ($param,$parstack,$safeeval,$context,$case_insensitive, $noelide) = @_;      my ($param,$parstack,$safeeval,$context,$case_insensitive, $noelide) = @_;
   
     if ( ! $context ) { $context = -1; }      if ( ! $context ) { $context = -1; }
     my $args ='';      my $args ='';
     if ( $#$parstack > (-2-$context) ) { $args=$$parstack[$context]; }      if ( $#$parstack > (-2-$context) ) { $args=$$parstack[$context]; }
Line 2201  sub get_param { Line 2059  sub get_param {
  $args=$Apache::lonxml::style_values.$args;   $args=$Apache::lonxml::style_values.$args;
     }      }
   
   
     if ($noelide) {      if ($noelide) {
         $args =~ s/'\$/'\\\$/g;  # $args =~ s/\\'/'/g;
    $args =~ s/'\$/'\\\$/g;
     }      }
   
     if ( ! $args ) { return undef; }      if ( ! $args ) { return undef; }
     if ( $case_insensitive ) {      if ( $case_insensitive ) {
  if ($args =~ s/(my (?:.*))(\$\Q$param\E[,\)])/$1.lc($2)/ei) {   if ($args =~ s/(my (?:.*))(\$\Q$param\E[,\)])/$1.lc($2)/ei) {
   
     return &Apache::run::run("{$args;".'return $'.$param.'}',      return &Apache::run::run("{$args;".'return $'.$param.'}',
                                      $safeeval); #'                                       $safeeval); #'
  } else {   } else {
Line 2215  sub get_param { Line 2076  sub get_param {
  }   }
     } else {      } else {
  if ( $args =~ /my .*\$\Q$param\E[,\)]/ ) {   if ( $args =~ /my .*\$\Q$param\E[,\)]/ ) {
       
     return &Apache::run::run("{$args;".'return $'.$param.'}',      return &Apache::run::run("{$args;".'return $'.$param.'}',
                                      $safeeval); #'                                       $safeeval); #'
  } else {   } else {

Removed from v.1.531.2.10  
changed lines
  Added in v.1.535


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