--- loncom/interface/londocs.pm 2008/12/21 15:47:50 1.314.2.2 +++ loncom/interface/londocs.pm 2009/01/30 11:39:38 1.332 @@ -1,7 +1,7 @@ # The LearningOnline Network # Documents # -# $Id: londocs.pm,v 1.314.2.2 2008/12/21 15:47:50 raeburn Exp $ +# $Id: londocs.pm,v 1.332 2009/01/30 11:39:38 tempelho Exp $ # # Copyright Michigan State University Board of Trustees # @@ -26,6 +26,8 @@ # http://www.lon-capa.org/ # + + package Apache::londocs; use strict; @@ -53,15 +55,9 @@ my %alreadyseen=(); my $hadchanges; -# Available help topics 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 -# sub mapread { my ($coursenum,$coursedom,$map)=@_; @@ -81,20 +77,20 @@ sub storemap { return ($errtext,0); } -# ----------------------------------------- Return hash with valid author names + sub authorhosts { my %outhash=(); my $home=0; my $other=0; - foreach (keys %env) { - if ($_=~/^user\.role\.(au|ca)\.(.+)$/) { + foreach my $key (keys(%env)) { + if ($key=~/^user\.role\.(au|ca)\.(.+)$/) { my $role=$1; my $realm=$2; - my ($start,$end)=split(/\./,$env{$_}); + my ($start,$end)=split(/\./,$env{$key}); if (($start) && ($start>time)) { next; } if (($end) && (time>$end)) { next; } - my $ca; my $cd; + my ($ca,$cd); if ($1 eq 'au') { $ca=$env{'user.name'}; $cd=$env{'user.domain'}; @@ -116,18 +112,16 @@ sub authorhosts { } return ($home,$other,%outhash); } -# ------------------------------------------------------ Generate "dump" button + sub dumpbutton { my ($home,$other,%outhash)=&authorhosts(); my $type = &Apache::loncommon::course_type(); if ($home+$other==0) { return ''; } if ($home) { - return '
'. - ''. - &Apache::loncommon::help_open_topic('Docs_Dump_Course_Docs'). - '
'; + &Apache::loncommon::help_open_topic('Docs_Dump_Course_Docs'); } else { return '
'. &mt('Dump '.$type. @@ -141,7 +135,8 @@ sub clean { $title=~s/[^\w\/\!\$\%\^\*\-\_\=\+\;\:\,\\\|\`\~]+/\_/gs; return $title; } -# -------------------------------------------------------- Actually dump course + + sub dumpcourse { my ($r) = @_; @@ -161,15 +156,15 @@ sub dumpcourse { my $title=$env{'form.authorfolder'}; $title=&clean($title); my %replacehash=(); - foreach (keys %env) { - if ($_=~/^form\.namefor\_(.+)/) { - $replacehash{$1}=$env{$_}; + foreach my $key (keys(%env)) { + if ($key=~/^form\.namefor\_(.+)/) { + $replacehash{$1}=$env{$key}; } } my $crs='/uploaded/'.$env{'request.course.id'}.'/'; $crs=~s/\_/\//g; - foreach (keys %replacehash) { - my $newfilename=$title.'/'.$replacehash{$_}; + foreach my $item (keys(%replacehash)) { + my $newfilename=$title.'/'.$replacehash{$item}; $newfilename=~s/\.(\w+)$//; my $ext=$1; $newfilename=&clean($newfilename); @@ -184,16 +179,16 @@ sub dumpcourse { unless(mkdir($makepath,0777)) { $fail=1; } } } - $r->print('
'.$_.' => '.$newfilename.': '); + $r->print('
'.$item.' => '.$newfilename.': '); if (my $fh=Apache::File->new('>'.$path.'/'.$newfilename)) { - if ($_=~/\.(sequence|page|html|htm|xml|xhtml)$/) { + if ($item=~/\.(sequence|page|html|htm|xml|xhtml)$/) { print $fh &Apache::lonclonecourse::rewritefile( - &Apache::lonclonecourse::readfile($env{'request.course.id'},$_), + &Apache::lonclonecourse::readfile($env{'request.course.id'},$item), (%replacehash,$crs => '') ); } else { print $fh - &Apache::lonclonecourse::readfile($env{'request.course.id'},$_); + &Apache::lonclonecourse::readfile($env{'request.course.id'},$item); } $fh->close(); } else { @@ -211,8 +206,8 @@ sub dumpcourse { $r->print( '

