--- loncom/interface/londocs.pm 2010/02/02 01:33:02 1.314.2.8 +++ loncom/interface/londocs.pm 2008/11/17 14:46:10 1.315 @@ -1,7 +1,7 @@ # The LearningOnline Network # Documents # -# $Id: londocs.pm,v 1.314.2.8 2010/02/02 01:33:02 raeburn Exp $ +# $Id: londocs.pm,v 1.315 2008/11/17 14:46:10 jms Exp $ # # Copyright Michigan State University Board of Trustees # @@ -26,6 +26,22 @@ # http://www.lon-capa.org/ # + +=head1 NAME + +Apache::londocs + +=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; use strict; @@ -53,15 +69,27 @@ my %alreadyseen=(); my $hadchanges; -# Available help topics + +=pod + +=item %help=() + + Available help topics + +=cut my %help=(); -# 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 -# +=pod + +=item mapread() + +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 { my ($coursenum,$coursedom,$map)=@_; @@ -81,7 +109,14 @@ sub storemap { return ($errtext,0); } -# ----------------------------------------- Return hash with valid author names + +=pod + +=item authorhosts() + + Return hash with valid author names + +=cut sub authorhosts { my %outhash=(); @@ -116,7 +151,13 @@ sub authorhosts { } return ($home,$other,%outhash); } -# ------------------------------------------------------ Generate "dump" button +=pod + +=item dumpbutton() + + Generate "dump" button + +=cut sub dumpbutton { my ($home,$other,%outhash)=&authorhosts(); @@ -141,7 +182,14 @@ sub clean { $title=~s/[^\w\/\!\$\%\^\*\-\_\=\+\;\:\,\\\|\`\~]+/\_/gs; return $title; } -# -------------------------------------------------------- Actually dump course + +=pod + +=item dumpcourse() + + Actually dump course + +=cut sub dumpcourse { my ($r) = @_; @@ -263,7 +311,13 @@ sub dumpcourse { } } -# ------------------------------------------------------ Generate "export" button +=pod + +=item exportbutton() + + Generate "export" button + +=cut sub exportbutton { my $type = &Apache::loncommon::course_type(); @@ -273,6 +327,12 @@ sub exportbutton { &Apache::loncommon::help_open_topic('Docs_Export_Course_Docs').''; } +=pod + +=item exportcourse() + +=cut + sub exportcourse { my $r=shift; my $type = &Apache::loncommon::course_type(); @@ -280,15 +340,6 @@ sub exportcourse { $env{'course.'.$env{'request.course.id'}.'.domain'}, $env{'course.'.$env{'request.course.id'}.'.num'}); my $numdisc = keys %discussiontime; my $navmap = Apache::lonnavmaps::navmap->new(); - if (!defined($navmap)) { - $r->print(&Apache::loncommon::start_page('Export '.lc($type).' to IMS content package'). - '

IMS Export Failed

'. - '
'. - &mt('Unable to retrieve information about course contents'). - '
'.&mt('Return to Course Editor').''); - &Apache::lonnet::logthis('IMS export failed - could not create navmap object in '.lc($type).':'.$env{'request.course.id'}); - return; - } my $it=$navmap->getIterator(undef,undef,undef,1,undef,undef); my $curRes; my $outcome; @@ -480,7 +531,8 @@ function containerCheck(item) { $r->print($display.''. '

'. '

'); + &mt('Export '.$type.' DOCS').'" />

