--- loncom/interface/londocs.pm 2008/12/15 03:02:19 1.321 +++ loncom/interface/londocs.pm 2009/01/28 18:10:04 1.329 @@ -1,7 +1,7 @@ # The LearningOnline Network # Documents # -# $Id: londocs.pm,v 1.321 2008/12/15 03:02:19 raeburn Exp $ +# $Id: londocs.pm,v 1.329 2009/01/28 18:10:04 droeschl Exp $ # # Copyright Michigan State University Board of Trustees # @@ -59,7 +59,6 @@ my $hadchanges; my %help=(); - sub mapread { my ($coursenum,$coursedom,$map)=@_; return @@ -120,11 +119,9 @@ sub dumpbutton { my $type = &Apache::loncommon::course_type(); if ($home+$other==0) { return ''; } if ($home) { - return '
'. '
'. - &Apache::loncommon::end_page()); + &mt('Export '.$type.' DOCS').'" />'); } } @@ -1280,9 +1284,33 @@ sub do_paste_from_buffer { # Maps need to be copied first if (($url=~/\.(page|sequence)$/) && ($url=~/^\/uploaded\//)) { $title=&mt('Copy of').' '.$title; - my $newid=$$.time; - $url=~/^(.+)\.(\w+)$/; - my $newurl=$1.$newid.'.'.$2; + my $newid=$$.int(rand(100)).time; + my ($oldid,$ext) = ($url=~/^(.+)\.(\w+)$/); + if ($oldid =~ m{^(/uploaded/\Q$coursedom\E/\Q$coursenum\E/)(\D+)(\d+)$}) { + 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; $storefn=~s{^/\w+/$match_domain/$match_username/}{}; my $paste_map_result = @@ -1340,6 +1368,20 @@ sub do_paste_from_buffer { # 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', 'hiddenresource' => 'string_yesno', 'encrypturl' => 'string_yesno', @@ -2098,19 +2140,27 @@ List Symbs sub list_symbs { my ($r) = @_; + my $type = &Apache::loncommon::course_type(); $r->print(&Apache::loncommon::start_page('Symb List')); $r->print(&Apache::lonhtmlcommon::breadcrumbs('Symb List')); my $navmap = Apache::lonnavmaps::navmap->new(); - $r->print("\n"); - foreach my $res ($navmap->retrieveResources()) { - $r->print($res->compTitle()."\t".$res->symb()."\n"); + if (!defined($navmap)) { + $r->print('\n"); $r->print(''.&mt('Return to DOCS').''); } - sub verifycontent { my ($r) = @_; my $type = &Apache::loncommon::course_type(); @@ -2468,6 +2518,7 @@ sub handler { return OK if $r->header_only; my $type = &Apache::loncommon::course_type(); + # --------------------------------------------- Initialize help topics for this foreach my $topic ('Adding_Course_Doc','Main_Course_Documents', 'Adding_External_Resource','Navigate_Content', @@ -2521,6 +2572,8 @@ sub handler { my $showdoc=0; my $containertag; my $uploadtag; + + &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'}, ['folderpath','pagepath', 'pagesymb']); @@ -2594,9 +2647,10 @@ sub handler { } # -------------------------------------------------------------------- Body tag $script = ''; - my @brcrum = [{href=>"/adm/createuser",text=>"$type Documents"}]; + my $brcrum = [{href=>"/adm/createuser",text=>"$type Documents"}]; $r->print(&Apache::loncommon::start_page("$type Documents", $script, - {'force_register' => $showdoc, bread_crumbs => @brcrum}). + {'force_register' => $showdoc, + 'bread_crumbs' => $brcrum}). &Apache::loncommon::help_open_menu('','',273,'RAT')); my %allfiles = (); @@ -2692,9 +2746,8 @@ sub handler { 'uplm' => 'Upload a new main '.lc($type).' document', 'upls' => 'Upload a new supplemental '.lc($type).' document', 'impp' => 'Import a document', - 'pubd' => 'Published documents', + 'pubd' => 'Published Documents', 'copm' => 'All documents out of a published map into this folder', - 'spec' => 'Special documents', 'upld' => 'Upload Document', 'srch' => 'Search', 'impo' => 'Import', @@ -2720,13 +2773,86 @@ sub handler { 'file' => 'File', 'title' => 'Title', 'comment' => 'Comment', - 'parse' => 'If HTML file, upload embedded images/multimedia files' + 'parse' => 'Upload embedded images/multimedia files if HTML file!', + 'nd' => 'New Document', + 'pm' => 'Published Map', + 'sd' => 'Special Document', + 'mo' => 'More Options', + 'hao' => 'Hide all Options' ); # ----------------------------------------------------------------------------- + my $fileupload=(<'.&mt('Retrieval of List Failed').'
'. + ''. + &mt('Unable to retrieve information about course contents'). + ''); + &Apache::lonnet::logthis('Symb list failed - could not create navmap object in '.lc($type).':'.$env{'request.course.id'}); + } else { + $r->print("\n"); + foreach my $res ($navmap->retrieveResources()) { + $r->print($res->compTitle()."\t".$res->symb()."\n"); + } + $r->print("\n\n"); } - $r->print("\n
+ $lt{'copm'}
+
+
+ $help{'Load_Map'}
+
-$lt{'file'}: - +$fileuploadform |
-
+$simpleeditdefaultform
- +$recoverform ENDFORM unless ($env{'form.pagepath'}) { $r->print(< +$extresourcesform + +$imspform ENDFORM } $r->print(' | ');
unless ($env{'form.pagepath'}) {
my $path = &HTML::Entities::encode($env{'form.folderpath'},'<>&"');
+
+
+
+ my $newpageform=(< - - - - - - - - - - - + +$newfolderform + +$newpageform + +$newsylform + +$newnavform + +$newsmppageform + +$newsmpproblemform + +$newdropboxform + +$newexuploadform + +$newbulform + +$newaboutmeform + +$newaboutsomeoneform + +$newgroupfileform + +$newrosterform ENDFORM } if ($env{'form.pagepath'}) { $r->print(< +$newsmpproblemform + +$newexuploadform ENDBLOCK } $r->print(' |
$lt{'upls'} | -$lt{'spec'} | -
---|
- | +
+$supnewfolderform
+$supnewextform - - - - -$lt{'comment'}: - +$supnewsylform - - - - - $help{'Uploading_From_Harddrive'} - - - |
-
-
- - - +$supnewaboutmeform |