'.&mt('Select the Construction Space').'

'); @@ -238,22 +233,22 @@ sub dumpcourse { .''.&mt('Title').'' .''.&mt('Save as ...').'' .&Apache::loncommon::end_data_table_header_row()); - foreach (&Apache::lonclonecourse::crsdirlist($origcrsid,'userfiles')) { + foreach my $file (&Apache::lonclonecourse::crsdirlist($origcrsid,'userfiles')) { $r->print(&Apache::loncommon::start_data_table_row() - .''.$_.''); - my ($ext)=($_=~/\.(\w+)$/); + .''.$file.''); + my ($ext)=($file=~/\.(\w+)$/); my $title=$hash{'title_'.$hash{ - 'ids_/uploaded/'.$origcrsdata{'domain'}.'/'.$origcrsdata{'num'}.'/'.$_}}; + 'ids_/uploaded/'.$origcrsdata{'domain'}.'/'.$origcrsdata{'num'}.'/'.$file}}; $r->print(''.($title?$title:' ').''); if (!$title) { - $title=$_; + $title=$file; } else { $title=~s|/|_|g; } $title=~s/\.(\w+)$//; $title=&clean($title); $title.='.'.$ext; - $r->print("\n" + $r->print("\n" .&Apache::loncommon::end_data_table_row()); } $r->print(&Apache::loncommon::end_data_table()); @@ -263,23 +258,33 @@ sub dumpcourse { } } -# ------------------------------------------------------ Generate "export" button + sub exportbutton { my $type = &Apache::loncommon::course_type(); - return '
'. - ''. - &Apache::loncommon::help_open_topic('Docs_Export_Course_Docs').'
'; + &Apache::loncommon::help_open_topic('Docs_Export_Course_Docs'); } + + sub exportcourse { my $r=shift; my $type = &Apache::loncommon::course_type(); my %discussiontime = &Apache::lonnet::dump('discussiontimes', $env{'course.'.$env{'request.course.id'}.'.domain'}, $env{'course.'.$env{'request.course.id'}.'.num'}); - my $numdisc = keys %discussiontime; + 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; @@ -448,8 +453,8 @@ function containerCheck(item) { } |; - foreach my $container (sort { $a <=> $b } keys %children) { - my @contents = split/:/,$children{$container}; + foreach my $container (sort { $a <=> $b } (keys(%children))) { + my @contents = split(/:/,$children{$container}); for (my $i=0; $i<@contents; $i ++) { $scripttag .= ' parents['.$container.']['.$i.'] = '.$contents[$i]."\n"; } @@ -471,8 +476,7 @@ function containerCheck(item) { $r->print($display.''. '

'. '

'. - &Apache::loncommon::end_page()); + &mt('Export '.$type.' DOCS').'" />