'. + &Apache::loncommon::end_page()); } } @@ -919,8 +971,15 @@ sub store_template { } } -# Imports the given (name, url) resources into the course -# coursenum, coursedom, and folder must precede the list +=pod + +=item group_import() + + Imports the given (name, url) resources into the course + coursenum, coursedom, and folder must precede the list + +=cut + sub group_import { my ($coursenum, $coursedom, $folder, $container, $caller, @files) = @_; @@ -1081,10 +1140,12 @@ sub log_docs { } } +=pod + +=item docs_change_log() + +=cut -# -# Docs Change Log -# sub docs_change_log { my ($r)=@_; my $folder=$env{'form.folder'}; @@ -1228,7 +1289,7 @@ sub update_paste_buffer { &Apache::lonnet::appenv({'docs.markedcopy_supplemental' => $title}); ($title) = &parse_supplemental_title($title); } elsif ($env{'docs.markedcopy_supplemental'}) { - &Apache::lonnet::delenv('docs.markedcopy_supplemental'); + &Apache::lonnet::delenv('docs\\.markedcopy_supplemental'); } $url=~s{http(:|:)//https(:|:)//}{https$2//}; @@ -1287,33 +1348,9 @@ sub do_paste_from_buffer { # Maps need to be copied first if (($url=~/\.(page|sequence)$/) && ($url=~/^\/uploaded\//)) { $title=&mt('Copy of').' '.$title; - 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 $newid=$$.time; + $url=~/^(.+)\.(\w+)$/; + my $newurl=$1.$newid.'.'.$2; my $storefn=$newurl; $storefn=~s{^/\w+/$match_domain/$match_username/}{}; &Apache::lonclonecourse::writefile($env{'request.course.id'},$storefn, @@ -1322,7 +1359,7 @@ sub do_paste_from_buffer { } # published maps can only exists once, so remove it from paste buffer when done if (($url=~/\.(page|sequence)$/) && ($url=~m {^/res/})) { - &Apache::lonnet::delenv('docs.markedcopy'); + &Apache::lonnet::delenv('docs\\.markedcopy'); } if ($url=~ m{/smppg$}) { my $db_name = &Apache::lonsimplepage::get_db_name($url); @@ -1362,20 +1399,6 @@ 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', @@ -1699,7 +1722,6 @@ sub parse_supplemental_title { $foldertitle=&Apache::lontexconvert::msgtexconverted($4); my $name = &Apache::loncommon::plainname($uname,$udom); $name = &HTML::Entities::encode($name,'"<>&\''); - $renametitle = &HTML::Entities::encode($renametitle,'"<>&\''); $title=''.&Apache::lonlocal::locallocaltime($time).' '. $name.':
'.$foldertitle; } @@ -1765,7 +1787,7 @@ sub entryline { ' '.&mt('Random Order').' '; +'; } if ($ispage) { my $pagename=&escape($pagetitle); @@ -1990,9 +2011,9 @@ END 'hd' => 'Hidden', 'ec' => 'URL hidden'); my $enctext= - ((&LONCAPA::map::getparameter($orderidx,'parameter_encrypturl'))[0]=~/^yes$/i?' checked="checked"':''); + ((&LONCAPA::map::getparameter($orderidx,'parameter_encrypturl'))[0]=~/^yes$/i?' checked="1"':''); my $hidtext= - ((&LONCAPA::map::getparameter($orderidx,'parameter_hiddenresource'))[0]=~/^yes$/i?' checked="checked"':''); + ((&LONCAPA::map::getparameter($orderidx,'parameter_hiddenresource'))[0]=~/^yes$/i?' checked="1"':''); $line.=(< $form_start @@ -2012,7 +2033,13 @@ ENDPARMS return $line; } -# ---------------------------------------------------------------- tie the hash +=pod + +=item tiehash() + +tie the hash + +=cut sub tiehash { my ($mode)=@_; @@ -2038,7 +2065,15 @@ sub untiehash { return OK; } -# --------------------------------------------------------------- check on this + +=pod + +=item checkonthis() + +check on this + +=cut + sub checkonthis { my ($r,$url,$level,$title)=@_; @@ -2112,36 +2147,38 @@ sub checkonthis { } -# -# ----------------------------------------------------------------- List Symbs -# + +=pod + +=item list_symbs() + +List Symbs + +=cut + 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(); - if (!defined($navmap)) { - $r->print('

'.&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");
+    foreach my $res ($navmap->retrieveResources()) {
+	$r->print($res->compTitle()."\t".$res->symb()."\n");
     }
+    $r->print("\n
\n"); $r->print(''.&mt('Return to DOCS').''); } -# -# -------------------------------------------------------------- Verify Content -# +=pod + +=item verifycontent() + +Verify Content + +=cut + sub verifycontent { my ($r) = @_; my $type = &Apache::loncommon::course_type(); @@ -2171,8 +2208,13 @@ sub verifycontent { &mt('Return to DOCS').''); } +=pod + +=item devalidateversioncache() & checkversions() -# -------------------------------------------------------------- Check Versions +Check Versions + +=cut sub devalidateversioncache { my $src=shift; @@ -2476,7 +2518,13 @@ sub changewarning { $help{'Caching'}.''."\n\n"); } -# =========================================== Breadcrumbs for special functions +=pod + +=item init_breadcrumbs() + +Breadcrumbs for special functions + +=cut sub init_breadcrumbs { my ($form,$text)=@_; @@ -2492,7 +2540,15 @@ sub init_breadcrumbs { bug=>'Instructor Interface'}); } -# ================================================================ Main Handler + +=pod + +=item handler() + +Main Handler + +=cut + sub handler { my $r = shift; &Apache::loncommon::content_type($r,'text/html'); @@ -3114,7 +3170,7 @@ ENDBLOCK

$lt{'comment'}:
-
@@ -3397,3 +3453,9 @@ ENDNEWSCRIPT } 1; __END__ + +=pod + +=back + +=cut