Diff for /loncom/interface/londocs.pm between versions 1.314.2.2 and 1.316

version 1.314.2.2, 2008/12/21 15:47:50 version 1.316, 2008/11/18 19:14:22
Line 26 Line 26
 # http://www.lon-capa.org/  # http://www.lon-capa.org/
 #  #
   
   
   =head1 NAME
   
   Apache::londocs.pm
   
   =head1 SYNOPSIS
   
   This is part of the LearningOnline Network with CAPA project
   described at http://www.lon-capa.org.
   
   =head1 SUBROUTINES
   
   =over
   
   =cut
   
 package Apache::londocs;  package Apache::londocs;
   
 use strict;  use strict;
Line 53  my %alreadyseen=(); Line 69  my %alreadyseen=();
   
 my $hadchanges;  my $hadchanges;
   
 # Available help topics  
   =pod
   
   =item %help=()
   
    Available help topics
   
   =cut
   
 my %help=();  my %help=();
   
 # Mapread read maps into LONCAPA::map:: global arrays   =pod
 # @order and @resources, determines status  
 # sets @order - pointer to resources in right order  =item mapread()
 # sets @resources - array with the resources with correct idx  
 #  Mapread read maps into LONCAPA::map:: global arrays 
   @order and @resources, determines status
   sets @order - pointer to resources in right order
   sets @resources - array with the resources with correct idx
   
   =cut
   
 sub mapread {  sub mapread {
     my ($coursenum,$coursedom,$map)=@_;      my ($coursenum,$coursedom,$map)=@_;
Line 81  sub storemap { Line 109  sub storemap {
     return ($errtext,0);      return ($errtext,0);
 }  }
   
 # ----------------------------------------- Return hash with valid author names  
   =pod
   
   =item authorhosts()
   
       Return hash with valid author names
   
   =cut
   
 sub authorhosts {  sub authorhosts {
     my %outhash=();      my %outhash=();
Line 116  sub authorhosts { Line 151  sub authorhosts {
     }      }
     return ($home,$other,%outhash);      return ($home,$other,%outhash);
 }  }
 # ------------------------------------------------------ Generate "dump" button  =pod
   
   =item dumpbutton()
   
       Generate "dump" button
   
   =cut
   
 sub dumpbutton {  sub dumpbutton {
     my ($home,$other,%outhash)=&authorhosts();      my ($home,$other,%outhash)=&authorhosts();
Line 141  sub clean { Line 182  sub clean {
     $title=~s/[^\w\/\!\$\%\^\*\-\_\=\+\;\:\,\\\|\`\~]+/\_/gs;      $title=~s/[^\w\/\!\$\%\^\*\-\_\=\+\;\:\,\\\|\`\~]+/\_/gs;
     return $title;      return $title;
 }  }
 # -------------------------------------------------------- Actually dump course  
   =pod
   
   =item dumpcourse()
   
       Actually dump course
   
   =cut
   
 sub dumpcourse {  sub dumpcourse {
     my ($r) = @_;      my ($r) = @_;
Line 263  sub dumpcourse { Line 311  sub dumpcourse {
     }      }
 }  }
   
 # ------------------------------------------------------ Generate "export" button  =pod
   
   =item exportbutton()
   
       Generate "export" button
   
   =cut
   
 sub exportbutton {  sub exportbutton {
     my $type = &Apache::loncommon::course_type();      my $type = &Apache::loncommon::course_type();
Line 273  sub exportbutton { Line 327  sub exportbutton {
     &Apache::loncommon::help_open_topic('Docs_Export_Course_Docs').'</div>';      &Apache::loncommon::help_open_topic('Docs_Export_Course_Docs').'</div>';
 }  }
   
   =pod
   
   =item exportcourse()
   
   =cut
   
 sub exportcourse {  sub exportcourse {
     my $r=shift;      my $r=shift;
     my $type = &Apache::loncommon::course_type();      my $type = &Apache::loncommon::course_type();
Line 911  sub store_template { Line 971  sub store_template {
     }      }
 }  }
   
 # Imports the given (name, url) resources into the course  =pod
 # coursenum, coursedom, and folder must precede the list  
   =item group_import()
   
       Imports the given (name, url) resources into the course
       coursenum, coursedom, and folder must precede the list
   
   =cut
   
 sub group_import {  sub group_import {
     my ($coursenum, $coursedom, $folder, $container, $caller, @files) = @_;      my ($coursenum, $coursedom, $folder, $container, $caller, @files) = @_;
   
Line 1073  sub log_docs { Line 1140  sub log_docs {
     }      }
 }  }
   
   =pod
   
   =item docs_change_log()
   
   =cut
   
 #  
 # Docs Change Log  
 #  
 sub docs_change_log {  sub docs_change_log {
     my ($r)=@_;      my ($r)=@_;
     my $folder=$env{'form.folder'};      my $folder=$env{'form.folder'};
Line 1280  sub do_paste_from_buffer { Line 1349  sub do_paste_from_buffer {
     if (($url=~/\.(page|sequence)$/) && ($url=~/^\/uploaded\//)) {      if (($url=~/\.(page|sequence)$/) && ($url=~/^\/uploaded\//)) {
  $title=&mt('Copy of').' '.$title;   $title=&mt('Copy of').' '.$title;
  my $newid=$$.time;   my $newid=$$.time;
  my ($oldid,$ext) = ($url=~/^(.+)\.(\w+)$/);   $url=~/^(.+)\.(\w+)$/;
         if ($oldid =~ m{^(/uploaded/\Q$coursedom\E/\Q$coursenum\E/)(\D+)(\d+)$}) {   my $newurl=$1.$newid.'.'.$2;
             my $path = $1;  
             my $prefix = $2;  
             my $ancestor = $3;  
             if (length($ancestor) > 10) {  
                 $ancestor = substr($ancestor,-10,10);  
             }  
             $oldid = $path.$prefix.$ancestor;  
         }  
         my $counter = 0;  
         my $newurl=$oldid.$newid.'.'.$ext;  
         my $is_unique = &uniqueness_check($newurl);  
         while (!$is_unique && $counter < 100) {  
             $counter ++;  
             $newid ++;  
             $newurl = $oldid.$newid;  
             $is_unique = &uniqueness_check($newurl);  
         }  
         if (!$is_unique) {  
             if ($url=~/\.page$/) {  
                 return &mt('Paste failed: an error occurred creating a unique URL for the composite page');  
             } else {  
                 return &mt('Paste failed: an error occurred creating a unique URL for the folder');  
             }  
         }  
  my $storefn=$newurl;   my $storefn=$newurl;
  $storefn=~s{^/\w+/$match_domain/$match_username/}{};   $storefn=~s{^/\w+/$match_domain/$match_username/}{};
  &Apache::lonclonecourse::writefile($env{'request.course.id'},$storefn,   &Apache::lonclonecourse::writefile($env{'request.course.id'},$storefn,
Line 1354  sub do_paste_from_buffer { Line 1399  sub do_paste_from_buffer {
 # Store the result  # Store the result
 }  }
   
 sub uniqueness_check {  
     my ($newurl) = @_;  
     my $unique = 1;  
     foreach my $res (@LONCAPA::map::order) {  
         my ($name,$url)=split(/\:/,$LONCAPA::map::resources[$res]);  
         $url=&LONCAPA::map::qtescape($url);  
         if ($newurl eq $url) {  
             $unique = 0;  
             last;      
         }  
     }  
     return $unique;  
 }  
   
 my %parameter_type = ( 'randompick'     => 'int_pos',  my %parameter_type = ( 'randompick'     => 'int_pos',
        'hiddenresource' => 'string_yesno',         'hiddenresource' => 'string_yesno',
        'encrypturl'     => 'string_yesno',         'encrypturl'     => 'string_yesno',
Line 1942  END Line 1973  END
     my $ro_set=      my $ro_set=
     ((&LONCAPA::map::getparameter($orderidx,'parameter_randomorder'))[0]=~/^yes$/i?' checked="checked"':'');      ((&LONCAPA::map::getparameter($orderidx,'parameter_randomorder'))[0]=~/^yes$/i?' checked="checked"':'');
  $rand_order_text ='   $rand_order_text ='
 <span class="LC_nobreak"><label><input type="checkbox" name="randomorder_'.$orderidx.'" onClick="this.form.changeparms.value=\'randomorder\';this.form.submit()" '.$ro_set.' /> '.&mt('Random Order').' </label></span>';  <nobr><label><input type="checkbox" name="randomorder_'.$orderidx.'" onClick="this.form.changeparms.value=\'randomorder\';this.form.submit()" '.$ro_set.' /> '.&mt('Random Order').' </label></nobr>';   
     }      }
     if ($ispage) {      if ($ispage) {
         my $pagename=&escape($pagetitle);          my $pagename=&escape($pagetitle);
Line 2002  ENDPARMS Line 2033  ENDPARMS
     return $line;      return $line;
 }  }
   
 # ---------------------------------------------------------------- tie the hash  =pod
   
   =item tiehash()
   
   tie the hash
   
   =cut
   
 sub tiehash {  sub tiehash {
     my ($mode)=@_;      my ($mode)=@_;
Line 2028  sub untiehash { Line 2065  sub untiehash {
     return OK;      return OK;
 }  }
   
 # --------------------------------------------------------------- check on this  
   =pod
   
   =item checkonthis()
   
   check on this
   
   =cut
   
   
 sub checkonthis {  sub checkonthis {
     my ($r,$url,$level,$title)=@_;      my ($r,$url,$level,$title)=@_;
Line 2102  sub checkonthis { Line 2147  sub checkonthis {
 }  }
   
   
 #  
 # ----------------------------------------------------------------- List Symbs  =pod
 #   
   =item list_symbs()
   
   List Symbs
   
   =cut
   
 sub list_symbs {  sub list_symbs {
     my ($r) = @_;      my ($r) = @_;
   
Line 2120  sub list_symbs { Line 2171  sub list_symbs {
 }  }
   
   
 #  =pod
 # -------------------------------------------------------------- Verify Content  
 #   =item verifycontent()
   
   Verify Content
   
   =cut
   
 sub verifycontent {  sub verifycontent {
     my ($r) = @_;      my ($r) = @_;
     my $type = &Apache::loncommon::course_type();      my $type = &Apache::loncommon::course_type();
Line 2152  sub verifycontent { Line 2208  sub verifycontent {
      &mt('Return to DOCS').'</a>');       &mt('Return to DOCS').'</a>');
 }  }
   
   =pod
   
   =item devalidateversioncache() & checkversions()
   
 # -------------------------------------------------------------- Check Versions  Check Versions
   
   =cut
   
 sub devalidateversioncache {  sub devalidateversioncache {
     my $src=shift;      my $src=shift;
Line 2457  sub changewarning { Line 2518  sub changewarning {
 $help{'Caching'}.'</span></h3></form>'."\n\n");  $help{'Caching'}.'</span></h3></form>'."\n\n");
 }  }
   
 # =========================================== Breadcrumbs for special functions  =pod
   
   =item init_breadcrumbs()
   
   Breadcrumbs for special functions
   
   =cut
   
 sub init_breadcrumbs {  sub init_breadcrumbs {
     my ($form,$text)=@_;      my ($form,$text)=@_;
Line 2473  sub init_breadcrumbs { Line 2540  sub init_breadcrumbs {
     bug=>'Instructor Interface'});      bug=>'Instructor Interface'});
 }  }
   
 # ================================================================ Main Handler  
   =pod
   
   =item handler()
   
   Main Handler
   
   =cut
   
 sub handler {  sub handler {
     my $r = shift;      my $r = shift;
     &Apache::loncommon::content_type($r,'text/html');      &Apache::loncommon::content_type($r,'text/html');
Line 3378  ENDNEWSCRIPT Line 3453  ENDNEWSCRIPT
 }  }
 1;  1;
 __END__  __END__
   
   =pod
   
   =back
   
   =cut

Removed from v.1.314.2.2  
changed lines
  Added in v.1.316


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