'); } } @@ -557,7 +561,7 @@ sub build_package { if ($curRes->is_sequence() || $curRes->is_page()) { $lastcontainer = $count; } - if (grep/^$count$/,@$exportitems) { + if (grep(/^$count$/,@$exportitems)) { &get_dependencies($exportitems,\%parent,$depth,\@dependencies); } } @@ -581,7 +585,7 @@ sub build_package { if (ref($curRes)) { $count ++; - if ((grep/^$count$/,@$exportitems) || (grep/^$count$/,@dependencies)) { + if ((grep(/^$count$/,@$exportitems)) || (grep(/^$count$/,@dependencies))) { my $symb = $curRes->symb(); my $isvisible = 'true'; my $resourceref; @@ -615,11 +619,11 @@ sub build_package { ' '."\n". ' '."\n"; - foreach (@hrefs) { + foreach my $item (@hrefs) { $imsresources .= - ' '."\n"; + ' '."\n"; } - if (grep/^$count$/,@$discussions) { + if (grep(/^$count$/,@$discussions)) { my $ressymb = $symb; my $mode; if ($ressymb =~ m|adm/($match_domain)/($match_username)/(\d+)/bulletinboard$|) { @@ -660,8 +664,8 @@ sub build_package { sub get_dependencies { my ($exportitems,$parent,$depth,$dependencies) = @_; if ($depth > 1) { - if ((!grep/^$$parent{$depth}$/,@$exportitems) && (!grep/^$$parent{$depth}$/,@$dependencies)) { - push @$dependencies, $$parent{$depth}; + if ((!grep(/^$$parent{$depth}$/,@$exportitems)) && (!grep(/^$$parent{$depth}$/,@$dependencies))) { + push(@{$dependencies},$$parent{$depth}); if ($depth > 2) { &get_dependencies($exportitems,$parent,$depth-1,$dependencies); } @@ -867,7 +871,7 @@ sub extract_media { my $copiedfile; if ($copiedfile = Apache::File->new('>'.$destination)) { print $copiedfile $embed_content; - push @{$href}, 'resources/'.$count.'/res/'.$filename; + push(@{$href},'resources/'.$count.'/res/'.$filename); my $attrib_regexp = ''; if (@{$allfiles{$embed_file}} > 1) { $attrib_regexp = join('|',@{$allfiles{$embed_file}}); @@ -911,8 +915,7 @@ sub store_template { } } -# Imports the given (name, url) resources into the course -# coursenum, coursedom, and folder must precede the list + sub group_import { my ($coursenum, $coursedom, $folder, $container, $caller, @files) = @_; @@ -1047,7 +1050,7 @@ sub log_docs { 'currentfolder' => $env{'form.folder'}); if ($parmidx) { $storehash{'parameter_res'}=$oldresources[$parmidx]; - foreach my $parm (keys %parmaction) { + foreach my $parm (keys(%parmaction)) { $storehash{'parameter_action_'.$parm}=$parmaction{$parm}; $storehash{'parameter_value_'.$parm}=$parmvalue{$parm}; } @@ -1074,9 +1077,9 @@ sub log_docs { } -# -# Docs Change Log -# + + + sub docs_change_log { my ($r)=@_; my $folder=$env{'form.folder'}; @@ -1271,7 +1274,9 @@ ENDPASTE sub do_paste_from_buffer { my ($coursenum,$coursedom,$folder) = @_; - return 0 if (!$env{'form.pastemarked'}); + if (!$env{'form.pastemarked'}) { + return; + } # paste resource to end of list my $url=&LONCAPA::map::qtescape($env{'docs.markedcopy_url'}); @@ -1279,7 +1284,7 @@ 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; + 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; @@ -1308,8 +1313,16 @@ sub do_paste_from_buffer { } my $storefn=$newurl; $storefn=~s{^/\w+/$match_domain/$match_username/}{}; - &Apache::lonclonecourse::writefile($env{'request.course.id'},$storefn, - &Apache::lonnet::getfile($url)); + my $paste_map_result = + &Apache::lonclonecourse::writefile($env{'request.course.id'},$storefn, + &Apache::lonnet::getfile($url)); + if ($paste_map_result eq '/adm/notfound.html') { + if ($url=~/\.page$/) { + return &mt('Paste failed: an error occurred saving the composite page'); + } else { + return &mt('Paste failed: an error occurred saving the folder'); + } + } $url = $newurl; } # published maps can only exists once, so remove it from paste buffer when done @@ -1351,6 +1364,7 @@ sub do_paste_from_buffer { $LONCAPA::map::resources[$newidx]= $title.':'.$url.':'.$ext.':normal:res'; push(@LONCAPA::map::order, $newidx); + return 'ok'; # Store the result } @@ -1483,9 +1497,14 @@ sub editor { } if ($env{'form.pastemarked'}) { - &do_paste_from_buffer($coursenum,$coursedom,$folder); - ($errtext,$fatal) = &storemap($coursenum,$coursedom,$folder.'.'.$container); - return $errtext if ($fatal); + my $paste_res = + &do_paste_from_buffer($coursenum,$coursedom,$folder); + if ($paste_res eq 'ok') { + ($errtext,$fatal) = &storemap($coursenum,$coursedom,$folder.'.'.$container); + return $errtext if ($fatal); + } elsif ($paste_res ne '') { + $r->print('

'.$paste_res.'

'); + } } $r->print($upload_output); @@ -1497,10 +1516,10 @@ sub editor { # Group import/search if ($env{'form.importdetail'}) { my @imports; - foreach (split(/\&/,$env{'form.importdetail'})) { - if (defined($_)) { + foreach my $item (split(/\&/,$env{'form.importdetail'})) { + if (defined($item)) { my ($name,$url,$residx)= - map {&unescape($_)} split(/\=/,$_); + map {&unescape($_)} split(/\=/,$item); push(@imports, [$name, $url, $residx]); } } @@ -1777,8 +1796,8 @@ sub entryline { # no copy for published maps $nocopy = 1; } else { - foreach (&Apache::lonsequence::attemptread(&Apache::lonnet::filelocation('',$url),1)) { - my ($title,$url,$ext,$type)=split(/\:/,$_); + foreach my $item (&Apache::lonsequence::attemptread(&Apache::lonnet::filelocation('',$url),1)) { + my ($title,$url,$ext,$type)=split(/\:/,$item); if (($url=~/\.(page|sequence)/) && ($type ne 'zombie')) { $nocopy=1; last; @@ -1942,7 +1961,7 @@ END my $ro_set= ((&LONCAPA::map::getparameter($orderidx,'parameter_randomorder'))[0]=~/^yes$/i?' checked="checked"':''); $rand_order_text =' -'; +'; } if ($ispage) { my $pagename=&escape($pagetitle); @@ -2002,7 +2021,13 @@ ENDPARMS return $line; } -# ---------------------------------------------------------------- tie the hash +=pod + +=item tiehash() + +tie the hash + +=cut sub tiehash { my ($mode)=@_; @@ -2028,7 +2053,8 @@ sub untiehash { return OK; } -# --------------------------------------------------------------- check on this + + sub checkonthis { my ($r,$url,$level,$title)=@_; @@ -2081,9 +2107,9 @@ sub checkonthis { } my $dependencies= &Apache::lonnet::metadata($url,'dependencies'); - foreach (split(/\,/,$dependencies)) { - if (($_=~/^\/res\//) && (!$alreadyseen{$_})) { - &checkonthis($r,$_,$level+1); + foreach my $dep (split(/\,/,$dependencies)) { + if (($dep=~/^\/res\//) && (!$alreadyseen{$dep})) { + &checkonthis($r,$dep,$level+1); } } } elsif ($result eq 'unavailable') { @@ -2102,27 +2128,39 @@ 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(); - $r->print("
\n");
-    foreach my $res ($navmap->retrieveResources()) {
-	$r->print($res->compTitle()."\t".$res->symb()."\n");
+    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
\n"); $r->print(''.&mt('Return to DOCS').''); } -# -# -------------------------------------------------------------- Verify Content -# sub verifycontent { my ($r) = @_; my $type = &Apache::loncommon::course_type(); @@ -2134,17 +2172,17 @@ sub verifycontent { undef %alreadyseen; %alreadyseen=(); &tiehash(); - foreach (keys %hash) { - if ($hash{$_}=~/\.(page|sequence)$/) { - if (($_=~/^src_/) && ($alreadyseen{&unescape($hash{$_})})) { + foreach my $key (keys(%hash)) { + if ($hash{$key}=~/\.(page|sequence)$/) { + if (($key=~/^src_/) && ($alreadyseen{&unescape($hash{$key})})) { $r->print('
'. &mt('The following sequence or page is included more than once in your '.$type.': '). - &unescape($hash{$_}).'
'. + &unescape($hash{$key}).'
'. &mt('Note that grading records for problems included in this sequence or folder will overlap.
')); } } - if (($_=~/^src\_(.+)$/) && (!$alreadyseen{&unescape($hash{$_})})) { - &checkonthis($r,$hash{$_},0,$hash{'title_'.$1}); + if (($key=~/^src\_(.+)$/) && (!$alreadyseen{&unescape($hash{$key})})) { + &checkonthis($r,$hash{$key},0,$hash{'title_'.$1}); } } &untiehash(); @@ -2153,8 +2191,6 @@ sub verifycontent { } -# -------------------------------------------------------------- Check Versions - sub devalidateversioncache { my $src=shift; &Apache::lonnet::devalidate_cache_new('courseresversion',$env{'request.course.id'}.'_'. @@ -2184,16 +2220,16 @@ sub checkversions { my %newsetversions=(); if ($env{'form.setmostrecent'}) { $haschanged=1; - foreach (keys %hash) { - if ($_=~/^ids\_(\/res\/.+)$/) { + foreach my $key (keys(%hash)) { + if ($key=~/^ids\_(\/res\/.+)$/) { $newsetversions{$1}='mostrecent'; &devalidateversioncache($1); } } } elsif ($env{'form.setcurrent'}) { $haschanged=1; - foreach (keys %hash) { - if ($_=~/^ids\_(\/res\/.+)$/) { + foreach my $key (keys(%hash)) { + if ($key=~/^ids\_(\/res\/.+)$/) { my $getvers=&Apache::lonnet::getversion($1); if ($getvers>0) { $newsetversions{$1}=$getvers; @@ -2203,11 +2239,11 @@ sub checkversions { } } elsif ($env{'form.setversions'}) { $haschanged=1; - foreach (keys %env) { - if ($_=~/^form\.set_version_(.+)$/) { + foreach my $key (keys(%env)) { + if ($key=~/^form\.set_version_(.+)$/) { my $src=$1; - if (($env{$_}) && ($env{$_} ne $setversions{$src})) { - $newsetversions{$src}=$env{$_}; + if (($env{$key}) && ($env{$key} ne $setversions{$src})) { + $newsetversions{$src}=$env{$key}; &devalidateversioncache($src); } } @@ -2228,8 +2264,8 @@ sub checkversions { # show all documents $header=&mt('All Documents in '.$type); $allsel=1; - foreach (keys %hash) { - if ($_=~/^ids\_(\/res\/.+)$/) { + foreach my $key (keys(%hash)) { + if ($key=~/^ids\_(\/res\/.+)$/) { my $src=$1; $changes{$src}=1; } @@ -2239,7 +2275,7 @@ sub checkversions { %changes=&Apache::lonnet::dump ('versionupdate',$env{'course.'.$env{'request.course.id'}.'.domain'}, $env{'course.'.$env{'request.course.id'}.'.num'}); - my $firstkey=(keys %changes)[0]; + my $firstkey=(keys(%changes))[0]; unless ($firstkey=~/^error\:/) { unless ($env{'form.timerange'}) { $env{'form.timerange'}=604800; @@ -2303,14 +2339,14 @@ sub checkversions { ENDHEADERS - foreach (sort keys %changes) { - if ($changes{$_}>$starttime) { - my ($root,$extension)=($_=~/^(.*)\.(\w+)$/); - my $currentversion=&Apache::lonnet::getversion($_); + foreach my $key (sort(keys(%changes))) { + if ($changes{$key}>$starttime) { + my ($root,$extension)=($key=~/^(.*)\.(\w+)$/); + my $currentversion=&Apache::lonnet::getversion($key); if ($currentversion<0) { $currentversion=&mt('Could not be determined.'); } - my $linkurl=&Apache::lonnet::clutter($_); + my $linkurl=&Apache::lonnet::clutter($key); $r->print( ' +'."\n". '


'. &Apache::lonnet::gettitle($linkurl). @@ -2457,7 +2493,6 @@ sub changewarning { $help{'Caching'}.''."\n\n"); } -# =========================================== Breadcrumbs for special functions sub init_breadcrumbs { my ($form,$text)=@_; @@ -2473,7 +2508,9 @@ sub init_breadcrumbs { bug=>'Instructor Interface'}); } -# ================================================================ Main Handler + + + sub handler { my $r = shift; &Apache::loncommon::content_type($r,'text/html'); @@ -2481,14 +2518,15 @@ sub handler { return OK if $r->header_only; my $type = &Apache::loncommon::course_type(); + # --------------------------------------------- Initialize help topics for this - foreach ('Adding_Course_Doc','Main_Course_Documents', - 'Adding_External_Resource','Navigate_Content', - 'Adding_Folders','Docs_Overview', 'Load_Map', - 'Supplemental','Score_Upload_Form','Adding_Pages', - 'Importing_LON-CAPA_Resource','Uploading_From_Harddrive', - 'Check_Resource_Versions','Verify_Content') { - $help{$_}=&Apache::loncommon::help_open_topic('Docs_'.$_); + foreach my $topic ('Adding_Course_Doc','Main_Course_Documents', + 'Adding_External_Resource','Navigate_Content', + 'Adding_Folders','Docs_Overview', 'Load_Map', + 'Supplemental','Score_Upload_Form','Adding_Pages', + 'Importing_LON-CAPA_Resource','Uploading_From_Harddrive', + 'Check_Resource_Versions','Verify_Content') { + $help{$topic}=&Apache::loncommon::help_open_topic('Docs_'.$topic); } # Composite help files $help{'Syllabus'} = &Apache::loncommon::help_open_topic( @@ -2534,6 +2572,8 @@ sub handler { my $showdoc=0; my $containertag; my $uploadtag; + + &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'}, ['folderpath','pagepath', 'pagesymb']); @@ -2607,8 +2647,10 @@ sub handler { } # -------------------------------------------------------------------- Body tag $script = ''; + my $brcrum = [{href=>"/adm/createuser",text=>"$type Documents"}]; $r->print(&Apache::loncommon::start_page("$type Documents", $script, - {'force_register' => $showdoc,}). + {'force_register' => $showdoc, + 'bread_crumbs' => $brcrum}). &Apache::loncommon::help_open_menu('','',273,'RAT')); my %allfiles = (); @@ -2647,12 +2689,12 @@ sub handler { } my @attributes = (); if ($env{'form.embedded_attrib_'.$i} =~ /:/) { - @attributes = split/:/,$env{'form.embedded_attrib_'.$i}; + @attributes = split(/:/,$env{'form.embedded_attrib_'.$i}); } else { @attributes = ($env{'form.embedded_attrib_'.$i}); } - foreach (@attributes) { - push(@{$attribs{$i}},&unescape($_)); + foreach my $attr (@attributes) { + push(@{$attribs{$i}},&unescape($attr)); } if ($javacodebase) { $codebase{$i} = $javacodebase; @@ -2670,7 +2712,7 @@ sub handler { my $updateflag = 0; my $getstatus = &Apache::lonnet::getuploaded('GET',$primary_url,$coursedom,$coursenum,\$content,\$rtncode); if ($getstatus eq 'ok') { - foreach my $item (keys %newname) { + foreach my $item (keys(%newname)) { if ($newname{$item} ne $origname{$item}) { my $attrib_regexp = ''; if (@{$attribs{$item}} > 1) { @@ -2704,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', @@ -2732,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=(< + +FIUP + + my $checkbox=(<$lt{'parse'}? + + --> + +CHBO + + my $fileuploadform=(< + $fileupload +
+ $lt{'title'}:
+ + $uploadtag + +
+ + $checkbox + +
+
+ + + $help{'Uploading_From_Harddrive'} + + +FUFORM + + my $simpleeditdefaultform=(< + $lt{'pubd'}
+ $uploadtag + +
+ + + $help{'Importing_LON-CAPA_Resource'} + +
+ +
+

+ $lt{'copm'}
+
+ + $help{'Load_Map'} +

+ +SEDFFORM + + my $extresourcesform=(< + $uploadtag + + + $help{'Adding_External_Resource'} + + +ERFORM + if ($allowed) { &update_paste_buffer($coursenum,$coursedom); - my $dumpbut=&dumpbutton(); - my $exportbut=&exportbutton(); my %lt=&Apache::lonlocal::texthash( 'vc' => 'Verify Content', 'cv' => 'Check/Set Resource Versions', @@ -2759,40 +2873,7 @@ sub handler { $uploadtag = ''; } - $r->print(< - - - - - $containertag - -
- - $uploadtag -
-
-
- -
- $help{'Verify_Content'} -
-
- $help{'Check_Resource_Versions'} -
- $dumpbut - $exportbut -
- -
-
- - -
-
-
-
 
-ENDCOURSEVERIFY + $r->print(&generate_admin_options($containertag,$uploadtag,\%lt,\%help,\%env)); $r->print(&Apache::loncommon::help_open_topic('Docs_Adding_Course_Doc', &mt('Editing the Table of Contents for your '.$type))); } @@ -2823,7 +2904,7 @@ ENDCOURSEVERIFY $r->print('

'.$error.'

'); } if ($hadchanges) { - &mark_hash_old() + &mark_hash_old(); } &changewarning($r,$postexec); my $folderseq='/uploaded/'.$coursedom.'/'.$coursenum.'/default_'.time. @@ -2835,223 +2916,267 @@ ENDCOURSEVERIFY $container='page'; } my $readfile='/uploaded/'.$coursedom.'/'.$coursenum.'/'.$folder.'.'.$container; + + + + my $recoverform=(< + + +RFORM + + my $imspform=(< + + + +IMSPFORM + + my $newnavform=(< + $uploadtag + + + + $help{'Navigate_Content'} + + +NNFORM + my $newsmppageform=(< + $uploadtag + + + $help{'Simple Page'} + + +NSPFORM + + my $newsmpproblemform=(< + $uploadtag + + + $help{'Simple Problem'} + + + +NSPROBFORM + + my $newdropboxform=(< + $uploadtag + + + + + +NDBFORM + + my $newexuploadform=(< + $uploadtag + + + + $help{'Score_Upload_Form'} + + +NEXUFORM + + my $newbulform=(< + $uploadtag + + + + $help{'Bulletin Board'} + + +NBFORM + + my $newaboutmeform=(< + $uploadtag + + + + $help{'My Personal Info'} + + +NAMFORM + + my $newaboutsomeoneform=(< + $uploadtag + + + + + +NASOFORM + + + my $newrosterform=(< + $uploadtag + + + + $help{'Course Roster'} + + +NROSTFORM + $r->print(< -
-$lt{'file'}:
-
- -
-$lt{'title'}:
- -$uploadtag - -
- - - -
-
- - - $help{'Uploading_From_Harddrive'} - -
+$fileuploadform
-
-$lt{'pubd'}
-$uploadtag - -
- - -$help{'Importing_LON-CAPA_Resource'} - -
- -
-

-$lt{'copm'}
-
- -$help{'Load_Map'} -

-
+$simpleeditdefaultform
-
- -
+$recoverform ENDFORM unless ($env{'form.pagepath'}) { $r->print(< -
-$uploadtag - - - $help{'Adding_External_Resource'} - -
-
- - -
+$extresourcesform +
+$imspform ENDFORM } $r->print('
'); unless ($env{'form.pagepath'}) { my $path = &HTML::Entities::encode($env{'form.folderpath'},'<>&"'); - $r->print(<
- - - -$help{'Adding_Folders'} - -
-
- - - -$help{'Adding_Pages'} - -
-
-$uploadtag - - - - $help{'Syllabus'} - -
-
-$uploadtag - - - -$help{'Navigate_Content'} - -
-
-$uploadtag - - - $help{'Simple Page'} - -
-
-$uploadtag - - -$help{'Simple Problem'} - -
-
-$uploadtag - - - - -
-
-$uploadtag - - - -$help{'Score_Upload_Form'} - -
-
-$uploadtag - - - -$help{'Bulletin Board'} - -
-
-$uploadtag - - - -$help{'My Personal Info'} - -
-
-$uploadtag - - - - -
-
-$uploadtag - - - -$help{'Group Files'} - -
-
-$uploadtag - - - -$help{'Course Roster'} - -
+ + + + my $newpageform=(< + + + + $help{'Adding_Pages'} + + +NPFORM + + my $newfolderform=(< + + + + $help{'Adding_Folders'} + + +NFFORM + + my $newsylform=(< + $uploadtag + + + + $help{'Syllabus'} + + +NSYLFORM + + my $newgroupfileform=(< + $uploadtag + + + + $help{'Group Files'} + + +NGFFORM + + + my $specialdocumentsform=(< +$newfolderform +
+$newpageform +
+$newsylform +
+$newnavform +
+$newsmppageform +
+$newsmpproblemform +
+$newdropboxform +
+$newexuploadform +
+$newbulform +
+$newaboutmeform +
+$newaboutsomeoneform +
+$newgroupfileform +
+$newrosterform ENDFORM - } + +$r->print($specialdocumentsform); + +my %orderhash = ( + 'aa' => 'New Document', + 'bb' => 'Published Documents', + 'cc' => 'Special Documents', + 'dd' => 'More Options', + 'zz' => 'Hide all Option', + ); +my %namehash = ( + 'New Document' => $fileuploadform, + 'Published Documents' => $simpleeditdefaultform, + 'Special Documents' => $specialdocumentsform, + 'More Options' => $extresourcesform.'
'.$imspform.'
'.$recoverform, + 'drei' => 'dr', + ); +my $varcd = 'Course Documents'; +$r->print(&generate_edit_table($varcd,\%namehash,\%orderhash)); + + } if ($env{'form.pagepath'}) { $r->print(< -$uploadtag - - -$help{'Simple Problem'} - - -
-$uploadtag - - - -$help{'Score_Upload_Form'} - -
+$newsmpproblemform +
+$newexuploadform ENDBLOCK } $r->print('
'); +#$r->print(&generate_edit_table(\%namehash,\%orderhash)); $r->print(''); } # ----------------------------------------------------- Supplemental documents @@ -3078,71 +3203,96 @@ ENDBLOCK '.sequence'; my $path = &HTML::Entities::encode($env{'form.folderpath'},'<>&"'); + + my $supupdocform=(< + $fileupload +
+
+ + $checkbox + +

+ $lt{'comment'}:
+ +
+ + + + + $help{'Uploading_From_Harddrive'} + + +SUPDOCFORM + + my $supnewfolderform=(< + + + + $help{'Adding_Folders'} + + +SNFFORM + + + my $supnewextform=(< + + + + $help{'Adding_External_Resource'} + + +SNEFORM + + my $supnewsylform=(< + + + + + $help{'Syllabus'} + + +SNSFORM + + my $supnewaboutmeform=(< + + + + + $help{'My Personal Info'} + + +SNAMFORM + $r->print(< -$lt{'upls'} -$lt{'spec'} - +
    +
  • $lt{'nd'}
  • +
  • $lt{'sd'}
  • +
  • $lt{'hao'}
  • +
+ + -
-
- +$supupdocform +
+$supnewfolderform
+$supnewextform
- - - -

-$lt{'comment'}:
- +$supnewsylform
- - - - - $help{'Uploading_From_Harddrive'} - - -
-
- - - - $help{'Adding_Folders'} - -
-
- - - - $help{'Adding_External_Resource'} - -
-
- - - - -$help{'Syllabus'} - -
-
- - - - -$help{'My Personal Info'} - -
+$supnewaboutmeform
ENDSUPFORM @@ -3158,6 +3308,7 @@ ENDSUPFORM '); } + } else { unless ($upload_result eq 'phasetwo') { # -------------------------------------------------------- This is showdoc mode @@ -3172,6 +3323,79 @@ ENDSUPFORM return OK; } +sub generate_admin_options { + my ($containertag,$uploadtag,$lt_ref,$help_ref,$env_ref) = @_; + my %lt = %{$lt_ref}; + my %help = %{$help_ref}; + my %env = %{$env_ref}; + my $dumpbut=&dumpbutton(); + my $exportbut=&exportbutton(); + return (< + + + + + $containertag + +
+ + $uploadtag +
+
+
    +
  • + $help{'Verify_Content'} +
  • +
  • + $help{'Check_Resource_Versions'} +
  • +
  • + $dumpbut +
  • +
  • + $exportbut +
  • +
  • + +
  • +
  • + + +
  • +
+
+
 
+ENDOPTIONFORM + +} + + +sub generate_edit_table { + my ($varcd,$namehash_ref,$orderhash_ref) = @_; + my %namehash = %{$namehash_ref}; #name verlinkt mit id + my %orderhash = %{$orderhash_ref}; #name mit kürzel verlinkt mit name + my $form; + + #foreach my $id (keys(%tablehash)){ + $form = '

'.&mt('Upload '.$varcd).'

'; + + $form .= '
'; +#} + return $form; +} sub editing_js { my ($udom,$uname) = @_; @@ -3374,7 +3598,157 @@ function markcopy(folderpath,index,oldti this.document.forms.renameform.submit(); } +function unselectInactive() { +currentNav = document.getElementById('navigation'); +currentLis = currentNav.getElementsByTagName('LI'); +for (i = 0; i < currentLis.length; i++) { +currentLis[i].className = 'i'; +} +} + +function hideAll(current) { + unselectInactive(); + current.className = 'active'; + currentData = document.getElementById('content'); + currentDivs = currentData.getElementsByTagName('DIV'); + for (i = 0; i < currentDivs.length; i++) { + currentDivs[i].style.display = 'none'; + } +} + +function showPage(current, pageId) { + hideAll(current); + unselectInactive(); + current.className = 'active'; + currentData = document.getElementById(pageId); + currentData.style.display = 'block'; + return false; +} + ENDNEWSCRIPT } 1; __END__ + + +=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 + +=item %help=() + +Available help topics + +=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 + +=item authorhosts() + +Return hash with valid author names + +=item dumpbutton() + +Generate "dump" button + +=item clean() + +=item dumpcourse() + + Actually dump course + + +=item exportbutton() + + Generate "export" button + +=item exportcourse() + +=item create_ims_store() + +=item build_package() + +=item get_dependencies() + +=item process_content() + +=item replicate_content() + +=item extract_media() + +=item store_template() + +=item group_import() + + Imports the given (name, url) resources into the course + coursenum, coursedom, and folder must precede the list + +=item breadcrumbs() + +=item log_docs() + +=item docs_change_log() + +=item update_paste_buffer() + +=item print_paste_buffer() + +=item do_paste_from_buffer() + +=item update_parameter() + +=item handle_edit_cmd() + +=item editor() + +=item process_file_upload() + +=item process_secondary_uploads() + +=item is_supplemental_title() + +=item parse_supplemental_title() + +=item entryline() + +=item tiehash() + +=item untiehash() + +=item checkonthis() + +check on this + +=item verifycontent() + +Verify Content + +=item devalidateversioncache() & checkversions() + +Check Versions + +=item mark_hash_old() + +=item is_hash_old() + +=item changewarning() + +=item init_breadcrumbs() + +Breadcrumbs for special functions + +=back + +=cut